spectrum_ensure_flux_density_unit#

jdaviz.core.unit_conversion_utils.spectrum_ensure_flux_density_unit(spectrum)[source]#

Ensure a Spectrum has flux in spectral flux density units.

If the input spectrum already has flux in a spectral flux density unit, it is returned unchanged. If the flux is in a supported flux or surface brightness unit, a new Spectrum is returned with flux converted to a spectral flux density unit using to_flux_density_unit().

When converting, uncertainty is preserved when possible:

  • If spectrum.uncertainty has a quantity attribute (e.g. StdDevUncertainty), the same uncertainty class is retained and rebuilt with the converted flux unit.

  • Otherwise, a unit-scaled array-like uncertainty is created.

Parameters:
spectrumspecutils.Spectrum

Input spectrum to check and convert.

Returns:
specutils.Spectrum

The original spectrum (if already in spectral flux density) or a new converted spectrum.

Raises:
NotImplementedError

Returned if the flux unit physical type is unsupported by this helper.