Skip to content
Snippets Groups Projects
Commit a9c09da4 authored by Zhou, Wenduo's avatar Zhou, Wenduo
Browse files

Merge pull request #13116 from mantidproject/nomad_fixes

Changes to fix the issue with NOMAD are reasonable via coding review.  Tests for the new feature were passed.  Issue is thus closed. 
parents 97319171 638a0989
No related branches found
No related tags found
No related merge requests found
......@@ -29,8 +29,10 @@ class SNSPowderReduction(DataProcessorAlgorithm):
_LRef = None
_DIFCref = None
_wavelengthMin = None
_wavelengthMax = None
_vanPeakFWHM = None
_vanSmoothing = None
_vanRadius = None
_scaleFactor = None
_outDir = None
_outPrefix = None
......@@ -92,6 +94,8 @@ class SNSPowderReduction(DataProcessorAlgorithm):
"Reference DIFC for resolution removal. Zero skips the correction")
self.declareProperty("CropWavelengthMin", 0.,
"Crop the data at this minimum wavelength. Overrides LowResRef.")
self.declareProperty("CropWavelengthMax", 0.,
"Crop the data at this maximum wavelength. Forces use of CropWavelengthMin.")
self.declareProperty("RemovePromptPulseWidth", 0.0,
"Width of events (in microseconds) near the prompt pulse to remove. 0 disables")
self.declareProperty("MaxChunkSize", 0.0, "Specify maximum Gbytes of file to read in one chunk. Default is whole file.")
......@@ -111,6 +115,7 @@ class SNSPowderReduction(DataProcessorAlgorithm):
"How far from the ideal position a vanadium peak can be during StripVanadiumPeaks. "\
"Default=0.05, negative turns off")
self.declareProperty("VanadiumSmoothParams", "20,2", "Default=20,2")
self.declareProperty("VanadiumRadius", .3175, "Radius for MultipleScatteringCylinderAbsorption")
self.declareProperty("BackgroundSmoothParams", "", "Default=off, suggested 20,2")
self.declareProperty("FilterBadPulses", 95.,
doc="Filter out events measured while proton charge is more than 5% below average")
......@@ -171,8 +176,10 @@ class SNSPowderReduction(DataProcessorAlgorithm):
self._LRef = self.getProperty("UnwrapRef").value
self._DIFCref = self.getProperty("LowResRef").value
self._wavelengthMin = self.getProperty("CropWavelengthMin").value
self._wavelengthMax = self.getProperty("CropWavelengthMax").value
self._vanPeakFWHM = self.getProperty("VanadiumFWHM").value
self._vanSmoothing = self.getProperty("VanadiumSmoothParams").value
self._vanRadius = self.getProperty("VanadiumRadius").value
calib = self.getProperty("CalibrationFile").value
self._scaleFactor = self.getProperty("ScaleData").value
self._outDir = self.getProperty("OutputDirectory").value
......@@ -393,7 +400,8 @@ class SNSPowderReduction(DataProcessorAlgorithm):
# do the absorption correction
vanRun = api.ConvertUnits(InputWorkspace=vanRun, OutputWorkspace=vanRun, Target="TOF")
api.SetSampleMaterial(InputWorkspace=vanRun, ChemicalFormula="V", SampleNumberDensity=0.0721)
vanRun = api.MultipleScatteringCylinderAbsorption(InputWorkspace=vanRun, OutputWorkspace=vanRun)
vanRun = api.MultipleScatteringCylinderAbsorption(InputWorkspace=vanRun, OutputWorkspace=vanRun,
CylinderSampleRadius=self._vanRadius)
# focus the data
vanRun = api.AlignAndFocusPowder(InputWorkspace=vanRun, OutputWorkspace=vanRun, CalFileName=calib,
......@@ -404,7 +412,8 @@ class SNSPowderReduction(DataProcessorAlgorithm):
CompressTolerance=self.COMPRESS_TOL_TOF,
UnwrapRef=self._LRef, LowResRef=self._DIFCref,
LowResSpectrumOffset=self._lowResTOFoffset,
CropWavelengthMin=self._wavelengthMin, **(focuspos))
CropWavelengthMin=self._wavelengthMin,
CropWavelengthMax=self._wavelengthMax, **(focuspos))
# strip peaks
......@@ -705,7 +714,7 @@ class SNSPowderReduction(DataProcessorAlgorithm):
PreserveEvents=preserveEvents,\
RemovePromptPulseWidth=self._removePromptPulseWidth, CompressTolerance=self.COMPRESS_TOL_TOF,\
UnwrapRef=self._LRef, LowResRef=self._DIFCref, LowResSpectrumOffset=self._lowResTOFoffset,\
CropWavelengthMin=self._wavelengthMin, **(focuspos))
CropWavelengthMin=self._wavelengthMin, CropWavelengthMax=self._wavelengthMax, **(focuspos))
for iws in xrange(temp.getNumberHistograms()):
spec = temp.getSpectrum(iws)
self.log().debug("[DBx131] ws %d: spectrum ID = %d. " % (iws, spec.getSpectrumNo()))
......
......@@ -131,6 +131,7 @@ private:
double LRef;
double DIFCref;
double minwl;
double maxwl;
double tmin;
double tmax;
bool m_preserveEvents;
......
......@@ -37,7 +37,7 @@ DECLARE_ALGORITHM(AlignAndFocusPowder)
AlignAndFocusPowder::AlignAndFocusPowder()
: API::DataProcessorAlgorithm(), m_l1(0.0), m_resampleX(0), dspace(false), xmin(0.0),
xmax(0.0), LRef(0.0), DIFCref(0.0), minwl(0.0), tmin(0.0), tmax(0.0),
xmax(0.0), LRef(0.0), DIFCref(0.0), minwl(0.0), maxwl(0.), tmin(0.0), tmax(0.0),
m_preserveEvents(false), m_processLowResTOF(false), m_lowResSpecOffset(0),
m_progress(NULL) {}
......@@ -145,6 +145,9 @@ void AlignAndFocusPowder::init() {
declareProperty(
"CropWavelengthMin", 0.,
"Crop the data at this minimum wavelength. Overrides LowResRef.");
declareProperty(
"CropWavelengthMax", EMPTY_DBL(),
"Crop the data at this maximum wavelength. Forces use of CropWavelengthMin.");
declareProperty("PrimaryFlightPath", -1.0,
"If positive, focus positions are changed. (Default -1) ");
declareProperty(new ArrayProperty<int32_t>("SpectrumIDs"),
......@@ -252,6 +255,8 @@ void AlignAndFocusPowder::exec() {
LRef = getProperty("UnwrapRef");
DIFCref = getProperty("LowResRef");
minwl = getProperty("CropWavelengthMin");
maxwl = getProperty("CropWavelengthMax");
if (maxwl == 0.) maxwl = EMPTY_DBL(); // python can only specify 0 for unused
tmin = getProperty("TMin");
tmax = getProperty("TMax");
m_preserveEvents = getProperty("PreserveEvents");
......@@ -463,7 +468,7 @@ void AlignAndFocusPowder::exec() {
}
m_progress->report();
if (LRef > 0. || minwl > 0. || DIFCref > 0.) {
if (LRef > 0. || minwl > 0. || DIFCref > 0. || (!isEmpty(maxwl))) {
m_outputW = convertUnits(m_outputW, "TOF");
}
m_progress->report();
......@@ -485,9 +490,15 @@ void AlignAndFocusPowder::exec() {
}
m_progress->report();
if (minwl > 0.) {
g_log.information() << "running RemoveLowResTOF(MinWavelength=" << minwl
<< ",Tmin=" << tmin << ". ";
if (minwl > 0. || (!isEmpty(maxwl))) { // just crop the worksapce
// turn off the low res stuff
m_processLowResTOF = false;
g_log.information() << "running CropWorkspace(MinWavelength=" << minwl;
if (!isEmpty(maxwl))
g_log.information() << ", MaxWavelength=" << maxwl;
g_log.information() << ")\n";
EventWorkspace_sptr ews =
boost::dynamic_pointer_cast<EventWorkspace>(m_outputW);
if (ews)
......@@ -495,19 +506,15 @@ void AlignAndFocusPowder::exec() {
<< ". ";
g_log.information("\n");
API::IAlgorithm_sptr removeAlg = createChildAlgorithm("RemoveLowResTOF");
m_outputW = convertUnits(m_outputW, "Wavelength");
API::IAlgorithm_sptr removeAlg = createChildAlgorithm("CropWorkspace");
removeAlg->setProperty("InputWorkspace", m_outputW);
removeAlg->setProperty("OutputWorkspace", m_outputW);
removeAlg->setProperty("MinWavelength", minwl);
if (tmin > 0.)
removeAlg->setProperty("Tmin", tmin);
if (m_processLowResTOF)
removeAlg->setProperty("LowResTOFWorkspace", m_lowResW);
removeAlg->setProperty("XMin", minwl);
removeAlg->setProperty("XMax", maxwl);
removeAlg->executeAsChildAlg();
m_outputW = removeAlg->getProperty("OutputWorkspace");
if (m_processLowResTOF)
m_lowResW = removeAlg->getProperty("LowResTOFWorkspace");
} else if (DIFCref > 0.) {
g_log.information() << "running RemoveLowResTof(RefDIFC=" << DIFCref
<< ",K=3.22)\n";
......@@ -552,7 +559,7 @@ void AlignAndFocusPowder::exec() {
m_progress->report();
// Convert units
if (LRef > 0. || minwl > 0. || DIFCref > 0.) {
if (LRef > 0. || minwl > 0. || DIFCref > 0. || (!isEmpty(maxwl))) {
m_outputW = convertUnits(m_outputW, "dSpacing");
if (m_processLowResTOF)
m_lowResW = convertUnits(m_lowResW, "dSpacing");
......
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