From dd19577129df7685fdcc3d485ab7ca5e94e37458 Mon Sep 17 00:00:00 2001
From: Conor Finn <conor.finn@stfc.ac.uk>
Date: Mon, 2 Dec 2019 16:58:01 +0000
Subject: [PATCH] RE #26848 Output calibration params table when loading

The calibration parameter table that is generated when creating a new
calibration is now loaded back into mantid from the file as a table
workspace, rather then just working in the background.
---
 .../tabs/calibration/model.py                      | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py
index 64546b5ee58..9d4ca4737c2 100644
--- a/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py
+++ b/scripts/Engineering/gui/engineering_diffraction/tabs/calibration/model.py
@@ -75,7 +75,8 @@ class CalibrationModel(object):
             logger.warning("Could not open GSAS calibration file: ", file_path)
             return
         try:
-            instrument, van_no, ceria_no = self.get_info_from_file(file_path)
+            instrument, van_no, ceria_no, params_table = self.get_info_from_file(file_path)
+            self.update_calibration_params_table(params_table)
         except RuntimeError:
             logger.error("Invalid file selected: ", file_path)
             return
@@ -238,11 +239,16 @@ class CalibrationModel(object):
         instrument = file_path.split("/")[-1].split("_", 1)[0]
         # Get run numbers from file.
         run_numbers = ""
+        params_table = []
         with open(file_path) as f:
             for line in f:
-                if line.startswith("INS    CALIB"):
+                if "INS    CALIB" in line:
                     run_numbers = line
-                    break
+                if "ICONS" in line:
+                    # If formatted correctly the line should be in the format INS bank ICONS difc difa tzero
+                    elements = line.split()
+                    bank = elements[1]
+                    params_table.append([int(bank) - 1, float(elements[3]), float(elements[4]), float(elements[5])])
 
         if run_numbers == "":
             raise RuntimeError("Invalid file format.")
@@ -250,7 +256,7 @@ class CalibrationModel(object):
         words = run_numbers.split()
         ceria_no = words[2]  # Run numbers are stored as the 3rd and 4th word in this line.
         van_no = words[3]
-        return instrument, van_no, ceria_no
+        return instrument, van_no, ceria_no, params_table
 
     @staticmethod
     def _generate_table_workspace_name(bank_num):
-- 
GitLab