fraunhofer package

Submodules

fraunhofer.models module

MODELS.PY - Programs to deal with model atmospheres

fraunhofer.models.mkmodel(teff, logg, metal, outfile=None, ntau=None, mtype='odfnew')[source]

Extracts and if necessary interpolates (linearly) a kurucz model from his grid. The routine is intended for stars cooler than 10000 K. The grid was ftp’ed from CCP7.

IN: teff - float - Effective temperature (K)

logg - float - log(g) log_10 of the gravity (cm s-2) metal - float - [Fe/H] = log N(Fe)/N(H) - log N(Fe)/N(H)[Sun]

OUT: outfile - string - name for the output file

KEYWORD: ntau - returns the number of depth points in the output model

type - by default, the k2odfnew grid is used (‘type’

is internally set to ‘odfnew’) but this keyword can be also set to ‘old’ or ‘alpha’ to use the old models from CCP7, or the ak2odfnew models ([alpha/Fe]=+0.4),respectively.

  1. Allende Prieto, UT, May 1999

    bug fixed, UT, Aug 1999 bug fixed to avoid rounoff errors, keyword ntau added

    UT, April 2005

    bug fixed, assignment of the right tauscale to each

    model (deltaT<1%), UT, March 2006

    odfnew grids (type keyword), April 2006

fraunhofer.models.model_interp(teff, logg, metal, mtype='odfnew')[source]

Interpolate Kurucz model.

fraunhofer.models.modeldir()[source]

Return the model atmospheres directory.

fraunhofer.models.read_kurucz(teff, logg, metal, mtype='odfnew')[source]

Read a Kurucz model from the large grid.

fraunhofer.models.strput(a, inp, pos)[source]

Put a substring into a string.

fraunhofer.models.trapz(x, y)[source]

Numerical integration using the composed trapezoidal rule

int[f(x)dx] ~= 1/2 (y1*(X2-X1)+yn*(Xn-Xn-1))+ 1/2*sum_i[yi*(Xi+1-Xi-1)]

IN: x - fltarr abscisas

y - fltarr ordinates

OUT: trazp - float the numerical approx. to the integral of y(x)

NOTE: double precision is used

C. Allende Prieto, Sep 1998 “, March 2010, changed loop variable to long

fraunhofer.specfit module

SPECFIT.PY - Generic stellar abundance determination software

class fraunhofer.specfit.SpecFitter(spec, params, fitparams=None, norm=True, verbose=False, alinefile=None, mlinefile=None)[source]

Bases: object

chisq(model)[source]
property fitparams
getstep(name, val, relstep=0.02)[source]

Calculate step for a parameter.

jac(x, *args)[source]

Compute the Jacobian matrix (an m-by-n matrix, where element (i, j) is the partial derivative of f[i] with respect to x[j]).

mkinputs(args)[source]

Make INPUTS dictionary.

model(xx, *args, retobj=False)[source]

Return a model spectrum flux with the given input arguments.

property params
fraunhofer.specfit.dopvrot_lsq(spec, models=None, initpar=None, verbose=False, logger=None)[source]

Least Squares fitting with forward modeling of the spectrum.

Parameters
specSpec1D object

The observed spectrum to match.

modelslist of Cannon models, optional

A list of Cannon models to use. The default is to load all of the Cannon models in the data/ directory and use those.

initparnumpy array, optional

Initial estimate for [teff, logg, feh, RV, vsini], optional.

verbosebool, optional

Verbose output of the various steps. This is False by default.

Returns
outnumpy structured array

The output structured array of the final derived RVs, stellar parameters and errors.

bmodelSpec1D object

The best-fitting Cannon model spectrum (as Spec1D object).

fraunhofer.specfit.fit(spec, params=None, elem=None, figfile=None, fitvsini=False, fitvmicro=False, fparamlims=None, verbose=1, alinefile=None, mlinefile=None, logger=None)[source]

Fit a spectrum with a synspec synthetic spectrum and determine stellar parameters and abundances using a multi-step iterative method.

Step 1: Fit Teff/logg/[Fe/H]/RV using Doppler Step 2: Fit Teff/logg/[Fe/H]/RV + vsini with Doppler model Step 3: Fit stellar parameters (Teff/logg/[Fe/H]/[alpha/H]), RV and broadening (Vrot/Vmicro) Step 4: Fit each element one at a time holding everything else fixed. Step 5: Fit everything simultaneously

Parameters
specSpec1D object

The observed spectrum to match.

paramsdict, optional

Dictionary of initial values to use or parameters/elements to hold fixed.

elemlist, optional

List of elements to fit. The default is: elem = [‘C’,’N’,’O’,’NA’,’MG’,’AL’,’SI’,’K’,’CA’,’TI’,’V’,’CR’,’MN’,’CO’,’NI’,’CU’,’CE’,’ND’] Input an empty list [] to fit no elements.

figfilestring, optional

The filename for a diagnostic plot showing the observed spectrum and model spectrum.

fitvsinibool, optional
Fit rotational velocity (vsini). By default, Vsini will be fit initially with a Doppler

model, but only included in the final fit if it improved chisq.

fitvmicrobool, optional

Fit Vmicro. Default is False. By default, Vmicro is set (if not included in PARAMS) logg>=3.8: vmicro = 2.0 logg<3.8: vmicro = 10^(0.226−0.0228*logg+0.0297*(logg)^2−0.0113*(logg)^3 )

fparamlimsdict, optional

Dictionary of lower and upper limits for each of the fitted parameter. For example, if params is {‘teff’: 9000, ‘logg’: 4.00, ‘rv’: -16.124}, fparamlims could be {‘teff’: [8000,10000], ‘logg’: [3.50,4.50], ‘rv’: [-20.124,-12.124]}.

verboseint, optional

Verbosity level (0, 1, or 2). The default is 0 and verbose=2 is for debugging.

alinefilestr, optional

The atomic linelist to use. Default is None which means the default synple linelist is used.

mlinefilestr, optional

The molecular linelist to use. Default is None which means the default synple linelist is used.

loggerlogging object, optional

Logging object.

Returns
outnumpy structured array

Catalog of best-fit values.

modelnumpy array

The best-fit synthetic stellar spectrum.

fraunhofer.specfit.fit_elem(spec, params, elem, verbose=0, alinefile=None, mlinefile=None, logger=None)[source]

Fit an individual element.

fraunhofer.specfit.fit_lsq(spec, params, fitparams=None, fparamlims=None, verbose=0, alinefile=None, mlinefile=None, logger=None)[source]

Fit a spectrum with a synspec synthetic spectrum and determine stellar parameters and abundances using least-squares.

Parameters
specSpec1D object

The observed spectrum to match.

paramsdict

Dictionary of initial values to use or parameters/elements to hold fixed.

fitparamslist, optional

List of parameter names to fit (e.g., TEFF, LOGG, FE_H, RV). By default all values in PARAMS are fit.

fparamlimsdict, optional

Dictionary of lower and upper limits for each of the fitparams.

verboseint, optional

Verbosity level (0, 1, or 2). The default is 0 and verbose=2 is for debugging.

alinefilestr, optional

The atomic linelist to use. Default is None which means the default synple linelist is used.

mlinefilestr, optional

The molecular linelist to use. Default is None which means the default synple linelist is used.

loggerlogging object, optional

Logging object.

Returns
outnumpy structured array

Catalog of best-fit values.

modelnumpy array

The best-fit synthetic stellar spectrum.

fraunhofer.specfit.getabund(inputs, verbose=False)[source]

Grab the abundances out of the input file and return array of abundances.

fraunhofer.specfit.initpars(params, fitparams, bounds=None)[source]

Make initial set of parameters given PARAMS and FITPARAMS.

fraunhofer.specfit.mkbounds(params, paramlims=None)[source]

Make lower and upper boundaries for parameters

fraunhofer.specfit.mkdxlim(fitparams)[source]

Make array of parameter changes at which curve_fit should finish.

fraunhofer.specfit.model_spectrum(inputs, verbose=False, keepextend=False, alinefile=None, mlinefile=None)[source]

This creates a model spectrum given the inputs: RV, Teff, logg, vmicro, vsini, [Fe/H], [X/Fe], w0, w1, dw. This creates the new synthetic spectrum and then convolves with vmicro, vsini and shifts to velocity RV.

The returned spectrum always uses AIR wavelengths!!!

Parameters
inputsdictionary

Input parameters, stellar parameters, abundances.

keepextendbool, optional

Keep the extensions on the ends. Default is False.

alinefilestr, optional

Atomic linelist filename. Default is None (use synple’s default one).

mlinefilestr, optional

Molecular linelist filename. Default is None (use synple’s default one).

verbosebool, optional

Verbose output. Default is False.

Returns
synspecSpec1D

The synthetic spectrum as Spec1D object.

fraunhofer.specfit.prepare_synthspec(synspec, lsf, norm=True, continuum_func=None)[source]

Prepare a synthetic spectrum to be compared to an observed spectrum.

fraunhofer.specfit.smoothshift_spectrum(inpspec, vmicro=None, vrot=None, rv=None)[source]

This smoothes the spectrum by Vrot+Vmicro and shifts it by RV.

fraunhofer.specfit.specfigure(figfile, spec, fmodel, out, original=None, verbose=True, figsize=10)[source]

Make diagnostic figure.

fraunhofer.specfit.synmodel(spec, params, alinefile=None, mlinefile=None, verbose=False, normalize=True)[source]

Synthetic spectrum model.

Parameters
specSpec1D object or str

The observed Spec1D spectrum to match or the name of a spectrum file.

paramsdict

Dictionary of initial values to use or parameters/elements to hold fixed.

normalizebool, optional

Renormalize the model spectrum using the observed spectrum’s continuum function. The synthetic spectrum will already have been normalized using the “true” continuum. This step is to simulate any systematic effects of the spectrum normalization algorithm that the observed spectrum undergoes. Default is True.

verboseint, optional

Verbosity level (0, 1, or 2). The default is 0 and verbose=2 is for debugging.

alinefilestr, optional

The atomic linelist to use. Default is None which means the default synple linelist is used.

mlinefilestr, optional

The molecular linelist to use. Default is None which means the default synple linelist is used.

Returns
modelSpec1D object

The synthetic spectrum. The “true” continuum is in model.cont.

fraunhofer.specfit.synple_wrapper(inputs, verbose=False, tmpbase='/tmp', alinefile=None, mlinefile=None)[source]

This is a wrapper around synple to generate a new synthetic spectrum.

fraunhofer.specfit.trim_spectrum(spec, w0, w1)[source]

Trim a synthetic spectrum to [w0,w1].

Module contents