diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py index 2cc9e8cbf5c7ad07415e90c0395cd056b45391df..d0a59e59c21cdeae92f0b9b19b32d70dd6be0b98 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/WANDPowderReduction.py @@ -1,11 +1,13 @@ from __future__ import absolute_import, division, print_function from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, MatrixWorkspaceProperty, PropertyMode) +from mantid.dataobjects import MaskWorkspaceProperty from mantid.simpleapi import (ConvertSpectrumAxis, Transpose, ResampleX, CopyInstrumentParameters, Divide, DeleteWorkspace, Scale, MaskAngle, ExtractMask, Minus, - RemoveMaskedSpectra, mtd) + ExtractUnmaskedSpectra, mtd, + BinaryOperateMasks) from mantid.kernel import StringListValidator, Direction, Property, FloatBoundedValidator @@ -48,6 +50,11 @@ class WANDPowderReduction(DataProcessorAlgorithm): validator=FloatBoundedValidator(0.0), doc="The background will be scaled by this number before being subtracted.") + self.declareProperty(MaskWorkspaceProperty("MaskWorkspace", '', + optional=PropertyMode.Optional, + direction=Direction.Input), + doc='The mask from this workspace will be applied before reduction') + self.copyProperties('ConvertSpectrumAxis', ['Target', 'EFixed']) self.copyProperties('ResampleX', ['XMin', 'XMax', 'NumberBins', 'LogBinning']) @@ -65,6 +72,7 @@ class WANDPowderReduction(DataProcessorAlgorithm): data = self.getProperty("InputWorkspace").value cal = self.getProperty("CalibrationWorkspace").value bkg = self.getProperty("BackgroundWorkspace").value + mask = self.getProperty("MaskWorkspace").value target = self.getProperty("Target").value eFixed = self.getProperty("EFixed").value xMin = self.getProperty("XMin").value @@ -88,13 +96,17 @@ class WANDPowderReduction(DataProcessorAlgorithm): if maskAngle != Property.EMPTY_DBL: MaskAngle(Workspace='__mask_tmp', MinAngle=maskAngle, Angle='Phi', EnableLogging=False) - RemoveMaskedSpectra(InputWorkspace=data, MaskedWorkspace='__mask_tmp', OutputWorkspace='__data_tmp', EnableLogging=False) + if mask is not None: + BinaryOperateMasks(InputWorkspace1='__mask_tmp', InputWorkspace2=mask, + OperationType='OR', OutputWorkspace='__mask_tmp', EnableLogging=False) + + ExtractUnmaskedSpectra(InputWorkspace=data, MaskWorkspace='__mask_tmp', OutputWorkspace='__data_tmp', EnableLogging=False) ConvertSpectrumAxis(InputWorkspace='__data_tmp', Target=target, EFixed=eFixed, OutputWorkspace=outWS, EnableLogging=False) Transpose(InputWorkspace=outWS, OutputWorkspace=outWS, EnableLogging=False) ResampleX(InputWorkspace=outWS, OutputWorkspace=outWS, XMin=xMin, XMax=xMax, NumberBins=numberBins, EnableLogging=False) if cal is not None: - RemoveMaskedSpectra(InputWorkspace=cal, MaskedWorkspace='__mask_tmp', OutputWorkspace='__cal_tmp', EnableLogging=False) + ExtractUnmaskedSpectra(InputWorkspace=cal, MaskWorkspace='__mask_tmp', OutputWorkspace='__cal_tmp', EnableLogging=False) CopyInstrumentParameters(data, '__cal_tmp', EnableLogging=False) ConvertSpectrumAxis(InputWorkspace='__cal_tmp', Target=target, EFixed=eFixed, OutputWorkspace='__cal_tmp', EnableLogging=False) Transpose(InputWorkspace='__cal_tmp', OutputWorkspace='__cal_tmp', EnableLogging=False) @@ -109,7 +121,7 @@ class WANDPowderReduction(DataProcessorAlgorithm): Scale(InputWorkspace=outWS, OutputWorkspace=outWS, Factor=cal_scale/data_scale, EnableLogging=False) if bkg is not None: - RemoveMaskedSpectra(InputWorkspace=bkg, MaskedWorkspace='__mask_tmp', OutputWorkspace='__bkg_tmp', EnableLogging=False) + ExtractUnmaskedSpectra(InputWorkspace=bkg, MaskWorkspace='__mask_tmp', OutputWorkspace='__bkg_tmp', EnableLogging=False) CopyInstrumentParameters(data, '__bkg_tmp', EnableLogging=False) ConvertSpectrumAxis(InputWorkspace='__bkg_tmp', Target=target, EFixed=eFixed, OutputWorkspace='__bkg_tmp', EnableLogging=False) Transpose(InputWorkspace='__bkg_tmp', OutputWorkspace='__bkg_tmp', EnableLogging=False) diff --git a/docs/source/release/v3.14.0/diffraction.rst b/docs/source/release/v3.14.0/diffraction.rst index 3e1bebd3e81151c493a06216ef8cad1b26babc30..70e29296f75199c704bbc47d7c72f6fabbbfc27f 100644 --- a/docs/source/release/v3.14.0/diffraction.rst +++ b/docs/source/release/v3.14.0/diffraction.rst @@ -13,6 +13,7 @@ Improvements ############ - :ref:`SNAPReduce <algm-SNAPReduce>` now has progress bar and all output workspaces have history +- Mask workspace option added to :ref:`WANDPowderReduction <algm-WANDPowderReduction>` :ref:`Release 3.14.0 <v3.14.0>`