Welcome to SpecMatch Synth’s documentation!¶
Contents:
Installation Instructions¶
- Install dependencies: pandas, astropy
- Download
specmatch-synth
from git repo - Run
python setup.py install
from within the main repo directory
Quickstart Tutorial¶
API¶
Contents:
Model Library Grid¶
Module to define the Library class
This module defines the Library object used for specmatch-synth
-
class
smsyn.library.
Library
(header, model_table, wav, model_spectra, wavlim=None)[source]¶ The Library object
This object handles reading the model grid and associating the models with stellar parameters
- Args:
- header (dict): a dictionary containing metadata that describes
- the model library. ‘model_name’ and ‘model_reference’ are the only required keys. (e.g. {‘model_name’: ‘coelho05’, ‘model_reference’: ‘Coelho et al. (2005)’})
- model_table (DataFrame): Pandas DataFrame with the following
- columns: teff, logg, fe, model_index. The model_index column should give the index to the model spectrum in the model_spectra array that is associated with the given parameters.
- wav (array): 1-d vector containng the wavelength scale for the
- model spectra
- model_spectra (array): array containing all model spectra
- ordered so that the they can be referenced by the indicies contained in the model_table.
- wavlim (2-element iterable): (optional) list, tuple, or other
- 2-element itarable that contains the upper and lower wavelengths limits to be read into memory
-
select_model
(pars)[source]¶ Select a model spectrum
Grab a model spectrum from the library that corresponds to a given set of stellar parameters.
- Args:
- pars (3-element iterable): A 3-element tuple containing teff, logg,
- and fe
- Returns:
- array: model spectrum flux resampled at the new wavelengths
-
synth
(wav, teff, logg, fe, vsini, psf, rotation='rot', interp_kw=None)[source]¶ Synthesize a model spectrum
For a given set of wavelengths teff, logg, fe, vsini, psf, compute a model spectrum by:
- Determine the 8 coelho models surounding the (teff,logg,fe)
- Perform trilinear interpolation
- Resample onto new wavelength scale
- Broaden with rot-macro turbulence
- Broaden with PSF (assume gaussian)
- Args:
- wav (array): wavelengths where the model will be calculated teff (float): effective temp (K) logg (float): surface gravity (logg) fe (float): metalicity [Fe/H] (dex) vsini (float): rotational velocity (km/s) psf (float): sigma for instrumental profile (pixels)
- Returns:
- array: synthesized model calculated at the wavelengths specified
- in the wav argument
-
smsyn.library.
read_hdf
(filename, wavlim=None)[source]¶ Read model library grid
Read in a model library grid from an h5 file and initialze a Library object.
- Args:
- filename (string): path to h5 file that contains the grid
- of stellar atmosphere models
- wavlim (2-element iterable): upper and lower wavelength limits
- (in Angstroms) to load into RAM
- Returns:
- Library object
-
smsyn.library.
trilinear_interp
(c, v0, v1, vi)[source]¶ Trilinear interpolation
Perform trilinear interpolation as described here. http://en.wikipedia.org/wiki/Trilinear_interpolation
- Args:
- c (8 x n array): where C each row of C corresponds to the value at one
- corner
v0 (length 3 array): with the origin v1 (length 3 array): with coordinates on the diagonal vi (length 3 array): specifying the interpolated coordinates
- Returns:
- interpolated value of c at vi
Spectrum Object¶
Defining Spectrum Class
-
class
smsyn.io.spectrum.
Spectrum
[source]¶ A light superclass on top of numpy record array that stores header information and and read and write to fits objects.
- Args:
- wav (array): wavelengths corresponding to each pixel in the
- flux array
- flux (array): continuum-normalized flux as a function of
- rest wavelength
uflux (array): relative flux uncertainty header (dict): dictionary containing metadata associated with the
observed spectrum. Similar to a header from a fits file. Required keys: object, observation
Match Object¶
This module defines the Match class that is used in fitting routines.
-
class
smsyn.match.
Match
(*args, **kwargs)[source]¶ -
masked_nresid
(params, **kwargs)[source]¶ Masked normalized residuals
Return the normalized residuals with masked wavelengths excluded
- Args:
- params (lmfit.Parameters): see params in self.model
- Returns:
- array: normalized residuals where self.wavmask == 1
-
model
(params, wav=None, **kwargs)[source]¶ Calculate model
Return the model for a given set of parameters
- Args:
- params (lmfit.Parameters): Parameters object containing at least
- teff, logg, fe, vsini, psf, and spline coefficients
- wav (array): (optional) array of wavelengths at which to
- calculate the model. Useful for generating a more finely sampled model for plotting
**kwargs: extra keyword arguments passed to lib.synth
-
nresid
(params, **kwargs)[source]¶ Normalized residuals
- Args:
- params (lmfit.Parameters): see params in self.model
- Returns:
- array: model minus data divided by errors
-