speclib¶
atmos.py
Routines for working with model atmospheres, including finding and filling “holes” in a rectangular atmospheres grid. Main routine is fill_holes(). Takes as input command line arguments with the grid parameters (start, end, step), and looks for existing atmospheres files. If file not found, adopt “nearest” atmosphere with algorithm as given in find_filler(), and copy this into the missing file location. For Kurucz models, need to then “fix” this file for appropriate parameters; MARCS models are left as is.
Also outputs holefile that gives location of holes and how they were filled.
dw.py
Development routine to create output plots and web pages comparing syntheses computed with different wavelength spacings
isochrones.py
Routine to read a Padova isochrone file and return data in structured array
lsf.py
Routines for constructing kernels and convolving spectrumn with a broadening profile using fast matrix operations, written largely by Jo Bovy. Includes LSF kernels, macroturbulence (Gaussian) kernels, and rotation kernels. Main routine is convolve, which does the convolution.
pca.py
Routines for creating and testing PCA-compresed synthetic spectra grids. Main routine is pca, which does the PCA compression. Also includes test, which will compare the PCA spectra to the raw ones for a representative sample of spectra (from existing test.ipf file), and run some FERRE fits to see how well parameters are recovered.
-
apogee.speclib.pca.dopca(pars)[source]¶ do a single PCA decomposition for a limited number of pixels
Parameters: pars – input tuple giving required input
-
apogee.speclib.pca.liblink(lib, outdir)[source]¶ Utility routine to create links in output directory to FERRE library files
Parameters: - Returns :
- prefix (str) : prefix giving relative directory of library files
-
apogee.speclib.pca.pca(planfile, dir='kurucz/giantisotopes/tgGK_150714_lsfcombo5', pcas=None, whiten=False, writeraw=False, test=False, incremental=False, threads=4, rawsynth=False, prefix='', piece=None, digits=2, py2=False)[source]¶ Read in grid of spectra and do PCA compression
- Args :
- planfile (str) : input file name with grid parameteris dir (str) : input directory relative to #$APOGEE_SPECLIB/synth/turbospec (default=’kurucz/giantisotopes/tgGK_150714_lsfcombo5’) pcas (2-tuple) : input number of PCA components and number of pieces (default=None –> get from input planfile) pieces (list) : process only specified pieces, useful if want to split across processors, use pieces=[] to bundle existing output (default=None –> all pieces) whiten (bool) : pre-whiten data? (default=False) writeraw (bool ) : output uncompressed grid in FERRE format ? (default=False) test (bool) : used abreviated grid for testing (speed) (default=False) incremental (bool) : use incremental PCA routline (default=False) (WARNING: if not incremental, default PCA is not perfectly repeatable!) threads (int) : number of threads to use for parallel calculation (default=4), large grids may require threads=0 rawsynth (bool) : work on raw highres synthesis output (default=False), UNTESTED??
Output: compressed grid in FERRE format
-
apogee.speclib.pca.test(planfile, grid='GKg', npiece=12, npca=75, runraw=True, runpca=True, fit=True, fast=False, niso=None, sns=[1000], rot=False)[source]¶ - Routine to set up and run a series of tests for a PCA library
Includes comparison of raw and PCA spectra for a sample suite, and several FERRE runs to recover parameters for the sample suite
Requires existing test.ipf file with sample suite parameters
- Args :
- planfile (str) : name of input plan file that includes filename npiece (int) : number of PCA pieces (for directory/file names) npca (int) : number of PCA pieces (for directory/file names) runraw (bool) : create the sample and input FERRE spectra (default=True) runpca (bool) : create the PCA-derived spectra (default=True) fit (bool) : do the raw-PCA FERRE runs and comparison (default=True) fit (bool) : submit the FERRE test runs to queue (default=True) fast (bool) : use the sdss-fast queue (default=False)
rbf.py
-
apogee.speclib.rbf.comp(planfile='tgGK_180625.par', dir='marcs/giantisotopes/tgGK_180625', grid='GK', fakehole=False, digits=2, cmrange=None, nmrange=None, vtrange=None, apstar=False, hard=None, out='rbf_')[source]¶
-
apogee.speclib.rbf.extend(start, end, vector, holevector)[source]¶ Extend the subgrids one point if possible, to avoid edges
-
apogee.speclib.rbf.fill(planfile='tgGK_180625.par', dir='marcs/giantisotopes/tgGK_180625', amrange=None, cmrange=None, nmrange=None, vtrange=None, grid='GK', digits=2, cmnear=False, apstar=False, threads=30, fakehole=False, out='rbf_', r0=1.0)[source]¶ routine to fill grid holes using RBF interpolation routine from Szabolcs
-
apogee.speclib.rbf.mergeholes(planfile='tgGK_180625.par', dir='marcs/giantisotopes/tgGK_180625', grid='GK', fakehole=False, digits=2, cmrange=None, nmrange=None, vtrange=None, apstar=False, hard=None, out='rbf_')[source]¶
sample.py
Routines for creating sample of test parameters/abundances to be used for testing of FERRE and/or for construction of training sample for an interpolator, etc.
-
apogee.speclib.sample.clip(x, lim, eps=None)[source]¶ Utility routine to clip values within limits, and move slightly off edges if requested
-
apogee.speclib.sample.comp(file, true=None, truespec=None, hard=False, plot=False, minchi2=0.0, testid=None, rot=False)[source]¶ Compare input parameters with output results
-
apogee.speclib.sample.elemsens(teffs=[3500, 4500, 5500], loggs=[1.0, 3.0, 5.0], mhs=[0.0], delta=0.1, suffix='', complement=False)[source]¶ create sample with small delta of each element at grid of [teff,logg,mh] to see sensitivities
-
apogee.speclib.sample.sample(name='test', gridclass=None, eps=0.01, tefflim=[3000, 8000], dtlo=100.0, logglim=[-0.5, 5.5], mhlim=[-2.5, 0.75], nmlim=[-0.5, 2.0], cmlim=[-1.5, 1.0], emlim=[-0.5, 1.0], vmicrolim=[0.3, 4.8], amlim=[-0.5, 1.0], vrotlim=[1.5, 96.0], rot=True, nsamp=1, niso=None, elems='all', fact=1.0, offgrid=False, extracool=1)[source]¶ Generate a test sample of parameters and abundances from isochrones
sim.py
synth.py :
Routines related making synthetic spectra using Turbospectrum. The low level routine mkturbospec does a single Turbospectrum synthesis and returns the resulting spectra (both raw and normalized). This is used by several higher level routines:
mkgrid will make a regular grid of synthetic spectra, as specified by an input planfile. These are used as the basis for the libraries used by FERRE, after (optionally) hole filling, convolution with an LSF, PCA compression, and bundling into a FERRE format library.
mksynth will make a series of synthetic spectra as specified by an input file with parameters and abundances on each line. These might be used as an input into a neural network interpolator..
synth also includes a number of utility routines to accomplish the above tasks.
welem.py
window.py