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
.- z : number
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: - filename : str
Spectrum filename.
- keep_neg : bool
See
Empirical1D
.- kwargs : dict
Keywords acceptable by
read_fits_spec()
(if FITS) orread_ascii_spec()
(if ASCII).
Returns: - sp :
SourceSpectrum
Empirical spectrum.
-
classmethod
from_vega
(**kwargs)[source]¶ Load Vega spectrum.
Parameters: - kwargs : dict
Keywords acceptable by
read_remote_spec()
.
Returns: - vegaspec :
SourceSpectrum
Empirical Vega spectrum.
-
plot
(wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs)[source]¶ Plot the spectrum.
Note
Uses
matplotlib
.Parameters: - wavelengths : array-like,
Quantity
, orNone
Wavelength values for integration. If not a Quantity, assumed to be in Angstrom. If
None
,self.waveset
is used.- flux_unit : str or
Unit
orNone
Flux is converted to this unit for plotting. If not given, internal unit is used.
- area, vegaspec
See
convert_flux()
.- kwargs : dict
See
BaseSpectrum.plot()
.
Raises: - synphot.exceptions.SynphotError
Invalid inputs.
- wavelengths : array-like,
-
to_fits
(filename, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs)[source]¶ Write the spectrum to a FITS file.
Parameters: - filename : str
Output filename.
- wavelengths : array-like,
Quantity
, orNone
Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If
None
,self.waveset
is used.- flux_unit : str or
Unit
orNone
Flux is converted to this unit before written out. If not given, internal unit is used.
- area, vegaspec
See
convert_flux()
.- kwargs : dict
Keywords accepted by
write_fits_spec()
.