SourceSpectrum

class synphot.spectrum.SourceSpectrum(modelclass, z=0, z_type='wavelength_only', **kwargs)[source]

Bases: synphot.spectrum.BaseSourceSpectrum

Class to handle source spectrum.

Parameters
modelclass, kwargs

See BaseSpectrum.

znumber

Redshift to apply to model.

z_type{‘wavelength_only’, ‘conserve_flux’}

Redshift can be done in one of the following ways:

  • 'wavelength_only' only shifts the wavelength without adjusting the flux. This is the default behavior to be backward compatible with ASTROLIB PYSYNPHOT.

  • 'conserve_flux' also scales the flux to conserve it.

Attributes Summary

model

Model of the spectrum with given redshift.

z

Redshift of the source spectrum.

z_type

Redshift behavior.

Methods Summary

from_file(filename[, keep_neg])

Create a spectrum from file.

from_vega(**kwargs)

Load Vega spectrum.

plot([wavelengths, flux_unit, area, vegaspec])

Plot the spectrum.

to_fits(filename[, wavelengths, flux_unit, …])

Write the spectrum to a FITS file.

Attributes Documentation

model

Model of the spectrum with given redshift.

z

Redshift of the source spectrum.

z_type

Redshift behavior.

Methods Documentation

classmethod from_file(filename, keep_neg=False, **kwargs)[source]

Create a spectrum from file.

If filename has ‘fits’ or ‘fit’ suffix, it is read as FITS. Otherwise, it is read as ASCII.

Parameters
filenamestr

Spectrum filename.

keep_negbool

See Empirical1D.

kwargsdict

Keywords acceptable by read_fits_spec() (if FITS) or read_ascii_spec() (if ASCII).

Returns
spSourceSpectrum

Empirical spectrum.

classmethod from_vega(**kwargs)[source]

Load Vega spectrum.

Parameters
kwargsdict

Keywords acceptable by read_remote_spec().

Returns
vegaspecSourceSpectrum

Empirical Vega spectrum.

plot(wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs)[source]

Plot the spectrum.

Note

Uses matplotlib.

Parameters
wavelengthsarray-like, Quantity, or None

Wavelength values for integration. If not a Quantity, assumed to be in Angstrom. If None, self.waveset is used.

flux_unitstr, Unit, or None

Flux is converted to this unit for plotting. If not given, internal unit is used.

area, vegaspec

See convert_flux().

kwargsdict

See BaseSpectrum.plot().

Raises
synphot.exceptions.SynphotError

Invalid inputs.

to_fits(filename, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs)[source]

Write the spectrum to a FITS file.

Parameters
filenamestr

Output filename.

wavelengthsarray-like, Quantity, or None

Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If None, self.waveset is used.

flux_unitstr, Unit, or None

Flux is converted to this unit before written out. If not given, internal unit is used.

area, vegaspec

See convert_flux().

kwargsdict

Keywords accepted by write_fits_spec().