Building the Library

The SpecMatch libary is stored as a monolithic HDF5 file and is downloaded upon installation of the code. It’s is constructed from a number of different data files. For simplicity, we do not make all the source files public. This document serves as a recipe for the specmatchemp developers.

Establish Wavelength References

Raw spectra from CPS are not wavelength-calibrated. They are stored as a list of intensities and pixel values. Spectra are resampled onto the rest wavelength scale using the NSO solar spectrum by cross-correlating spectral segments of ~500 HIRES pixels. When the spectra are significantly different from solar, the cross-correlation peak is not well-defined. We have implemented a bootstrapping approach to accomodate a range of spectral types. We establish a ladder of spectra seperated in effective temperature by 500–1000 K. These spectra are:

$ ls ${SMEMP_WKDIR}/spectra/
nso.fits # solar spectrum, ~5800 K
*j55.1872.fits # ~4800 K
*j26.532.fits # ~3700 K
*j59.1926.fits # ~6200 K

Where at least the r chip must be provided.

We shift the spectra using by

$ python specmatchemp/buildlib/shift_references.py
Shifting spectrum j55.1872 onto reference nso
Shifting spectrum j26.532 onto reference nso
Shifting spectrum j59.1926 onto reference j55.1872

Which leaves the wavelength calibrated spectra here:

$ ls ${SMEMP_WKDIR}/shifted_spectra/
nso_adj.fits
j26.532_adj.fits
j55.1872_adj.fits
j59.1926_adj.fits

Build Table of Library Parameters

The parameters of the stars in the SpecMatch library come from a variety of literature sources. Run python buildlib/read_catalogs.py to read the parameters into a master csv file. The library sources are heterogeneous, giving (some have logg while others give stellar radius). Missing values are given as nans.

By default, the parameters are stored in the file:

${SMEMP_WKDIR}/libstars.csv

Fill in Parameters with Isochrones

The missing values are filled in with Dartmouth isochrones. Run python buildlib/get_isochrones.py to fill in the missing values.

This script creates the following files:

${SMEMP_WKDIR}/libstars_mask.csv
${SMEMP_WKDIR}/isochrone_models/
${SMEMP_WKDIR}/isochrone_models/errors.txt

The libstars_mask.csv file contains a boolean mask, marked with True for literature parameters, and False for parameters derived using isochrones.

The isochrone_models/ directory is used to contain the models generated by isochrones. By default, get_isochrones.py looks in this folder for existing models with the same cps_name, and does not run the fit again. Overwrite this behavior with the -o flag.

The script checks the Dartmouth models for consistency with the existing library parameters (and does not overwrite them). If the MCMC/MultiNest 2-sigma range fails to overlap with the library values, it prints a warning message into errors.txt.

Shift Library Spectra onto Rest Wavelength Scale

We shift the remainder of the library spectra onto the rest wavelength scale with the following command, where jXXX.XXXX is the cps observation id. Only the rj chip is required.

$ smemp shift jXXX.XXXX

Build Library HDF5 File

Finally, we assemble all the intermediate files into a monolithic HDF5 file that contains the spectra and their associated parameters using the following script. This requires the parameter csv file, parameter mask csv file, and all the spectra contained in *_adj.fits files.

$ python buildlib/combine_library.py

If the -a flag is specified, this will append the parameters and spectra to the existing library at ${SMEMP_WKDIR}/library.h5