BaseSourceSpectrum¶
- class synphot.spectrum.BaseSourceSpectrum(modelclass, clean_meta=False, **kwargs)[source]¶
Bases:
BaseSpectrum
Base class to handle spectrum with flux unit like source spectrum and observation. Do not use directly.
Methods Summary
__call__
(wavelengths[, flux_unit])Sample the spectrum.
normalize
(renorm_val[, band, wavelengths, ...])Renormalize the spectrum to the given Quantity and band.
Methods Documentation
- __call__(wavelengths, flux_unit=None, **kwargs)[source]¶
Sample the spectrum.
- Parameters:
- wavelengthsarray-like or
Quantity
Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom.
- flux_unitstr,
Unit
, orNone
Flux is converted to this unit. If not given, internal unit is used.
- kwargsdict
Keywords acceptable by
convert_flux()
.
- wavelengthsarray-like or
- Returns:
- sampled_result
Quantity
Sampled flux in the given unit. Might have negative values.
- sampled_result
- normalize(renorm_val, band=None, wavelengths=None, force=False, area=None, vegaspec=None)[source]¶
Renormalize the spectrum to the given Quantity and band.
Warning
Redshift attribute (
z
) is reset to 0 in the normalized spectrum even ifself.z
is non-zero. This is because the normalization simply adds a scale factor to the existing composite model. This is confusing but should not affect the flux sampling.- Parameters:
- renorm_valnumber or
Quantity
Value to renormalize the spectrum to. If not a Quantity, assumed to be in internal unit.
- band
SpectralElement
Bandpass to use in renormalization.
- wavelengthsarray-like,
Quantity
, orNone
Wavelength values for renormalization. If not a Quantity, assumed to be in Angstrom. If
None
,self.waveset
is used.- forcebool
By default (
False
), renormalization is only done when band wavelength limits are withinself
or at least 99% of the flux is within the overlap. Set toTrue
to force renormalization for partial overlap (this changes the underlying model ofself
to always extrapolate, if applicable). Disjoint bandpass raises an exception regardless.- area, vegaspec
See
convert_flux()
.
- renorm_valnumber or
- Returns:
- spobj
Renormalized spectrum.
- Raises:
- synphot.exceptions.DisjointError
Renormalization band does not overlap with
self
.- synphot.exceptions.PartialOverlap
Renormalization band only partially overlaps with
self
and significant amount of flux falls outside the overlap.- synphot.exceptions.SynphotError
Invalid inputs or calculation failed.