Skip to content

Commit

Permalink
Add file reader for rrlvl files (#247)
Browse files Browse the repository at this point in the history
* add rrlvl file reader

* add test for rrlvl reader

* parse Z, ion too; add tech report reference

---------

Co-authored-by: Will Barnes <[email protected]>
  • Loading branch information
jwreep and wtbarnes authored Jan 10, 2024
1 parent 0302c74 commit 8f6acc0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,12 @@ @techreport{dere_chianti_2017
urldate = {2022-08-21},
langid = {english}
}

@techreport{young_chianti_2019,
title = {{{CHIANTI Technical Report No}}. 24: {{The CHIANTI}} Level-Resolved Recombination Files (Rrlvl)},
author = {Young, Peter R.},
year = {2019},
month = feb,
number = {24},
urldate = {2024-01-09}
}
47 changes: 47 additions & 0 deletions fiasco/io/sources/ion_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'DrparamsParser',
'DiparamsParser',
'AutoParser',
'RrlvlParser',
]


Expand Down Expand Up @@ -461,3 +462,49 @@ def preprocessor(self, table, line, index):
super().preprocessor(table, line, index)
# remove the dash in the second-to-last entry
table[-1][-2] = table[-1][-2].split('-')[0].strip()


class RrlvlParser(GenericIonParser):
"""
Level-resolved recombination rates as a function of temperature.
These files contain the *Direct* radiative recombination rates from
the recombining ion to the recombined ion. Note that these files contain
the *effective* radiation recombination rate coefficients.
A given ion should have either a ``.rrlvl`` file or a ``.reclvl`` file,
but not both. For a full description of these files, see :cite:t:`young_chianti_2019`.
"""
filetype = 'rrlvl'
dtypes = [int, int, int, int, float, float]
units = [None, None, None, None, u.K, (u.cm**3)/u.s]
headings = [
'Z',
'ion',
'initial_level',
'final_level',
'temperature',
'rate',
]
descriptions = [
'atomic number',
'ionization state',
'level index of the recombining ion',
'index of the final level of the transition in the recombined ion',
'temperatures at which rates are tabulated',
'direct radiative recombination rate coefficients',
]

def preprocessor(self, table, line, index):
# NOTE: Every pair of lines has the same first four entries. On the even
# lines, the remaining entries contain the temperatures and on the odd
# lines, the remaining entries are the rate coefficients. Thus, every
# other line needs to be added to the one above it.
line = line.strip().split()
if index % 2 == 0:
row = line[:4]
temperature = np.array(line[4:], dtype=float)
row += [temperature]
table.append(row)
else:
rate_coefficient = np.array(line[4:], dtype=float)
table[-1].append(rate_coefficient)
1 change: 1 addition & 0 deletions fiasco/io/sources/tests/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'fe_12.drparams',
'al_3.diparams',
pytest.param('fe_23.auto', marks=pytest.mark.requires_dbase_version('>=9')),
pytest.param('fe_23.rrlvl', marks=pytest.mark.requires_dbase_version('>=9')),
])
def test_ion_sources(ascii_dbase_root, filename,):
parser = fiasco.io.Parser(filename, ascii_dbase_root=ascii_dbase_root)
Expand Down

0 comments on commit 8f6acc0

Please sign in to comment.