Plot Broadband SEDs
Plot an object’s per-band measurements against each band’s wavelength.
Each band is read straight off the object’s own per-band columns - the ones named
f"{band}_{brightness_field}", such as u_psfMag or g_psfFlux - and plotted
against that band’s wavelength. The matching uncertainty is read from
f"{band}_{brightness_field}Err", when the object has such a column.
If you want additional configuration, you may be better served creating your own plotting function, as this is intended for quick inspection of individual objects in HATS-formatted data products.
- plot_sed(obj: Series, title='LSST broadband SED', mag_field='psfMag', flux_field=None, band_names=None, band_wavelengths=None, band_widths=None, x_units='nm', y_units=None, filter_colors=None, filter_symbols=None, plot_kwargs=None, legend_kwargs=None, ax=None)[source]
Convenience method to plot a single object’s broadband SED.
Each band is read straight off the object’s own per-band columns - the ones named
f"{band}_{brightness_field}", such asu_psfMagorg_psfFlux- and plotted against that band’s wavelength, with a horizontal bar spanning the band’s throughput FWHM. The matching uncertainty is read fromf"{band}_{brightness_field}Err", when the object has such a column.Bands the object has no column for, or whose value is null, are left out - so an object measured only in
grizis plotted as four points.Note: The y-axis is upside-down whenever it carries magnitudes.
If you want additional configuration, you may be better served creating your own plotting function, as this is intended for quick inspection of individual objects in HATS-formatted data products.
- Parameters:
obj (pd.Series) – A single row of an object catalog, e.g.
catalog.compute().iloc[0].title (str, optional) – Title for the plot. Defaults to “LSST broadband SED”.
mag_field (str, optional) – Name of the per-band magnitude, without its band prefix. Defaults to “psfMag”. If using magnitude, the y-axis will be inverted.
flux_field (str, optional) – Name of the per-band flux, without its band prefix. If None, uses mag_field instead. Defaults to None.
band_names (list, optional) – List of band names to plot, in plotting order. These are the column prefixes, not the values of any
bandcolumn. Defaults to None (uses ugrizy).band_wavelengths (dict, optional) – Mapping of band name to wavelength, in nanometers. Defaults to band_wavelengths_ugrizy.
band_widths (dict, optional) – Mapping of band name to throughput FWHM, in nanometers, drawn as a horizontal bar through each point spanning half a width either side of the band’s wavelength. Bands missing from the mapping are drawn without a bar. Defaults to band_widths_ugrizy; pass an empty dict for bare points.
x_units (str or astropy.units.UnitBase, optional) – Units for the x-axis. Anything astropy reads as a wavelength (“nm”, “angstrom”, “micron”), a frequency (“THz”, “GHz”), an energy (“eV”, “keV”), or a wavenumber (“1/cm”). Defaults to “nm”.
y_units (str or astropy.units.UnitBase, optional) – Units for the y-axis. The stored values are taken to be nanojanskys for a flux_field and AB magnitudes for a mag_field, and converted from there at each band’s wavelength through astropy’s spectral flux density equivalencies - so “nJy”, “ABmag”, “FLAM”, or any unit astropy can reach, such as u.erg / u.s / u.cm**2 / u.AA. See y_unit_aliases for the shorthand names. Defaults to None, which leaves the values as they are stored and labels the axis in those same units.
filter_colors (dict, optional) – Mapping of band names to colors. Defaults to plot_filter_colors_white_background.
filter_symbols (dict, optional) – Mapping of band names to marker symbols. Defaults to plot_filter_symbols.
plot_kwargs (dict, optional) – Additional keyword arguments for Axes.errorbar(). Defaults to None.
legend_kwargs (dict, optional) – Keyword arguments for Axes.legend(). The legend is titled with the column the measurements were read from. Pass a title of your own to override that, or None to drop it. Defaults to None.
ax (matplotlib.axes.Axes, optional) – Axes to draw on. Defaults to the current axes, creating a figure to hold them when no figure is open yet.
- Returns:
The axes the SED was drawn on.
- Return type:
matplotlib.axes.Axes
X-axis units
x_units picks what the x-axis measures. It takes anything astropy.units reads as a
wavelength ("nm", the default, or "angstrom", "micron"), a frequency ("THz",
"GHz", "Hz"), an energy ("eV", "keV"), or a wavenumber ("1/cm") - as a
string, or as an astropy unit object. Whichever you pick, band_wavelengths and band_widths
are still given in nanometers; this converts them for display only.
- x_axis_quantities = {'energy': 'energy', 'frequency': 'frequency', 'length': 'wavelength', 'wavenumber': 'wavenumber'}
The physical quantities
plot_sed()will plot a band against, mapped to the axis label each one draws. Any astropy unit of one of these is a usablex_units, since they are the quantitiesastropy.units.spectral()converts a wavelength into.
Y-axis units
y_units picks what the y-axis measures. The values are read as the catalog stores them -
nanojanskys for a flux_field, AB magnitudes for a mag_field - and left in those units,
and labelled as such, unless you ask for others. Pass y_units and they are converted
through
astropy’s spectral flux density equivalencies,
at each band’s own wavelength: "nJy", "ABmag", "FLAM", or any unit astropy can
reach, such as u.erg / u.s / u.cm**2 / u.AA.
The axis is labeled with what it measures rather than the column it came from, worked out
from the unit’s physical_type - so "nJy" and "FLAM" both read as a flux density,
with the units after it saying which, and either magnitude system reads as a magnitude. The
column the measurements were read from titles the legend instead.
- y_axis_quantities = {'energy flux': 'energy flux', 'photon flux density': 'photon flux density', 'photon flux density wav': 'photon flux density', 'spectral flux density': 'flux density', 'spectral flux density wav': 'flux density'}
The physical quantities
plot_sed()names on the y-axis, mapped to the axis label each one draws. A flux density per unit frequency and one per unit wavelength are different physical types -astropycalls themspectral flux densityandspectral flux density wav- but both read as a flux density on a label, with the units after it saying which.energy fluxcovers the ν·F_ν and λ·F_λ an SED is often drawn as.
- y_unit_aliases = {'ABmag': Unit("mag(AB)"), 'FLAM': Unit("erg / (Angstrom s cm2)"), 'FNU': Unit("erg / (Hz s cm2)"), 'PHOTLAM': Unit("ph / (Angstrom s cm2)"), 'STmag': Unit("mag(ST)")}
Shorthand names
plot_sed()accepts asy_units, for the magnitude systems and spectral flux densities thatastropy.unitswill not parse from a bare string.
- flux_column_unit = Unit("nJy")
The units a flux column is taken to be in, when converting to
y_units.Rubin data products store fluxes in nanojanskys.
- mag_column_unit = Unit("mag(AB)")
The units a magnitude column is taken to be in, when converting to
y_units.Rubin data products store AB magnitudes.
Scaling and inverting the axes
Both axes are left linear, and plot_sed draws on the axes you pass as ax - or on the
current ones - so you can scale or invert either axis with matplotlib after the call. The
y-axis is automatically inverted whenever what it carries is a magnitude.
Colors, symbols, wavelengths, and band names
filter_colors, filter_symbols, band_names, band_wavelengths, and
band_widths all take the shared band defaults. See LSST Bands.