Skip to content
Snippets Groups Projects
Unverified Commit 02a7e615 authored by WHITFIELDRE email's avatar WHITFIELDRE email Committed by GitHub
Browse files

Merge pull request #24102 from mantidproject/revert-24055-WAND²PowderReduction_rebin

Revert "Switch WANDPowderReduction to use Rebin"
parents c8f3440c 80e85091
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory, ...@@ -9,7 +9,7 @@ from mantid.api import (DataProcessorAlgorithm, AlgorithmFactory,
MatrixWorkspaceProperty, PropertyMode) MatrixWorkspaceProperty, PropertyMode)
from mantid.dataobjects import MaskWorkspaceProperty from mantid.dataobjects import MaskWorkspaceProperty
from mantid.simpleapi import (ConvertSpectrumAxis, Transpose, from mantid.simpleapi import (ConvertSpectrumAxis, Transpose,
Rebin, CopyInstrumentParameters, ResampleX, CopyInstrumentParameters,
Divide, DeleteWorkspace, Scale, Divide, DeleteWorkspace, Scale,
MaskAngle, ExtractMask, Minus, MaskAngle, ExtractMask, Minus,
ExtractUnmaskedSpectra, mtd, ExtractUnmaskedSpectra, mtd,
...@@ -63,7 +63,7 @@ class WANDPowderReduction(DataProcessorAlgorithm): ...@@ -63,7 +63,7 @@ class WANDPowderReduction(DataProcessorAlgorithm):
self.copyProperties('ConvertSpectrumAxis', ['Target', 'EFixed']) self.copyProperties('ConvertSpectrumAxis', ['Target', 'EFixed'])
self.copyProperties('Rebin', ['Params']) self.copyProperties('ResampleX', ['XMin', 'XMax', 'NumberBins', 'LogBinning'])
self.declareProperty('NormaliseBy', 'Monitor', StringListValidator(['None', 'Time', 'Monitor']), "Normalise to monitor or time. ") self.declareProperty('NormaliseBy', 'Monitor', StringListValidator(['None', 'Time', 'Monitor']), "Normalise to monitor or time. ")
...@@ -81,7 +81,9 @@ class WANDPowderReduction(DataProcessorAlgorithm): ...@@ -81,7 +81,9 @@ class WANDPowderReduction(DataProcessorAlgorithm):
mask = self.getProperty("MaskWorkspace").value mask = self.getProperty("MaskWorkspace").value
target = self.getProperty("Target").value target = self.getProperty("Target").value
eFixed = self.getProperty("EFixed").value eFixed = self.getProperty("EFixed").value
params = self.getProperty("Params").value xMin = self.getProperty("XMin").value
xMax = self.getProperty("XMax").value
numberBins = self.getProperty("NumberBins").value
normaliseBy = self.getProperty("NormaliseBy").value normaliseBy = self.getProperty("NormaliseBy").value
maskAngle = self.getProperty("MaskAngle").value maskAngle = self.getProperty("MaskAngle").value
outWS = self.getPropertyValue("OutputWorkspace") outWS = self.getPropertyValue("OutputWorkspace")
...@@ -107,14 +109,15 @@ class WANDPowderReduction(DataProcessorAlgorithm): ...@@ -107,14 +109,15 @@ class WANDPowderReduction(DataProcessorAlgorithm):
ExtractUnmaskedSpectra(InputWorkspace=data, MaskWorkspace='__mask_tmp', OutputWorkspace='__data_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) ConvertSpectrumAxis(InputWorkspace='__data_tmp', Target=target, EFixed=eFixed, OutputWorkspace=outWS, EnableLogging=False)
Transpose(InputWorkspace=outWS, OutputWorkspace=outWS, EnableLogging=False) Transpose(InputWorkspace=outWS, OutputWorkspace=outWS, EnableLogging=False)
Rebin(InputWorkspace=outWS, OutputWorkspace=outWS, Params=params, EnableLogging=False) ResampleX(InputWorkspace=outWS, OutputWorkspace=outWS, XMin=xMin, XMax=xMax, NumberBins=numberBins, EnableLogging=False)
if cal is not None: if cal is not None:
ExtractUnmaskedSpectra(InputWorkspace=cal, MaskWorkspace='__mask_tmp', OutputWorkspace='__cal_tmp', EnableLogging=False) ExtractUnmaskedSpectra(InputWorkspace=cal, MaskWorkspace='__mask_tmp', OutputWorkspace='__cal_tmp', EnableLogging=False)
CopyInstrumentParameters(data, '__cal_tmp', EnableLogging=False) CopyInstrumentParameters(data, '__cal_tmp', EnableLogging=False)
ConvertSpectrumAxis(InputWorkspace='__cal_tmp', Target=target, EFixed=eFixed, OutputWorkspace='__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) Transpose(InputWorkspace='__cal_tmp', OutputWorkspace='__cal_tmp', EnableLogging=False)
Rebin(InputWorkspace='__cal_tmp', OutputWorkspace='__cal_tmp', Params=params, EnableLogging=False) ResampleX(InputWorkspace='__cal_tmp', OutputWorkspace='__cal_tmp', XMin=xMin, XMax=xMax, NumberBins=numberBins,
EnableLogging=False)
Divide(LHSWorkspace=outWS, RHSWorkspace='__cal_tmp', OutputWorkspace=outWS, EnableLogging=False) Divide(LHSWorkspace=outWS, RHSWorkspace='__cal_tmp', OutputWorkspace=outWS, EnableLogging=False)
if normaliseBy == "Monitor": if normaliseBy == "Monitor":
cal_scale = cal.run().getProtonCharge() cal_scale = cal.run().getProtonCharge()
...@@ -128,7 +131,8 @@ class WANDPowderReduction(DataProcessorAlgorithm): ...@@ -128,7 +131,8 @@ class WANDPowderReduction(DataProcessorAlgorithm):
CopyInstrumentParameters(data, '__bkg_tmp', EnableLogging=False) CopyInstrumentParameters(data, '__bkg_tmp', EnableLogging=False)
ConvertSpectrumAxis(InputWorkspace='__bkg_tmp', Target=target, EFixed=eFixed, OutputWorkspace='__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) Transpose(InputWorkspace='__bkg_tmp', OutputWorkspace='__bkg_tmp', EnableLogging=False)
Rebin(InputWorkspace='__bkg_tmp', OutputWorkspace='__bkg_tmp', Params=params, EnableLogging=False) ResampleX(InputWorkspace='__bkg_tmp', OutputWorkspace='__bkg_tmp', XMin=xMin, XMax=xMax, NumberBins=numberBins,
EnableLogging=False)
if cal is not None: if cal is not None:
Divide(LHSWorkspace='__bkg_tmp', RHSWorkspace='__cal_tmp', OutputWorkspace='__bkg_tmp', EnableLogging=False) Divide(LHSWorkspace='__bkg_tmp', RHSWorkspace='__cal_tmp', OutputWorkspace='__bkg_tmp', EnableLogging=False)
if normaliseBy == "Monitor": if normaliseBy == "Monitor":
......
...@@ -56,22 +56,24 @@ class WANDPowderReductionTest(unittest.TestCase): ...@@ -56,22 +56,24 @@ class WANDPowderReductionTest(unittest.TestCase):
# data normalised by monitor # data normalised by monitor
pd_out=WANDPowderReduction(InputWorkspace=data, pd_out=WANDPowderReduction(InputWorkspace=data,
Target='Theta', Target='Theta',
Params=0.04) NumberBins=1000)
x = pd_out.extractX() x = pd_out.extractX()
y = pd_out.extractY() y = pd_out.extractY()
self.assertAlmostEqual(x.min(), 8.06946698) self.assertAlmostEqual(x.min(), 8.07086781)
self.assertAlmostEqual(x.max(), 50.83030150) self.assertAlmostEqual(x.max(), 50.82973519)
self.assertAlmostEqual(y.min(), 0.00306758) self.assertAlmostEqual(y.min(), 0.00328244)
self.assertAlmostEqual(y.max(), 4.37085727) self.assertAlmostEqual(y.max(), 4.88908824)
self.assertAlmostEqual(x[0,y.argmax()], 45.10946698) self.assertAlmostEqual(x[0,y.argmax()], 45.094311535)
# data and calibration, limited range # data and calibration, limited range
pd_out2=WANDPowderReduction(InputWorkspace=data, pd_out2=WANDPowderReduction(InputWorkspace=data,
CalibrationWorkspace=cal, CalibrationWorkspace=cal,
Target='Theta', Target='Theta',
Params='10,0.015,40') NumberBins=2000,
XMin=10,
XMax=40)
x = pd_out2.extractX() x = pd_out2.extractX()
y = pd_out2.extractY() y = pd_out2.extractY()
...@@ -87,17 +89,17 @@ class WANDPowderReductionTest(unittest.TestCase): ...@@ -87,17 +89,17 @@ class WANDPowderReductionTest(unittest.TestCase):
CalibrationWorkspace=cal, CalibrationWorkspace=cal,
BackgroundWorkspace=bkg, BackgroundWorkspace=bkg,
Target='Theta', Target='Theta',
Params=0.04, NumberBins=1000,
NormaliseBy='Time') NormaliseBy='Time')
x = pd_out3.extractX() x = pd_out3.extractX()
y = pd_out3.extractY() y = pd_out3.extractY()
self.assertAlmostEqual(x.min(), 8.06946698) self.assertAlmostEqual(x.min(), 8.07086781)
self.assertAlmostEqual(x.max(), 50.83030150) self.assertAlmostEqual(x.max(), 50.82973519)
self.assertAlmostEqual(y.min(), 0) self.assertAlmostEqual(y.min(), 0)
self.assertAlmostEqual(y.max(), 19.97454882) self.assertAlmostEqual(y.max(), 19.97968357)
self.assertAlmostEqual(x[0,y.argmax()], 44.98946698) self.assertAlmostEqual(x[0,y.argmax()], 45.008708196)
# data, cal and background. To d spacing # data, cal and background. To d spacing
pd_out4=WANDPowderReduction(InputWorkspace=data, pd_out4=WANDPowderReduction(InputWorkspace=data,
...@@ -105,16 +107,16 @@ class WANDPowderReductionTest(unittest.TestCase): ...@@ -105,16 +107,16 @@ class WANDPowderReductionTest(unittest.TestCase):
BackgroundWorkspace=bkg, BackgroundWorkspace=bkg,
Target='ElasticDSpacing', Target='ElasticDSpacing',
EFixed=30, EFixed=30,
Params=0.002) NumberBins=1000)
x = pd_out4.extractX() x = pd_out4.extractX()
y = pd_out4.extractY() y = pd_out4.extractY()
self.assertAlmostEqual(x.min(), 1.92408134) self.assertAlmostEqual(x.min(), 1.92800159)
self.assertAlmostEqual(x.max(), 11.76333605) self.assertAlmostEqual(x.max(), 11.7586705)
self.assertAlmostEqual(y.min(), 0) self.assertAlmostEqual(y.min(), 0)
self.assertAlmostEqual(y.max(), 19.96633911) self.assertAlmostEqual(y.max(), 19.03642005)
self.assertAlmostEqual(x[0,y.argmax()], 2.15808134) self.assertAlmostEqual(x[0,y.argmax()], 2.1543333)
# data, cal and background with mask angle, to Q. # data, cal and background with mask angle, to Q.
pd_out4=WANDPowderReduction(InputWorkspace=data, pd_out4=WANDPowderReduction(InputWorkspace=data,
...@@ -122,17 +124,17 @@ class WANDPowderReductionTest(unittest.TestCase): ...@@ -122,17 +124,17 @@ class WANDPowderReductionTest(unittest.TestCase):
BackgroundWorkspace=bkg, BackgroundWorkspace=bkg,
Target='ElasticQ', Target='ElasticQ',
EFixed=30, EFixed=30,
Params=0.0035, NumberBins=2000,
MaskAngle=60) MaskAngle=60)
x = pd_out4.extractX() x = pd_out4.extractX()
y = pd_out4.extractY() y = pd_out4.extractY()
self.assertAlmostEqual(x.min(), 0.53587138, places=4) self.assertAlmostEqual(x.min(), 0.53479223, places=4)
self.assertAlmostEqual(x.max(), 3.21632108, places=4) self.assertAlmostEqual(x.max(), 3.21684994, places=4)
self.assertAlmostEqual(y.min(), 0, places=4) self.assertAlmostEqual(y.min(), 0, places=4)
self.assertAlmostEqual(y.max(), 19.9705871, places=4) self.assertAlmostEqual(y.max(), 19.9948756, places=4)
self.assertAlmostEqual(x[0,y.argmax()], 2.91237138, places=4) self.assertAlmostEqual(x[0,y.argmax()], 2.9122841, places=4)
# data, cal and background, scale background # data, cal and background, scale background
pd_out4=WANDPowderReduction(InputWorkspace=data, pd_out4=WANDPowderReduction(InputWorkspace=data,
...@@ -140,17 +142,17 @@ class WANDPowderReductionTest(unittest.TestCase): ...@@ -140,17 +142,17 @@ class WANDPowderReductionTest(unittest.TestCase):
BackgroundWorkspace=bkg, BackgroundWorkspace=bkg,
BackgroundScale=0.5, BackgroundScale=0.5,
Target='Theta', Target='Theta',
Params=0.04, NumberBins=1000,
NormaliseBy='Time') NormaliseBy='Time')
x = pd_out4.extractX() x = pd_out4.extractX()
y = pd_out4.extractY() y = pd_out4.extractY()
self.assertAlmostEqual(x.min(), 8.06946698) self.assertAlmostEqual(x.min(), 8.07086781)
self.assertAlmostEqual(x.max(), 50.83030150) self.assertAlmostEqual(x.max(), 50.82973519)
self.assertAlmostEqual(y.min(), 0.75) self.assertAlmostEqual(y.min(), 0.75)
self.assertAlmostEqual(y.max(), 20.72454882) self.assertAlmostEqual(y.max(), 20.72968357)
self.assertAlmostEqual(x[0,y.argmax()], 44.98946698) self.assertAlmostEqual(x[0,y.argmax()], 45.008708196)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -24,8 +24,6 @@ algorithm will work on data loaded with :ref:`LoadEventNexus ...@@ -24,8 +24,6 @@ algorithm will work on data loaded with :ref:`LoadEventNexus
<algm-FilterEvents>` but you will need to specify `EFixed` if <algm-FilterEvents>` but you will need to specify `EFixed` if
converting to anything except `Theta`. converting to anything except `Theta`.
:ref:`Rebin <algm-Rebin>` is used to bin the data so see it's
documentation for use of the `Params` parameter.
MaskAngle MaskAngle
######### #########
...@@ -51,7 +49,7 @@ Usage ...@@ -51,7 +49,7 @@ Usage
WANDPowderReduction(InputWorkspace=silicon, WANDPowderReduction(InputWorkspace=silicon,
CalibrationWorkspace=vanadium, CalibrationWorkspace=vanadium,
Target='Theta', Target='Theta',
Params=0.1, NumberBins=1000,
OutputWorkspace='silicon_powder') OutputWorkspace='silicon_powder')
.. figure:: /images/WANDPowderReduction_silicon_powder.png .. figure:: /images/WANDPowderReduction_silicon_powder.png
...@@ -66,7 +64,9 @@ Usage ...@@ -66,7 +64,9 @@ Usage
WANDPowderReduction(InputWorkspace=silicon, WANDPowderReduction(InputWorkspace=silicon,
CalibrationWorkspace=vanadium, CalibrationWorkspace=vanadium,
Target='ElasticQ', Target='ElasticQ',
Params='4.5,0.0035,6.25', XMin=4.5,
Xmax=6.25,
NumberBins=500,
OutputWorkspace='silicon_powder_q') OutputWorkspace='silicon_powder_q')
.. figure:: /images/WANDPowderReduction_silicon_powder_q.png .. figure:: /images/WANDPowderReduction_silicon_powder_q.png
...@@ -81,7 +81,7 @@ Usage ...@@ -81,7 +81,7 @@ Usage
WANDPowderReduction(InputWorkspace=silicon2, WANDPowderReduction(InputWorkspace=silicon2,
CalibrationWorkspace=vanadium, CalibrationWorkspace=vanadium,
Target='ElasticDSpacing', Target='ElasticDSpacing',
Params=0.002, NumberBins=1000,
OutputWorkspace='silicon_powder_d_spacing') OutputWorkspace='silicon_powder_d_spacing')
.. figure:: /images/WANDPowderReduction_silicon_powder_d.png .. figure:: /images/WANDPowderReduction_silicon_powder_d.png
...@@ -103,7 +103,7 @@ Usage ...@@ -103,7 +103,7 @@ Usage
CalibrationWorkspace=vanadium, CalibrationWorkspace=vanadium,
BackgroundWorkspace=bkg, BackgroundWorkspace=bkg,
Target='Theta', Target='Theta',
Params=0.1, NumberBins=1000,
OutputWorkspace='silicon_powder_background') OutputWorkspace='silicon_powder_background')
# Scale background by 50% # Scale background by 50%
...@@ -112,7 +112,7 @@ Usage ...@@ -112,7 +112,7 @@ Usage
BackgroundWorkspace=bkg, BackgroundWorkspace=bkg,
BackgroundScale=0.5, BackgroundScale=0.5,
Target='Theta', Target='Theta',
Params=0.1, NumberBins=1000,
OutputWorkspace='silicon_powder_background_0.5') OutputWorkspace='silicon_powder_background_0.5')
.. figure:: /images/WANDPowderReduction_silicon_powder_bkg.png .. figure:: /images/WANDPowderReduction_silicon_powder_bkg.png
......
...@@ -22,7 +22,6 @@ Improvements ...@@ -22,7 +22,6 @@ Improvements
- :ref:`AlignAndFocusPowder <algm-AlignAndFocusPowder>` and :ref:`AlignAndFocusPowderFromFiles <algm-AlignAndFocusPowderFromFiles>` now support outputting the unfocussed data and weighted events (with time). This allows for event filtering **after** processing the data. - :ref:`AlignAndFocusPowder <algm-AlignAndFocusPowder>` and :ref:`AlignAndFocusPowderFromFiles <algm-AlignAndFocusPowderFromFiles>` now support outputting the unfocussed data and weighted events (with time). This allows for event filtering **after** processing the data.
- :ref:`LoadWAND <algm-LoadWAND>` has grouping option added and loads faster - :ref:`LoadWAND <algm-LoadWAND>` has grouping option added and loads faster
- Mask workspace option added to :ref:`WANDPowderReduction <algm-WANDPowderReduction>` - Mask workspace option added to :ref:`WANDPowderReduction <algm-WANDPowderReduction>`
- :ref:`WANDPowderReduction <algm-WANDPowderReduction>` has been change from using ResampleX to Rebin so that bin size can be specified instead of number of bins as requested by the instrument scientist.
- :ref:`Le Bail concept page <Le Bail Fit>` moved from mediawiki - :ref:`Le Bail concept page <Le Bail Fit>` moved from mediawiki
- Rework of :ref:`powder diffraction calibration <Powder Diffraction Calibration>` documentation - Rework of :ref:`powder diffraction calibration <Powder Diffraction Calibration>` documentation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment