kcorrect.response

Classes

ResponseDictSingleton

ResponseDict

Dictionary of all responses (singleton)

Response

Astronomical bandpass description

Functions

all_responses([response_dir, check_validity])

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 ResponseDictSingleton[source]

Bases: type

_instances[source]
__call__(*args, **kwargs)[source]
class ResponseDict[source]

Bases: dict

Dictionary of all responses (singleton)

load_response(response=None, reload=False)[source]

Load response into dictionary

Parameters:
  • response (str) – response to load

  • reload (bool) – if True, reload the response if already in ResponseDict (default False)

class Response(filename=None, wave=None, response=None)[source]

Bases: object

Astronomical 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

filename[source]

source filename, or None

Type:

str

fwhm, fwhm_low, fwhm_hight

FWHM of response, with low and high wavelength limits (Angstroms)

Type:

np.float32

interp[source]

interpolation object

Type:

scipy.interpolate.interp1d object

lambda_eff[source]

effective wavelength in Angstroms

Type:

np.float32

nwave

number of wavelength samples

Type:

int

response

response function

Type:

ndarray of np.float32

solar_magnitude[source]

absolute magnitude of Sun through filter, or None

Type:

np.float32

solar_sed[source]

SED associated with Sun for solar_magnitude

Type:

kcorrect.template.SED object

vega2ab

magnitude offset from Vega to AB (m_AB - m_Vega), or None

Type:

np.float32

vega_sed[source]

SED associated with Vega for vega_magnitude

Type:

kcorrect.template.SED object

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

filename = None[source]
solar_sed = None[source]
solar_magnitude = None[source]
vega_sed = None[source]
vega_magnitude = None[source]
lambda_eff = None[source]
interp = None[source]
fwhm = None[source]
fwhm_low = None[source]
fwhm_high = None[source]
_setup()[source]

Some initial setup after an input

response_dtype()[source]

Returns numpy dtype for SED

set_interp()[source]

Sets attribute interp to interpolation function

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_lambda_eff()[source]

Set effective wavelength

Notes

Sets attribute lambda_eff

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)

set_solar_magnitude()[source]

Set absolute magnitude of Sun through filter

Notes

Uses lcbsun.ori model from Lejeune et al (1997)

If the response function is outside the model wavelength range, solar_magnitude is set to None.

set_vega2ab()[source]

Set Vega to AB magnitude conversion

Notes

Uses lcbvega.ori model from Lejeune et al (1997)

If the response function is outside the model wavelength range, vega2ab is set to None.