openmicroanalysis / pyxray

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

Get Lithium or light elements transitions #19

Closed drix00 closed 4 years ago

drix00 commented 4 years ago

This pull request allow to get transitions for light elements when no probability are available in the database, but a relative weight is available using element_xray_transitions. See commit 3021322ac9ba2f1f29b213cc2617ff29d0d479e3.

The implementation is not great. I was not able to combine table_probability and table_relative_weight in one SQL operation, the SQL query did not work. So the implementation duplicates the SQL query for table_probability, but using table_relative_weight if the number of transitions found with table_probability is zero.

The print_element_xray_transitions is also modified to output the relative weight of each transition.

A test was added to test the new functionality of element_xray_transitions and tests pass.

What I try and it did not work was to add a join for table_relative_weight and modify the clause table_probability.c['value'] > 0.0 to use a sqlalchemy.or_ on both. Various was tried and either the SQL gives an error or the number of transitions was too large (>1000).

Thanks, Hendrix

codecov[bot] commented 4 years ago

Codecov Report

Merging #19 into master will decrease coverage by 0.23%. The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #19      +/-   ##
==========================================
- Coverage   94.01%   93.78%   -0.24%     
==========================================
  Files          39       39              
  Lines        2908     2945      +37     
==========================================
+ Hits         2734     2762      +28     
- Misses        174      183       +9     
Impacted Files Coverage Δ
pyxray/base.py 66.96% <0.00%> (-2.49%) :arrow_down:
pyxray/sql/data.py 97.54% <100.00%> (+0.17%) :arrow_up:
tests/sql/test_data.py 96.29% <100.00%> (-3.71%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2d4f8f2...33c8694. Read the comment docs.

ppinard commented 4 years ago

I also had a try to create a single SQL query but I don't think it is possible without using SELECT DISTINCT or UNION, which are not really any better than searching for the probability first and then the relative weight.