From 5ef4b9f941031424f2cf526d5353dbf3c70db268 Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Wed, 27 Oct 2021 15:54:35 +0200 Subject: [PATCH] Cleanup --- src/calng/agipd_gpu.py | 5 +---- src/calng/base_correction.py | 4 +++- src/calng/base_gpu.py | 14 +++++--------- src/calng/calcat_utils.py | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/calng/agipd_gpu.py b/src/calng/agipd_gpu.py index 5ae1aa9c..aa0a4519 100644 --- a/src/calng/agipd_gpu.py +++ b/src/calng/agipd_gpu.py @@ -178,16 +178,13 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner): def load_rel_gain_ff_map(self, slopes_ff_map): # constant shape: y, x, memory cell if slopes_ff_map.shape[2] == 2: + # TODO: remove support for old format # old format, is per pixel only (shape is y, x, 2) # note: we should not support this in online slopes_ff_map = np.broadcast_to( slopes_ff_map[..., 0][..., np.newaxis], (self.pixels_y, self.pixels_x, self.constant_memory_cells), ) - else: - # TODO: maybe extend in case constant has too few memory cells - # TODO: maybe divide by something because new constants are absolute - ... self.rel_gain_xray_map_gpu.set(np.transpose(slopes_ff_map).astype(np.float32)) def set_g_gain_value(self, override_value): diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py index 9d393830..36fabc31 100644 --- a/src/calng/base_correction.py +++ b/src/calng/base_correction.py @@ -3,7 +3,6 @@ import threading import timeit import dateutil.parser -import hashToSchema import numpy as np from karabo.bound import ( BOOL_ELEMENT, @@ -710,6 +709,9 @@ class BaseCorrection(PythonDevice): ): if self.get("state") is State.PROCESSING: self.updateState(State.ON) + self.log_status_info( + f"No new train in {PROCESSING_STATE_TIMEOUT} s, switching state." + ) def handle_eos(self, channel): self.updateState(State.ON) diff --git a/src/calng/base_gpu.py b/src/calng/base_gpu.py index e51bc99b..4850dcba 100644 --- a/src/calng/base_gpu.py +++ b/src/calng/base_gpu.py @@ -73,7 +73,6 @@ class BaseGpuRunner: self.preview_corrected = np.empty(self.preview_shape, dtype=np.float32) # to get data from respective buffers to cell, x, y shape for preview computation - # TODO: handle shape juggling programmatically, removing need for these two helpers def _preview_preprocess_raw(self): """Should return view of self.input_data_gpu with shape (cell, x, y)""" raise NotImplementedError() @@ -112,16 +111,14 @@ class BaseGpuRunner: will be loaded into the provided array, which must match shape / dtype. """ # TODO: avoid copy - # TODO: check if necessary to make contiguous if output_order == self._corrected_axis_order: - self.reshaped_data_gpu = cupy.ascontiguousarray(self.processed_data_gpu) + self.reshaped_data_gpu = self.processed_data_gpu else: - self.reshaped_data_gpu = cupy.ascontiguousarray( - cupy.transpose( - self.processed_data_gpu, - utils.transpose_order(self._corrected_axis_order, output_order), - ) + self.reshaped_data_gpu = cupy.transpose( + self.processed_data_gpu, + utils.transpose_order(self._corrected_axis_order, output_order), ) + return self.reshaped_data_gpu.get(out=out) def load_data(self, raw_data): @@ -156,7 +153,6 @@ class BaseGpuRunner: ): image_data = preprocces() if preview_index >= 0: - # TODO: change axis order when moving reshape to after correction image_data[preview_index].astype(np.float32).get(out=output_buffer) elif preview_index == -1: # TODO: confirm that max is pixel and not integrated intensity diff --git a/src/calng/calcat_utils.py b/src/calng/calcat_utils.py index 5b5818ca..e6c6a8f1 100644 --- a/src/calng/calcat_utils.py +++ b/src/calng/calcat_utils.py @@ -315,7 +315,7 @@ class BaseCalcatFriend: self.device.set(f"{self.param_prefix}.{key}", value) def _get_status(self, constant, key): - return self.device.get(f"{self.status_prefix}.{constant.name}.{key}", value) + return self.device.get(f"{self.status_prefix}.{constant.name}.{key}") def _set_status(self, constant, key, value): """Helper to update information about found constants on device""" -- GitLab