interpolate

Classes used to interpolate and predict lithium abundances and spectra.

spectra

Class used to predict lithium abundance from spectra and predict spectra from lithium abundance.

class breidablik.interpolate.spectra.Spectra(model_path=None, scalar_path=None, save_num=1)

Interpolation class for spectra. Used to interpolate between the stellar parameters. Can find the abundance of an input flux given the stellar parameters. Can also predict a flux from the stellar parameters and abundance.

X
__init__(model_path=None, scalar_path=None, save_num=1)

Initialise the data by loading the pickled models and scalar.

Parameters:
  • model_path (str, optional) – The path to the model to be used to predict the flux. By default, this path points to models/kri in breidablik.

  • scalar_path (str, optional) – The path to the scalar corresponding to the model. By default, this path points to models/kri/scalar.npy in breidablik.

  • save_num (int) – The number of cubic spline models to save. This makes the code run faster, but takes memory. Only worth increasing if you are repeatedly analysing different observations of multiple stars.

cut_models = None
find_abund(wavelength, flux, flux_err, eff_t, surf_g, met, accuracy=0.0001, method='bayes', min_abund=-0.5, max_abund=4, initial_accuracy=0.1, abunds=None, prior=None)

Finds the abundance of the spectrum.

Parameters:
  • wavelength (List[Real] or 1darray) – The wavelengths that correspond to the flux. Needs to be monotonically increasing.

  • flux (List[Real] or 1darray) – The flux that the abundance will be found for. Needs to be the same length as wavelength.

  • flux_err (List[Real] or 1darray) – The error in each flux point. Needs to be the same length as wavelength.

  • eff_t (Real) – The effective temperature of the star.

  • surf_g (Real) – The log surface gravity of the star.

  • met (Real) – The metallicity of the star.

  • accuracy (Real, optional) – The decimal place you want the result to be accurate to.

  • method (str, optional) – The method of finding the abundance. Accepted methods are: ‘bayes’ and ‘chisq’.

  • min_abund (Real, optional) – The minimum abundance that the algorithm should search to.

  • max_abund (Real, optional) – The maximum abundance that the algorithm should search to.

  • initial_accuracy (Real, optional) – The initial accuracy that the algorithm starts searching through. If ‘bayes’ is returning warnings try decreasing the initial accuracy. Note that this does make the algorithm run slower.

  • abunds (List[Real], 1darray, optional) – Determine the abundances you want the probability caculated over. Overrides the min_abund and max_abund parameters. This parameter is ignored if prior is not set. Only used if method is ‘bayes’.

  • prior (List[Real], 1darray, optional) – Set the prior to the abundances specified via abunds. This parameter is ignored if abunds is not set. Only used if method is ‘bayes’. If method is ‘bayes’ but no prior is set, uses uniform prior + gaussian with sigma=1 below -0.5. Needs to be the same length as abunds.

Returns:

(abundance, error) – The abundance that matches best with the input flux and the error value associated with the abundance. The error list has 2 values, left is the negative error, right is the positive error. The error can be None if the method is ‘chisq’ or if abunds and prior were given but error cannot be calculated.

Return type:

(float, list)

model_path
models
predict_flux(eff_t, surf_g, met, abundance)

Predicts the flux for the input stellar parameters and abundances.

Parameters:
  • eff_t (Real) – The effective temperature of the star.

  • surf_g (Real) – The log surface gravity of the star.

  • met (Real) – The metallicity of the star.

  • abundance (Real) – The lithium abundance of the star.

Returns:

predicted – The predicted flux given the input stellar parameters and lithium abundance.

Return type:

1darray

relative_error
save_num
scalar
scalar_path

rew

Class used to predict lithium abundance from REW.

class breidablik.interpolate.rew.Rew(dim=3, model_path=None, scalar_path=None, model_path_610=None, scalar_path_610=None, model_path_810=None, scalar_path_810=None)

Interpolation class for REW. Used to interpolate between the stellar parameters. Can find the abundance given the REW and stellar parameters.

__init__(dim=3, model_path=None, scalar_path=None, model_path_610=None, scalar_path_610=None, model_path_810=None, scalar_path_810=None)

Initialise the data by reading the pickled models and scalar.

Parameters:
  • dim (int, optional) – The dimensionality of the model atmospheres. By default this is 3 for 3D, referring to Stagger model atmospheres. Alternatively 1 for 1D marcs model atmospheres - useful if you need consistent abundances for stellar parameters outside of the Stagger grid. Note that this only applies to the 670 line.

  • model_path (str, optional) – The path to the rew model to be used to predict the lithium abundance. By default, this path points to models/rew in breidablik.

  • scalar_path (str, optional) – The path to the scalar corresponding to the rew model. By default, this path points to models/rew/scalar.npy in breidablik.

  • model_path_610 (str, optional) – Similar to model_path, except for the 610 line.

  • scalar_path_610 (str, optional) – Similar to scalar_path, except for 610 line.

  • model_path_810 (str, optional) – Similar to model_path, except for 810 line.

  • scalar_path_810 (str, optional) – Similar to scalar_path, except for 810 line.

dim
find_abund(eff_t, surf_g, met, rew, center=670.9659)

Find the abundance based on the stellar parameters and measured reduced equivalent width.

Parameters:
  • rew (Real) – The reduced equivalent width for the lithium line at 670.9 nm.

  • eff_t (Real) – The effective temperature of the star.

  • surf_g (Real) – The log surface gravity of the star.

  • met (Real) – The metallicity of the star.

  • center (Real, optional) – The center of the lithium line that the input rew corresponds to, in angstroms. The 3 lithium lines are centered at 610.5298, 670.9659, and 812.8606 nm in the Balder results. The input center value will snap to the closest value out of those 3.

Returns:

predcited_li – The predicted lithium abundance.

Return type:

float

model_path_610
model_path_810
models
scalar
scalar_610
scalar_810
scalar_path_610
scalar_path_810
scalars

nlte

Class used to find the NLTE correction for lithium abundance for a given 1D LTE lithium abundance.

class breidablik.interpolate.nlte.Nlte(model_path=None, scalar_path=None, model_path_610=None, scalar_path_610=None, model_path_810=None, scalar_path_810=None)

Interpolation class for REW. Used to interpolate between the stellar parameters. Can find the abundance given the REW and stellar parameters.

__init__(model_path=None, scalar_path=None, model_path_610=None, scalar_path_610=None, model_path_810=None, scalar_path_810=None)

Initialise the data by reading the pickled models and scalar.

Parameters:
  • model_path (str, optional) – The path to the rew model to be used to predict the lithium abundance. By default, this path points to models/nlte.pkl in breidablik.

  • scalar_path (str, optional) – The path to the scalar corresponding to the rew model. By default, this path points to models/nlte_scalar.pkl in breidablik.

model_path
model_path_610
model_path_810
models
nlte_correction(eff_t, surf_g, met, abundance, center=670.9659)

Find the abundance based on the stellar parameters and measured reduced equivalent width.

Parameters:
  • rew (Real) – The reduced equivalent width for the lithium line at 670.9 nm.

  • eff_t (Real) – The effective temperature of the star.

  • surf_g (Real) – The log surface gravity of the star.

  • abundance (Real) – The 1D LTE abundance.

  • center (Real, optional) – The center of the lithium line that the input rew corresponds to, in angstroms. The 3 lithium lines are centered at 610.5298, 670.9659, and 812.8606 nm in the Balder results. The input center value will snap to the closest value out of those 3.

Returns:

predcited_li – The predicted correction on the lithium abundance.

Return type:

float

scalar
scalar_610
scalar_810
scalar_path
scalar_path_610
scalar_path_810
scalars