-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
The error
I installed atomphys and failed to run the example from README.md:
>>> from atomphys import Atom
>>> Rb = Atom('Rb')
This code resulted in an error:
Traceback (most recent call last):
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 40, in __init__
self.load(atom)
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 92, in load
with open(filename) as file:
FileNotFoundError: [Errno 2] No such file or directory: 'Rb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 4, in <module>
Rb = Atom('Rb', refresh_cache=True)
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 42, in __init__
self.load_nist(atom, refresh_cache)
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/atom.py", line 114, in load_nist
self._load_states(nist.parse_states(nist.fetch_states(atom, refresh_cache)))
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/data/nist.py", line 55, in parse_states
return [
File "/home/evgeny/work/other_studies/programming_notes/atomic_physics_mgrau/src/atomphys/atomphys/data/nist.py", line 70, in <listcomp>
if print_term(state["Term"], J=state["J"])
KeyError: 'Term'
The solution
In nist.py, change the options in values dictionary (line 27) to the following:
values = {
"spectrum": atom,
"units": 2, # energy units {0: cm^-1, 1: eV, 2: Ry}
"format": 3, # format {0: HTML, 1: ASCII, 2: CSV, 3: TSV}
"multiplet_ordered": 1, # energy ordred
"term_out": "on", # output the term symbol string
"conf_out": "on", # output the configutation string
"level_out": "on", # output the energy level
"unc_out": 1, # uncertainty on energy # --- changed 0 to 1
"j_out": "on", # output the J level
"g_out": "on", # output the g-factor
"lande_out": "on", # output experimentally measured g-factor # changed from "off" to "on"
}
Comment
I discovered that the error is caused by incorrect data retrieval from NIST. In fetch_states in nist.py, the URL request constructed from the values dictionary is not correctly processed by https://physics.nist.gov. Instead of a .tsv with the energy levels, https://physics.nist.gov returns the error page "Invalid Column Setting". The example URL request generated by current code version and causing error:
https://physics.nist.gov/cgi-bin/ASD/energy1.pl?spectrum=rb+i&units=2&format=3&multiplet_ordered=1&term_out=on&conf_out=on&level_out=on&unc_out=0&j_out=on&g_out=on&lande_out=off
Changing the options to lande_out=on and unc_out=1 yields the correct result.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels