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 autoionization files #240

Merged
merged 9 commits into from
Jan 9, 2024
Merged

Add file reader for autoionization files #240

merged 9 commits into from
Jan 9, 2024

Conversation

jwreep
Copy link
Collaborator

@jwreep jwreep commented Dec 12, 2023

Fixes #48

Adds the function to read the files. I'm not sure where that would then need to be called within fiasco itself.

Tested with the .auto files in CHIANTI v10:

(base) C:\Users\reep\Documents>python
Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from astropy.table import QTable
>>>
>>> import fiasco.io
>>> paser = fiasco.io.Parser('fe_23.auto')
>>> table = paser.parse()
>>> table
<QTable length=84>
lower_level upper_level autoionization_rate lower_label     upper_label
                               1 / s
   int32       int32          float64          str12           str17
----------- ----------- ------------------- ------------ -----------------
          1         167    62100000000000.0 1s2.2s 2S0.5 - 1s.2s2.2p 3P0.0
          3         167     3970000000000.0 1s2.2p 2P1.5 - 1s.2s2.2p 3P0.0
          2         167   123000000000000.0 1s2.2p 2P0.5 - 1s.2s2.2p 3P0.0
          1         168    58100000000000.0 1s2.2s 2S0.5 - 1s.2s2.2p 3P1.0
          3         168    19200000000000.0 1s2.2p 2P1.5 - 1s.2s2.2p 3P1.0
          2         168   108000000000000.0 1s2.2p 2P0.5 - 1s.2s2.2p 3P1.0
          1         169    61400000000000.0 1s2.2s 2S0.5 - 1s.2s2.2p 3P2.0
          3         169   127000000000000.0 1s2.2p 2P1.5 - 1s.2s2.2p 3P2.0
          2         169     3200000000000.0 1s2.2p 2P0.5 - 1s.2s2.2p 3P2.0
        ...         ...                 ...          ...               ...
          2         193    19700000000000.0 1s2.2p 2P0.5    - 1s.2p3 3P0.0
          1         194     1710000000000.0 1s2.2s 2S0.5    - 1s.2p3 3P1.0
          3         194   108000000000000.0 1s2.2p 2P1.5    - 1s.2p3 3P1.0
          2         194    15900000000000.0 1s2.2p 2P0.5    - 1s.2p3 3P1.0
          1         195     1290000000000.0 1s2.2s 2S0.5    - 1s.2p3 3P2.0
          3         195   156000000000000.0 1s2.2p 2P1.5    - 1s.2p3 3P2.0
          2         195     4290000000000.0 1s2.2p 2P0.5    - 1s.2p3 3P2.0
          1         196      119000000000.0 1s2.2s 2S0.5    - 1s.2p3 1P1.0
          3         196   107000000000000.0 1s2.2p 2P1.5    - 1s.2p3 1P1.0
          2         196    18600000000000.0 1s2.2p 2P0.5    - 1s.2p3 1P1.0
>>> table.meta
OrderedDict([('footer', "filename:  fe_23.auto\nTheoretical energy levels and autoionization rates:  Autostructure calculation\nA Breit-Pauli distorted wave implementation for AUTOSTRUCTURE\nBadnell, N.R., 2011, Computer Physics Communications, 182, 1528\nADSref:  http://adsabs.harvard.edu/abs/2011CoPhC.182.1528B\nAutostructure calculation optimized with 'SHFTIC' file using energy corrections from the following sources:\nObserved energy levels:  Kramida, A., Ralchenko, Yu., Reader, J., and NIST ASD Team (2012). NIST Atomic Spectra Database (ver. 5.0), [Online]. Available: http://physics.nist.gov/asd [2012, September 14]. National Institute of Standards and Technology, Gaithersburg, MD.\ntheoretical energy levels used to correct autostructure levels\nYerokhin, V. A.; Surzhykov, A.; Fritzsche, S.\nRelativistic configuration-interaction calculation of K-alpha transition energies in berylliumlike iron\nPhysical Review A, Volume 90, Issue 2, id.022509\nDOI:  10.1103/PhysRevA.90.022509\nadsRef:  http://adsabs.harvard.edu/abs/2014PhRvA..90b2509Y\nobserved energy levels 168 ( 53215318.) and 173 (53464915.) from\nRudolph, J. K.; Bernitt, S.; Epp, S. W.; Steinbrugge, R.; Beilmann, C.; Brown, G. V.; Eberle, S.; Graf, A.; Harman, Z.; Hell, N.; Leutenegger, M.; Mueller, A.; Schlage, K.; Wille, H.-C.; Yavas, H.; Ullrich, J.; Crespo Lopez-Urrutia, J. R.\nX-Ray Resonant Photoexcitation: Linewidths and Energies of K-alpha Transitions in Highly Charged Fe Ions\nPhysical Review Letters, vol. 111, Issue 10, id. 103002\nDOI:  10.1103/PhysRevLett.111.103002\nadsRef:  http://adsabs.harvard.edu/abs/2013PhRvL.111j3002R\nproduced as a part of the  'CHIANTI' atomic database for astrophysical spectroscopy\nK. Dere (GMU) - 2017 December 24\ncomment: Fixed text problem in comments. No change to data.  Peter Young, 25-Jul-2019"), ('chianti_version', '8.0.7'), ('filename', 'fe_23.auto'), ('descriptions', {'lower_level': 'lower level index', 'upper_level': 'upper level index', 'autoionization_rate': 'autoionization rate', 'lower_label': 'lower level label', 'upper_label': 'upper level label'}), ('element', 'fe'), ('ion', 'fe_23'), ('dielectronic', False)])

@pep8speaks
Copy link

pep8speaks commented Dec 12, 2023

Hello @jwreep! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2023-12-12 01:10:51 UTC

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (800de31) 91.95% compared to head (81d038b) 91.17%.

Files Patch % Lines
fiasco/io/sources/ion_sources.py 81.81% 2 Missing ⚠️
fiasco/util/util.py 88.88% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #240      +/-   ##
==========================================
- Coverage   91.95%   91.17%   -0.78%     
==========================================
  Files          23       23              
  Lines        2014     2040      +26     
==========================================
+ Hits         1852     1860       +8     
- Misses        162      180      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wtbarnes
Copy link
Owner

Thanks Jeff! This looks good to me. Most of the test failures are not related to this PR and are related to another bug that I can fix separately.

Thanks also for adding a test. That's definitely the right way to do that. The only issue is that the database we currently test against by default (v8) does not have these (.auto) files so the test fails because it cannot find the file. I guess we need some way to conditionally test files based on version or more gracefully handle when files are missing. This is also related to #113 as we really should be checking against multiple versions of the database all of the time.

@jwreep
Copy link
Collaborator Author

jwreep commented Dec 13, 2023

Yup, is there any functionality that allows a version check?

A simple check along these lines:

if chianti_version >= 9:
   include .auto files in tests

@wtbarnes
Copy link
Owner

wtbarnes commented Jan 9, 2024

Yup, is there any functionality that allows a version check?

Sorry this took me so long to get back to. This ended up being easier than I initially thought in pytest but was still slightly tricky. There's now a custom pytest "mark" that can be added to each test to add conditionals to skip tests based on the database version. My reasoning for implementing this complexity now is I'm sure we're going to need this for lots of tests in the future as fiasco supports more and more versions of CHIANTI.

The CI also now includes tests for versions 9 and 10 of the database.

@wtbarnes
Copy link
Owner

wtbarnes commented Jan 9, 2024

So I don't forget: I'd like to add a docstring to the AutoParser class that includes a brief description of the filetype and what the data are. I'm happy to take care of this if you don't have time at the moment!

@jwreep
Copy link
Collaborator Author

jwreep commented Jan 9, 2024

Thanks for the help, Will.

I've added a description copied from the CHIANTI docs directly, along with a link with their description of the variables. Hopefully that's sufficient?

@wtbarnes
Copy link
Owner

wtbarnes commented Jan 9, 2024

Thanks! Yep, that's great. I just made a quick fix to the reference and included in the bib file for the whole repo to keep the citation style consistent. Once all the tests pass, this is ready to go. Thanks again!

@wtbarnes wtbarnes merged commit 0bec292 into wtbarnes:main Jan 9, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support reading autoionization files
4 participants