You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into this problem at least twice now where calibrating a spectrum with 32-bit int/uint channel values and a high-degree polynomial term silently returns inaccurate calibrated values. Below is a MWE comparing bq.Calibration.__call__, a numpy solution, and a manual calculation. At least on my machine, no warnings are produced unless I add np.float16 to the dtypes loop, even with warnings.simplefilter("always").
@markbandstra suggested that perhaps the 1e-13 coefficient was getting rounded to 0 under 32-bit precision. However, running with 1e-6 instead shows that the behavior persists, and so the precision loss is not quite so straightforward:
Note also that a uint32 should be able to represent 4e9 perfectly well, so it's not simply rollover in the result. It must be more subtle precision loss in the intermediate calculations.
The main problem we should fix is that the failure occurs silently. We should either (a) warn on 32-bit inputs (though float32 might be OK or (b) upcast the input to float64 automatically (and warn if we do so).
I've run into this problem at least twice now where calibrating a spectrum with 32-bit int/uint channel values and a high-degree polynomial term silently returns inaccurate calibrated values. Below is a MWE comparing
bq.Calibration.__call__
, anumpy
solution, and a manual calculation. At least on my machine, no warnings are produced unless I addnp.float16
to thedtypes
loop, even withwarnings.simplefilter("always")
.Should we raise a
CalibrationWarning
if the input to__call__
is potentially too imprecise (np.uint32
,np.int32
, or lower)?The text was updated successfully, but these errors were encountered: