scipp / ess

European Spallation Source facility bespoke, neutron scattering tools based on scipp.
https://scipp.github.io/ess/
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

Verify check to drop variances when subtracting background from monitors is OK #174

Closed nvaytet closed 1 year ago

nvaytet commented 1 year ago

In the SANS workflow, we remove background noise from the monitors in the function sans/i_of_q/preprocess_monitor_data. The background noise is approximately computed as the mean of the low counts in the monitor signal, and its value thus usually has a variance. The background subtraction is then simply done a subtracting this scalar value from the counts in all monitor bins.

This is a broadcast operation that introduces correlations and is forbidden by Scipp. In #170 we removed the variances on the background value to allow the operation to proceed. Before doing so, we check that the background value is smaller than 0.1 * the total number of counts.

This was inspired by the derivations in Heybrock et al. (2023), but is not strictly derived in the paper. We would need to compute the covariance for the background term. The background is a sum over some of the signal range, and the calculation is not immediately trivial.