Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file reader for rrlvl files #247

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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