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

Error in retrieving data from NIST #7

Open
EvgAnikin opened this issue Oct 13, 2023 · 0 comments
Open

Error in retrieving data from NIST #7

EvgAnikin opened this issue Oct 13, 2023 · 0 comments

Comments

@EvgAnikin
Copy link

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.

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

No branches or pull requests

1 participant