Spectral Template Libraries

The two main full-spectrum-fitting modules of the DAP, the stellar kinematics module (mangadap.proc.stellarcontinuummodel.StellarContinuumModel) and the emission-line module (mangadap.proc.emissionlinemodel.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
MASTARHC [5] Stellar Empirical README
MILES [6] Stellar Empirical README
MILESAVG [6] Stellar Empirical README
MILESHC [7] Stellar Empirical README
MILESTHIN [6] Stellar 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 mangadap.util.fileio.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 mangadap.util.fileio.wavelength_vector()). The wavelength range of each spectrum need not be the same.
  • The inverse variance or wavelength dependent spectral resolution (:math:R=lambda/deltalambda`) 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/python/mangadap/config/spectral_templates. These configuration files are parsed by mangadap.proc.templatelibrary.available_template_libraries(), which provides a list of mangadap.proc.templatelibrary.TemplateLibraryDef() instances that can be selected using a keyword.

The critical components to the definition of the template library are:

  • file_search: the search string used by glob.glob to find the fits files with the template library spectra and
  • fwhm or sres_ext: the FWHM of the (Gaussian) line-spread function in angstroms or the name of the extension in each template fits file with the spectral resolution, :math:R=lambda/deltalambda`.


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

The path (directory_path) and name of the file (processed_file) can be defined upon instantiating the object. If not provided, the default path is set by mangadap.config.defaults.default_dap_common_path(), and the output file name is set by mangadap.config.defaults.default_dap_file_name().

The format of the output file is:

HDU Name Description
1 WAVE Wavelength vector
2 FLUX Flux array
3 MASK Bitmask values; see mangadap.proc.templatelibrary.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 mangadap.util.resolution.match_spectral_resolution().

Adding new template libraries

Adding new template libraries is relatively straight-forward. First, make sure the templates adhere to the Input Data Format. Then, you can either use the library by defining it programmatically, or by adding a new configuration file to the $MANGADAP_DIR/python/mangadap/config/spectral_templates directory. See the TemplateLibrary templatelibrary-usage and the TemplateLibrary example provided by the DAP Development Guidelines.

[1]Bruzual & Charlot (2003, MNRAS, 344, 1000)
[3]Eldridge et al. (2017, PASA, 34, 58)
[4](1, 2, 3, 4, 5) Maraston & Strömbäch (2011, MNRAS, 418, 2785)
[5]Yan et al. (2019, ApJ, 883, 175)
[6](1, 2, 3) Falcón-Barroso et al. (2011, A&A, 532, 95)
[7]Westfall et al. (2019, AJ, 158, 231)
[8](1, 2) Vazdekis et al. (2012, MNRAS, 424, 157)
[9]Le Borgne et al. (2003, A&A, 402, 433)