Commit 5ef9ff60 authored by Dominik Arominski's avatar Dominik Arominski
Browse files

Exposed setting wavelength to SANSILL Reduction and AutoProcess

parent b9d851e9
......@@ -408,6 +408,8 @@ class SANSILLAutoProcess(DataProcessorAlgorithm):
self.copyProperties('SANSILLIntegration', ['ShapeTable'])
self.copyProperties('SANSILLReduction', 'Wavelength')
def PyExec(self):
self.setUp()
outputSamples = []
......@@ -721,11 +723,34 @@ class SANSILLAutoProcess(DataProcessorAlgorithm):
NormaliseBy=self.normalise)
return container_name
def getWavelength(self, logs):
"""Returns wavelength from the property Wavelength, if defined, otherwise attempts to obtain it from
the logs."""
WAVELENGTH_LOG1 = "wavelength"
WAVELENGTH_LOG2 = "selector.wavelength"
wavelength = None
if not self.getProperty('Wavelength').isDefault:
wavelength = self.getProperty('Wavelength').value
else:
try:
wavelength = float(logs[WAVELENGTH_LOG1])
if wavelength < 0.0:
wavelength = None
raise ValueError
except:
try:
wavelength = float(logs[WAVELENGTH_LOG2])
if wavelength < 0.0:
wavelength = None
raise ValueError
except:
logger.notice("Unable to get a valid wavelength from the "
"sample logs.")
return wavelength
def createCustomSuffix(self, ws):
DISTANCE_LOG = "L2"
COLLIMATION_LOG = "collimation.actual_position"
WAVELENGTH_LOG1 = "wavelength"
WAVELENGTH_LOG2 = "selector.wavelength"
logs = mtd[ws].run().getProperties()
logs = {log.name:log.value for log in logs}
......@@ -757,21 +782,9 @@ class SANSILLAutoProcess(DataProcessorAlgorithm):
except:
logger.notice("Unable to get a valid collimation distance from "
"the sample logs.")
wavelength = None
try:
wavelength = float(logs[WAVELENGTH_LOG1])
if wavelength < 0.0:
wavelength = None
raise ValueError
except:
try:
wavelength = float(logs[WAVELENGTH_LOG2])
if wavelength < 0.0:
wavelength = None
raise ValueError
except:
logger.notice("Unable to get a valid wavelength from the "
"sample logs.")
wavelength = self.getWavelength(logs)
suffix = ""
if distance:
suffix += "_d{:.1f}m".format(distance)
......@@ -879,6 +892,7 @@ class SANSILLAutoProcess(DataProcessorAlgorithm):
self.getProperty('SampleThickness').value,
WaterCrossSection=
self.getProperty('WaterCrossSection').value,
Wavelength=self.getProperty('Wavelength').value
)
output_sample = self.output + '_#' + str(i + 1)
......
......@@ -268,6 +268,10 @@ class SANSILLReduction(PythonAlgorithm):
self.setPropertySettings('SolventInputWorkspace', sample)
self.declareProperty('Wavelength', 0.0,
validator=FloatBoundedValidator(lower=0.),
doc='Wavelength set for the data, will override nexus, intended for D16 reduction.')
def _normalise(self, ws, monID=None):
"""
Normalizes the workspace by time (SampleLog Timer) or Monitor
......@@ -761,7 +765,11 @@ class SANSILLReduction(PythonAlgorithm):
progress = Progress(self, start=0.0, end=1.0, nreports=processes.index(process) + 1)
ws = '__' + self.getPropertyValue('OutputWorkspace')
if self.getPropertyValue('Run'):
LoadAndMerge(Filename=self.getPropertyValue('Run').replace('+', ','), LoaderName='LoadILLSANS', OutputWorkspace=ws)
loader_options = {}
if not self.getProperty('Wavelength').isDefault:
loader_options['Wavelength'] = self.getProperty('Wavelength').value
LoadAndMerge(Filename=self.getPropertyValue('Run').replace('+', ','), LoaderName='LoadILLSANS',
OutputWorkspace=ws, LoaderOptions=loader_options)
if isinstance(mtd[ws], WorkspaceGroup):
# we do not want the summing done by LoadAndMerge since it will be pair-wise and slow
# instead we load and list, and merge once with merge runs
......
......@@ -244,8 +244,9 @@ class RundexSettings(object):
"WavelengthRange",
"StitchReferenceIndex",
"ClearCorrected2DWorkspace",
"ShapeTable"
],
"ShapeTable",
"Wavelength"
],
SANS_PSCAN : [
"SensitivityMap",
"DefaultMaskFile",
......
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