sncosmo.Spectrum¶
- class sncosmo.Spectrum(wave=None, flux=None, fluxerr=None, fluxcov=None, bin_edges=None, wave_unit=Unit('Angstrom'), unit=Unit('erg / (Angstrom cm2 s)'), time=None)[source]¶
An observed spectrum of an object.
This class is designed to represent an observed spectrum. An observed spectrum is a set of contiguous bins in wavelength (referred to as “spectral elements”) with associated flux measurements. We assume that each spectral element has uniform transmission in wavelength. A spectrum can optionally have associated uncertainties or covariance between the observed fluxes of the different spectral elements. A spectrum can also optionally have a time associated with it.
Internally, we store the edges of each of the spectral element wavelength bins. These are automatically recovered in the common case where a user has a list of central wavelengths for each bin. The wavelengths are stored internally in units of Angstroms. The flux is stored as a spectral flux density F_λ (units of erg / s / cm^2 / Angstrom).
- Parameters:
- wavelist-like
Central wavelengths of each spectral element. This must be monotonically increasing. This is assumed to be in units of Angstroms unless
wave_unit
is specified.- fluxlist-like
Observed fluxes for each spectral element. By default this is assumed to be a spectral flux density F_λ unless
unit
is explicitly specified.- fluxerrlist-like
Uncertainties on the observed fluxes for each spectral element.
- fluxcovtwo-dimensional
ndarray
Covariance of the observed fluxes for each spectral element. Only one of
fluxerr
andfluxcov
may be specified.- bin_edgeslist-like
Edges of each spectral element in wavelength. This should be a list that is length one longer than
flux
. Only one ofwave
andbin_edges
may be specified.- wave_unit
Unit
Wavelength unit. Default is Angstroms.
- unit
Unit
Flux unit. Default is F_λ (erg / s / cm^2 / Angstrom).
- timefloat
The time associated with the spectrum. This is required if fitting a model to the spectrum.
- __init__(wave=None, flux=None, fluxerr=None, fluxcov=None, bin_edges=None, wave_unit=Unit('Angstrom'), unit=Unit('erg / (Angstrom cm2 s)'), time=None)[source]¶
Methods
__init__
([wave, flux, fluxerr, fluxcov, ...])bandflux
(band[, zp, zpsys])Perform synthentic photometry in a given bandpass.
bandfluxcov
(band[, zp, zpsys])Like bandflux(), but also returns model covariance on values.
bandmag
(band, magsys)Magnitude through the given bandpass(es), and for the given magnitude system(s).
get_sampling_matrix
()Build an appropriate sampling for the spectral elements.
has_uncertainties
()Check whether there is uncertainty information available.
rebin
([wave, bin_edges])Rebin the spectrum on a new wavelength grid.
Attributes
bin_ends
Return the end of each bin.
bin_starts
Return the start of each bin.
fluxcov
Return the covariance matrix
fluxerr
Return the uncertainties on each flux bin
wave
Return the centers of each bin.