pysep.opac.tops package¶
Subpackages¶
Submodules¶
pysep.opac.tops.err module¶
pysep.opac.tops.parseChemFile module¶
Author: Thomas M. Boudreaux
Created: May 2021
Last Modified: May 2021
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.
- pysep.opac.tops.parseChemFile.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
chem (float) – \(a(i)\) for the \(i^{th}\) element. For example for He chem might be 10.93. For Hydrogen it would definititionally be 12.
mass (float) – Mass of \(i^{th}\) element given in atomic mass units.
X (float) – Hydrogen mass fraction
- Returns
mf – Mass fraction of \(i^{th}\) element.
- Return type
float
- pysep.opac.tops.parseChemFile.open_and_parse(path)¶
Open and parse the contents of a chemical composition file
- Parameters
path (str) – Path to open file
- Returns
parsed –
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.
- Return type
dict
- pysep.opac.tops.parseChemFile.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
path (str) – Path to file to open
- Returns
contents – List of list of strings. The outter index selects the row, the inner index selectes the column within the row.
- Return type
list
- pysep.opac.tops.parseChemFile.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
contents (list) – 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
extracted –
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.
- Return type
dict
Module contents¶
Module for interacting with ATOMIC and TOPS opacities. This includes querying them from the los alamos web server, parsing them, interpolating them from LogT-rho space into LogT-LogR space, and writing them out as dsep formated tables.
This can be called either programatically or from the command line. For details on calling programatically see the docs of pysep.opac.tops.api. If you want to call from the command line here is an example.
Say there is an abundance file called ‘GS98.abun’ at a relative path of ./inputs/abund/GS98.abun, then you could generate a high temperature opacity table for that file with the following command
>>> generateTOPStables ./inputs/abund/GS98.abun -d GS98_opac -o GS98_ht_opac -j 25
- The flags here are as follows
- -d
The name of the directory to save TOPS query results too. If the directory does not exist, it will be created. If it does exist the program will raise an exception unless the -f flag is also set, in which case the directory will be deleted and recreated.
- -o
The name of the OPAL formated file to create. This is the file generated from all of the individual TOPS queries. This is the final dataproduct of using this script.
- -j
The number of concurrent connections to allow to the TOPS web form. This should be somewhere between 20-30. Too high and the webserver can kick you off, too low and the script will take hours to run.
If you have already queried the TOPS webserver but want to regenerate the high temperaute opacity file form the query results without requeriying you can do
>>> generateTOPStables ./inputs/abund/GS98.abun -d GS98_opac -o GS98_ht_opac --nofetch
Here the –nofetch flag tells the script to jump over the fetch section and assume results are already in the -d directory.