# Observation¶

class synphot.observation.Observation(spec, band, binset=None, force='none')[source]

This 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 : SourceSpectrum Source spectrum. band : SpectralElement Bandpass. binset : array-like, Quantity, or None Center of binned wavelengths. If not a Quantity, assumed to be in Angstrom. If None, input self.waveset values are used. force : {None, ‘none’, ‘extrap’, ‘taper’} Force creation of an observation even when source spectrum and bandpass do not fully overlap: None or ‘none’ - Source must encompass bandpass (default) ‘extrap’ - Extrapolate source spectrum (this changes the underlying model of spec to always extrapolate, if applicable) ‘taper’ - Taper source spectrum 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 Bandpass of the observation. bin_edges Edges of binned wavelengths. binflux Binned flux corresponding to binset. binset Center of binned wavelengths. spectrum Source spectrum of the observation.

Methods Summary

 as_spectrum(self[, binned, wavelengths]) Reduce the observation to an empirical source spectrum. binned_pixelrange(self, waverange, \*\*kwargs) Calculate the number of pixels within the given wavelength range and binset. binned_waverange(self, cenwave, npix, \*\*kwargs) Calculate the wavelength range covered by the given number of pixels centered on the given central wavelengths of binset. countrate(self, area[, binned, wavelengths, …]) Calculate effective stimulus in count/s. effective_wavelength(self[, binned, …]) Calculate effective wavelength. effstim(self[, flux_unit, wavelengths, …]) Calculate effective stimulus for given flux unit. plot(self[, binned, wavelengths, flux_unit, …]) Plot the observation. sample_binned(self[, wavelengths, flux_unit]) Sample binned observation without interpolation. taper(self, \*\*kwargs) Tapering is disabled.

Attributes Documentation

bandpass

Bandpass of the observation.

bin_edges

Edges of binned wavelengths.

binflux

Binned flux corresponding to binset.

binset

Center of binned wavelengths.

spectrum

Source spectrum of the observation.

Methods Documentation

as_spectrum(self, 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: binned : bool Write out data in native wavelengths if False. Else, write binned data (default). wavelengths : array-like, Quantity, or None Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If None, self.waveset or binset is used, depending on binned. sp : SourceSpectrum Empirical source spectrum.
binned_pixelrange(self, waverange, **kwargs)[source]

Calculate the number of pixels within the given wavelength range and binset.

Parameters: waverange : tuple of float or Quantity Lower and upper limits of the desired wavelength range. If not a Quantity, assumed to be in Angstrom. kwargs : dict Keywords accepted by synphot.binning.pixel_range(). npix : int Number of pixels.
binned_waverange(self, cenwave, npix, **kwargs)[source]

Calculate the wavelength range covered by the given number of pixels centered on the given central wavelengths of binset.

Parameters: cenwave : float or Quantity Desired central wavelength. If not a Quantity, assumed to be in Angstrom. npix : int Desired number of pixels, centered on cenwave. kwargs : dict Keywords accepted by synphot.binning.wave_range(). waverange : Quantity Lower and upper limits of the wavelength range, in the unit of cenwave.
countrate(self, area, binned=True, wavelengths=None, waverange=None, force=False)[source]

Calculate effective stimulus in count/s.

Parameters: area : float or Quantity Area that flux covers. If not a Quantity, assumed to be in $$cm^{2}$$. binned : bool Sample data in native wavelengths if False. Else, sample binned data (default). wavelengths : array-like, Quantity, or None Wavelength values for sampling. This must be given if self.waveset is undefined for the underlying spectrum model(s). If not a Quantity, assumed to be in Angstrom. If None, self.waveset or binset is used, depending on binned. waverange : tuple 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. force : bool 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. count_rate : Quantity Observation effective stimulus in count/s. 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.
effective_wavelength(self, binned=True, wavelengths=None, mode='efflerg')[source]

Calculate effective wavelength.

Parameters: binned : bool Sample data in native wavelengths if False. Else, sample binned data (default). wavelengths : array-like, Quantity, or None Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If None, self.waveset or binset is used, depending on binned. mode : {‘efflerg’, ‘efflphot’} Flux is first converted to the unit below before calculation: ‘efflerg’ - FLAM ‘efflphot’ - PHOTLAM (deprecated) eff_lam : Quantity Observation effective wavelength. synphot.exceptions.SynphotError Invalid mode.
effstim(self, flux_unit=None, wavelengths=None, area=None, vegaspec=None)[source]

Calculate effective stimulus for given flux unit.

Parameters: flux_unit : str or Unit or None The unit of effective stimulus. COUNT gives result in count/s (see countrate() for more options). If not given, internal unit is used. wavelengths : array-like, Quantity, or None Wavelength values for sampling. This must be given if self.waveset is undefined for the underlying spectrum model(s). If not a Quantity, assumed to be in Angstrom. If None, self.waveset is used. area, vegaspec eff_stim : Quantity Observation effective stimulus based on given flux unit.
plot(self, binned=True, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs)[source]

Plot the observation.

Note

Uses matplotlib.

Parameters: binned : bool Plot data in native wavelengths if False. Else, plot binned data (default). wavelengths : array-like, Quantity, or None Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If None, self.waveset or binset is used, depending on binned. flux_unit : str or Unit or None Flux is converted to this unit for plotting. If not given, internal unit is used. area, vegaspec kwargs : dict synphot.exceptions.SynphotError Invalid inputs.
sample_binned(self, wavelengths=None, flux_unit=None, **kwargs)[source]

Sample binned observation without interpolation.

To sample unbinned data, use __call__.

Parameters: wavelengths : array-like, Quantity, or None Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If None, binset is used. flux_unit : str or Unit or None Flux is converted to this unit. If not given, internal unit is used. kwargs : dict Keywords acceptable by convert_flux(). flux : Quantity Binned flux in given unit. synphot.exceptions.InterpolationNotAllowed Interpolation of binned data is not allowed.
taper(self, **kwargs)[source]

Tapering is disabled.