Spectral Template Libraries

The two main full-spectrum-fitting modules of the DAP, the stellar kinematics module (StellarContinuumModel) and the emission-line module (EmissionLineModel), use template libraries to fit the stellar continuum. We describe below the template libraries included in the DAP repository and the format needed to add new libraries.

Included Libraries

The following spectral template libraries are included with the DAP distribution:

Key

Reference

Type

Pedigree

Comments

BC03

[1] [2]

SPS

Empirical

README

BPASS

[3]

SPS

Theoretical

README

M11ELODIE

[4]

SPS

Empirical

README

M11MARCS

[4]

SPS

Theoretical

README

M11MILES

[4]

SPS

Empirical

README

M11STELIB

[4]

SPS

Empirical

README

M11STELIBZSOL

[4]

SPS

Empirical

README

MASTARHC

[5]

Stellar

Empirical

README

MASTARHC2

[5]

Stellar

Empirical

README

MASTARSSP

[10]

SPS

Empirical

README

MILES

[6]

Stellar

Empirical

README

MILESAVG

[6]

Stellar

Empirical

README

MILESHC

[7]

Stellar

Empirical

README

MILESTHIN

[6]

Stellar

Empirical

README

MIUSCAT

[8]

SPS

Empirical

README

MIUSCATTHIN

[8]

SPS

Empirical

README

STELIB

[9]

Stellar

Empirical

README

Template Library Datamodel

Input Data Format

The primary constraint on the format of the spectra to be used as templates is that they are read using read_template_spectrum(). That is:

  • Each spectrum must be in its own fits file.

  • The flux data must be in the first extension.

  • The wavelength vector is constructed from the header WCS (see wavelength_vector()). The wavelength range of each spectrum need not be the same.

  • The inverse variance or wavelength dependent spectral resolution (\(R=\lambda/\delta\lambda\)) can be optionally provided. If the spectral resolution is not provided, it should be defined by the Template Library Definition.

Template Library Definition

Template libraries are defined for use in the DAP using the configuration files in $MANGADAP_DIR/mangadap/config/spectral_templates or by defining the required parameters in the Analysis Plans. The required parameters are:

Key

Type

Options

Default

Description

key

str

MILESHC

Keyword to distinguish the template library.

file_search

str

miles_cluster/*.fits

Search pattern used to find the 1D fits spectra to include in the template library. The search string must either include the full path or be within the template directory of the DAP source distribution.

fwhm

int, float

2.5

FWHM of the resolution element in angstroms.

sres_ext

str

Extension in the fits files with measurements of the spectral resolution as a function of wavelength. If present, this supercedes any provided FWHM.

in_vacuum

bool

False

Flag that the wavelengths of the spectra are in vacuum, not air.

wave_limit

ndarray, list

Two-element array with the starting and ending wavelengths for the valid spectral range of the templates.

lower_flux_limit

int, float

Minimum valid flux in the template spectra.

log10

bool

False

Flag that the template spectra have been binned logarithmically in wavelength.

For example, to define a new template library for use in the stellar-continuum fitting module, you could include the following in your Analysis Plans:

[default.continuum.fit.templates]
 key = 'MYLIB'                              # Library keyword
 file_search = '/path/to/library/*.fits'    # Search string
 fwhm = 2.50                                # FWHM of resolution element
 in_vacuum = false                          # Wavelength in vacuum?
 wave_limit = [3575., 7400. ]               # Valid wavelength range
 lower_flux_limit = 0.0                     # Lower limit for valid flux
 log10 = False                              # Log binned?

Whereas to use one of the existing template libraries, you only need to define the keyword of the library:

[default.continuum.fit.templates]
 key = 'MILESHC'

Output

When instantiating a template library, the processed library will be written to disk, depending on the hardcopy argument; by default this argument is False. If the template library has already been processed and written to disk, the instantiation of the object will skip processing the library and just read the result of the previous instantiation.

The path (output_path) and name of the file (output_file) can be defined upon instantiating the object. If not provided, the default path is set to the current working directory and the output file name is set to the name of the library; see default_paths().

The format of the output file is:

HDU

Name

Description

0

PRIMARY

Empty

1

WAVE

Wavelength vector

2

FLUX

Flux array

3

MASK

Bitmask values; see TemplateLibraryBitMask

4

SPECRES

Spectral resolution

5

SIGOFF

If needed, the offset in km/s between the target resolution of the spectra and the actual resolution acheived. See match_spectral_resolution().

Adding new template libraries

Adding new template libraries is straight-forward. First, make sure the templates adhere to the Input Data Format. Then add the parameters for the templates to your Analysis Plans file, as described above.