diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py index 39ffeec873229a7359cde684cd338ee41ec76268..c474e950d02dcb7a3f90b244e235ab9507e6641d 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SANSILLReduction.py @@ -246,6 +246,20 @@ class SANSILLReduction(PythonAlgorithm): def _check_processed_flag(ws, value): return ws.getRun().getLogData('ProcessedAs').value == value + @staticmethod + def _parallax_correction(ws): + formula = ws.getInstrument().getStringParameter('parallax')[0] + import numpy as np + l2 = ws.getRun().getLogData('L2').value + n_spectra = ws.getNumberHistograms() + p = np.empty(n_spectra) + for i in range(n_spectra): + d = ws.getDetector(i).getPos() + p[i] = np.arctan(d[0]/l2) + parallax_ws = ws.getName() + '_parallax' + parallax_ws = CreateWorkspace(NSpec=n_spectra, DataY=eval(formula), DataX=ws.extractX(), ParentWorkspace=ws, StoreInADS=False) + Divide(LHSWorkspace=ws, RHSWorkspace=parallax_ws, OutputWorkspace=ws.getName()) + def PyExec(self): # noqa: C901 process = self.getPropertyValue('ProcessAs') @@ -311,6 +325,11 @@ class SANSILLReduction(PythonAlgorithm): DeleteWorkspace(masked_ws) thickness = self.getProperty('SampleThickness').value NormaliseByThickness(InputWorkspace=ws, OutputWorkspace=ws, SampleThickness=thickness) + # parallax (gondola) effect + if mtd[ws].getInstrument().hasParameter('parallax'): + # for the moment it's only D22 that has this + self.log().information('Performing parallax correction') + self._parallax_correction(mtd[ws]) if process == 'Reference': sensitivity_out = self.getPropertyValue('SensitivityOutputWorkspace') if sensitivity_out: diff --git a/instrument/D22_Parameters.xml b/instrument/D22_Parameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..df9e87462874262de08174941160f41a3230980f --- /dev/null +++ b/instrument/D22_Parameters.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<parameter-file instrument = "D22" valid-from="2017-10-01 23:59:59"> + + <component-link name="D22"> + + <!-- This is the formula to model the theta dependency of the + detector sensitivities because of varying path lengths in the + detector volume. This is evaluated with python eval. + Note that the np stands for the numpy, p must be the parallax: + p = arctan(x/l2) [in radians], where x is the coordinate of the + detector pixel, l2 is the sample to detector distance. --> + <parameter name="parallax" type="string"> + <value val="1+0.14*np.exp(-4*np.log(2.)*((np.abs(p)-0.588)/0.414)**2)"/> + </parameter> + + </component-link> +</parameter-file> diff --git a/instrument/D22lr_Parameters.xml b/instrument/D22lr_Parameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..b6fc8c44aaf517b6321ee87f9e3754be1dc06f4f --- /dev/null +++ b/instrument/D22lr_Parameters.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<parameter-file instrument = "D22lr" valid-from="2017-10-01 23:59:59"> + + <component-link name="D22lr"> + + <!-- This is the formula to model the theta dependency of the + detector sensitivities because of varying path lengths in the + detector volume. This is evaluated with python eval. + Note that the np stands for the numpy, p must be the parallax: + p = arctan(x/l2) [in radians], where x is the coordinate of the + detector pixel, l2 is the sample to detector distance. --> + <parameter name="parallax" type="string"> + <value val="1+0.14*np.exp(-4*np.log(2.)*((np.abs(p)-0.588)/0.414)**2)"/> + </parameter> + + </component-link> +</parameter-file>