From 78fc4be8c63c0e548ef63c169072dea0ae97b993 Mon Sep 17 00:00:00 2001
From: Antti Soininen <soininen@ill.fr>
Date: Thu, 25 Oct 2018 17:56:17 -0400
Subject: [PATCH] Improve ComputeCalibrationCoefVan

- Add property to enable/disable the Debye-Waller factor correction
- Add support for time series temperature sample log
- Add support for giving the temperature log entry name in the IPF
- Update IN4, IN5, IN6 IPFs

Re #18457
---
 .../algorithms/ComputeCalibrationCoefVan.py   |  74 ++++++------
 .../ComputeCalibrationCoefVanTest.py          | 107 ++++++++++++++----
 .../ComputeCalibrationCoefVan-v1.rst          |  26 ++---
 .../release/v3.14.0/direct_inelastic.rst      |   5 +
 instrument/IN4_Parameters.xml                 |  18 +--
 instrument/IN5_Parameters.xml                 |  10 +-
 instrument/IN6_Parameters.xml                 |  10 +-
 7 files changed, 163 insertions(+), 87 deletions(-)

diff --git a/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py b/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py
index 0b4774fd4de..bb5a9befbf8 100644
--- a/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py
+++ b/Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py
@@ -9,15 +9,15 @@ from __future__ import (absolute_import, division, print_function)
 from mantid.api import (PythonAlgorithm, AlgorithmFactory,
                         MatrixWorkspaceProperty, Progress, InstrumentValidator,
                         ITableWorkspaceProperty)
-from mantid.kernel import Direction, FloatBoundedValidator, Property
+from mantid.kernel import Direction, FloatBoundedValidator, FloatTimeSeriesProperty, Property
 import numpy as np
 from scipy import integrate
 import scipy as sp
 
 
 class ComputeCalibrationCoefVan(PythonAlgorithm):
-    """ Calculate coefficients to normalize by Vanadium and correct Debye
-        Waller factor
+    """Calculate coefficients to normalize by Vanadium and correct Debye
+       Waller factor
     """
 
     def __init__(self):
@@ -31,22 +31,20 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
         self.DebyeT = 389.0         # K, Debye temperature for Vanadium
 
     def category(self):
-        """ Return category
-        """
+        """Return category."""
         return "CorrectionFunctions\\EfficiencyCorrections"
 
     def name(self):
-        """ Return summary
-        """
+        """Return algorithm's name."""
         return "ComputeCalibrationCoefVan"
 
     def summary(self):
+        """Return summary."""
         return ("Calculate coefficients for detector efficiency correction " +
                 "using the Vanadium data.")
 
     def PyInit(self):
-        """ Declare properties
-        """
+        """Declare properties."""
         self.declareProperty(MatrixWorkspaceProperty(
                              "VanadiumWorkspace", "",
                              direction=Direction.Input,
@@ -65,13 +63,12 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
                              validator=FloatBoundedValidator(lower=0.0),
                              direction=Direction.Input,
                              doc=("Temperature during the experiment (in " +
-                                  "Kelvins) if the 'temperature' sample log " +
-                                  "is missing or needs to be overriden."))
-        return
+                                  "Kelvins) if temperature is not given in the sample logs " +
+                                  "or needs to be overriden."))
+        self.declareProperty("EnableDWF", True, "Enable or disable the Debye-Waller correction.")
 
     def validateInputs(self):
-        """ Validate the inputs
-        """
+        """Validate the inputs."""
         issues = dict()
         inws = self.getProperty("VanadiumWorkspace").value
         run = inws.getRun()
@@ -100,30 +97,37 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
         return issues
 
     def get_temperature(self):
-        """Return the temperature
-        """
-        if not self.getProperty("Temperature").isDefault:
-            return self.getProperty("Temperature").value
+        """Return the temperature."""
+        temperatureProperty = self.getProperty("Temperature")
+        if not temperatureProperty.isDefault:
+            return temperatureProperty.value
+        temperatureLogName = "temperature"
+        instrument = self.vanaws.getInstrument()
+        LOG_ENTRY = "temperature_log_entry"
+        if instrument.hasParameter(LOG_ENTRY, False):
+            temperatureLogName = instrument.getStringParameter(LOG_ENTRY)[0]
         run = self.vanaws.getRun()
-        if not run.hasProperty('temperature'):
+        if not run.hasProperty(temperatureLogName):
             self.log().warning("No Temperature given and the 'temperature' " +
                                "sample log is not present in " +
                                self.vanaws.name() +
-                               " T=293K is assumed for Debye-Waller factor.")
+                               ". T = 293K is assumed for Debye-Waller factor.")
             return self.defaultT
         try:
-            temperature = float(run.getProperty('temperature').value)
+            temperature = run.getProperty(temperatureLogName)
+            if isinstance(temperature, FloatTimeSeriesProperty):
+                temperature = temperature.timeAverageValue()
+            else:
+                temperature = float(temperature.value)
+            return temperature
         except ValueError as err:
             self.log().warning("Error of getting temperature from the " +
-                               "sample log " + err + " T=293K is assumed " +
+                               "sample log " + err + ". T = 293K is assumed " +
                                "for Debye-Waller factor.")
             return self.defaultT
 
-        return temperature
-
     def PyExec(self):
-        """ Main execution body
-        """
+        """Main execution body."""
 
         # returns workspace instance
         self.vanaws = self.getProperty("VanadiumWorkspace").value
@@ -140,20 +144,21 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
         integrate.execute()
         prog_reporter.report("Computing DWFs")
         outws = integrate.getProperty("OutputWorkspace").value
-        # calculate array of Debye-Waller factors
         prog_reporter.report("Applying DWFs")
-        dwf = self.calculate_dwf()
-        for idx in range(nhist):
-            ys = outws.dataY(idx)
-            ys /= dwf[idx]
-            es = outws.dataE(idx)
-            es /= dwf[idx]
+        if self.getProperty('EnableDWF').value:
+            # calculate array of Debye-Waller factors
+            dwf = self.calculate_dwf()
+            for idx in range(nhist):
+                ys = outws.dataY(idx)
+                ys /= dwf[idx]
+                es = outws.dataE(idx)
+                es /= dwf[idx]
         prog_reporter.report("Done")
         self.setProperty("OutputWorkspace", outws)
 
     def calculate_dwf(self):
         """
-        Calculates Debye-Waller factor according to
+        Calculate Debye-Waller factor according to
         Sears and Shelley Acta Cryst. A 47, 441 (1991)
         """
         run = self.vanaws.getRun()
@@ -165,6 +170,7 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
 
         # T in K
         temperature = self.get_temperature()
+        self.log().debug('Using T = {}K for the Debye-Waller factor.'.format(temperature))
         # Wavelength, Angstrom
         wlength = float(run.getLogData('wavelength').value)
         # Vanadium mass, kg
diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py
index 54c3ee55af5..80883ff430b 100644
--- a/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py
+++ b/Framework/PythonInterface/test/python/plugins/algorithms/ComputeCalibrationCoefVanTest.py
@@ -7,9 +7,10 @@
 from __future__ import (absolute_import, division, print_function)
 
 import unittest
+from mantid.kernel import FloatTimeSeriesProperty
 from mantid.simpleapi import (DeleteWorkspace, CreateSampleWorkspace,
-                              AddSampleLog, EditInstrumentGeometry,
-                              CloneWorkspace, CompareWorkspaces, FindEPP)
+                              AddSampleLog, AddTimeSeriesLog, EditInstrumentGeometry,
+                              CloneWorkspace, CompareWorkspaces, FindEPP, SetInstrumentParameter)
 from testhelpers import run_algorithm
 from mantid.api import AnalysisDataService
 from scipy.constants import N_A, hbar, k
@@ -28,10 +29,13 @@ class ComputeCalibrationCoefVanTest(unittest.TestCase):
         self._table = FindEPP(input_ws, OutputWorkspace="table")
         AddSampleLog(self._input_ws, LogName='wavelength', LogText='4.0',
                      LogType='Number', LogUnit='Angstrom')
-        # These ranges correspond to 6*FWHM of the gaussian above,
-        # the integration ranges of ComputeCalibrationCoefVan.
-        self._lowerBoundRange = slice(28, 73)
-        self._upperBoundRange = slice(27, 74)
+        for i in range(input_ws.getNumberHistograms()):
+            y = input_ws.dataY(i)
+            y.fill(0.)
+            y[51] = 100.
+            e = input_ws.dataE(i)
+            e.fill(0.)
+            e[51] = 10.
 
     def test_output(self):
         outputWorkspaceName = "output_ws"
@@ -62,16 +66,9 @@ class ComputeCalibrationCoefVanTest(unittest.TestCase):
         self.assertTrue(alg_test.isExecuted())
         wsoutput = AnalysisDataService.retrieve(outputWorkspaceName)
 
-        # Check whether the sum is calculated correctly, for theta=0, dwf=1
-        # The result should be somewhere between the full bin sums.
-        y_sumMin = np.sum(self._input_ws.readY(0)[self._lowerBoundRange])
-        y_sumMax = np.sum(self._input_ws.readY(0)[self._upperBoundRange])
-        e_sumMin = np.sqrt(np.sum(np.square(self._input_ws.readE(0)[self._lowerBoundRange])))
-        e_sumMax = np.sqrt(np.sum(np.square(self._input_ws.readE(0)[self._upperBoundRange])))
-        self.assertLess(y_sumMin, wsoutput.readY(0)[0])
-        self.assertGreater(y_sumMax, wsoutput.readY(0)[0])
-        self.assertLess(e_sumMin, wsoutput.readE(0)[0])
-        self.assertGreater(e_sumMax, wsoutput.readE(0)[0])
+        for i in range(wsoutput.getNumberHistograms()):
+            self.assertEqual(100., wsoutput.readY(i)[0])
+            self.assertEqual(10., wsoutput.readE(i)[0])
 
         DeleteWorkspace(wsoutput)
 
@@ -108,6 +105,53 @@ class ComputeCalibrationCoefVanTest(unittest.TestCase):
 
         DeleteWorkspace(wsoutput)
 
+    def test_temperature_log_is_time_series(self):
+        outputWorkspaceName = "output_ws"
+        EditInstrumentGeometry(self._input_ws, L2="4,8", Polar="0,15",
+                               Azimuthal="0,0", DetectorIDs="1,2")
+        AddTimeSeriesLog(
+            self._input_ws,
+            'temperature',
+            '2010-09-14T04:20:12',
+            Value='0.0')
+        AddTimeSeriesLog(
+            self._input_ws,
+            'temperature',
+            '2010-09-14T04:20:13',
+            Value='0.0')
+        AddTimeSeriesLog(
+            self._input_ws,
+            'temperature',
+            '2010-09-14T04:20:14',
+            Value='0.0')
+        alg_test = run_algorithm("ComputeCalibrationCoefVan",
+                                 VanadiumWorkspace=self._input_ws,
+                                 EPPTable=self._table,
+                                 OutputWorkspace=outputWorkspaceName)
+        self.assertTrue(alg_test.isExecuted())
+        wsoutput = AnalysisDataService.retrieve(outputWorkspaceName)
+
+        self._checkDWF(wsoutput, 0.0)
+
+    def test_temperature_log_name_from_IPF(self):
+        self._input_ws.mutableRun().addProperty('sample.temperature', 0.0, True)
+        EditInstrumentGeometry(self._input_ws, L2="4,8", Polar="0,15",
+                               Azimuthal="0,0", DetectorIDs="1,2")
+        SetInstrumentParameter(
+            Workspace=self._input_ws,
+            ParameterName="temperature_log_entry",
+            ParameterType="String",
+            Value="sample.temperature")
+        outputWorkspaceName = "output_ws"
+        alg_test = run_algorithm("ComputeCalibrationCoefVan",
+                                 VanadiumWorkspace=self._input_ws,
+                                 EPPTable=self._table,
+                                 OutputWorkspace=outputWorkspaceName)
+        self.assertTrue(alg_test.isExecuted())
+        wsoutput = AnalysisDataService.retrieve(outputWorkspaceName)
+
+        self._checkDWF(wsoutput, 0.)
+
     def test_temperature_input_overrides_sample_log(self):
         self._input_ws.mutableRun().addProperty('temperature', 567.0, True)
         outputWorkspaceName = "output_ws"
@@ -136,6 +180,25 @@ class ComputeCalibrationCoefVanTest(unittest.TestCase):
         self.assertTrue(CompareWorkspaces(backup, self._input_ws)[0])
         DeleteWorkspace(backup)
 
+    def test_disabled_debye_waller_correction(self):
+        outputWorkspaceName = "output_ws"
+
+        # change theta to make dwf != 1
+        EditInstrumentGeometry(self._input_ws, L2="4,8", Polar="0,15",
+                               Azimuthal="0,0", DetectorIDs="1,2")
+        alg_test = run_algorithm("ComputeCalibrationCoefVan",
+                                 VanadiumWorkspace=self._input_ws,
+                                 EPPTable=self._table,
+                                 OutputWorkspace=outputWorkspaceName,
+                                 EnableDWF=False)
+        self.assertTrue(alg_test.isExecuted())
+        wsoutput = AnalysisDataService.retrieve(outputWorkspaceName)
+        for i in range(wsoutput.getNumberHistograms()):
+            self.assertEqual(100., wsoutput.readY(i)[0])
+            self.assertEqual(10., wsoutput.readE(i)[0])
+
+        DeleteWorkspace(wsoutput)
+
     def tearDown(self):
         if AnalysisDataService.doesExist(self._input_ws.name()):
             DeleteWorkspace(self._input_ws)
@@ -144,6 +207,8 @@ class ComputeCalibrationCoefVanTest(unittest.TestCase):
             DeleteWorkspace(self._table)
 
     def _checkDWF(self, wsoutput, temperature):
+        self.assertEqual(100., wsoutput.readY(0)[0])
+        self.assertEqual(10., wsoutput.readE(0)[0])
         if temperature == 0.0:
             integral = 0.5
         elif temperature == 293.0:
@@ -151,18 +216,12 @@ class ComputeCalibrationCoefVanTest(unittest.TestCase):
         else:
             raise RuntimeError("Unsupported temperature supplied to " +
                                "_checkDWF(). Use 0K or 293K only.")
-        y_sumMin = np.sum(self._input_ws.readY(1)[self._lowerBoundRange])
-        y_sumMax = np.sum(self._input_ws.readY(1)[self._upperBoundRange])
-        e_sumMin = np.sqrt(np.sum(np.square(self._input_ws.readE(1)[self._lowerBoundRange])))
-        e_sumMax = np.sqrt(np.sum(np.square(self._input_ws.readE(1)[self._upperBoundRange])))
         mvan = 0.001*50.942/N_A
         Bcoef = 3.0*integral*1e+20*hbar*hbar/(2.0*mvan*k*389.0)
         dwf = np.exp(
             -1.0*Bcoef*(4.0*np.pi*np.sin(0.5*np.radians(15.0))/4.0)**2)
-        self.assertLess(y_sumMin/dwf, wsoutput.readY(1)[0])
-        self.assertGreater(y_sumMax/dwf, wsoutput.readY(1)[0])
-        self.assertLess(e_sumMin/dwf, wsoutput.readE(1)[0])
-        self.assertGreater(e_sumMax/dwf, wsoutput.readE(1)[0])
+        self.assertEqual(100./dwf, wsoutput.readY(1)[0])
+        self.assertEqual(10./dwf, wsoutput.readE(1)[0])
 
 
 if __name__ == "__main__":
diff --git a/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst b/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst
index b8e71df999a..89d292a4627 100644
--- a/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst
+++ b/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst
@@ -9,9 +9,15 @@
 Description
 -----------
 
-Algorithm creates a workspace with  detector sensitivity correction coefficients using the given Vanadium workspace. The correction coefficients are calculated as follows.
+Algorithm creates a workspace with detector sensitivity correction coefficients using the given Vanadium workspace. The correction coefficients are calculated as follows.
 
-1. Calculate the Debye-Waller factor according to Sears and Shelley *Acta Cryst. A* **47**, 441 (1991):
+#. Load the peak centre and sigma from the *EPPTable*. These values are used to calculate sum :math:`S_i` as
+
+   :math:`S_i = \sum_{x = x_C - 3\,\mathrm{fwhm}}^{x_C + 3\,\mathrm{fwhm}} Y_i(x)`
+
+   where :math:`x_C` is the peak centre position and :math:`Y_i(x)` is the corresponding to :math:`x` :math:`Y` value for i-th detector.
+
+#. (If *EnableDWF* is true) Calculate the Debye-Waller factor according to Sears and Shelley *Acta Cryst. A* **47**, 441 (1991):
 
    :math:`D_i = \exp\left[-B_i\cdot\left(\frac{4\pi\sin\theta_i}{\lambda}\right)^2\right]`
 
@@ -21,19 +27,13 @@ Algorithm creates a workspace with  detector sensitivity correction coefficients
 
    :math:`J(y) = \int_0^1 x\cdot\mathrm{coth}\left(\frac{x}{2y}\right)\,\mathrm{d}x`
 
-   where :math:`y=T/T_m` is the ratio of the temperature during the experiment :math:`T` to the Debye temperature :math:`T_m = 389K`, :math:`m_V` is the Vanadium atomic mass (in kg) and :math:`\theta_i` is the polar angle of the i-th detector. By default, the temperature is read from the 'temperature' entry in the sample logs. If the entry is missing, or incorrect, the *Temperature* input property can be used instead.
+   where :math:`y=T/T_m` is the ratio of the temperature during the experiment :math:`T` to the Debye temperature :math:`T_m = 389K`, :math:`m_V` is the Vanadium atomic mass (in kg) and :math:`\theta_i` is the polar angle of the i-th detector. By default, the temperature is read from the sample logs. The log entry can be given as the 'temperature_sample_log' in the IPF, otherwise 'temperature' entry is used. If the log is missing, or incorrect, the *Temperature* input property can be used instead.
 
 .. warning::
 
-    If the input *Temperature* is not specified or the sample log 'temperature' is not present in the given Vanadium workspace, or is set to an invalid value, T=293K will be taken for the Debye-Waller factor calculation. The algorithm will produce a warning in this case.
-
-2. Load the peak centre and sigma from the *EPPTable*. These values are used to calculate sum :math:`S_i` as
-
-   :math:`S_i = \sum_{x = x_C - 3\,\mathrm{fwhm}}^{x_C + 3\,\mathrm{fwhm}} Y_i(x)`
-
-   where :math:`x_C` is the peak centre position and :math:`Y_i(x)` is the corresponding to :math:`x` :math:`Y` value for i-th detector.
+    If no temperature is available, or is set to an invalid value, :math:`T` = 293K will be taken for the Debye-Waller factor calculation. The algorithm will produce a warning in this case.
 
-3. Finally, the correction coefficients :math:`K_i` are calculated as
+#. (If *EnableDWF* is true)Finally, the correction coefficients :math:`K_i` are calculated as
 
    :math:`K_i = \frac{S_i}{D_i}`
 
@@ -71,11 +71,11 @@ Usage
     wsVana = LoadMLZ(Filename='TOFTOFTestdata.nxs')
     # find elastic peak positions
     epptable = FindEPP(wsVana)
-    # calculate correction coefficients      
+    # calculate correction coefficients
     wsCoefs = ComputeCalibrationCoefVan(wsVana, epptable)
     print('Spectrum 4 of the output workspace is filled with:  {}'.format(round(wsCoefs.readY(999)[0])))
 
-    # wsCoefs can be used as rhs with Divide algorithm to apply correction to the data 
+    # wsCoefs can be used as rhs with Divide algorithm to apply correction to the data
     wsCorr = wsVana/wsCoefs
     print('Spectrum 4 of the input workspace is filled with:  {}'.format(round(wsVana.readY(999)[0], 1)))
     print('Spectrum 4 of the corrected workspace is filled with:  {}'.format(round(wsCorr.readY(999)[0], 5)))
diff --git a/docs/source/release/v3.14.0/direct_inelastic.rst b/docs/source/release/v3.14.0/direct_inelastic.rst
index c4f908a56f3..f16be24b49c 100644
--- a/docs/source/release/v3.14.0/direct_inelastic.rst
+++ b/docs/source/release/v3.14.0/direct_inelastic.rst
@@ -22,6 +22,11 @@ Improvements
 ############
 
 - :ref:`DirectILLIntegrateVanadium <algm-DirectILLIntegrateVanadium>` now masks zero counting detectors from the integral.
+- Changes to :ref:`ComputeCalibrationCoefVan <algm-ComputeCalibrationCoefVan>`:
+
+  - It is now possible to turn off the Debye-Waller correction
+  - The temperature sample log entry can be given in an instrument parameter ``temperature_sample_log``.
+  - The temperature sample log can now be a time series.
 
 Bugfixes
 ########
diff --git a/instrument/IN4_Parameters.xml b/instrument/IN4_Parameters.xml
index f3df8a53cfc..c171988289b 100644
--- a/instrument/IN4_Parameters.xml
+++ b/instrument/IN4_Parameters.xml
@@ -7,7 +7,7 @@
 			<value val="direct" />
 		</parameter>
 
-		<!-- Distance between sample and equatorial line of the detector. Mandatory 
+		<!-- Distance between sample and equatorial line of the detector. Mandatory
 			if you want to correct the flight paths. -->
 		<parameter name="l2" type="string">
 			<value val="2.0" />
@@ -60,12 +60,14 @@
 		<parameter name="sample_logs_fail_tolerances" type="string">
 			<value val="0, 0, 0, 0.02, 5, 5" />
 		</parameter>
-
+		<parameter name="temperature_sample_log" type="string">
+			<value val="sample.temperature" />
+		</parameter>
 	</component-link>
 
 	<component-link name="wide_angle">
-		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
-			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available
 			operators -->
 		<parameter name="formula_eff" type="string">
 			<value val="0.951*exp(-0.0887/sqrt(e))*(1-exp(-5.597/sqrt(e)))" />
@@ -73,8 +75,8 @@
 	</component-link>
 
 	<component-link name="rosace">
-		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
-			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available
 			operators -->
 		<parameter name="formula_eff" type="string">
 			<value val="1-exp(-6.1343/sqrt(e))" />
@@ -82,8 +84,8 @@
 	</component-link>
 
 	<component-link name="monitors">
-		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
-			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available
 			operators -->
 		<parameter name="formula_eff" type="string">
 			<value val="1" />
diff --git a/instrument/IN5_Parameters.xml b/instrument/IN5_Parameters.xml
index 52f5071317a..eb1d90293af 100644
--- a/instrument/IN5_Parameters.xml
+++ b/instrument/IN5_Parameters.xml
@@ -7,14 +7,14 @@
 			<value val="direct" />
 		</parameter>
 
-		<!-- Distance between sample and equatorial line of the detector. Mandatory 
+		<!-- Distance between sample and equatorial line of the detector. Mandatory
 			if you want to correct the flight paths. -->
 		<parameter name="l2" type="string">
 			<value val="4.0" />
 		</parameter>
 
-		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
-			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available
 			operators -->
 		<parameter name="formula_eff" type="string">
 			<value val="1-exp(-5.6/sqrt(e))" />
@@ -73,7 +73,9 @@
 		<parameter name="sample_logs_fail_tolerances" type="string">
 			<value val="0, 0, 0" />
 		</parameter>
-
+		<parameter name="temperature_sample_log" type="string">
+			<value val="sample.temperature" />
+		</parameter>
 	</component-link>
 
 </parameter-file>
diff --git a/instrument/IN6_Parameters.xml b/instrument/IN6_Parameters.xml
index ea90ca60c5d..23d0fa74669 100644
--- a/instrument/IN6_Parameters.xml
+++ b/instrument/IN6_Parameters.xml
@@ -7,14 +7,14 @@
 			<value val="direct" />
 		</parameter>
 
-		<!-- Distance between sample and equatorial line of the detector. Mandatory 
+		<!-- Distance between sample and equatorial line of the detector. Mandatory
 			if you want to correct the flight paths. -->
 		<parameter name="l2" type="string">
 			<value val="2.483" />
 		</parameter>
 
-		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
-			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available
 			operators -->
 		<parameter name="formula_eff" type="string">
 			<!-- The xml escape sequence &gt; below means 'greater than' -->
@@ -72,7 +72,9 @@
 		<parameter name="sample_logs_fail_tolerances" type="string">
 			<value val="0, 0, 0, 0.02, 5, 5" />
 		</parameter>
-
+		<parameter name="temperature_sample_log" type="string">
+			<value val="sample.temperature" />
+		</parameter>
 	</component-link>
 
 </parameter-file>
-- 
GitLab