kcorrect.utils

Functions

sed_ab([wave])

Calculate AB source spectrum

read_basel([filename])

Read Basel-style spectrum file

sdss_ab_correct([maggies, ivar, abfix])

Return AB maggies based on SDSS standard maggies

error_floor([floor, maggies, ivar])

Calculate new inverse variance with fractional error floors

sdss_asinh_to_maggies([mag, mag_err, extinction])

Calculate maggies and ivar based on catalog parameters

maggies2flambda([maggies, ivar, responses])

Return arrays of wave, flambda for maggies

Module Contents

sed_ab(wave=None)[source]

Calculate AB source spectrum

Parameters:

wave (ndarray of np.float32) – wavelength in Angstrom

Returns:

ab – AB flux in erg cm^{-2} s^{-1} Angstrom^{-1}

Return type:

ndarray of np.float32

read_basel(filename=None)[source]

Read Basel-style spectrum file

Parameters:

filename (str) – file to read from

Returns:

  • info (dict) – meta-data for model

  • wave (ndarray of np.float32) – [1221] wavelengths in nm

  • flux (ndarray of np.float32) – [N, 1221] fluxes in erg/cm^2/s/Hz

Notes

1221 hardcoded as number of spectral elements.

Model parameters stored as arrays in info attribute are:

‘modelno’ ‘teff’ ‘logg’ ‘mh’ ‘vturb’ ‘xh’

sdss_ab_correct(maggies=None, ivar=None, abfix=[-0.036, 0.012, 0.01, 0.028, 0.04])[source]

Return AB maggies based on SDSS standard maggies

Parameters:
  • maggies (ndarray of np.float32) – array of fluxes in standard SDSS system

  • ivar (ndarray of np.float32) – inverse variances in standard SDSS system (optional)

  • abfix (ndarray or list of np.float32) – [5]-array of magnitude offset to apply to standard values

Returns:

  • ab_maggies (ndarray of np.float32) – array of fluxes converted to AB

  • ab_ivar (ndarray of np.float32) – inverse variances converted to AB (if ivar input)

Notes

Uses the AB conversions produced by D. Eisenstein, in his message sdss-calib/1152

u(AB,2.5m) = u(database, 2.5m) - 0.036
g(AB,2.5m) = g(database, 2.5m) + 0.012
r(AB,2.5m) = r(database, 2.5m) + 0.010
i(AB,2.5m) = i(database, 2.5m) + 0.028
z(AB,2.5m) = z(database, 2.5m) + 0.040

Unless an alternative is specified with the abfix parameter.

error_floor(floor=None, maggies=None, ivar=None)[source]

Calculate new inverse variance with fractional error floors

Parameters:
  • floor (ndarray of np.float32) – [Nr] fractional error floor for each response

  • maggies (ndarray of np.float32) – [N, Nr] or [Nr] array of maggies

  • ivar (ndarray of np.float32) – [N, Nr] or [Nr] array of inverse variance of maggies

Returns:

ivar – [N, Nr] or [Nr] array of inverse variances

Return type:

ndarray of np.float32

sdss_asinh_to_maggies(mag=None, mag_err=None, extinction=None)[source]

Calculate maggies and ivar based on catalog parameters

Parameters:
  • mag (ndarray of np.float32) – [N, 5] or [5] array of asinh magnitudes from SDSS

  • mag_err (ndarray of np.float32) – [N, 5] or [5] array of asinh magnitude errors from SDSS

  • extinction (ndarray or list of np.float32) – [N, 5] or [5] array of Galactic extinctions from SDSS

Returns:

  • maggies (ndarray of np.float32) – [N, 5] or [5] array of maggies

  • ivar (ndarray of np.float32) – [N, 5] or [5] array of inverse variances

Notes

If extinction set, applies extinction (after converting to maggies).

Does not apply AB corrections.

If mag_err is None on input, only maggies is returned.

maggies2flambda(maggies=None, ivar=None, responses=None)[source]

Return arrays of wave, flambda for maggies

Parameters:
  • maggies (np.float32 or ndarray of np.float32) – maggies to convert

  • ivar (np.float32 or ndarray of np.float32) – inverse variance of maggies to convert (or None)

  • responses (list of str) – names of responses that each maggies corresponds to

Returns:

  • wave (np.float32 or ndarray of np.float32) – effective wavelength of each response curve

  • flux (np.float32 or ndarray of np.float32) – flux in erg/s/cm^2/A corresponding to maggies

  • flux_ivar (np.float32 or ndarray of np.float32) – inverse variance of flux (if ivar input)

Notes

If ivar is set on input, output is (wave, flux, flux_ivar).

If ivar is not set on input, output is (wave, flux)

Effective wavelength is derived from response curve; curve is loaded into the response dictionary if it isn’t there already.