From 7e9d9579253ec69fc4b040e123793014701f9308 Mon Sep 17 00:00:00 2001
From: David Hammer <dhammer@mailbox.org>
Date: Wed, 3 Nov 2021 14:56:23 +0100
Subject: [PATCH] Select cell ID to preview instead of pulse

---
 src/calng/AgipdCorrection.py | 15 ++++++++-------
 src/calng/base_correction.py |  5 +++--
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/calng/AgipdCorrection.py b/src/calng/AgipdCorrection.py
index 74d8c058..d619ec40 100644
--- a/src/calng/AgipdCorrection.py
+++ b/src/calng/AgipdCorrection.py
@@ -315,19 +315,20 @@ class AgipdCorrection(BaseCorrection):
             if do_generate_preview:
                 if self._correction_flag_enabled != self._correction_flag_preview:
                     self.gpu_runner.correct(self._correction_flag_preview)
+                # WARNING: actually looking for cell ID at the request of SPB
                 preview_slice_index = self._schema_cache["preview.pulse"]
                 if preview_slice_index >= 0:
-                    # look at pulse_table to find which index this pulse ID is in
-                    pulse_id_found = np.where(pulse_table == preview_slice_index)[0]
-                    if len(pulse_id_found) == 0:
-                        pulse_found_instead = pulse_table[0]
+                    # look at cell_table to find which index this pulse ID is in
+                    cell_id_found = np.where(cell_table == preview_slice_index)[0]
+                    if len(cell_id_found) == 0:
+                        cell_found_instead = cell_table[0]
                         self.log_status_info(
-                            f"Pulse {preview_slice_index} not found, arbitrary pulse "
-                            f"{pulse_found_instead} will be shown instead."
+                            f"Cell {preview_slice_index} not found, arbitrary cell "
+                            f"{cell_found_instead} will be shown instead."
                         )
                         preview_slice_index = 0
                     else:
-                        preview_slice_index = pulse_id_found[0]
+                        preview_slice_index = cell_id_found[0]
                 preview_raw, preview_corrected = self.gpu_runner.compute_preview(
                     preview_slice_index
                 )
diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py
index 11f68b42..271736c0 100644
--- a/src/calng/base_correction.py
+++ b/src/calng/base_correction.py
@@ -338,9 +338,10 @@ class BaseCorrection(PythonDevice):
             .defaultValue(True)
             .reconfigurable()
             .commit(),
+            # TODO: Split into AGIPD-specific or see if others like cell ID over pulse ID
             INT32_ELEMENT(expected)
             .key("preview.pulse")
-            .displayedName("Pulse (or stat) for preview")
+            .displayedName("Cell (or stat) for preview")
             .description(
                 "If this value is ≥ 0, the corresponding index from data will be "
                 "sliced for the preview. If this value is ≤ 0, preview will be one of "
@@ -603,7 +604,7 @@ class BaseCorrection(PythonDevice):
         # TODO: allow sending *all* frames for commissioning (request: Jola)
         preview_hash = Hash()
         preview_hash.set("image.trainId", train_id)
-        preview_hash.set("image.pulseId", self._schema_cache["preview.pulse"])
+        preview_hash.set("image.cellId", self._schema_cache["preview.pulse"])
 
         # note: have to construct because setting .tid after init is broken
         timestamp = Timestamp(Epochstamp(), Trainstamp(train_id))
-- 
GitLab