lbl-anp / becquerel

Becquerel is a Python package for analyzing nuclear spectroscopic measurements.
Other
43 stars 16 forks source link

Fitter method to compute component-wise areas and their uncertainties #303

Closed jvavrek closed 2 years ago

jvavrek commented 2 years ago

image

>>> fitter.calc_area_and_unc()
2002647.92714046+/-1415.3747870339978

>>> (fitter.y.sum(), np.sqrt(fitter.y.sum()))
(2002646, 1415.1487554317391)

>>> fitter.model.components
[<lmfit.Model: Model(gauss, prefix='gauss0_')>,
 <lmfit.Model: Model(gauss, prefix='gauss1_')>,
 <lmfit.Model: Model(line, prefix='line_')>]

>>> areas = {comp.name: fitter.calc_area_and_unc(component=comp) for comp in fitter.model.components}
{"Model(gauss, prefix='gauss0_')": 99936.80253652389+/-656.5995003915539,
 "Model(gauss, prefix='gauss1_')": 99861.92313776605+/-645.2239560410361,
 "Model(line, prefix='line_')": 1802849.20146617+/-1535.034662198673}

>>> sum([a.n for a in areas.values()])
2002647.92714046
jvavrek commented 2 years ago

Please add test(s) of the new method.

Yeah, you got me there.

jvavrek commented 2 years ago

@markbandstra I've added tests of the new method. Something strange is going on with either black or pytest-black in the CI, but tests pass locally.

jccurtis commented 2 years ago

@markbandstra I've added tests of the new method. Something strange is going on with either black or pytest-black in the CI, but tests pass locally.

@jvavrek that is really weird. I triggered the jobs again. This appears to be something in pytest-black which was fixed in: https://github.com/shopkeep/pytest-black/issues/42

jccurtis commented 2 years ago

@jvavrek can you try pytest-black>=0.3.10

jccurtis commented 2 years ago

@jvavrek also try pytest<7.0.0

jvavrek commented 2 years ago

@jvavrek can you try pytest-black>=0.3.10

ERROR: Could not find a version that satisfies the requirement pytest-black>=0.3.10 (from versions: 0.1.4, 0.1.5, 0.1.6, 0.1.7, 0.1.9, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.3.9, 0.3.10, 0.3.11, 0.3.12)

???

jvavrek commented 2 years ago

@jvavrek also try pytest<7.0.0

This worked 🚀

Why was the CI installing 7.x when conda and pypi both only have 6.2.5?

Bizarrely, it looks like it was not installing 7.x: https://github.com/lbl-anp/becquerel/runs/4723159061?check_suite_focus=true#step:5:196

jccurtis commented 2 years ago

@jvavrek also try pytest<7.0.0

This worked 🚀

Why was the CI installing 7.x when conda and pypi both only have 6.2.5?

Bizarrely, it looks like it was not installing 7.x: https://github.com/lbl-anp/becquerel/runs/4723159061?check_suite_focus=true#step:5:196

Well I'll be scratching my head on that one ... thanks for posting #307 ... I'm sure this will be resolved by the plugin developers eventually