From 67938cfcaa495c20fc53169056b9a469ac758dfa Mon Sep 17 00:00:00 2001
From: Joe Ramsay <joseph.ramsay@stfc.ac.uk>
Date: Wed, 30 May 2018 14:43:50 +0100
Subject: [PATCH] Re #22456 Expose SaveGDA by save_gda parameter

---
 docs/source/techniques/ISISPowder-GEM-v1.rst      | 15 +++++++++++++++
 scripts/Diffraction/isis_powder/gem.py            |  4 ++++
 .../gem_routines/gem_advanced_config.py           |  1 +
 .../isis_powder/gem_routines/gem_param_mapping.py |  1 +
 .../isis_powder/routines/common_output.py         |  7 +++++++
 5 files changed, 28 insertions(+)

diff --git a/docs/source/techniques/ISISPowder-GEM-v1.rst b/docs/source/techniques/ISISPowder-GEM-v1.rst
index d384ae6ba6f..9f3b5298923 100644
--- a/docs/source/techniques/ISISPowder-GEM-v1.rst
+++ b/docs/source/techniques/ISISPowder-GEM-v1.rst
@@ -124,6 +124,7 @@ The following parameters may also be optionally set:
 - :ref:`texture_mode_isis-powder-diffraction-ref`
 - :ref:`unit_to_keep_gem_isis-powder-diffraction-ref`
 - :ref:`save_angles_gem_isis-powder-diffraction-ref`
+- :ref:`save_gda_gem_isis-powder-diffraction-ref`
 
 If :ref:`sample_empty_gem_isis-powder-diffraction-ref` is
 set then the following parameter is also required:
@@ -719,6 +720,20 @@ On GEM this is set to the following:
 
    save_angles: False
 
+.. _save_gda_gem_isis-powder-diffraction-ref:
+
+save_gda
+^^^^^^^^
+
+If set to **True**, this saves the focused data to the MAUD-readable
+``.gda`` format, using :ref:`SaveGDA <algm-SaveGDA>`.
+
+On GEM this is set to the following:
+
+.. code-block:: python
+
+   save_gda: False
+
 .. _save_maud_gem_isis-powder-diffraction-ref:
 
 save_maud
diff --git a/scripts/Diffraction/isis_powder/gem.py b/scripts/Diffraction/isis_powder/gem.py
index 28f5b792f17..194f6a33522 100644
--- a/scripts/Diffraction/isis_powder/gem.py
+++ b/scripts/Diffraction/isis_powder/gem.py
@@ -71,6 +71,10 @@ class Gem(AbstractInst):
             angles_filename = filename_stub + "_grouping.new"
             out_file_names["angles_filename"] = angles_filename
 
+        if self._inst_settings.save_gda:
+            gda_filename = filename_stub + ".gda"
+            out_file_names["gda_filename"] = gda_filename
+
         return out_file_names
 
     @staticmethod
diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py b/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py
index 808da188016..4aa2c66c8bc 100644
--- a/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py
+++ b/scripts/Diffraction/isis_powder/gem_routines/gem_advanced_config.py
@@ -14,6 +14,7 @@ absorption_correction_params = {
 gem_adv_config_params = {
     "raw_tof_cropping_values": (500, 20000),
     "save_angles": False,
+    "save_gda": False,
     "spline_coefficient": 30
 }
 
diff --git a/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py b/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py
index 627384e8c27..db13b33c0e5 100644
--- a/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py
+++ b/scripts/Diffraction/isis_powder/gem_routines/gem_param_mapping.py
@@ -23,6 +23,7 @@ attr_mapping = \
      ParamMapEntry(ext_name="sample_empty",              int_name="sample_empty",   optional=True),
      ParamMapEntry(ext_name="sample_empty_scale",        int_name="sample_empty_scale"),
      ParamMapEntry(ext_name="save_angles",               int_name="save_angles"),
+     ParamMapEntry(ext_name="save_gda",                  int_name="save_gda"),
      ParamMapEntry(ext_name="save_maud",                 int_name="save_maud"),
      ParamMapEntry(ext_name="spline_coefficient",        int_name="spline_coeff"),
      ParamMapEntry(ext_name="suffix",                    int_name="suffix",         optional=True),
diff --git a/scripts/Diffraction/isis_powder/routines/common_output.py b/scripts/Diffraction/isis_powder/routines/common_output.py
index eb5a845ad56..a882aaa7e7a 100644
--- a/scripts/Diffraction/isis_powder/routines/common_output.py
+++ b/scripts/Diffraction/isis_powder/routines/common_output.py
@@ -67,11 +67,18 @@ def save_focused_data(d_spacing_group, tof_group, output_paths, run_number_strin
     if "angles_filename" in output_paths:
         _save_angles(d_spacing_group, output_paths["angles_filename"])
 
+    if "gda_filename" in output_paths:
+        _save_gda(tof_group, output_paths["gda_filename"])
+
 
 def _save_angles(d_spacing_group, output_path):
     mantid.SaveBankScatteringAngles(InputWorkspace=d_spacing_group, Filename=output_path)
 
 
+def _save_gda(tof_group, output_path):
+    mantid.SaveGDA(InputWorkspace=tof_group, Filename=output_path)
+
+
 def _save_maud(d_spacing_group, output_path):
     for i, ws in enumerate(d_spacing_group):
         mantid.SaveFocusedXYE(InputWorkspace=ws, Filename=output_path, SplitFiles=False, StartAtBankNumber=i,
-- 
GitLab