SpectralElement

class synphot.spectrum.SpectralElement(modelclass, clean_meta=False, **kwargs)[source]

Bases: synphot.spectrum.BaseUnitlessSpectrum

Class to handle instrument filter bandpass.

Parameters:
modelclass, kwargs

See BaseSpectrum.

Methods Summary

check_overlap(self, other[, wavelengths, …]) Check for wavelength overlap between two spectra.
efficiency(self[, wavelengths]) Calculate dimensionless efficiency.
emflx(self, area[, wavelengths]) Calculate equivalent monochromatic flux.
equivwidth(self[, wavelengths]) Calculate bandpass equivalent width.
from_file(filename, \*\*kwargs) Creates a bandpass from file.
from_filter(filtername, \*\*kwargs) Load pre-defined filter bandpass.
fwhm(self, \*\*kwargs) Calculate FWHM of equivalent gaussian.
photbw(self[, wavelengths, threshold]) Calculate the bandpass RMS width as in IRAF SYNPHOT.
rectwidth(self[, wavelengths]) Calculate bandpass rectangular width.
rmswidth(self[, wavelengths, threshold]) Calculate the bandpass RMS width.
tlambda(self, \*\*kwargs) Calculate throughput at bandpass average wavelength.
to_fits(self, filename[, wavelengths]) Write the bandpass to a FITS file.
tpeak(self[, wavelengths]) Calculate peak bandpass throughput.
unit_response(self, area[, wavelengths]) Calculate unit response of this bandpass.
wpeak(self[, wavelengths]) Calculate wavelength at peak throughput.

Methods Documentation

check_overlap(self, other, wavelengths=None, threshold=0.01)[source]

Check for wavelength overlap between two spectra.

Only wavelengths where self throughput is non-zero are considered.

Example of full overlap:

|---------- other ----------|
   |------ self ------|

Examples of partial overlap:

|---------- self ----------|
   |------ other ------|

|---- other ----|
   |---- self ----|

|---- self ----|
   |---- other ----|

Examples of no overlap:

|---- self ----|  |---- other ----|

|---- other ----|  |---- self ----|
Parameters:
other : BaseSpectrum
wavelengths : array-like, Quantity, or None

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

threshold : float

If less than this fraction of flux or throughput falls outside wavelength overlap, the lack of overlap is insignificant. This is only used when partial overlap is detected. Default is 1%.

Returns:
result : {‘full’, ‘partial_most’, ‘partial_notmost’, ‘none’}
  • ‘full’ - self coverage is within or same as other
  • ‘partial_most’ - Less than threshold fraction of self flux is outside the overlapping wavelength region, i.e., the lack of overlap is insignificant
  • ‘partial_notmost’ - self partially overlaps with other but does not qualify for ‘partial_most’
  • ‘none’ - self does not overlap other
Raises:
synphot.exceptions.SynphotError

Invalid inputs.

efficiency(self, wavelengths=None)[source]

Calculate dimensionless efficiency.

Parameters:
wavelengths : array-like, Quantity, or None

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

Returns:
qtlam : Quantity

Dimensionless efficiency.

emflx(self, area, wavelengths=None)[source]

Calculate equivalent monochromatic flux.

Parameters:
area, wavelengths

See unit_response().

Returns:
em_flux : Quantity

Equivalent monochromatic flux.

equivwidth(self, wavelengths=None)[source]

Calculate bandpass equivalent width.

Parameters:
wavelengths : array-like, Quantity, or None

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

Returns:
equvw : Quantity

Bandpass equivalent width.

classmethod from_file(filename, **kwargs)[source]

Creates a bandpass from file.

If filename has ‘fits’ or ‘fit’ suffix, it is read as FITS. Otherwise, it is read as ASCII.

Parameters:
filename : str

Bandpass filename.

kwargs : dict

Keywords acceptable by read_fits_spec() (if FITS) or read_ascii_spec() (if ASCII).

Returns:
bp : SpectralElement

Empirical bandpass.

classmethod from_filter(filtername, **kwargs)[source]

Load pre-defined filter bandpass.

Parameters:
filtername : str

Filter name. Choose from ‘bessel_j’, ‘bessel_h’, ‘bessel_k’, ‘cousins_r’, ‘cousins_i’, ‘johnson_u’, ‘johnson_b’, ‘johnson_v’, ‘johnson_r’, ‘johnson_i’, ‘johnson_j’, or ‘johnson_k’.

kwargs : dict

Keywords acceptable by read_remote_spec().

Returns:
bp : SpectralElement

Empirical bandpass.

Raises:
synphot.exceptions.SynphotError

Invalid filter name.

fwhm(self, **kwargs)[source]

Calculate FWHM of equivalent gaussian.

Parameters:
kwargs : dict

See photbw().

Returns:
fwhm_val : Quantity

FWHM of equivalent gaussian.

photbw(self, wavelengths=None, threshold=None)[source]

Calculate the bandpass RMS width as in IRAF SYNPHOT.

This is a compatibility function. To calculate the actual bandpass RMS width, use rmswidth().

Parameters:
wavelengths : array-like, Quantity, or None

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

threshold : float or Quantity, optional

Data points with throughput below this value are not included in the calculation. By default, all data points are included.

Returns:
bandw : Quantity

IRAF SYNPHOT RMS width of the bandpass.

Raises:
synphot.exceptions.SynphotError

Threshold is invalid.

rectwidth(self, wavelengths=None)[source]

Calculate bandpass rectangular width.

Parameters:
wavelengths : array-like, Quantity, or None

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

Returns:
rectw : Quantity

Bandpass rectangular width.

rmswidth(self, wavelengths=None, threshold=None)[source]

Calculate the bandpass RMS width. Not to be confused with photbw().

Parameters:
wavelengths : array-like, Quantity, or None

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

threshold : float or Quantity, optional

Data points with throughput below this value are not included in the calculation. By default, all data points are included.

Returns:
rms_width : Quantity

RMS width of the bandpass.

Raises:
synphot.exceptions.SynphotError

Threshold is invalid.

tlambda(self, **kwargs)[source]

Calculate throughput at bandpass average wavelength.

Parameters:
kwargs : dict

See avgwave().

Returns:
t_lambda : Quantity

Throughput at bandpass average wavelength.

to_fits(self, filename, wavelengths=None, **kwargs)[source]

Write the bandpass to a FITS file.

Throughput column is automatically named ‘THROUGHPUT’.

Parameters:
filename : str

Output filename.

wavelengths : array-like, Quantity, or None

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

kwargs : dict

Keywords accepted by write_fits_spec().

tpeak(self, wavelengths=None)[source]

Calculate peak bandpass throughput.

Parameters:
wavelengths : array-like, Quantity, or None

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

Returns:
tpeak : Quantity

Peak bandpass throughput.

unit_response(self, area, wavelengths=None)[source]

Calculate unit response of this bandpass.

Parameters:
area : float or Quantity

Area that flux covers. If not a Quantity, assumed to be in \(cm^{2}\).

wavelengths : array-like, Quantity, or None

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

Returns:
uresp : Quantity

Flux (in FLAM) of a star that produces a response of one photon per second in this bandpass.

wpeak(self, wavelengths=None)[source]

Calculate wavelength at peak throughput.

If there are multiple data points with peak throughput value, only the first match is returned.

Parameters:
wavelengths : array-like, Quantity, or None

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

Returns:
wpeak : Quantity

Wavelength at peak throughput.