diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py index 12a10b244d5a15e6c2af70066de23223fe10f2f1..7ac07b0dac0df3b373e5d34fc6fd200167b7ddfd 100644 --- a/src/calng/base_correction.py +++ b/src/calng/base_correction.py @@ -928,36 +928,30 @@ class BaseCorrection(PythonDevice): elif not data_hash.has(self._image_data_path): self.log_status_info("Ignoring hash without image node") return - - train_id = metadata.getAttribute("timestamp", "tid") - self._train_ratio_tracker.update(train_id) - cell_table = data_hash.get(self._cell_table_path) - if ( - isinstance(cell_table, np.ndarray) - and (len(cell_table.shape) == 0 or cell_table.size == 0) - ) or len(cell_table) == 0: - self.log_status_warn("Empty cell table, DAQ probably not sending data.") + 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 - cell_table = np.ravel(cell_table) - # no more common reasons to skip input, so go to processing if state is State.ON: self.updateState(State.PROCESSING) self.log_status_info("Processing data") - correction_cell_num = self.unsafe_get("constantParameters.memoryCells") - cell_table_max = np.max(cell_table) + 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") - image_data = data_hash.get(self._image_data_path) if cell_table.size != self.unsafe_get("dataFormat.memoryCells"): self.log_status_info( - f"Updating new input shape {image_data.shape}, updating buffers" + f"Updating new input shape to account for {cell_table.size} cells" ) self.set("dataFormat.memoryCells", cell_table.size) - with self._buffer_lock: - self._update_frame_filter() + 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 @@ -986,7 +980,6 @@ class BaseCorrection(PythonDevice): self._rate_tracker.update() def _update_rate_and_state(self): - if self.get("state") is State.PROCESSING: self._buffered_status_update.set( "performance.rate", self._rate_tracker.get()