From 62133f2d1bf3ffee0378be80a28bd436a0be7c58 Mon Sep 17 00:00:00 2001
From: Elliot Oram <elliot.oram@stfc.ac.uk>
Date: Tue, 5 Dec 2017 16:31:42 +0000
Subject: [PATCH] Add rebinning step to finest binning (bank 5)

Refs #21294
---
 .../tests/analysis/ISIS_PowderPolarisTest.py   | 18 +++++++++---------
 .../polaris_routines/polaris_algs.py           |  2 ++
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py
index cd82879b08d..1e007cddf5e 100644
--- a/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py
+++ b/Testing/SystemTests/tests/analysis/ISIS_PowderPolarisTest.py
@@ -106,16 +106,16 @@ class TotalScatteringTest(stresstesting.MantidStressTest):
 
     def validate(self):
         # Whilst total scattering is in development, the validation will avoid using reference files as they will have
-        # to be updated very frequently. In the meantime, the expected peak in the PDF at ~4 Angstrom will be checked.
-        # expected_peak_values = [bin_index, y_value] (each list item is a bank (1-5))
-        expected_peak_values = [[7,  0.149],
-                                [11, 0.285],
-                                [23, 0.504],
-                                [37, 0.382],
-                                [52, 0.700]]
+        # to be updated very frequently. In the meantime, the expected peak in the PDF at ~3.9 Angstrom will be checked.
+        # After rebin this is at X index 51
+        mantid.SaveNexus(Filename='~\\total_scattering_output.nxs', InputWorkspace=self.pdf_output)
+        expected_peak_values = [0.0187231,
+                                0.0583586,
+                                0.2241280,
+                                0.2752230,
+                                1.0252800]
         for index, ws in enumerate(self.pdf_output):
-            self.assertAlmostEqual(ws.dataY(0)[expected_peak_values[index][0]], expected_peak_values[index][1],
-                                   places=3)
+            self.assertAlmostEqual(ws.dataY(0)[51], expected_peak_values[index], places=3)
 
 
 def run_total_scattering(run_number, merge_banks):
diff --git a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py
index c45e9d3d8d3..b14cc6c2295 100644
--- a/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py
+++ b/scripts/Diffraction/isis_powder/polaris_routines/polaris_algs.py
@@ -83,6 +83,8 @@ def generate_ts_pdf(run_number, focus_file_path, merge_banks=False):
         raise RuntimeError("Merging banks is currently not supported")
     pdf_output = mantid.PDFFourierTransform(Inputworkspace=pdf_output, InputSofQType="S(Q)", PDFType="G(r)",
                                             Filter=True)
+    pdf_output = mantid.RebinToWorkspace(WorkspaceToRebin=pdf_output, WorkspaceToMatch=pdf_output[4],
+                                         PreserveEvents=True)
     return pdf_output
 
 
-- 
GitLab