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]:
from carsus.io.cmfgen import CMFGENEnergyLevelsParser, CMFGENOscillatorStrengthsParser, CMFGENCollisionalStrengthsParser
 ChiantiPy version 0.15.0
 found PyQt5 widgets
 using PyQt5 widgets
[                py.warnings][WARNING] - /home/runner/micromamba/envs/carsus/lib/python3.12/site-packages/ChiantiPy/tools/data.py:72: UserWarning: klgfb files are not present:
  it will not be possible to use the freeBound continuum method
  warnings.warn('klgfb files are not present: \n  it will not be possible to use the freeBound continuum method')
 (warnings.py:112)
[2]:
si2_lvl = CMFGENEnergyLevelsParser('/tmp/atomic/SIL/II/16sep15/si2_osc_kurucz')
[3]:
si2_osc = CMFGENOscillatorStrengthsParser('/tmp/atomic/SIL/II/16sep15/si2_osc_kurucz')
[4]:
si2_col = CMFGENCollisionalStrengthsParser('/tmp/atomic/SIL/II/16sep15/si2_col')

Header information is stored in the header attribute and the DataFrame in the base attribute:

[5]:
si2_col.header
[5]:
{'Number of transitions': '406',
 'Number of T values OMEGA tabulated at': '14',
 'Scaling factor for OMEGA': '1.0',
 'Value for OMEGA if f=0': '0.1'}
[6]:
si2_lvl.base
[6]:
label g E(cm^-1) 10^15 Hz eV Lam(A) ID ARAD C4 C6
0 3s2_3p_2Po[1/2] 2.0 0.00 3.95241 16.346 758.505847 1 0.000000e+00 -5.290000e-17 7.470000e-33
1 3s2_3p_2Po[3/2] 4.0 287.24 3.94380 16.310 760.162036 2 0.000000e+00 -5.300000e-17 7.460000e-33
2 3s_3p2_4Pe[1/2] 2.0 42824.29 2.66857 11.036 1123.420681 3 1.222000e+04 -5.340000e-17 7.490000e-33
3 3s_3p2_4Pe[3/2] 4.0 42932.62 2.66532 11.023 1124.789552 4 2.110000e+03 -5.340000e-17 7.490000e-33
4 3s_3p2_4Pe[5/2] 6.0 43107.91 2.66007 11.001 1127.011617 5 3.246000e+03 -5.350000e-17 7.490000e-33
... ... ... ... ... ... ... ... ... ... ...
152 3s_3p(3Po)4p_4Pe[3/2] 4.0 134079.00 -0.06718 -0.278 -44625.724052 153 1.159000e+08 -1.500000e-16 3.080000e-32
153 3s_3p(3Po)4p_4Pe[5/2] 6.0 134213.63 -0.07122 -0.295 -42096.577969 154 1.167000e+08 -1.500000e-16 3.090000e-32
154 3s_3p(3Po)4p_4Se[3/2] 4.0 134905.28 -0.09195 -0.380 -32603.663348 155 9.275000e+07 -9.750000e-17 2.770000e-32
155 3p3_2Do[5/2] 6.0 135297.30 -0.10370 -0.429 -28908.752414 156 2.437000e+09 4.200000e-17 1.450000e-32
156 3p3_2Do[3/2] 4.0 135303.50 -0.10389 -0.430 -28857.030727 157 2.438000e+09 1.390000e-17 1.460000e-32

157 rows × 10 columns

Photoionization Cross-sections

Photoionization cross-sections are provided by the pho files.

[7]:
from carsus.io.cmfgen import CMFGENPhoCrossSectionsParser
[8]:
si2_cross_sections = CMFGENPhoCrossSectionsParser('/tmp/atomic/SIL/II/16sep15/phot_nahar_A')
[9]:
si2_cross_sections.header
[9]:
{'Date': '05-Sep-2015 16:54:54',
 'Number of energy levels': '93',
 'Number of photoionization routes': '2',
 'Screened nuclear charge': '2.0',
 'Final state in ion': '3s2_1Se/3s21Se',
 'Excitation energy of final state': '0.0',
 'Statistical weight of ion': '1.0',
 'Sigma used for Gaussian smoothing': '0.0D0',
 'Cross-section unit': 'Megabarns',
 'Split J levels': 'False',
 'Total number of data pairs': '95107',
 'Configuration name': '3s2_3p_2Po',
 'Type of cross-section': '20',
 'Number of cross-section points': '1487'}

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.

[10]:
type(si2_cross_sections.base)
[10]:
list
[11]:
len(si2_cross_sections.base)
[11]:
93
[12]:
si2_cross_sections.base[0]
[12]:
energy sigma
0 1.000000 1.414000
1 1.000333 1.405000
2 1.000666 1.397000
3 1.000999 1.388000
4 1.001332 1.379000
... ... ...
1482 17.034180 0.001255
1483 18.825680 0.000929
1484 20.805590 0.000689
1485 22.993730 0.000510
1486 25.412010 0.000378

1487 rows × 2 columns

[13]:
si2_cross_sections.base[0].attrs
[13]:
{'Configuration name': '3s2_3p_2Po',
 'Type of cross-section': 20,
 'Number of cross-section points': 1487}

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.

from carsus.io.cmfgen import hdf_dumphdf_dump('/tmp/atomic/', ['osc', 'OSC', 'Osc'], CMFGENEnergyLevelsParser(), chunk_size=10, ignore_patterns=['ERROR_CHK'])

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.

[14]:
from carsus.io.cmfgen import CMFGENReader
[15]:
cmfgen_reader = CMFGENReader.from_config('Si 0-1', '/tmp/atomic', ionization_energies=True, cross_sections=True, collisions=True, drop_mismatched_labels=True)
[      carsus.io.cmfgen.base][WARNING] - Selecting H 0 from CMFGEN (required to ingest cross-sections). (base.py:557)
[      carsus.io.cmfgen.base][   INFO] - Configuration schema found for H 0. (base.py:571)
[      carsus.io.cmfgen.base][   INFO] - Configuration schema found for Si 0. (base.py:571)
[      carsus.io.cmfgen.base][   INFO] - Configuration schema found for Si 1. (base.py:571)
[      carsus.io.cmfgen.base][   INFO] - Loading atomic data for H 0. (base.py:856)
[      carsus.io.cmfgen.base][   INFO] - Loading atomic data for Si 0. (base.py:856)
[      carsus.io.cmfgen.base][   INFO] - Loading atomic data for Si 1. (base.py:856)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Dropping collisional ionization data. (base.py:1054)
[      carsus.io.cmfgen.base][   INFO] - Entries having label(s): 3s2_3p2_3Pe, 3s_3p3_5So will be dropped for ion: (np.int64(14), 0). (base.py:1059)
[      carsus.io.cmfgen.base][   INFO] - Filling in 1 values for ion (1, 0) that are outside the tabulated temperature range using the last tabulated value. (base.py:1119)
[      carsus.io.cmfgen.base][   INFO] - Filling in 7 values for ion (np.int64(14), 0) that are outside the tabulated temperature range using the last tabulated value. (base.py:1119)
[      carsus.io.cmfgen.base][   INFO] - Filling in 4 values for ion (np.int64(14), 1) that are outside the tabulated temperature range using the last tabulated value. (base.py:1119)
[16]:
cmfgen_reader.levels
[16]:
energy j label method priority
atomic_number ion_charge level_index
1 0 0 0.000000 0.5 1___ meas 10
1 82259.096334 3.5 2___ meas 10
2 97492.300647 8.5 3___ meas 10
3 102823.892736 15.5 4___ meas 10
4 105291.651183 24.5 5___ meas 10
... ... ... ... ... ... ... ...
14 1 152 134079.000000 1.5 3s_3p(3Po)4p_4Pe[3/2] meas 10
153 134213.630000 2.5 3s_3p(3Po)4p_4Pe[5/2] meas 10
154 134905.280000 1.5 3s_3p(3Po)4p_4Se[3/2] meas 10
155 135297.300000 2.5 3p3_2Do[5/2] meas 10
156 135303.500000 1.5 3p3_2Do[3/2] meas 10

680 rows × 5 columns

[17]:
cmfgen_reader.lines
[17]:
energy_lower energy_upper gf j_lower j_upper wavelength
atomic_number ion_charge level_index_lower level_index_upper
1 0 0 1 0.00 82259.096334 8.324000e-01 0.5 3.5 121.5670
2 0.00 97492.300647 1.582000e-01 0.5 8.5 102.5720
3 0.00 102823.892736 5.798000e-02 0.5 15.5 97.2540
4 0.00 105291.651183 2.788000e-02 0.5 24.5 94.9740
5 0.00 106632.159810 1.559800e-02 0.5 35.5 93.7800
... ... ... ... ... ... ... ... ... ...
14 1 152 156 134079.00 135303.500000 1.300000e-05 1.5 1.5 8164.3728
153 155 134213.63 135297.300000 3.963000e-06 2.5 2.5 9225.3865
156 134213.63 135303.500000 2.477400e-07 2.5 1.5 9172.9055
154 155 134905.28 135297.300000 3.069200e-05 1.5 2.5 25500.0000
156 134905.28 135303.500000 2.697600e-06 1.5 1.5 25100.0000

26422 rows × 6 columns

[18]:
cmfgen_reader.cross_sections
[18]:
energy sigma
atomic_number ion_charge level_index
1 0 0 0.999466 6.310022
0 1.015765 6.042398
0 1.032328 5.786125
0 1.049162 5.540721
0 1.066271 5.305726
... ... ... ... ...
14 1 154 -263.073454 0.000000
155 -0.031522 0.000000
155 -3.152219 0.000000
156 -0.031579 0.000000
156 -3.157868 0.000000

385466 rows × 2 columns

[19]:
cmfgen_reader.ionization_energies
[19]:
atomic_number  ion_charge
1              0             13.598434
14             0              8.151683
               1             16.345846
Name: ionization_energy, dtype: float64

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.

[20]:
cmfgen_reader.collisions
[20]:
0 1 2 3 4 5 6 7 8 9 ... 11 12 13 14 15 16 17 18 19 20
atomic_number ion_charge level_index_lower level_index_upper
1 0 0 1 0.331250 0.331250 0.331250 0.331250 0.331250 0.342092 0.372950 0.393113 0.417929 0.450500 ... 0.531217 0.589667 0.659250 0.701471 0.820400 0.820400 0.820400 0.820400 0.820400 0.820400
2 0.096550 0.096550 0.096550 0.096550 0.096550 0.096992 0.098250 0.100395 0.103035 0.106500 ... 0.125060 0.138500 0.154500 0.164377 0.192200 0.192200 0.192200 0.192200 0.192200 0.192200
3 0.008550 0.008550 0.008550 0.008550 0.008550 0.009850 0.013550 0.015903 0.018799 0.022600 ... 0.031010 0.037100 0.044350 0.047992 0.058250 0.058250 0.058250 0.058250 0.058250 0.058250
4 0.011700 0.011700 0.011700 0.011700 0.011700 0.012090 0.013200 0.013980 0.014940 0.016200 ... 0.019583 0.022033 0.024950 0.026535 0.031000 0.031000 0.031000 0.031000 0.031000 0.031000
5 0.006550 0.006550 0.006550 0.006550 0.006550 0.006771 0.007400 0.007829 0.008357 0.009050 ... 0.010964 0.012350 0.014000 0.014891 0.017400 0.017400 0.017400 0.017400 0.017400 0.017400
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
14 1 25 29 39.000000 39.000000 39.000000 43.500000 46.652174 50.750000 61.750000 68.750000 76.000000 83.250000 ... 97.000000 102.500000 105.638528 109.750000 110.750000 105.500000 100.794276 95.000000 95.000000 95.000000
30 13.950000 13.950000 13.950000 15.300000 16.180435 17.325000 20.175000 21.925000 23.775000 25.750000 ... 29.250000 30.500000 31.257576 32.250000 32.500000 31.000000 29.543467 27.750000 27.750000 27.750000
26 29 3.550000 3.550000 3.550000 3.866667 4.011594 4.200000 4.600000 4.816667 5.050000 5.283333 ... 5.716667 5.883333 5.962698 6.066667 6.016667 5.700000 5.460979 5.166667 5.166667 5.166667
30 44.833333 44.833333 44.833333 51.333333 55.681159 61.333333 75.666667 84.333333 93.666667 103.000000 ... 120.500000 127.666667 131.707071 137.000000 138.666667 132.333333 126.432505 119.166667 119.166667 119.166667
29 30 17.900000 17.900000 17.900000 19.350000 20.241304 21.400000 24.250000 26.100000 28.150000 30.400000 ... 35.250000 37.700000 39.583117 42.050000 44.950000 45.500000 44.626080 43.550000 43.550000 43.550000

849 rows × 21 columns

[21]:
cmfgen_reader.collisional_metadata
[21]:
temperatures    [100, 2000, 2500, 4000, 5000, 6300, 10000, 126...
dataset                                                  [cmfgen]
info            The dataframe values are thermally-averaged ef...
dtype: object