CMFGEN
Database from John Hillier’s CMFGEN, a radiative transfer code designed to solve the radiative transfer and statistical equilibrium equations in spherical geometry.
Note:
In this example, the data was downloaded from the CMFGEN website and extracted to the /tmp/atomic folder.
Parsers
The CMFGEN parsers retrieves data from text files preserving its original form (no unit conversions) and stores it in DataFrames. Currently, just osc, col and pho files are supported.
Levels, Lines and Collisions
Energy levels and spectral lines are stored in the osc files, while collisions strengths are provided by the col files.
[1]:
import pathlib
from carsus.io.cmfgen import CMFGENEnergyLevelsParser, CMFGENOscillatorStrengthsParser, CMFGENCollisionalStrengthsParser
[ ]:
cmfgen_path = '../../../carsus-data-cmfgen/atomic/'
if not pathlib.Path(cmfgen_path).exists():
cmfgen_path = "/tmp/atomic/"
[ ]:
si2_lvl = CMFGENEnergyLevelsParser(cmfgen_path+'SIL/II/16sep15/si2_osc_kurucz')
[ ]:
si2_osc = CMFGENOscillatorStrengthsParser(cmfgen_path+'SIL/II/16sep15/si2_osc_kurucz')
[ ]:
si2_col = CMFGENCollisionalStrengthsParser(cmfgen_path+'SIL/II/16sep15/si2_col')
Header information is stored in the header attribute and the DataFrame in the base attribute:
[ ]:
si2_col.header
[ ]:
si2_lvl.base
Photoionization Cross-sections
Photoionization cross-sections are provided by the pho files.
[ ]:
from carsus.io.cmfgen import CMFGENPhoCrossSectionsParser
[ ]:
si2_cross_sections = CMFGENPhoCrossSectionsParser(cmfgen_path+'SIL/II/16sep15/phot_nahar_A')
[ ]:
si2_cross_sections.header
In this case, base is a list containing many DataFrames. Also, each individual DataFrame contains information relative to that specific target under the attribute attr.
[ ]:
type(si2_cross_sections.base)
[ ]:
len(si2_cross_sections.base)
[ ]:
si2_cross_sections.base[0]
[ ]:
si2_cross_sections.base[0].attrs
Batch Convert Files to HDF5
To convert multiple CMFGEN files to the HDF5 format import the hdf_dump function.
Note:
This feature has been temporary disabled.
Required parameters are cmfgen_dir, patterns and parser, while chunk_size and ignore_patterns are optional.
CMFGENReader
The CMFGENReader provides processed levels, lines, ionization_energies, cross_sections and collisions tables to work with. You can provide temperatures for the collisions dataframe using the temperature_grid option.
[ ]:
from carsus.io.cmfgen import CMFGENReader
[ ]:
cmfgen_reader = CMFGENReader.from_config('Si 0-1', cmfgen_path, ionization_energies=True, cross_sections=True, collisions=True, drop_mismatched_labels=True)
[ ]:
cmfgen_reader.levels
[ ]:
cmfgen_reader.lines
[ ]:
cmfgen_reader.cross_sections
[ ]:
cmfgen_reader.ionization_energies
The values in the collisions dataframe are thermally-averaged effective collision strengths divided by the statistical weights of the lower levels. Please see Eq. A1 and A2 of [PrzybillaButler04] for definitions. More information about the collisions table is stored inside the collisional_metadata attribute.
[ ]:
cmfgen_reader.collisions
[ ]:
cmfgen_reader.collisional_metadata