From 1a655dcc0efa13b4c798de85d4bb511ee302e704 Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Fri, 1 Apr 2022 18:20:30 +0200 Subject: [PATCH] New handling of invalid arrays from DAQ (need Karabo >= 2.14.1) --- src/calng/base_correction.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py index 7ac07b0d..b451c5ee 100644 --- a/src/calng/base_correction.py +++ b/src/calng/base_correction.py @@ -924,13 +924,19 @@ class BaseCorrection(PythonDevice): if source not in self.sources: self.log_status_info(f"Ignoring hash with unknown source {source}") - return + continue elif not data_hash.has(self._image_data_path): self.log_status_info("Ignoring hash without image node") - return - elif len(self.input_data_shape) != len(data_hash.get(f"{self._image_data_path}.shape")): - self.log_status_info("DAQ probably not sending data") - return + continue + + try: + image_data = data_hash.get(self._image_data_path) + cell_table = 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}" + ) + continue # no more common reasons to skip input, so go to processing if state is State.ON: @@ -939,7 +945,6 @@ class BaseCorrection(PythonDevice): train_id = metadata.getAttribute("timestamp", "tid") self._train_ratio_tracker.update(train_id) - cell_table = data_hash.get(self._cell_table_path).ravel() if self.unsafe_get("constantParameters.memoryCells") <= cell_table.max(): self.log_status_warn("Input cell IDs out of range of constants") @@ -951,7 +956,6 @@ class BaseCorrection(PythonDevice): self.set("dataFormat.memoryCells", cell_table.size) self._lock_and_update_in_background(self._update_frame_filter) - image_data = data_hash.get(self._image_data_path) # DataAggregator typically tells us the wrong axis order if self.unsafe_get("dataFormat.overrideInputAxisOrder"): expected_shape = self.input_data_shape -- GitLab