Observation¶
- class synphot.observation.Observation(spec, band, binset=None, force='none')[source]¶
Bases:
BaseSourceSpectrumThis is an observed spectrum, where a source spectrum has gone through a bandpass.
Usually, this is the end point of a chain of spectral manipulation. It has extra attributes that deal with binning, which is introduced by the detector.
- Parameters:
- spec
SourceSpectrumorspecutils.Spectrum1D Source spectrum.
- band
SpectralElement Bandpass.
- binsetarray-like,
Quantity, orNone Center of binned wavelengths. If not a Quantity, assumed to be in Angstrom. If
None, inputself.wavesetvalues are used.- force{
None, ‘none’, ‘extrap’, ‘taper’} Force creation of an observation even when source spectrum and bandpass do not fully overlap:
Noneor ‘none’ - Source must encompass bandpass (default)‘extrap’ - Extrapolate source spectrum (this changes the underlying model of
specto always extrapolate, if applicable)‘taper’ - Taper source spectrum
- spec
- Raises:
- synphot.exceptions.DisjointError
Bandpass does not overlap with source spectrum.
- synphot.exceptions.PartialOverlap
Bandpass only partially overlaps with source spectrum when they must fully overlap.
- synphot.exceptions.SynphotError
Invalid inputs.
- synphot.exceptions.UndefinedBinset
Missing binned wavelength set.
Attributes Summary
Bandpass of the observation.
Edges of binned wavelengths.
Binned flux corresponding to
binset.Center of binned wavelengths.
Source spectrum of the observation.
Methods Summary
as_spectrum([binned, wavelengths])Reduce the observation to an empirical source spectrum.
binned_pixelrange(waverange, **kwargs)Calculate the number of pixels within the given wavelength range and
binset.binned_waverange(cenwave, npix, **kwargs)Calculate the wavelength range covered by the given number of pixels centered on the given central wavelengths of
binset.countrate(area[, binned, wavelengths, ...])Calculate effective stimulus in count/s.
effective_wavelength([binned, wavelengths, mode])Calculate effective wavelength.
effstim([flux_unit, wavelengths, area, vegaspec])Calculate effective stimulus for given flux unit.
plot([binned, wavelengths, flux_unit, area, ...])Plot the observation.
sample_binned([wavelengths, flux_unit])Sample binned observation without interpolation.
taper(**kwargs)Tapering is disabled.
Attributes Documentation
- bandpass¶
Bandpass of the observation.
- bin_edges¶
Edges of binned wavelengths.
- binset¶
Center of binned wavelengths.
- spectrum¶
Source spectrum of the observation.
Methods Documentation
- as_spectrum(binned=True, wavelengths=None)[source]¶
Reduce the observation to an empirical source spectrum.
An observation is a complex object with some restrictions on its capabilities. At times, it would be useful to work with the observation as a simple object that is easier to manipulate and takes up less memory.
This is also useful for writing an observation as sampled spectrum out to a FITS file.
- Parameters:
- Returns:
- sp
SourceSpectrum Empirical source spectrum.
- sp
- binned_pixelrange(waverange, **kwargs)[source]¶
Calculate the number of pixels within the given wavelength range and
binset.- Parameters:
- waverangetuple of float or
Quantity Lower and upper limits of the desired wavelength range. If not a Quantity, assumed to be in Angstrom.
- kwargsdict
Keywords accepted by
synphot.binning.pixel_range().
- waverangetuple of float or
- Returns:
- npixint
Number of pixels.
- binned_waverange(cenwave, npix, **kwargs)[source]¶
Calculate the wavelength range covered by the given number of pixels centered on the given central wavelengths of
binset.- Parameters:
- cenwavefloat or
Quantity Desired central wavelength. If not a Quantity, assumed to be in Angstrom.
- npixint
Desired number of pixels, centered on
cenwave.- kwargsdict
Keywords accepted by
synphot.binning.wave_range().
- cenwavefloat or
- Returns:
- waverange
Quantity Lower and upper limits of the wavelength range, in the unit of
cenwave.
- waverange
- countrate(area, binned=True, wavelengths=None, waverange=None, force=False)[source]¶
Calculate effective stimulus in count/s.
- Parameters:
- areafloat or
Quantity Area that flux covers. If not a Quantity, assumed to be in \(cm^{2}\).
- binnedbool
Sample data in native wavelengths if
False. Else, sample binned data (default).- wavelengthsarray-like,
Quantity, orNone Wavelength values for sampling. This must be given if
self.wavesetis undefined for the underlying spectrum model(s). If not a Quantity, assumed to be in Angstrom. IfNone,self.wavesetorbinsetis used, depending onbinned.- waverangetuple of float, Quantity, or
None Lower and upper limits of the desired wavelength range. If not a Quantity, assumed to be in Angstrom. If
None, the full range is used.- forcebool
If a wavelength range is given, partial overlap raises an exception when this is
False(default). Otherwise, it returns calculation for the overlapping region. Disjoint wavelength range raises an exception regardless.
- areafloat or
- Returns:
- count_rate
Quantity Observation effective stimulus in count/s.
- count_rate
- Raises:
- synphot.exceptions.DisjointError
Wavelength range does not overlap with observation.
- synphot.exceptions.PartialOverlap
Wavelength range only partially overlaps with observation.
- synphot.exceptions.SynphotError
Calculation failed, including but not limited to NaNs in flux.
- effective_wavelength(binned=True, wavelengths=None, mode='efflerg')[source]¶
Calculate effective wavelength.
- Parameters:
- binnedbool
Sample data in native wavelengths if
False. Else, sample binned data (default).- wavelengthsarray-like,
Quantity, orNone Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If
None,self.wavesetorbinsetis used, depending onbinned.- mode{‘efflerg’, ‘efflphot’}
Flux is first converted to the unit below before calculation:
‘efflerg’ - FLAM
‘efflphot’ - PHOTLAM (deprecated)
- Returns:
- eff_lam
Quantity Observation effective wavelength.
- eff_lam
- Raises:
- synphot.exceptions.SynphotError
Invalid mode.
- effstim(flux_unit=None, wavelengths=None, area=None, vegaspec=None)[source]¶
Calculate effective stimulus for given flux unit.
- Parameters:
- flux_unitstr or
UnitorNone The unit of effective stimulus. COUNT gives result in count/s (see
countrate()for more options). If not given, internal unit is used.- wavelengthsarray-like,
Quantity, orNone Wavelength values for sampling. This must be given if
self.wavesetis undefined for the underlying spectrum model(s). If not a Quantity, assumed to be in Angstrom. IfNone,self.wavesetis used.- area, vegaspec
See
convert_flux().
- flux_unitstr or
- Returns:
- eff_stim
Quantity Observation effective stimulus based on given flux unit.
- eff_stim
- plot(binned=True, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs)[source]¶
Plot the observation.
Note
Uses
matplotlib.- Parameters:
- binnedbool
Plot data in native wavelengths if
False. Else, plot binned data (default).- wavelengthsarray-like,
Quantity, orNone Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If
None,self.wavesetorbinsetis used, depending onbinned.- flux_unitstr or
UnitorNone Flux is converted to this unit for plotting. If not given, internal unit is used.
- area, vegaspec
See
convert_flux().- kwargsdict
- Raises:
- synphot.exceptions.SynphotError
Invalid inputs.
- sample_binned(wavelengths=None, flux_unit=None, **kwargs)[source]¶
Sample binned observation without interpolation.
To sample unbinned data, use
__call__.- Parameters:
- Returns:
- flux
Quantity Binned flux in given unit.
- flux
- Raises:
- synphot.exceptions.InterpolationNotAllowed
Interpolation of binned data is not allowed.