Spectrum1D#

class aesop.Spectrum1D(wavelength=None, flux=None, name=None, mask=None, wcs=None, meta={}, time=None, continuum_normalized=None)[source]#

Bases: object

Simple 1D spectrum object.

A Spectrum1D object can be used to describe one order of an echelle spectrum, for example.

If the spectrum is initialized with wavelength``s that are not strictly increasing, ``Spectrum1D will sort the wavelength, flux and mask arrays so that wavelength is monotonically increasing.

Parameters:
wavelengthndarray

Wavelengths

fluxndarray

Fluxes

namestr (optional)

Name for the spectrum

maskndarray (optional)

Boolean mask of the same shape as flux

wcsSpectrum1DLookupWCS (optional)

Store the WCS parameters

metadict (optional)

Metadata dictionary.

continuum_normalizedbool (optional)

Is this spectrum continuum normalized?

Attributes Summary

masked_flux

masked_wavelength

Methods Summary

flux_calibrate(flux_calibrated_spectrum, ...)

Calculates coefficients of sensitivity function, then returns flux-calibrated spectrum

flux_calibrate_parameters(...[, plots])

Interpolate high-res spectrum to low-res flux calibrated spectrum, then fit the ratio with a polynomial to flux calibrate.

from_array(wavelength, flux[, ...])

Initialize a spectrum with the same call signature as from_array.

from_specutils(spectrum1d[, name])

Convert a Spectrum1D object into our Spectrum1D object.

mask_outliers([reject_negative, mad_clip, ...])

Identify outliers, update the mask attribute.

plot([ax])

Plot the spectrum.

Attributes Documentation

masked_flux#
masked_wavelength#

Methods Documentation

flux_calibrate(flux_calibrated_spectrum, polynomial_order)[source]#

Calculates coefficients of sensitivity function, then returns flux-calibrated spectrum

Parameters:
flux_calibrated_spectrumSpectrum1D

Already flux calibrated low-resolution spectrum of the same object

polynomial_orderint

Order of polynomial fit

Returns:
transformed_spectrumSpectrum1D

Spectrum transformed with sensitivity polynomial

flux_calibrate_parameters(flux_calibrated_spectrum, polynomial_order, plots=False)[source]#

Interpolate high-res spectrum to low-res flux calibrated spectrum, then fit the ratio with a polynomial to flux calibrate. Returns polynomial coefficients

Parameters:
flux_calibrated_spectrumSpectrum1D

Already flux calibrated low-resolution spectrum of the same object

polynomial_orderint

Order of polynomial fit

plotsbool

If True, plot the sensitivity data and the fit

Returns:
fit_paramsndarray

Best-fit polynomial coefficients

classmethod from_array(wavelength, flux, dispersion_unit=None, name=None, **kwargs)[source]#

Initialize a spectrum with the same call signature as from_array.

Parameters:
wavelengthQuantity

Spectrum wavelengths

fluxQuantity or ndarray

Spectrum fluxes

dispersion_unitUnit (optional)

Unit of the wavelength

namestr (optional)

Name of the target/spectrum

classmethod from_specutils(spectrum1d, name=None, **kwargs)[source]#

Convert a Spectrum1D object into our Spectrum1D object.

Parameters:
spectrum1dSpectrum1D

Input spectrum

namestr

Target/spectrum name

mask_outliers(reject_negative=True, mad_clip=True, mad_outlier_factor=3)[source]#

Identify outliers, update the mask attribute.

Parameters:
reject_negativebool (optional)

Reject fluxes < -0.5. Default is True.

mad_clipbool

Reject fluxes more than mad_outlier_factor times the median absolute deviation (MAD) from the continuum flux.

mad_outlier_factorfloat

MAD-masking factor – fluxes more than mad_outlier_factor away from the continuum flux will be masked.

plot(ax=None, **kwargs)[source]#

Plot the spectrum.

Parameters:
axAxes (optional)

The Axes to draw on, if provided.

kwargs

All other keyword arguments are passed to plot