mantid
mantid copied to clipboard
Add option to ignore masked pixels in integration algorithms and improve skew background determination
Description of work
This work comprises 2 improvements to single-crystal integration methods:
- When determining background bins by minimising third moment (skew) in
IntegratePeaksSkew
- ensure loop terminates if skew < 0 (we expect minimum skew of background to be 0 - for low counts it should in fact be positive) - Add option to ignore peaks for which mask (or shoebox etc.) includes a masked detector - this affects
-
IntegratePeaksSkew
-
IntegratePeaksShoeboxTOF
-
IntegratePeaks1DProfile
-
Purpose of work
Change (1) stops peak mask of IntegratePEaksSkew
including too many pixels due to small diffuse scattering - see issue #37105
Change (2) allows the user to make a custom mask for edges (or dodgy tube etc.) - whereas NcolsEdge
and NRowsEdge
are assumed to be the same for all banks. To support this functionality the minimum value for NrowsEdge
and NColsEdge
has been decreased to 0 - i.e. it is now possible to only define edges using masked detectors on the workspace. Note this is how detector edges are denoted in other integration algorithms such as IntegratePeaksMD
.
Fixes #37105
To test:
(1) Run this script
ws = Load(Filename=r'C:\mantid-conda\mantid\build\ExternalData\Testing\Data\DocTest\SXD23767.raw', OutputWorkspace='SXD23767')
# peaks = FindSXPeaksConvolve(InputWorkspace='SXD23767', PeaksWorkspace='peaks_out', ThresholdIoverSigma=4, GetNBinsFromBackToBackParams=True, NFWHM=6, PeakFindingStrategy='VarianceOverMean', ThresholdVarianceOverMean=1.25)
peaks = CreatePeaksWorkspace(InstrumentWorkspace=ws, NumberOfPeaks=0, OutputWorkspace="peaks_out")
pk_pos = [(3169, 1851.59), (752, 2292.94), (1971, 3169.28), (3633, 4623.41), (6469, 1531.5)]
for detid, tof in pk_pos:
AddPeak(PeaksWorkspace=peaks, RunWorkspace=ws, TOF=tof, DetectorID=detid, EnableLogging=False)
skew_params = {'UseNearestPeak': True, 'IntegrateIfOnEdge': False,
'NRowsEdge': 1, 'NColsEdge': 1,
'LorentzCorrection': True,
'NVacanciesMax': 2, 'NPixPerVacancyMin': 2, 'NTOFBinsMin': 2,
'UpdatePeakPosition': False, 'OptimiseMask': True,
'GetTOFWindowFromBackToBackParams': False,
'ScaleThetaWidthByWavelength': True,
'BackScatteringTOFResolution': 0.035, 'ThetaWidth': 1.5,
'OptimiseXWindowSize':True, 'ThresholdIoverSigma': 20}
skew_params['OutputFile'] = rf"C:\Users\xhg73778\Desktop\{ws.name()}_peaks_skew_zero_skew.pdf"
peaks_int = IntegratePeaksSkew(InputWorkspace=ws, PeaksWorkspace=peaks, **skew_params)
(2) Open the pdf output and check the mask still covers the peaks (should look like the left hand column in the screenshots above)
Reviewer
Please comment on the points listed below (full description). Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
- Is the code of an acceptable quality?
- Does the code conform to the coding standards?
- Are the unit tests small and test the class in isolation?
- If there is GUI work does it follow the GUI standards?
- If there are changes in the release notes then do they describe the changes appropriately?
- Do the release notes conform to the release notes guide?
Functional Tests
- Do changes function as described? Add comments below that describe the tests performed?
- Do the changes handle unexpected situations, e.g. bad input?
- Has the relevant (user and developer) documentation been added/updated?
Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers
will take care of it.
Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.