kcorrect.template

Classes

SED

Spectral energy distribution(s)

Template

Spectral energy distribution template(s)

Module Contents

class SED(filename=None, wave=None, flux=None, ext='FLUX', interpolate=True)[source]

Bases: object

Spectral energy distribution(s)

Parameters:
  • filename (str) – name of FITS file to read from

  • wave (ndarray of np.float32) – rest frame wavelength grid in Angstroms

  • flux (ndarray of np.float32) – [nsed, nwave] rest frame flux grid in erg/cm^2/s/A at 10pc

  • ext (str) – extension from which to read FLUX in FITS file

  • interpolate (bool) – create interpolation object

binimage[source]

if True, files use WAVE and FLUX extensions

Type:

bool

filename[source]

name of FITS file associated with this SED

Type:

str

flux

[nsed, nwave] flux grid in erg/cm^2/s/A at 10pc and currently set redshift

Type:

ndarray of np.float32

info[source]

dictionary for storing assorted metadata associated with spectra

Type:

dict

interp[source]

interpolation object for spectra

Type:

scipy.interpolate.interp1d object

interpolate[source]

“interp” object created

Type:

bool

nsed

number of SEDs

Type:

np.float32

nwave

number of wavelengths in grid

Type:

np.int32

redshift

redshift of SED

Type:

np.float32

restframe_flux[source]

[nsed, nwave] rest frame flux grid in erg/cm^2/s/A at 10pc

Type:

ndarray of np.float32

restframe_wave[source]

[nwave] rest frame wavelength grid in Angstroms

Type:

ndarray of np.float32

wave

[nwave] wavelength grid in Angstroms

Type:

ndarray of np.float32

Notes

The fluxes are a bit funnily defined, in terms of the flux that the galaxy would have at 10pc, analogous to an absolute magnitude. When the redshift is applied, the bolometric flux is conserved (i.e. there is no luminosity distance applied, it is a pure redshifting of the spectrum).

If filename is set, overrides wave and flux.

If binimage is True, then instead of a FLUX HDU table, there should be WAVE and FLUX HDUs with binary images.

restframe_wave = None[source]
restframe_flux = None[source]
filename = None[source]
interp = None[source]
interpolate = True[source]
info[source]
binimage = False[source]
_setup()[source]

Set up after restframe_wave and restframe_flux are read in

sed_dtype()[source]

Returns numpy dtype for SED

set_interp()[source]

Sets attribute interp to interpolation function

fromfits(filename=None, ext='FLUX')[source]

Read SED from FITS files

Parameters:
  • filename (str) – input file name

  • ext (str or int) – extension to read from

Notes

The FITS table should have two columns:

wave - an [nwave] array of wavelengths in Angstrom flux - an [nsed, nwave] array of fluxes

Only imports the first row of the FITS table.

tofits(filename=None, ext='FLUX', clobber=True)[source]

Write SED to FITS files

Parameters:
  • filename (str) – output file name

  • ext (str or int) – extension to write to

  • clobber (bool) – whether to clobber the existing file or add an HDU

Notes

Writes a one-row FITS table with two columns:

wave : an [nwave] array of restframe wavelengths in Angstrom

flux : an [nsed, nwave] array of restframe fluxes

If binimage is set for this object, instead write two HDUs.

set_redshift(redshift=0.0)[source]

Set redshift of SED

Parameters:

redshift (np.float32) – redshift to shift to

Notes

Conserves bolometric integral of flux.

plot(indx=None, wavelim=None)[source]

Simple matplotlib plot of template(s)

Parameters:
  • indx (np.int32 or ndarray of np.int32) – index of template(s) to plot

  • wavelim (list or ndarray of np.float32) – [2] wavelength limits of plot

Notes

Plots log of wavelength and log of lambda * flux_lambda.

class Template(filename=None, ext='FLUX', interpolate=False)[source]

Bases: SED

Spectral energy distribution template(s)

Parameters:
  • filename (str) – name of FITS file to read from

  • binimage (bool) – if True, read in WAVE and FLUX extensions as binary images

  • ext (str) – extension from which to read FLUX in FITS file

  • interpolate (bool) – create interpolation object

binimage[source]

if True, read in WAVE and FLUX extensions as binary images

Type:

bool

filename[source]

name of FITS file associated with this SED

Type:

str

flux

[nsed, nwave] flux grid in erg/cm^2/s/A

Type:

ndarray of np.float32

info[source]

dictionary for storing assorted metadata associated with spectra

Type:

dict

interp[source]

interpolation object for spectra

Type:

scipy.interpolate.interp1d object

interpolate[source]

“interp” object created

Type:

bool

intsfh[source]

[nsed] integrated star formation history in solar masses

Type:

ndarray of np.float32

m300[source]

[nsed] stars formed last 300 million years in solar masses

Type:

ndarray of np.float32

m1000[source]

[nsed] stars formed last billion years in solar masses

Type:

ndarray of np.float32

mets[source]

[nsed] metallicity in current stars and stellar remnants

Type:

ndarray of np.float32

mremain[source]

[nsed] remaining mass in stars and remnants in solar masses

Type:

ndarray of np.float32

nsed

number of SEDs

Type:

np.float32

nwave

number of wavelengths in grid

Type:

np.int32

redshift

redshift of SED

Type:

np.float32

restframe_flux[source]

[nsed, nwave] rest frame flux grid in erg/cm^2/s/A

Type:

ndarray of np.float32

restframe_wave[source]

[nwave] rest frame wavelength grid in Angstroms

Type:

ndarray of np.float32

wave

[nwave] wavelength grid in Angstroms

Type:

ndarray of np.float32

Notes

If filename is set, overrides wave and flux.

The file should have the HDUs:

FLUXan ndarray with two tags:

‘wave’ : an [nwave]-array of np.float32 with wavelength in Ang. ‘flux’ : an [nsed, nwave]-array of np.float32 with flux in erg/s/cm^2/A

METS : an [nsed]-array with metallicity INTSFH : an [nsed]-array with integrated SF in solar units MREMAIN : an [nsed]-array with current stellar mass in solar units M50 : an [nsed]-array with mass formed within 50 My in solar units M300 : an [nsed]-array with mass formed within 300 My in solar units M1000 : an [nsed]-array with mass formed within 1 Gy in solar units

If binimage is True, then instead of a FLUX HDU table, there should be WAVE and FLUX HDUs with binary images.

intsfh[source]
mremain[source]
mets[source]
m300[source]
m1000[source]
tofits(filename=None, clobber=True)[source]

Write template set to FITS

Parameters:
  • filename (str) – file to write to

  • clobber (bool) – if True, overwrite existing file