mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
210 stars 122 forks source link

Provide a post-fitting check in PDCalibration/FitPeaks for I/Sigma ratio. #35224

Closed RichardWaiteSTFC closed 3 weeks ago

RichardWaiteSTFC commented 1 year ago

Describe the solution you'd like Be able to provide minimum I/sigma in PDCalibration (and possibly FitPeaks) for inclusion of peak centres in fit to determine diffractometer constants.

Additional context Came up during discussion of PR #35094. @bolotovskyr has opened this issue as a story in the Engineering Workflow Management system: Story 356 [Enabler] Provide a post-fitting check in PDCalibration/FitPeaks for I/Sigma ratio

bolotovskyr commented 1 year ago

I think the implementation would involve the following tasks:

RichardWaiteSTFC commented 1 year ago

Thanks for the break-down!

The estimated error of the integrated intensity Sigma can be calculated by propagating the errors of all fitted parameters used in the I calculation. This would require calculating partial derivatives of the peak and background functions with respect to their parameters. Looking at the source code, PDCalibration may use the following peak functions: BackToBackExponential, Gaussian, Lorentzian, PseudoVoigt, IkedaCarpenterPV and the following background functions: Flat, Linear, Quadratic.

Due to the number of different functions I propose we get the error on the integrated intensity from a quadrature sum of the errors on the individual points over a region for which the peak function (i.e. fit curve - background) is some threshold e.g. 1% of the height as is done here (although not assuming raw counts - i.e. the error in each bin may not be e=sqrt(y) - for example if the data have been normalised).

https://docs.mantidproject.org/nightly/algorithms/IntegratePeaksProfileFitting-v1.html#integrating-the-model

Note that the situation is slightly complicated by the fact some fit function have the height as the fit parameter and other such as the BackToBackExpoential and IkedaCarpenter have the area (though for those functions I suppose we could get the error from the covariance matrix - but I think it's better to treat all peaks equally)

RichardWaiteSTFC commented 1 year ago

@mguthriem also suggested (https://github.com/mantidproject/mantid/pull/35094#issuecomment-1515280341) a check on width (larger than 1 bin width) - could also say width shouldn't be larger than the window to rule out the peak fitting broad background as well.

github-actions[bot] commented 3 weeks ago

Closed by #37826.