kcorrect.response
Classes
Dictionary of all responses (singleton) |
|
Astronomical bandpass description |
Functions
|
List all responses available |
Module Contents
- all_responses(response_dir=os.path.join(kcorrect.KCORRECT_DIR, 'data', 'responses'), check_validity=False)[source]
List all responses available
- Parameters:
response_dir (str) – path to directory containing responses
check_validity (bool) – if True, check the validity of the files
- Returns:
responses – response names for available bandpasses
- Return type:
list of str
Notes
Returns all base names of files with the suffix ‘.dat’ in the response_dir directory.
By default, response_dir is the “data/responses” directory within the kcorrect Python distribution.
If the user specifies response_dir and check_validity is False, there is no guarantee that the response files in the specified directory are valid!
If check_validity is True, the responses are also loaded into the ResponseDict() singleton.
- class Response(filename=None, wave=None, response=None)[source]
Bases:
objectAstronomical bandpass description
- Parameters:
filename (str) – file name to read from
wave (ndarray of np.float32) – wavelength grid in Angstroms
response (ndarray of np.float32) – response function
- fwhm, fwhm_low, fwhm_hight
FWHM of response, with low and high wavelength limits (Angstroms)
- Type:
np.float32
- nwave
number of wavelength samples
- Type:
int
- response
response function
- Type:
ndarray of np.float32
- vega2ab
magnitude offset from Vega to AB (m_AB - m_Vega), or None
- Type:
np.float32
- wave
wavelength grid in Angstroms
- Type:
ndarray of np.float32
Notes
The response should be the relative response of the system (atmosphere, telescope, detector, etc) to a photon at each given wavelength entering the Earth’s atmosphere (for a ground based telescope) or the telescope aperture (space based).
If a file is given it is assumed to be in fixed_width format, readable and writeable by astropy.io.ascii
The wavelengths are sorted on input so the attribute wave is always increasing.
The attribute interp() takes wavelength in Angstroms as its one positional argument.
The effective wavelength is defined as described in Blanton & Roweis (2007).
- fromfits(filename=None, ext=1)[source]
Read response from FITS files
- Parameters:
filename (str) – input file name
ext (str or int) – extension to read from
- fromdat(filename=None)[source]
Read response from fixed_width file
- Parameters:
filename (str) – input file name
Notes
If an absolute path, reads that. If not, looks relative to KCORRECT_DIR/python/kcorrect/data/responses
- tofits(filename=None, ext='FLUX', clobber=True)[source]
Write SED to FITS files
- filenamestr
output file name
- extstr or int
extension to write to
- clobberbool
whether to clobber the existing file or add an HDU
- project(sed=None, wave=None, flux=None)[source]
Project spectrum onto response
- Parameters:
sed (kcorrect.template.SED object) – spectrum in kcorrect format
wave (ndarray of np.float32) – wavelength grid (used only if sed and func not set)
flux (ndarray of np.float32) – flux grid (used only if sed and func not set)
- Returns:
maggies – [nsed] nmaggies associated with spectrum through bandpass
- Return type:
np.float32
Notes
Fluxes should be in erg cm^{-2} s^{-1} Angstrom^{-1}
If “flux” and “wave” are specified, then wave must be a 1-dimensional array, and flux must be a 1-dimensional or 2-dimensional array, with the last axis corresponding to wavelength and with the same number of elements as wave.
Assumes AB calibration.
If the bandpass is outside the range of the solar model, 0 is returned.
- set_fwhm_limits()[source]
Set limits for FWHM
Notes
Sets attributes fwhm_low, fwhm_high, fwhm.
fwhm_low is the lowest wavelength value for which the response reaches 50% maximum when starting from the low end.
fwhm_high is the highest wavelength value for which the response reaches 50% maximum when starting from the high end.
fwhm is (fwhm_high - fwhm_low)