@rsibille-psi , true, there is an error in the code (a missing divider), however, thinking a bit more about how the calculation of average in this case should be done properly, it might not be as trivial. Probably, there is a simple way to calculate statistics for neutron counts I'm just not aware of.
After the fix of that issue we would use an average for the number of counts (counts1 + counts2 + ...) / N and sqrt(sigma1^2 + sigma2^2 + ...) / N for the error of that average (currently, dividing by N is missing for sigma). However, for the situation with different sigma values for the same measurement, the direct averaging might not be the most right approach, see for example https://physics.stackexchange.com/a/452809
thanks!
In our case, we assume (and it's correct unless there is a problem with the instrument motors or temperature etc) that the error is purely statistical on counting, not related to uncertainties.
Therefore we should simply have
counts = (counts1 + counts2 + ...)/N
error = sqrt((counts1 + counts2 + ...)/N)
OK, but if I understood it correctly, this way will not lead to a statistic improvement. For example, assume we have 2 measurements at the same motor position, both with 100 counts. Each individual measurement will have an error = sqrt(100) = 10, at the same time, based on your formula, their average error = sqrt((100+100)/2) = 10. And this will be true for any number of averaged measurements. Does it make sense to implement it this way?
I just checked merging exactly the same scans with our old tool "fit", and the results are now exactly the same.
So I think this fix can also go on the main server.
Thank you!