Skip to content

Commit

Permalink
add .auto file reader
Browse files Browse the repository at this point in the history
  • Loading branch information
jwreep authored and wtbarnes committed Jan 8, 2024
1 parent 800de31 commit 1400368
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fiasco/io/sources/ion_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,26 @@ def preprocessor(self, table, line, index):
ionization_potential = tmp[0]
cs_spline = np.array(tmp[1:], dtype=float)*1e-14
table[-1] = [ionization_potential] + table[-1] + [cs_spline] + [0.0]


class AutoParser(GenericIonParser):
"""
Autoionization rates for each level in an ion
"""
filetype = 'auto'
dtypes = [int, int, float, str, str]
units = [None, None, 1/u.s, None, None]
headings = ['lower_level', 'upper_level', 'autoionization_rate', 'lower_label', 'upper_label']
descriptions = [
'lower level index',
'upper level index',
'autoionization rate',
'lower level label',
'upper level label'
]
fformat = fortranformat.FortranRecordReader('(2I7,E12.2,A30,A30)')

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()
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 @@ -22,6 +22,7 @@
'fe_2.trparams',
'fe_12.drparams',
'al_3.diparams',
'fe_23.auto',
])
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 1400368

Please sign in to comment.