diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py index 9135d0c48c1e9156d92b7639d149ce91b75e2a92..29999c98255ebc326366aafa53c414434462bcee 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py @@ -16,7 +16,7 @@ from mantid.kernel import (CompositeValidator, Direction, FloatArrayProperty, Fl RebinParamsValidator, StringListValidator) from mantid.simpleapi import (BinWidthAtX, ConvertSpectrumAxis, ConvertToDistribution, ConvertUnits, CorrectKiKf, DetectorEfficiencyCorUser, Divide, GenerateGroupingPowder, GroupDetectors, MaskDetectors, - Rebin, Scale, SofQWNormalisedPolygon, Transpose) + Rebin, Scale, SofQWNormalisedPolygon, Transpose, MaskNonOverlappingBins) import math import numpy import os @@ -538,6 +538,13 @@ class DirectILLReduction(DataProcessorAlgorithm): else: params = self.getProperty(common.PROP_REBINNING_PARAMS_W).value rebinnedWS = _rebin(mainWS, params, self._names, self._subalgLogging) + # For PSD based instruments we have to mask all the bins that were + # out of range from the original ragged workspace in delta E. + # The mask is later respected by the detector grouping + # to get the normalisation right also in the non-overlapping regions. + if mainWS.getInstrument().getName() in ['IN5', 'PANTHER']: + rebinnedWS = MaskNonOverlappingBins(InputWorkspace=rebinnedWS, ComparisonWorkspace=mainWS, RaggedInputs='Ragged', + OutputWorkspace=rebinnedWS.name(), MaskPartiallyOverlapping=True) self._cleanup.cleanup(mainWS) return rebinnedWS diff --git a/Testing/Data/SystemTest/ILL/IN5/176053.nxs.md5 b/Testing/Data/SystemTest/ILL/IN5/176053.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..bab6fc1589dd0f3100684a8c7627f9f4beff7051 --- /dev/null +++ b/Testing/Data/SystemTest/ILL/IN5/176053.nxs.md5 @@ -0,0 +1 @@ +40a6afb7c8ac8fc203671a980c3e0a79 diff --git a/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py b/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py index a28d6dada881742b8e11eb27bd6b746f70f80f6b..02fb92adb7d797303336c2f644d1823615d08c50 100644 --- a/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py +++ b/Testing/SystemTests/tests/analysis/ILLDirectGeometryReductionTest.py @@ -219,3 +219,50 @@ class IN5_Tube_Background(systemtesting.MantidSystemTest): 'OutputWorkspace':'Flat'} alg = create_algorithm('DirectILLTubeBackground', **args) assertRaisesNothing(self, alg.execute) + + +class IN5_Mask_Non_Overlapping_Bins(systemtesting.MantidSystemTest): + + def validate(self): + self.tolerance = 1e-7 + self.tolerance_is_rel_err = True + return ['red', 'ILL_IN5_Tweak_sqw.nxs'] + + @staticmethod + def ecrase(ws): + import numpy as np + y = ws.extractY() + y_prime = np.full_like(y, 0.1) + for i in range(ws.getNumberHistograms()): + ws.setY(i, y_prime[i]) + + def runTest(self): + + run = 'ILL/IN5/176053.nxs' + + DirectILLCollectData( + Run=run, + Normalisation='Normalisation Time', + OutputIncidentEnergyWorkspace='Ei', + OutputElasticChannelWorkspace='Elc', + OutputWorkspace='raw', + OutputEPPWorkspace='Epp' + ) + + ws = Load(run) + self.ecrase(ws) + + DirectILLCollectData( + InputWorkspace='ws', + Normalisation='Normalisation Time', + IncidentEnergyWorkspace='Ei', + ElasticChannelWorkspace='Elc', + OutputWorkspace='Eone' + ) + + DirectILLReduction( + InputWorkspace='Eone', + EnergyRebinning='a', + QBinningParams='', + OutputWorkspace='red' + ) diff --git a/Testing/SystemTests/tests/analysis/reference/ILL_IN5_Tweak_sqw.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/ILL_IN5_Tweak_sqw.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..361fbfec37ccea3ca9465c3741dec82d6d72a588 --- /dev/null +++ b/Testing/SystemTests/tests/analysis/reference/ILL_IN5_Tweak_sqw.nxs.md5 @@ -0,0 +1 @@ +1fff9714a67a8a667e6d84434695718c diff --git a/docs/source/release/v4.3.0/direct_geometry.rst b/docs/source/release/v4.3.0/direct_geometry.rst index 2250c429fca2c8f8c403172999cd002a925b9a11..5d222de726e664006ef876a223158fc3fe95d438 100644 --- a/docs/source/release/v4.3.0/direct_geometry.rst +++ b/docs/source/release/v4.3.0/direct_geometry.rst @@ -11,4 +11,6 @@ Direct Geometry Changes * New ``NOW4`` instrument definition for SNS +- For Panther and IN5 the :ref:`DirectILLReduction <algm-DirectILLReduction-v1>` will now correctly mask the non-overlapping bins before grouping the pixels onto Debye-Scherrer rings. + :ref:`Release 4.3.0 <v4.3.0>`