From 620f99a2e2f93807b5d3ea83a792e338f1f8b97d Mon Sep 17 00:00:00 2001
From: David Fairbrother <DavidFair@users.noreply.github.com>
Date: Wed, 31 May 2017 17:28:26 +0100
Subject: [PATCH] Re #19574 Store splined workspace with their mode as unique
 names

---
 scripts/Diffraction/isis_powder/abstract_inst.py   |  8 ++++++++
 scripts/Diffraction/isis_powder/pearl.py           | 14 ++++++++++++--
 .../Diffraction/isis_powder/routines/calibrate.py  |  5 ++++-
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/scripts/Diffraction/isis_powder/abstract_inst.py b/scripts/Diffraction/isis_powder/abstract_inst.py
index 10d8554fa7a..e5dfa7b95af 100644
--- a/scripts/Diffraction/isis_powder/abstract_inst.py
+++ b/scripts/Diffraction/isis_powder/abstract_inst.py
@@ -196,6 +196,14 @@ class AbstractInst(object):
         """
         return str()
 
+    def _get_current_tt_mode(self):
+        """
+        Returns the current tt_mode this is only applicable
+        to PEARL. Otherwise returns None
+        :return: Current tt_mode on PEARL, otherwise None
+        """
+        return None
+
     def _normalise_ws_current(self, ws_to_correct, run_details=None):
         """
         Normalises the workspace by the beam current at the time it was taken using
diff --git a/scripts/Diffraction/isis_powder/pearl.py b/scripts/Diffraction/isis_powder/pearl.py
index 82fd89167e0..074726ca045 100644
--- a/scripts/Diffraction/isis_powder/pearl.py
+++ b/scripts/Diffraction/isis_powder/pearl.py
@@ -87,13 +87,23 @@ class Pearl(AbstractInst):
         # instead we don't try to run this automatically
         raise NotImplementedError("You must run the create_vanadium method manually on Pearl")
 
+    def _get_current_tt_mode(self):
+        return self._inst_settings.tt_mode
+
     def _get_monitor_spectra_index(self, run_number):
         return self._inst_settings.monitor_spec_no
 
     def _spline_vanadium_ws(self, focused_vanadium_spectra):
         focused_vanadium_spectra = pearl_algs.strip_bragg_peaks(focused_vanadium_spectra)
-        return common.spline_workspaces(focused_vanadium_spectra=focused_vanadium_spectra,
-                                        num_splines=self._inst_settings.spline_coefficient)
+        splined_list = common.spline_workspaces(focused_vanadium_spectra=focused_vanadium_spectra,
+                                                num_splines=self._inst_settings.spline_coefficient)
+        # Ensure the name is unique if we are in tt_mode all
+        new_workspace_names = []
+        for ws in splined_list:
+            new_name = ws.getName() + '_' + self._inst_settings.tt_mode
+            new_workspace_names.append(mantid.RenameWorkspace(InputWorkspace=ws, OutputWorkspace=new_name))
+
+        return new_workspace_names
 
     def _output_focused_ws(self, processed_spectra, run_details, output_mode=None):
         if not output_mode:
diff --git a/scripts/Diffraction/isis_powder/routines/calibrate.py b/scripts/Diffraction/isis_powder/routines/calibrate.py
index 96e06873fe4..2556ddf8888 100644
--- a/scripts/Diffraction/isis_powder/routines/calibrate.py
+++ b/scripts/Diffraction/isis_powder/routines/calibrate.py
@@ -63,4 +63,7 @@ def _create_vanadium_splines(focused_spectra, instrument, run_details):
         mantid.SaveNexus(Filename=out_spline_van_file_path, InputWorkspace=ws, Append=append)
         append = True
     # Group for user convenience
-    mantid.GroupWorkspaces(InputWorkspaces=splined_ws_list, OutputWorkspace="Van_spline_data")
+    group_name = "Van_spline_data"
+    tt_mode = instrument._get_current_tt_mode()
+    group_name = group_name + '_' + tt_mode if tt_mode else group_name
+    mantid.GroupWorkspaces(InputWorkspaces=splined_ws_list, OutputWorkspace=group_name)
-- 
GitLab