Template

class eazy.templates.Template(file=None, name=None, arrays=None, sp=None, meta={}, to_angstrom=1.0, velocity_smooth=0, norm_filter=None, resample_wave=None, fits_column='flux', redfunc=<Redden None, Av/tau_V=0.0>, redshifts=[0], verbose=True, flux_unit=Unit("solLum / Angstrom"), **kwargs)[source]

Bases: object

Template object.

Can optionally specify a 2D flux array with the first dimension indicating the template for the nearest redshift in the corresponding redshifts list. See When integrating the filter fluxes with integrate_filter, the template index with the redshift nearest to the specified redshift will be used.

Parameters:
filestr

Filename of ascii or FITS template

arrays(array, array)

Tuple of wave, flux arrays. Here flux assumed to have units f-lambda.

spobject

Object with wave, flux attributes, e.g., from prospector. Here flux is assumed to have units of f-nu.

to_angstromfloat

Scale factor such that wave * to_angstrom has units of astropy.units.Angstrom

velocity_smoothfloat

Velocity smooothing in km/s, applied if > 0

resample_wavearray

Grid to resample the template wavelengths read from the input

fits_columnstr

Column name of the flux column if arrays read from a file

redfunceazy.templates.Redden

Object to apply additional reddening.

redshiftsarray-like

Redshift grid for redshift-dependent templates

flux_unitastropy.units.core.Unit

Units of flux array.

Attributes:
wavearray

wavelength in astropy.units.Angstrom, dimensions [NWAVE].

fluxarray

Flux density f-lambda, can have redshift dependence, dimensions [NZ, NWAVE].

namestr

Label name

metadict

Metadata

redfunceazy.templates.Redden, optional

Object for applying dust reddening.

Attributes Summary

redden

Return multiplicative scaling from self.redfunc, which is expected to return attenuation in magnitudes.

shape

Shape of flux attribute

Methods Summary

absorbed_energy([i])

flux_flam([iz, z, redshift_type])

Get redshift-dependent template in units of f-lambda

flux_fnu([iz, z, redshift_type])

Get redshift-dependent template in units of f-nu

igm_absorption(z[, scale_tau, pow])

Compute IGM absorption with eazy.igm.Inoue14.

integrate_filter(filt[, flam, scale, z, ...])

Integrate the template through a FilterDefinition filter object.

integrate_filter_list(filters[, ...])

Integrate template through all filters

resample(new_wave[, z, in_place, ...])

Resample the template to a new wavelength grid

set_fnu()

Deprecated.

smooth_velocity(velocity_smooth[, in_place, ...])

Smooth template in velocity using sedpy (formerly in astro-prospector)

to_observed_frame([z, scalar, extra_sigma, ...])

Smooth and resample to observed-frame wavelengths, including an optional Line Spread Function (LSF)

to_table([formats, with_units, flatten])

Return template as an astropy.table.Table.

zindex([z, redshift_type])

Get the redshift index of a multi-dimensional template array

zscale(z[, scalar, include_igm])

Redshift the template and multiply by a scalar.

Attributes Documentation

redden

Return multiplicative scaling from self.redfunc, which is expected to return attenuation in magnitudes.

shape

Shape of flux attribute

Methods Documentation

absorbed_energy(i=0)[source]
flux_flam(iz=0, z=None, redshift_type='nearest')[source]

Get redshift-dependent template in units of f-lambda

Parameters:
izint

Index of template to retrieve

zfloat, None

If specified, get the redshift index with zindex.

redshift_type‘nearest’, ‘interp’

See zindex.

Returns:
flamarray

Template flux density in units of f-lambda, including any reddening specified in the redden attribute.

flux_fnu(iz=0, z=None, redshift_type='nearest')[source]

Get redshift-dependent template in units of f-nu

Parameters:
izint

Index of template to retrieve

zfloat, None

If specified, get the redshift index with zindex.

redshift_typestr

See zindex.

Returns:
fnuarray

Template flux density in units of f-nu, including any reddening specified in the redden attribute.

igm_absorption(z, scale_tau=1.0, pow=1)[source]

Compute IGM absorption with eazy.igm.Inoue14.

Parameters:
zfloat

Redshift to use for IGM absorption factors

scale_taufloat

Scale factor multiplied to of IGM tau values

powfloat

Scale the absorption strength as eazy.igm.Inoue14()**pow.

integrate_filter(filt, flam=False, scale=1.0, z=0, include_igm=False, redshift_type='nearest', iz=None)[source]

Integrate the template through a FilterDefinition filter object.

Note

The grizli interpolation function grizli.utils_c.interp.interp_conserve_c will be used if available.

Parameters:
filtFilterDefinition object or a list of them

Filter(s) to interpolate

flambool

Return integrated fluxes in f-lambda, rather than f-nu

scalefloat, array

Scale factor applied to template before integrating. If an array is specified, it must have the same size as the template wave array.

zfloat

Redshift the template before integrating through the filter

include_igmbool

Include IGM absorption

redshift_typestr

See zindex.

izint

Evaluate for a specific index of the flux array rather than calculating with zindex

Returns:
fnufloat or array

Template integrated through one or more filters from filt. By defaults has units of fnu

Note

The interpolated fluxes do not include factors of (1+z) from the redshifted templates.

integrate_filter_list(filters, include_igm=True, norm_index=None, **kwargs)[source]

Integrate template through all filters

filters: list of Filter objects

[rewritten as simple wrapper]

resample(new_wave, z=0, in_place=True, return_array=False, interp_func=None)[source]

Resample the template to a new wavelength grid

Parameters:
new_wavearray

New wavelength array, can have units.

zfloat

Redshift internal wavelength before resampling. (z=0 yields no shift).

in_placebool

Set internal wave and flux arrays to the resampled values

return_arraybool

Return the resampled flux array if true, else return a new Template object.

interp_funcNone

Interpolation function. If nothing specified, tries to use grizli.utils_c.interp.interp_conserve_c and falls back to eazy.utils.interp_conserve.

set_fnu()[source]

Deprecated. flux_fnu is now a more cmoplicated function.

smooth_velocity(velocity_smooth, in_place=True, raise_error=False, smoothspec_kwargs={'fftsmooth': True})[source]

Smooth template in velocity using sedpy (formerly in astro-prospector)

Parameters:
velocity_smooth: float

Velocity smoothing sigma, in km/s.

in_placebool

Set internal flux array to the smoothed array. If False, then return a new Template object.

raise_errorbool

If from sedpy.smoothing import smooth_vel fails, raise an exception or die quietly.

to_observed_frame(z=0, scalar=1.0, extra_sigma=0, lsf_func=None, to_air=False, wavelengths=None, smoothspec_kwargs={'fftsmooth': False}, include_igm=True, clip_wavelengths=[4500, 9400], as_template=True)[source]

Smooth and resample to observed-frame wavelengths, including an optional Line Spread Function (LSF)

Note that the smoothing is performed with sedpy.smoothing.smoothspec, which doesn’t integrate precisely over “pixels” for spectral resolutions that are similar to or less than the target smoothing factor.

Parameters:
zfloat

Target redshift. Note that only the wavelength array is shifted by (1+z). The flux densities optionally include IGM absorption (and dust from the redfunc attribute) but don’t include the fl_obs = fl_rest / (1+z) scaling.

scalarfloat, array

Scalar value or array with same dimensions as wave and flux attributes

extra_sigmafloat

Extra velocity dispersion (sigma, km/s) to add in quadrature with the MUSE LSF

lsf_func‘Bacon’, function

Line Spread Function (LSF). If 'Bacon', then use the “UDF-10” MUSE LSF from Bacon et al. 2017 (Eq. 8). Can also be a function that takes an argument of wavelength in Angstroms and returns the LSF sigma, in Angstroms. If neither of these, then only extra_sigma will be applied.

to_airbool

Apply vacuum-to-air conversion with mpdaf.obj.vactoair

wavelengthsarray, None

Optional wavelength grid (observed frame) of the target output (e.g., MUSE) spectrum

smoothspec_kwargsdict

Extra keyword arguments to pass to the sedpy/prospector smoothing function sedpy.smoothing.smoothspec. When testing with very high resolution templates around a specific wavelength, smoothspec_kwargs = {'fftsmooth':True} did not always work as expected, so be careful with this option (which is much faster).

include_igmbool

Include IGM absorption at indicated redshift

clip_wavelengths[float, float]

Trim the full observed-frame wavelength array before convolving. The defaults bracket the nominal MUSE range.

Returns:
tobsTemplate or array-like

Smoothed and resampled Template object or flux array, depending on is_array

to_table(formats={'flux': '.5e', 'wave': '.5e'}, with_units=False, flatten=True)[source]

Return template as an astropy.table.Table.

Parameters:
formatsdict

Set format attributes of table columns

with_unitsbool

Set unit attributes of table columns

flattenbool

If no redshift dependence (NZ==0), columns are 1D arrays.

Returns:
tabastropy.table.Table

Output table

zindex(z=0.0, redshift_type='nearest')[source]

Get the redshift index of a multi-dimensional template array

Parameters:
zfloat

Redshift to retrieve

redshift_type‘nearest’, ‘interp’, ‘floor’

Interpolation type:

  • ‘nearest’: nearest step in the template redshift grid

  • ‘interp’: Returns index below z and interpolation fraction

  • ‘floor’: last index where redshift grid < z.

Returns:
izint

Array index, i.e, self.flux[iz,:]

fracfloat, optional

Fraction for interpolation, if redshift_type == 'interp'.

zscale(z, scalar=1, include_igm=True, **kwargs)[source]

Redshift the template and multiply by a scalar.

Parameters:
zfloat

Redshift to use.

scalarfloat or array

Multiplicative factor. Additional factor of 1./(1+z) is implicit.

include_igmbool

Include Inoue (2014) IGM absorption (also can be passed as apply_igm in kwargs.)

Returns:
ztempTemplate

Redshifted and scaled spectrum.