Unverified Commit 97aa2f6e authored by Peterson, Peter's avatar Peterson, Peter Committed by GitHub
Browse files

Merge pull request #28799 from mantidproject/28791_add_reference_with_lrautoreduction

`LRAutoReduction` can now use `LRReductionWithReference`
parents 11e1f6c6 f1055fb8
......@@ -84,6 +84,10 @@ class LRAutoReduction(PythonAlgorithm):
self.declareProperty(IntArrayProperty("SequenceInfo", [0, 0, 0], direction=Direction.Output),
"Run sequence information (run number, sequence ID, sequence number).")
self.declareProperty("SlitTolerance", 0.02, doc="Tolerance for matching slit positions")
self.declareProperty("NormalizationType", "DirectBeam",
doc="Normalization type for reduction. Allowed values: ['DirectBeam', 'WithReference']")
self.declareProperty("Refl1DModelParameters", "",
doc="JSON string for Refl1D theoretical model parameters for 'NormalizationType'=='WithReference' ")
def load_data(self):
"""
......@@ -650,34 +654,45 @@ class LRAutoReduction(PythonAlgorithm):
# Write template before we start the computation
self._write_template(data_set, run_number, first_run_of_set, sequence_number)
# Execute the reduction
LiquidsReflectometryReduction(#RunNumbers=[int(run_number)],
InputWorkspace=self.event_data,
NormalizationRunNumber=str(data_set.norm_file),
SignalPeakPixelRange=data_set.DataPeakPixels,
SubtractSignalBackground=data_set.DataBackgroundFlag,
SignalBackgroundPixelRange=data_set.DataBackgroundRoi[:2],
NormFlag=data_set.NormFlag,
NormPeakPixelRange=data_set.NormPeakPixels,
NormBackgroundPixelRange=data_set.NormBackgroundRoi,
SubtractNormBackground=data_set.NormBackgroundFlag,
LowResDataAxisPixelRangeFlag=data_set.data_x_range_flag,
LowResDataAxisPixelRange=data_set.data_x_range,
LowResNormAxisPixelRangeFlag=data_set.norm_x_range_flag,
LowResNormAxisPixelRange=data_set.norm_x_range,
TOFRange=data_set.DataTofRange,
IncidentMediumSelected=incident_medium,
GeometryCorrectionFlag=False,
QMin=data_set.q_min,
QStep=data_set.q_step,
AngleOffset=data_set.angle_offset,
AngleOffsetError=data_set.angle_offset_error,
ScalingFactorFile=str(data_set.scaling_factor_file),
SlitsWidthFlag=data_set.slits_width_flag,
ApplyPrimaryFraction=True,
SlitTolerance=slit_tolerance,
PrimaryFractionRange=[data_set.clocking_from, data_set.clocking_to],
OutputWorkspace='reflectivity_%s_%s_%s' % (first_run_of_set, sequence_number, run_number))
# input args for both reduction
kwargs = {
"InputWorkspace": self.event_data,
"NormalizationRunNumber": str(data_set.norm_file),
"SignalPeakPixelRange": data_set.DataPeakPixels,
"SubtractSignalBackground": data_set.DataBackgroundFlag,
"SignalBackgroundPixelRange": data_set.DataBackgroundRoi[:2],
"NormFlag": data_set.NormFlag,
"NormPeakPixelRange": data_set.NormPeakPixels,
"NormBackgroundPixelRange": data_set.NormBackgroundRoi,
"SubtractNormBackground": data_set.NormBackgroundFlag,
"LowResDataAxisPixelRangeFlag": data_set.data_x_range_flag,
"LowResDataAxisPixelRange": data_set.data_x_range,
"LowResNormAxisPixelRangeFlag": data_set.norm_x_range_flag,
"LowResNormAxisPixelRange": data_set.norm_x_range,
"TOFRange": data_set.DataTofRange,
"IncidentMediumSelected": incident_medium,
"GeometryCorrectionFlag": False,
"QMin": data_set.q_min,
"QStep": data_set.q_step,
"AngleOffset": data_set.angle_offset,
"AngleOffsetError": data_set.angle_offset_error,
"ScalingFactorFile": str(data_set.scaling_factor_file),
"SlitsWidthFlag": data_set.slits_width_flag,
"ApplyPrimaryFraction": True,
"SlitTolerance": slit_tolerance,
"PrimaryFractionRange": [data_set.clocking_from, data_set.clocking_to],
"OutputWorkspace": 'reflectivity_%s_%s_%s' % (first_run_of_set, sequence_number, run_number)
}
# Execute the reduction for the selected normalization type
norm_type = self.getProperty("NormalizationType").value
if norm_type == "DirectBeam":
LiquidsReflectometryReduction(**kwargs)
elif "WithReference":
refl1d_parameters = self.getProperty("Refl1DModelParameters").value
kwargs['Refl1DModelParameters'] = refl1d_parameters
LRReductionWithReference(**kwargs)
# Put the reflectivity curve together
self._save_partial_output(data_set, first_run_of_set, sequence_number, run_number)
......
......@@ -71,7 +71,7 @@ class LRReductionWithReference(DataProcessorAlgorithm):
def PyInit(self):
self.copyProperties(LR_ALG_FOR_PROPS, PROPS_TO_COPY)
self.declareProperty("Refl1DModelParameters", "",
doc="JSON string for Refl1D theoretical model paramters")
doc="JSON string for Refl1D theoretical model parameters")
def PyExec(self):
try:
......
......@@ -22,6 +22,7 @@ Improvements
- Sample waviness term is removed from resolution calculation in incoherent mode in :ref:`ReflectometryMomentumTransfer <algm-ReflectometryMomentumTransfer>`.
- Flag to enable / disable apply scaling factor from `ScalingFactorFile`, called `ApplyScalingFactor`, added to :ref:`algm-LiquidsReflectometryReduction`.
- Modified :ref:`algm-LRAutoReduction` to allow the option to autoreduce data with a reference measurement for normalization (instead of only direct beam) using the new :ref:`algm-LRReductionWithReference` algorithm of this release
Bug fixes
---------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment