lbl-anp / becquerel

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

Fix FWHM formula used by `PeakFilter` #254

Closed markbandstra closed 3 years ago

markbandstra commented 3 years ago

A user with a keen eye noticed that the PeakFilter class has been using an erroneous formula for the spectral energy resolution:

f(x) = np.sqrt(f0 ** 2 + (f1 ** 2 - f0 ** 2) * (x / x1) ** 2)

which interpolates between f(0) = f0 and f(x1) = f1, but it scales roughly as x, not the intended sqrt(x).

This formula has been changed to

f(x) = np.sqrt(f0 ** 2 + (f1 ** 2 - f0 ** 2) * (x / x1))

and the notebook has been brought up to date.

markbandstra commented 3 years ago

I should also note that this appears to be the only location where this bug crops up. This change may require users to adjust existing code that uses the autocal tools, although the PeakFilter kernels are pretty robust (which is why we never noticed that problem) so it is also possible that no changes will be needed.

jvavrek commented 3 years ago

Ah, autocal tests fail

markbandstra commented 3 years ago

Dangit, always run the tests. I'll look into it.