Newer
Older
Michael Whitty
committed
from msg_reducer import MSGReducer
import inelastic_indirect_reduction_steps as steps
Michael Whitty
committed
Michael Whitty
committed
class MSGDiffractionReducer(MSGReducer):
"""Reducer for Diffraction on IRIS and TOSCA.
"""
Michael Whitty
committed
Michael Whitty
committed
def __init__(self):
super(MSGDiffractionReducer, self).__init__()
Michael Whitty
committed
def _setup_steps(self):
self.append_step(steps.IdentifyBadDetectors(
MultipleFrames=self._multiple_frames))
Michael Whitty
committed
self.append_step(steps.HandleMonitor(
MultipleFrames=self._multiple_frames))
self.append_step(steps.CorrectByMonitor(
MultipleFrames=self._multiple_frames, EMode="Elastic"))
Michael Whitty
committed
if self._multiple_frames:
if self._fold_multiple_frames:
self.append_step(steps.FoldData())
else:
return
step = mantid.AlgorithmManager.create("ConvertUnits")
Michael Whitty
committed
step.setPropertyValue("Target", "dSpacing")
step.setPropertyValue("EMode", "Elastic")
self.append_step(step)
Michael Whitty
committed
if self._rebin_string is not None:
step = mantid.AlgorithmManager.create("Rebin")
Michael Whitty
committed
step.setPropertyValue("Params", self._rebin_string)
self.append_step(step)
else:
self.append_step(steps.RebinToFirstSpectrum())
Michael Whitty
committed
step = steps.Grouping()
step.set_grouping_policy("All")
self.append_step(step)
Michael Whitty
committed
# The "SaveItem" step saves the files in the requested formats.
if (len(self._save_formats) > 0):
step = steps.SaveItem()
step.set_formats(self._save_formats)
self.append_step(step)
Michael Whitty
committed
step = steps.Naming()
self.append_step(step)
Michael Whitty
committed
def getStringProperty(workspace, property):
"""This function is used in the interface.
"""
inst = mantid.AnalysisDataService[workspace].getInstrument()
Michael Whitty
committed
try:
Michael Whitty
committed
prop = inst.getStringParameter(property)[0]
except IndexError: return ""
return prop