openmicroanalysis / pyxray

Definitions and properties of X-ray transitions
MIT License
6 stars 4 forks source link

Extract atomic weight from NIST/CIAAW #3

Closed ppinard closed 7 years ago

ppinard commented 8 years ago

Referring to issue #2, this issue is to populate the SQL database with atomic weight. Ideally, this should be done automatically from an available online resource.

The most official tabulation of atomic weight appears to come from the CIAAW. Unfortunately, their website does not directly provide an ASCII table of the values. NIST has an online database of atomic weight and isotopes which can be generated as an ASCII file (website, results). The information appears to come from the CIAAW/IUPAC.

The goal would therefore to write a parser to extract the atomic weight from the NIST output. I would proceed as follows:

  1. Use the Python library requests to download the NIST ASCII output
  2. Parse each isotope, storing their Atomic Number, Relative Atomic Mass and Isotopic Composition
  3. For each atomic number, multiply the relative atomic mass by the isotopic composition and sum over all isotopes.
  4. Add values to the SQL database using the ElementAtomicWeightProperty model (see populate_element_symbol_table(engine) in pyxray/sql/default.py as an example)
  5. Write some unit tests to compare the values with those appearing in the NIST periodic table

The code should go in a new function populate_element_atomic_weight_table_(engine) in pyxray/sql/default.py.

ppinard commented 8 years ago

I would modify the above procedure.

First, I think it is better to use the Standard Atomic Weight field to retrieve the atomic weight. Secondly, since the parser strategy has changed (see #4), a parser should be created for the NIST database in pyxray/parser/nist.py and should return ElementAtomicWeight objects.

ppinard commented 8 years ago

The commit f73c35ebdc2a46b9a736b6c982f0ec8f05cdd547 looks very good. I modified some small syntax issues in commit b2f214240b1dfb347a4b51fad5ea406c9fd8388c:

Finally, I activated caching in commit cf011617305b0193dbb2e5479d533f5e21cac43e and added a unit test in 51f70bd687895ebb6794b2d7024637f9253b38d2.

Unless @fingenerf sees other issues, I would close this issue.