From 29d1db58b3aadd65d7e381a457fa68076f878680 Mon Sep 17 00:00:00 2001
From: Steffen Hauf <fxeonc@exflong01.desy.de>
Date: Mon, 25 Apr 2022 09:53:33 +0200
Subject: [PATCH] Overrides for GOTTHARD-II testing

---
 src/calng/Gotthard2Correction.py | 7 ++++++-
 src/calng/base_correction.py     | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/calng/Gotthard2Correction.py b/src/calng/Gotthard2Correction.py
index 126e0dee..24429bae 100644
--- a/src/calng/Gotthard2Correction.py
+++ b/src/calng/Gotthard2Correction.py
@@ -105,6 +105,7 @@ class Gotthard2CpuRunner:
     def correct(self, flags, out=None):
         if out is None:
             out = np.empty(self.processed_shape, dtype=np.float32)
+
         self.correction_kernel(
             self.input_data,
             self.input_gain_stage,
@@ -299,9 +300,12 @@ class Gotthard2Correction(BaseCorrection):
         do_generate_preview,
     ):
         # cell table currently not used for GOTTHARD2 (assume alternating)
+        gain_map = np.asarray(data_hash.get("data.gain"))
+        if self.unsafe_get("dataFormat.overrideInputAxisOrder"):
+            gain_map.shape = self.input_data_shape
         try:
             self.kernel_runner.load_data(
-                image_data, data_hash.get("data.gain")
+                image_data, gain_map
             )
         except Exception as e:
             self.log_status_warn(f"Unknown exception when loading data: {e}")
@@ -309,6 +313,7 @@ class Gotthard2Correction(BaseCorrection):
         buffer_handle, buffer_array = self._shmem_buffer.next_slot()
         self.kernel_runner.correct(self._correction_flag_enabled, out=buffer_array)
 
+
         if do_generate_preview:
             if self._correction_flag_enabled != self._correction_flag_preview:
                 self.kernel_runner.correct(self._correction_flag_preview)
diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py
index ec264827..c458e504 100644
--- a/src/calng/base_correction.py
+++ b/src/calng/base_correction.py
@@ -957,8 +957,8 @@ class BaseCorrection(PythonDevice):
                 continue
 
             try:
-                image_data = data_hash.get(self._image_data_path)
-                cell_table = data_hash.get(self._cell_table_path).ravel()
+                image_data = np.asarray(data_hash.get(self._image_data_path))
+                cell_table = np.asarray(data_hash.get(self._cell_table_path)).ravel()
             except RuntimeError as err:
                 self.log_status_info(
                     f"Failed to load image data; probably empty hash from DAQ: {err}"
-- 
GitLab