You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
The error
I installed
atomphys
and failed to run the example fromREADME.md
:This code resulted in an error:
The solution
In
nist.py
, change the options invalues
dictionary (line 27) to the following:Comment
I discovered that the error is caused by incorrect data retrieval from NIST. In
fetch_states
innist.py
, the URL request constructed from thevalues
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:Changing the options to
lande_out=on
andunc_out=1
yields the correct result.The text was updated successfully, but these errors were encountered: