Plotter

multi_absolute.py

Module to plot multiple absolute spectra.

class MultiAbsolutePlotter(spectra, sampling, multi, show_plot, output_path, output_file, format, legend)[source]

Bases: Plotter

def _plot_multi_xp(self):

show_legend = self.legend spectra_df = self.spectra spectra_class = self.spectra_class max_flux = 0 fig, ax = plt.subplots(ncols=2, figsize=(16, 8)) # Set titles ax[0].set_title(BANDS.bp.upper()) ax[1].set_title(BANDS.rp.upper()) ax[1].yaxis.set_label_position(‘right’) ax[1].yaxis.tick_right() for _, spectrum in spectra_df.iterrows():

x, y, e = self._get_inputs(spectrum) max_flux = max(y) if max(y) > max_flux else max_flux axis = BANDS.index(spectrum.xp.lower()) ax[axis].plot(x, y, lw=2, alpha=0.95, label=spectrum.source_id)

for axis in ax:

axis.set_ylim(0, 1.05 * max_flux) axis.set_xlabel(spectra_class._get_position_label()) axis.set_ylabel(spectra_class._get_flux_label()) if show_legend:

handles, labels = plt.gca().get_legend_handles_labels() by_label = dict(zip(labels, handles)) fig.subplots_adjust(top=0.95, bottom=0.05, left=0.05, right=0.85, wspace=0.020) fig.legend(by_label.values(), by_label.keys(), bbox_to_anchor=(1, 1), loc=’upper right’, borderaxespad=0.1)

multi_xp.py

Module to plot multiple XP spectra.

class MultiXpPlotter(spectra, sampling, multi, show_plot, output_path, output_file, format, legend)[source]

Bases: Plotter

plot_spectra.py

Module to plot spectra.

plot_spectra(spectra, sampling=None, multi=False, show_plot=True, output_path=None, output_file=None, format='jpg', legend=True)[source]

” Plot one or more spectra.

Parameters
  • spectra (list) – List of spectra to be plotted.

  • multi (bool) – Generate a multiple subplots. Default value of False plots each spectrum in its own figure. If True, errors will not be plotted.

  • show_plot (bool) – Show plots if True.

  • output_path (str) – Path to the directory where the figures will be saved. E.g.: ‘/home/user/folder’

  • output_file (str) – Name of the file to be saved.

  • format (str) – File format for the saved figure. Default value: png.

  • legend (bool) – Print legend. Valid only if multi is True.

plotter.py

Module to create a plotter object.

class Plotter(spectra, sampling, multi, show_plot, output_path, output_file, format, legend)[source]

Bases: object

single.py

Module to plot a single spectrum, either absolute or XP.

class SinglePlotter(spectra, sampling, multi, show_plot, output_path, output_file, format, legend)[source]

Bases: Plotter

for index, spectrum in spectra_df.iterrows():

x, y, e = self._get_inputs(spectrum) ax.plot(x, y, lw=2, alpha=0.95, label=spectrum.source_id)