# 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

Source spectrum.

bandSpectralElement

Bandpass.

binsetarray-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

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 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([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.

binflux

Binned flux corresponding to binset.

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:
binnedbool

Write out data in native wavelengths if False. Else, write binned data (default).

wavelengthsarray-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.

Returns:
spSourceSpectrum

Empirical source spectrum.

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().

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().

Returns:
waverangeQuantity

Lower and upper limits of the wavelength range, in the unit of cenwave.

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, 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.

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.

Returns:
count_rateQuantity

Observation effective stimulus in count/s.

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, 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)

Returns:
eff_lamQuantity

Observation effective wavelength.

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 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.

wavelengthsarray-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
Returns:
eff_stimQuantity

Observation effective stimulus based on given flux unit.

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, 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_unitstr or Unit or None

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

area, vegaspec
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:
wavelengthsarray-like, Quantity, or None

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

flux_unitstr or Unit or None

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

kwargsdict

Keywords acceptable by convert_flux().

Returns:
fluxQuantity

Binned flux in given unit.

Raises:
synphot.exceptions.InterpolationNotAllowed

Interpolation of binned data is not allowed.

taper(**kwargs)[source]

Tapering is disabled.