mangadap.proc.templatelibrary module

Class that reads and prepares template libraries for use in fitting the stellar-continuum of a spectrum. See available_template_libraries() for the list of default template libraries.

The “raw” template libraries are expected to consist of 1D fits files. The wavelength sampling can be either linear or logarithmic in wavelength. The reference frame of the template wavelengths must be defined as either vacuum or air. It is expected that the object spectra to be fit are calibrated to vacuum wavelengths. When preparing the template spectra for analysis, this class will use pydl.goddard.astro.airtovac to convert the template wavelengths to vacuum. Finally, one can specify that the template library is only valid within a certain wavelength range and above a certian flux limit; see TemplateLibraryDef.

Preparation of the template library for use in stellar-continuum fitting consists of a number of steps as described in the documentation of TemplateLibrary.process_template_library().

A template library that has been prepared for analysis is automatically written to disk for later recovery.

Two support classes are also provided. One is a derived mangadap.par.parset.ParSet instance that provides the defining parameters of a DAP template library. The second is a derived mangadap.util.bitmask.BitMask instance that defines the bitmasks for the template library spectra.

License:
Copyright (c) 2015, SDSS-IV/MaNGA Pipeline Group
Licensed under BSD 3-clause license - see LICENSE.rst
Source location:
$MANGADAP_DIR/python/mangadap/proc/templatelibrary.py
Class usage examples:

Assuming you have the default directory structure setup, you can do:

# Imports
from mangadap.drpfits import DRPFits
from mangadap.proc.templatelibrary import TemplateLibrary
from matplotlib import pyplot

# Define the DRP file
drpf = DRPFits(7495, 12703, 'CUBE')

# Build the template library
tpl_lib = TemplateLibrary('M11MILES', drpf=drpf, directory_path='.')
# Writes: ./manga-7495-12703-LOGCUBE_M11-MILES.fits

# Plot one of the spectra
pyplot.plot(tpl_lib.hdu['WAVE'].data, tpl_lib.hdu['FLUX'].data[0,:])
pyplot.show()

As part of the instantiation of the TemplateLibrary object in the above call, the template library is prepared for use in fitting the specified DRP file. If the required processing has already been done, the instantiation of the TemplateLibrary object simply reads the existing file. If you do not have the default directory structure setup, you’ll need to define the paths to, e.g., the DRP file; see mangadap.dapfile.dapfile.

If you do not want to process the template (match the spectral resolution and sampling to that of the DRP data), you can force the TemplateLibrary object to only provide the “raw” spectra:

# Imports
from mangadap.proc.templatelibrary import TemplateLibrary
from matplotlib import pyplot

# Read the raw template library
tpl_lib = TemplateLibrary('M11MILES', process=False)
# Nothing should be written to disk

# Plot one of the spectra
pyplot.plot(tpl_lib.hdu['WAVE'].data[0,:], tpl_lib.hdu['FLUX'].data[0,:])
pyplot.show()

Note that in the previous example, the wavelength data was already one-dimensional, whereas for the raw library, the wavelength vector can be spectrum-dependent.

In the above examples, the user has not provided a list of template libraries, meaning that the default set available to the DAP is used. The default set is defined in available_template_libraries(). If you want to use your own template library, you have to define its parameters using TemplateLibraryDef. Currently, the template library spectra are expected to be 1D fits files with WCS header keywords defining the wavelength solution; see above. Using an existing DAP library as an example:

# Imports
from mangadap.proc.templatelibrary import TemplateLibraryDef
from mangadap.proc.templatelibrary import TemplateLibrary
from mangadap.config.defaults import dap_source_dir
from matplotlib import pyplot

# Define the search string for the library
search_str = dap_source_dir()+'/data/stellar_templates/miles/*.fits'

# Define the template library parameters
tpl_par = TemplateLibraryDef(key='MILES',    # Unique keyword for the library
                        file_search=search_str, # Search string
                        fwhm=2.50,              # FWHM of resolution element (assumed const)
                        in_vacuum=False,        # Wavelength in vacuum?
                        wave_limit=numpy.array([ 3575., 7400. ]),   # Range of valid lambda
                        lower_flux_limit=0.0)   # Lower limit for valid flux

# Read the raw template library
tpl_lib = TemplateLibrary('MILES', tpllib_list=tpl_par, process=False)
# Nothing should be written to disk

# Plot one of the spectra
pyplot.plot(tpl_lib.hdu['WAVE'].data[0,:], tpl_lib.hdu['FLUX'].data[0,:])
pyplot.show()

Note that the keyword you use must be provided both to the parameter set and when instantiating the TemplateLibrary object. In the example above, I have not processed the library, but you can by following a similar approach to the first example.

You can also process the spectra to a user-provided resolution and pixel sampling, toggle on/off the renormalization of the library to a mean flux of unity and define various paths if you’re not working within the nominal DAP directory structure. See the optional instantiation arguments for TemplateLibrary.

Revision history:
23 Apr 2015: Implementation begun by K. Westfall (KBW)
26 May 2015: (KBW) Added some Sphinx documentation.
17 Jun 2015: (KBW) Added flexibility in definition of template libraries from which to choose using the new TemplateLibraryDef class.
23 Jun 2015: (KBW) Allow user to provided non-DRP input spectra, meaning they need to provide the velocity scale and the wavelength and spectral resolution vectors. They must also directly set the name of the output processed file.
01 Feb 2016: (KBW) Propagated changes to TemplateLibraryDef and changed procedure for reading raw template library.
04 Feb 2016: (KBW) Converted from mangadap.util.instrument.log_rebin() to mangadap.util.instrument.resample_vector(). Allows input library to be logarithmically sampled and provides a different approach to subsampling spectra. Implemented other convenience operations, such as selecting a certain wavelength range for the processed library.
19 May 2016: (KBW) Added loggers and quiet keyword arguments to TemplateLibrary
22 Jun 2016: (KBW) Included MILESHC library in documentation. Allow to specify how the resolution and sampling are matched to the DRP data. The TemplateLibrary class should be generalized to make this more transparent (and unnecessary).
03 Apr 2017: (KBW) Include arguments for mangadap.util.instrument.match_spectral_resolution() that specify the minimum sigma in pixels for the convolution kernel and any offset in the resolution required in the call for the template library. Check that the resampling of the spectrum does not reach the two-pixel resolution limit; flag the spectrum in those regions that do and change the resolution to the two pixel limit.
30 Aug 2017: (KBW) Switch from using mangadap.util.instrument.resample_vector() to mangadap.util.instrument.resample1d()
30 Aug 2018: (KBW) Switch from using resample1d to mangadap.util.sampling.Resample.
class mangadap.proc.templatelibrary.TemplateLibrary(library_key, tpllib_list=None, dapsrc=None, drpf=None, match_to_drp_resolution=True, velscale_ratio=None, sres=None, velocity_offset=0.0, min_sig_pix=0.0, no_offset=True, spectral_step=None, log=True, wavelength_range=None, renormalize=True, dapver=None, analysis_path=None, directory_path=None, processed_file=None, read=True, process=True, hardcopy=True, symlink_dir=None, clobber=False, checksum=False, loggers=None, quiet=False)[source]

Bases: object

Object used to read, store, and prepare template libraries for use in analyzing object spectra.

The default list of available libraries provided by the MaNGA DAP defined in available_template_libraries(). The user can provide their own library for use with this class provided they are contained in 1D fits spectra, sampled linearly in wavelength with the wavelength coordinates available via the WCS keywords (CRPIX1, CRVAL1, CDELT1), and they have an appropriately defined spectral resolution (FWHM in angstroms that is constant as a function of wavelength). See TemplateLibraryDef and _build_raw_hdu().

The class is optimized for use in analyzing MaNGA DRP files; however, one can provide the necessary information so that the class can be used with a non-DRP spectrum. In the latter case, the user must supply the velocity scale of the pixel for the logarithmically resampled template library, and a mangadap.util.resolution.SpectralResolution object the defines the instrumental resolution of the spectrum/spectra to be analyzed.

Todo

  • below is out of date.
  • Only works with DRP files that have log-linear wavelength binning!
  • Allow to process, where process is just to change the sampling or the resolution (not necessarily both).
  • Need to make this more general, removing all dependence on DRPFits object. This would simplify the functionality to change how the resolution and sampling matching is specified.

On initialization, if the DRP file object is not provided (is None), the default behavior is to read the raw template library if read=True. If the DRP file is provided, the routine will check for the resolution matched fits file; if it doesn’t exist and read is True, it will prepare the template library for use in analyzing the DRP file and write the prepared library file. If clobber=True, the preparation and writing of the template library will be done even if the library already exists.

Parameters:
  • library_key (str) – Keyword selecting the library to use.
  • tpllib_list (list) – (Optional) List of TemplateLibraryDef objects that define the parameters required to read and interpret a template library. The library_key must select one of the objects in this list.
  • dapsrc (str) – (Optional) Root path to the DAP source directory. If not provided, the default is defined by mangadap.config.defaults.dap_source_dir().
  • drpf (mangadap.drpfits.DRPFits) – (Optional) DRP file (object) with which the template library is associated for analysis
  • match_to_drp_resolution (bool) – (Optional) Match the spectral resolution of the template library to the resolution provided by the mangadap.drpfits.DRPFits object; the latter must be provided for this argument to have any use.
  • velscale_ratio (int) – (Optional) Resample the template spectra such that the ratio of the pixel scale in the provided mangadap.drpfits.DRPFits object is this many times larger than the pixels in the resampled template spectrum.
  • sres (mangadap.util.resolution.SpectralResolution) – (Optional) The object is used simply to access the spectral resolution and associated wavelength coordinate vector needed when matching the spectral resolution of the template library; this is used in place of the attributes in any provided DRP file object.
  • velocity_offset (float) – (Optional) Velocity offset to use when matching the spectral resolution between the template library and the galaxy spectra.
  • spectral_step (float) – (Optional) Target logarithmic (*log*=True) or linear (*log*=False) step in wavelength for the template library.
  • log (bool) – (Optional) Flag to force the library to be logarithmically sampled in wavelength.
  • wavelength_range (array-like) – (Optional) Force the template library to covert this spectral range. Unobserved spectral regions will be flagged.
  • renormalize (bool) – (Optional) After processing, renormalize the flux to unity.
  • dapver (str) – (Optional) DAP version, which is used to define the default DAP analysis path. Default is defined by mangadap.config.defaults.default_dap_version()
  • analysis_path (str) – (Optional) The path to the top level directory containing the DAP output files for a given DRP and DAP version. Default is defined by mangadap.config.defaults.default_analysis_path().
  • directory_path (str) – (Optional) The exact path to the processed template library file. Default is defined by mangadap.config.defaults.default_dap_common_path().
  • processed_file (str) – (Optional) The name of the file containing the prepared template library output file. The file should be found at directory_path/processed_file. Default is defined by mangadap.config.defaults.default_dap_file_name().
  • process (bool) – (Optional) If drpf is defined and the prepared template library does not exist, this will process the template library in preparation for use in fitting the provided DRP file.
  • hardcopy (bool) – (Optional) Flag to keep a hardcopy of the processed template library. Default is True.
  • symlink_dir (str) – (Optional) Create a symlink to the file in this directory. Default is for no symlink.
  • clobber (bool) – (Optional) If drpf is define and process is True, this will clobber any existing processed template library.
bitmask

A BitMask object used to toggle mask values; see TemplateLibraryBitMask().

Type:BitMask
library

Parameter set required to read and prepare the library.

Type:TemplateLibraryDef
file_list

The list of files found using glob.glob and file_search.

Type:list
ntpl

Number of template spectra in the library

Type:int
drpf

DRP file (object) with which the template library is associated for analysis

Type:mangadap.drpfits.DRPFits
sres

The object is used simply to access the spectral resolution and associated wavelength coordinate vector needed when matching the spectral resolution of the template library; this is used in place of the attributes in any provided DRP file object.

Type:mangadap.util.resolution.SpectralResolution
velocity_offset

Velocity offset to use when matching the spectral resolution between the template library and the galaxy spectra.

Type:float
spectral_step

Target logarithmic (:attr:`log10_sampling`=True) or linear (:attr:`log10_sampling`=False) step in wavelength for the template library.

Type:float
log10_sampling

Flag that the processed template library is logarithmically sampled in wavelength.

Type:bool
directory_path

The exact path to the processed template library file. Default is defined by mangadap.config.defaults.default_dap_common_path().

Type:str
processed_file

The name of the file containing (to contain) the prepared template library output file. The file should be found at directory_path/processed_file.

Type:str
processed

Flag that the template library has been prepared for use in the DAP.

Type:bool
hardcopy

Flag to keep a hardcopy of the processed template library.

Type:bool

Symlink created to the file in this directory

Type:str
hdu

HDUList read from the DAP file

Type:astropy.io.fits.hdu.hdulist.HDUList
_build_raw_hdu(npix)[source]

Build the “raw” template library arrays. This simply reads the provided list of fits files and puts them into arrays of size \(N_{\rm tpl} \times N_{\rm pix}\).

This will force reading of the data, even if the hdu is already initialized.

The hdu will contain the appropriate extensions, but it is important to note that the wavelength vectors will not necessarily be the same. That is, reading of the raw template spectra can accommodate spectra that have different wavelength coordinates. Any pixels that have no data are masked using the ‘NO_DATA’ bitmask flag; see TemplateLibraryBitMask().

The spectral resolution is set using fwhm, and the spectral resolution offset is initialized to zero (see mangadap.util.resolution.GaussianKernelDifference()).

Warning

Currently no errors are saved because none are expected for the template libraries.

Parameters:npix (int) – Number of spectral channels for the output arrays
_can_set_paths(directory_path, drpf, processed_file, quiet=False)[source]
_define_library(library_key, tpllib_list=None, dapsrc=None)[source]

Select the library from the provided list. Used to set library; see mangadap.proc.util.select_proc_method().

Parameters:
  • library_key (str) – Keyword of the selected library. Available libraries are proved by available__template_libraries()
  • tpllib_list (list) – (Optional) List of TemplateLibraryDef objects that define the parameters required to read and interpret a template library.
  • dapsrc (str) – (Optional) Root path to the DAP source directory. If not provided, the default is defined by mangadap.config.defaults.dap_source_dir().
_get_file_list()[source]
_get_nchannels()[source]

Get the maximum number of wavelength channels needed to store all the template spectra in a single array.

Todo

  • What happens if the spectrum has an empty primary extension?
Returns:Maximum number of pixels used by the listed spectra.
Return type:int
Raises:ValueError – Raised if the input template spectra are not one-dimensional.
_minimum_sampling()[source]

Return the minimum sampling of the available wavelength vectors.

Returns:minimum sampling of all (will just be one if the library has been processed) wavelength vectors.
Return type:float
_modify_spectral_resolution()[source]

Modify the spectral resolution to match the provided sres.

Returns:Redshift used when matching the spectral resolution.
Return type:float
_process_library(wavelength_range=None, renormalize=True)[source]

Process the template library for use in analyzing object spectra. See process_template_library().

Todo

  • Add wavelength coordinate WCS information to the appropriate extension headers.
  • Include ‘step’ as an argument
  • Include limit on covering fraction used to mask data as an argument
_read_raw()[source]

Read the ‘raw’ versions of the template library; i.e., the library before it has been resolution and sampling matched to a DRP file.

The file list read by the search key is sorted for consistency.

_rebin_masked(i, flag, fullRange, rmsk_lim=0.5)[source]

Determine the mask value to adopt for a rebinned spectrum by rebinning the mask pixels, setting a masked pixel to unity, and an unmasked pixel to zero. After rebinning, any pixel with a value of larger than rmsk_lim is masked; otherwise it is left unmasked.

Although the function can be used with multiple flags, its intended use is to determine which pixels should be masked with a specific flag.

Parameters:
  • i (int) – Index of the spectrum to be rebinned.
  • flag (str or list) – Flags to consider when determining which pixels to mask; see mangadap.util.bitmasks.BitMask.flagged().
  • fullRange (numpy.ndarray) – Two-element array with the wavelength range for the rebinned spectrum.
  • rmsk_lim (float) – Limit of the rebinned mask value that is allowed before considering the pixel as masked.
Returns:

Boolean array indicating which pixels in the rebinned spectrum should be masked.

Return type:

numpy.ndarray

_reset_hdu(wave, flux, mask, sres, soff)[source]

(Re)Set hdu to a new HDUList object using the input arrays. Also sets the header items indicating the version of the template reader and the keyword for the library.

Parameters:
  • wave (numpy.ndarray) – Array with the wavelengths of each pixel.
  • flux (numpy.ndarray) – Array with the flux in each pixel.
  • mask (numpy.ndarray) – Bitmask values for each pixel.
  • sres (numpy.ndarray) – Spectral resolution, \(R=\lambda/\delta\lambda\), at each pixel.
  • soff (numpy.ndarray) – The spectral resolution offset for each spectrum (see mangadap.util.resolution.GaussianKernelDifference()).
_set_paths(directory_path, dapver, analysis_path, drpf, processed_file)[source]

Set the I/O path to the processed template library. Used to set directory_path and processed_file. If not provided, the defaults are set using, respectively, mangadap.config.defaults.default_dap_common_path() and mangadap.config.defaults.default_dap_file_name().

Parameters:
  • directory_path (str) – The exact path to the DAP template library file. See directory_path.
  • dapver (str) – DAP version.
  • analysis_path (str) – The path to the top-level directory containing the DAP output files for a given DRP and DAP version.
  • drpf (mangadap.drpfits.DRPFits) – The container object of the DRP file that is used to construct the path for the processed template library.
  • processed_file (str) – The name of the file with the prepared template library. See processed_file.
_wavelength_range(flag=None)[source]

Return the valid wavelength range for each spectrum based on the first and last unmasked pixel; interspersed masked regions are not considered.

Parameters:flag (str or list) – (Optional) Flags to consider when determining the wavelength range; see mangadap.util.bitmasks.BitMask.flagged().
Returns:Two-element vector with wavelengths of the first and last valid pixels.
Return type:numpy.ndarray
file_name()[source]

Return the name of the processed file.

file_path()[source]

Return the full path to the processed file.

process_template_library(library_key=None, tpllib_list=None, dapsrc=None, drpf=None, match_to_drp_resolution=True, velscale_ratio=None, sres=None, velocity_offset=0.0, min_sig_pix=0.0, no_offset=True, spectral_step=None, log=True, wavelength_range=None, renormalize=True, dapver=None, analysis_path=None, directory_path=None, processed_file=None, hardcopy=True, symlink_dir=None, clobber=False, loggers=None, quiet=False)[source]

Process the template library for use in analyzing object spectra. Primary steps are to:

  • Read the raw 1D fits files; see _read_raw().
  • Convert the wavelengths to vacuum, if necessary; see mangadap.util.idlutils.airtovac().
  • Mask wavelengths outside the rest wavelength range of the DRP spectrum, due to need to extrapolate these values; see mangadap.util.bitmasks.HDUList_mask_wavelengths().
  • Match the spectral resolution of the template to that of the DRP spectra; see mangadap.util.resolution.match_spectral_resolution().
  • Mask the template pixels where the spectral resolution was too low to match to the DRP spectra; see mangadap.util.bitmasks.BitMask.turn_on().
  • Force a common wavelength range and sampling for all templates, where the sampling is forced to match the sampling of the DRP spectra; see mangadap.util.sampling.resample_vector_pix(). The masks are appropriately resampled as well; see _rebin_masked().

Warning

The routine does not check that that an existing processed file or the existing object has been processed using the same DRPFits, velocity_offset, velscale, or sres input. If unsure, use clobber=True.

Parameters:
  • library_key (str) – (Optional) Keyword selecting the library to use; default is to use existing library.
  • tpllib_list (list) – (Optional) List of TemplateLibraryDef objects that define the parameters required to read and interpret a template library. Input ignored if library_key is None.
  • dapsrc (str) – (Optional) Root path to the DAP source directory. If not provided, the default is defined by mangadap.config.defaults.dap_source_dir(). Input ignored if library_key is None.
  • drpf (mangadap.drpfits.DRPFits) – (Optional) DRP file (object) with which the template library is associated for analysis. If not provided, the user must define velscale and sres such that the library can be processed; and the user must provide directory_path and processed_file such that the output file can be written.
  • match_to_drp_resolution (bool) – (Optional) Match the spectral resolution of the template library to the resolution provided by the mangadap.drpfits.DRPFits object; the latter must be provided for this argument to have any use.
  • velscale_ratio (int) – (Optional) Resample the template spectra such that the ratio of the pixel scale in the provided mangadap.drpfits.DRPFits object is this many times larger than the pixels in the resampled template spectrum.
  • sres (mangadap.util.resolution.SpectralResolution) – (Optional) The object is used simply to access the spectral resolution and associated wavelength coordinate vector needed when matching the spectral resolution of the template library. This takes prededence over the values provided by the DRP file object.
  • velocity_offset (float) – (Optional) Velocity offset to use when matching the spectral resolution between the template library and the galaxy spectra.
  • spectral_step (float) – (Optional) Target logarithmic (*log*=True) or linear (*log*=False) step in wavelength for the template library.
  • log (bool) – (Optional) Flag to force the library to be logarithmically sampled in wavelength.
  • wavelength_range (array-like) – (Optional) Force the template library to covert this spectral range. Unobserved spectral regions will be flagged.
  • renormalize (bool) – (Optional) After processing, renormalize the flux to unity.
  • dapver (str) – (Optional) DAP version, which is used to define the default DAP analysis path. Default is defined by mangadap.config.defaults.default_dap_version()
  • analysis_path (str) – (Optional) The path to the top level directory containing the DAP output files for a given DRP and DAP version. Default is defined by mangadap.config.defaults.default_analysis_path().
  • directory_path (str) – (Optional) The exact path for the processed template library file. Default is defined by mangadap.config.defaults.default_dap_common_path().
  • processed_file (str) – (Optional) The name of the file containing (to contain) the prepared template library output file. The file should be found at directory_path/processed_file. Default is defined by mangadap.config.defaults.default_dap_file_name().
  • hardcopy (bool) – (Optional) Flag to keep a hardcopy of the processed template library. Default is True.
  • symlink_dir (str) – (Optional) Create a symlink to the file in this directory. Default is for no symlink.
  • clobber (bool) – (Optional) Clobber any existing processed library.
Raises:

ValueError – If the velocity scale, spectral resolution, or file name for the processed data are not define.

Todo

  • type checking
  • If a DRP file is provided, the processing to a logarithmic binning is done by default (log=True). But linearly sampled DRP data are available, so need to have mangadap.drpfits.DRPFits return the spectral sampling type.
  • Documentation needs updating!
read_raw_template_library(library_key=None, tpllib_list=None, dapsrc=None)[source]

Read the identified template library. If all the arguments are the default, the preset attributes from the initialization of the object are used.

Parameters:
  • library_key (str) – (Optional) Keyword selecting the library to use.
  • tpllib_list (list) – (Optional) List of TemplateLibraryDef objects that define the parameters required to read and interpret a template library.
  • dapsrc (str) – (Optional) Root path to the DAP source directory. If not provided, the default is defined by mangadap.config.defaults.dap_source_dir().
single_spec_to_fits(i, ofile, clobber=True)[source]

Write one of the template spectra to a 1D fits file.

Output is a one-dimensional fits file with a single extension containing the flux measurements and headers keywords needed to determine the wavelength of each pixel.

Parameters:
  • i (int) – Index of the spectrum in the avaiable list to output.
  • ofile (str) – Name of the file to write
  • clobber (bool) – (Optional) Flag to clobber any existing file of the same name.
Raises:

ValueError – Raised if the selected index is not available.

class mangadap.proc.templatelibrary.TemplateLibraryBitMask(dapsrc=None)[source]

Bases: mangadap.util.bitmask.BitMask

Derived class that specifies the mask bits for the template library data. See mangadap.util.bitmask.BitMask for attributes.

A list of the bits and meanings are provided by the base class function mangadap.util.bitmask.BitMask.info(); i.e.,:

from mangadap.proc.templatelibrary import TemplateLibraryBitMask
t = TemplateLibraryBitMask()
t.info()
class mangadap.proc.templatelibrary.TemplateLibraryDef(key=None, file_search=None, fwhm=None, sres_ext=None, in_vacuum=False, wave_limit=None, lower_flux_limit=None, log10=False)[source]

Bases: mangadap.par.parset.ParSet

Class with parameters used to define the template library. See mangadap.par.parset.ParSet for attributes.

Parameters:
  • key (str) – Keyword to distinguish the template library.
  • file_search (str) – Search string used by glob to find the 1D fits spectra to include in the template library.
  • fwhm (int or float) – 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.
  • in_vacuum (bool) – Flag that the wavelengths of the spectra are in vacuum, not air.
  • wave_limit (numpy.ndarray) – 2-element array with the starting and ending wavelengths for the valid spectral range of the templates.
  • lower_flux_limit (int or float) – Minimum valid flux in the template spectra.
  • log10 (bool) – Flag that the template spectra have been binned logarithmically in wavelength.
mangadap.proc.templatelibrary.available_template_libraries(dapsrc=None)[source]

Return the list of library keys, the searchable string of the 1D template library fits files for the template libraries available for use by the DAP, the FWHM of the libraries, and whether or not the wavelengths are in vacuum.

The stellar template library files should be a list of 1D fits files, and be associated with one of the following library keys:

KEY
Spectral

res (ang)

Vacuum
Wavelength

Range (ang)

Lower Limit
M11MARCS 2.73 No full None
M11STELIB 3.40 No full None
M11STELIBZSOL 3.40 No full None
M11ELODIE 0.55 No < 6795 None
M11MILES 2.54 No 3550 - 7400 None
MILES 2.50 No < 7400 None
MILESAVG 2.50 No < 7400 None
MILESTHIN 2.50 No < 7400 None
MILESHC 2.50 No < 7400 None
STELIB 3.40 No full 0.0
MIUSCAT 2.51 No 3480 - 9430 None
MIUSCATTHIN 2.51 No 3480 - 9430 None
Parameters:

dapsrc (str) – (Optional) Root path to the DAP source directory. If not provided, the default is defined by mangadap.config.defaults.dap_source_dir().

Returns:

A list of mangadap.proc.templatelibrary.TemplateLibraryDef() objects, each defining a separate template library.

Return type:

list

Raises:
  • NotADirectoryError – Raised if the provided or default dapsrc is not a directory.
  • OSError/IOError – Raised if no template configuration files could be found.
  • KeyError – Raised if the template-library keywords are not all unique.

Todo

  • Add backup function for Python 2.
  • Somehow add a python call that reads the databases and constructs the table for presentation in sphinx so that the text above doesn’t have to be edited with changes in the available databases.
mangadap.proc.templatelibrary.validate_spectral_template_config(cnfg)[source]

Validate the mangadap.util.parser.DefaultConfig object with the template library parameters.

Parameters:

cnfg (mangadap.util.parser.DefaultConfig) – Object with the template library parameters to validate.

Raises:
  • KeyError – Raised if required keyword does not exist.
  • ValueError – Raised if key has unacceptable value.