CoolDwarf.utils.abun package

Subpackages

Submodules

CoolDwarf.utils.abun.parse module

Author: Emily M. Boudreaux

Created: May 2021

Last Modified: July 2024

Module responsible for the parsing and handeling of chemical composition files in the form of

#STD [Fe/H] [alpha/Fe] [C/Fe] [N/Fe] [O/Fe] [r/Fe] [s/Fe] C/O X Y,Z
F -1.13 0.32 -0.43 -0.28 0.31 -1.13 -1.13 0.10 0.7584 0.2400,1.599E-03
#H He Li Be B C N O F Ne
12.00 10.898 -0.08 0.25 1.57 6.87 6.42 7.87 3.43 7.12
#Na Mg Al Si P S Cl Ar K Ca
5.11 6.86 5.21 6.65 4.28 6.31 -1.13 5.59 3.90 5.21
#Sc Ti V Cr Mn Fe Co Ni Cu Zn
2.02 3.82 2.80 4.51 4.30 6.37 3.86 5.09 3.06 2.30
#Ga Ge As Se Br Kr Rb Sr Y Zr
0.78 1.39 0.04 1.08 0.28 0.99 0.26 0.61 1.08 1.45
#Nb Mo Tc Ru Rh Pd Ag Cd In Sn
-0.80 -0.38 -99.00 -0.51 -1.35 -0.69 -1.32 -0.55 -1.46 -0.22
#Sb Te I Xe Cs Ba La Ce Pr Nd
-1.25 -0.08 -0.71 -0.02 -1.18 1.05 -0.03 0.45 -1.54 0.29
#Pm Sm Eu Gd Tb Dy Ho Er Tm Yb
-99.00 -1.30 -0.61 -1.19 -1.96 -1.16 -1.78 -1.34 -2.16 -1.42
#Lu Hf Ta W Re Os Ir Pt Au Hg
-2.16 -1.41 -2.38 -1.41 -2.00 -0.86 -0.88 -0.64 -1.34 -1.09
#Tl Pb Bi Po At Rn Fr Ra Ac Th
-1.36 -0.51 -1.61 -99.00 -99.00 -99.00 -99.00 -99.00 -99.00 -2.20
#Pa U
-99.00 -2.80

Where each number is a(i) for the ith element and lines starting with # are comments.

CoolDwarf.utils.abun.parse.chem_to_mass_frac(chem: float, mass: float, X: float) float

Convert \(a(i)\) for the \(i^{th}\) element to a mass fraction using the expression

\[a(i) = \log(1.008) + \log(F_{i}) - \left[\log(X) + \log(m_{i})\right] + 12\]

Or, equivilenetly, to go from \(a(i)\) to mass fraction

\[F_{i} = \left[\frac{X m_{i}}{1.008}\right]\times 10^{a(i)-12}\]

Where \(F_{i}\) is the math fraction of the \(i^{th}\) element, \(X\) is the Hydrogen mass fraction, and \(m_{i}\) is the ith element mass in hydrogen masses.

Parameters:
chemfloat

\(a(i)\) for the \(i^{th}\) element. For example for He chem might be 10.93. For Hydrogen it would definititionally be 12.

massfloat

Mass of \(i^{th}\) element given in atomic mass units.

Xfloat

Hydrogen mass fraction

Returns:
mffloat

Mass fraction of \(i^{th}\) element.

CoolDwarf.utils.abun.parse.open_and_parse(path)

Open and parse the contents of a chemical composition file

Parameters:
pathstr

Path to open file

Returns:
parseddict

Dictionary with two indexes.

  • Abundance Ratio

    Includes the indexes:

    • STD (str)

    • [Fe/H] (float)

    • [alpha/Fe] (float)

    • [C/Fe] (float)

    • [N/Fe] (float)

    • [O/Fe] (float)

    • [r/Fe] (float)

    • [s/Fe] (float)

    • C/O (float)

    • X (float)

    • Y (float)

    • Z (float)

  • RelativeAbundance

    Includes an index for each chemical symbol given in the file format definition provided in the module documentation. These are all floats.

CoolDwarf.utils.abun.parse.open_chm_file(path)

Open a chemical composition file (format defined in the module documentation). Split the contents by line then remove all lines which start with #. Finally split each line by both whitespace and commas.

Parameters:
pathstr

Path to file to open

Returns:
contentslist

List of list of strings. The outter index selects the row, the inner index selectes the column within the row.

CoolDwarf.utils.abun.parse.parse(contents: list) dict

Parse chem file in the format described in the module documentation.

The abuundance ratios and abundances on the first row are added to a dict under the key [‘AbundanceRatio’] and sub indexed by the comments above each entry (Note that these are not read; rather, they are assumed to be the same in every file). The subsequent values (on all other rows) are added to the same dict under the key [‘RelativeAbundance’] and sub indexed by their chemical symbols.

Parameters:
contentslist

List of list of strings. The outter index selects the row, the inner index selected the column in the row and at each coordinate is a string which can be cast as a float. The one exception is that string at 0,0 is a charectar.

Returns:
extracteddict

Dictionary with two indexes.

  • Abundance Ratio

    Includes the indexes:

    • STD (str)

    • [Fe/H] (float)

    • [alpha/Fe] (float)

    • [C/Fe] (float)

    • [N/Fe] (float)

    • [O/Fe] (float)

    • [r/Fe] (float)

    • [s/Fe] (float)

    • C/O (float)

    • X (float)

    • Y (float)

    • Z (float)

  • RelativeAbundance

    Includes an index for each chemical symbol given in the file format from the module documentation. These are all floats.

CoolDwarf.utils.abun.utils module

CoolDwarf.utils.abun.utils.a_to_mfrac(a, amass, X)

Convert a for the ith element to the mass fraction of the ith element using the equation:

\[F_{i} = \left[\frac{Xm_{i}}{1.008}\right]\times 10^{a(i)-12}\]

Where \(F_{i}\) is the mass fraction for the \(i^{th}\) element and \(m_{i}\) is the mass fraction for the \(i^{th}\) element.

Parameters:
afloat

a for the ith element

amassfloat

Mass of the ith element in atomic mass units.

Xfloat

Hydrogen mass fraction

Returns:
mfracfloat

mass fraction for the ith element

CoolDwarf.utils.abun.utils.est_feh_from_Z_and_X(abunTable: dict, Xt: float, Zt: float) float

Analytically estimate feh from Z and X

Parameters:
abunTabledict

Abundance Table dictionary in the form described in the docs for pysep.misc.abun.util.open_and_parse.

Xtfloat

Target X to move to

Ztfloat

Target Z to move to.

Returns:
FeHfloat

[Fe/H] value to add to every a(i) for every tracked element i where i > 2 (i.e all the metals).

CoolDwarf.utils.abun.utils.gen_abun_map(abunTable)

Generate an analytic mapping between X, Y, Z and FeH given an abundance table.

Parameters:
abunTablestr

Path of checmical abundance table to use for composition. Format of this table is defined in the ext module documentation.

Returns:
MetalAbunMapfunction(X,Y,Z) -> (Fe/H,0.0,a(He))

Function build from interpolation of a grid of FeH, alpha/Fe, and a(He) which will returned the set of those values giving the composition most similar to an input X, Y, and Z.

CoolDwarf.utils.abun.utils.get_atomic_masses()

Return a dict of atomic masses from Hydrogen all the way to plutonium

Returns:
amassesdict of floats

Dicionary of atomic masses in atomic mass units indexed by elemental symbol.

CoolDwarf.utils.abun.utils.mfrac_to_a(mfrac, amass, X, Y)

Convert mass fracition of a given element to a for that element at a given hydrogen mass fraction using the equation

\[a(i) = \log(1.008) + \log(F_{i}) - \left[\log(X) + \log(m_{i}) \right]\]

Where \(F_{i}\) is the mass fraction for the \(i^{th}\) element and \(m_{i}\) is the mass fraction for the \(i^{th}\) element.

Parameters:
mfracfloat

Mass fraction of the ith element.

amassfloat

Mass of the ith element in atomic mass units.

Xfloat

Hydrogen mass fraction

Yfloat

Helium mass fraction, will be used as reference if X = 0

Returns:
afloat

a for the ith element

CoolDwarf.utils.abun.utils.parse_abundance_map() ndarray

Parse Hydroge, Helium, and metal mass fraction out of a csv where each row is one composition, the first column is X, second is Y, and the third is Z. Comments may be included in the file if the first non white space charectar on the line is a hash.

Returns:
pContentsnp.ndarray(shape=(n,3))

numpy array of all the compositions of length n where n is the number of rows whos first non white space charectar was not a hash. For a dsep n=126. Along the second axis the first column is X, the second is Y, and the third is Z.

Module contents

Chemical abundance tables which might be needed.

Avalible Aubundance Tables

GS98.abun

[1] Grevesse, N. and Sauval, A.J., 1998. Standard solar composition. Space Science Reviews, 85(1), pp.161-174.

AGSS09.abun

[1] Asplund, M., Grevesse, N., Sauval, A.J. and Scott, P., 2009. The chemical composition of the Sun. Annual review of astronomy and astrophysics, 47, pp.481-522.