From 579a0d7d207ac83afdabcf3f2cf299342d1dffca Mon Sep 17 00:00:00 2001 From: David Hammer <dhammer@mailbox.org> Date: Tue, 1 Mar 2022 14:39:25 +0100 Subject: [PATCH] Fix up loading and axis orders (I think) --- src/calng/LpdCorrection.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/calng/LpdCorrection.py b/src/calng/LpdCorrection.py index 6d2505d8..665d6b80 100644 --- a/src/calng/LpdCorrection.py +++ b/src/calng/LpdCorrection.py @@ -34,7 +34,7 @@ class LpdConstants(enum.Enum): class LpdGpuRunner(base_gpu.BaseGpuRunner): _kernel_source_filename = "lpd_gpu.cu" - _corrected_axis_order = "cxy" # TODO: get specs for LPD data + _corrected_axis_order = "cxy" def __init__( self, @@ -97,28 +97,28 @@ class LpdGpuRunner(base_gpu.BaseGpuRunner): self.offset_map_gpu.set( np.transpose( constant_data.astype(np.float32), - (2, 0, 1, 3), + (2, 1, 0, 3), ) ) elif constant_type in (LpdConstants.BadPixelsDark, LpdConstants.BadPixelsFF): self.bad_pixel_map_gpu |= cupy.asarray( np.transpose( constant_data.astype(np.uint32), - (2, 0, 1, 3), + (2, 1, 0, 3), ) ) elif constant_type is LpdConstants.GainAmpMap: self.gain_amp_map_gpu.set( np.transpose( constant_data.astype(np.float32), - (2, 0, 1, 3), + (2, 1, 0, 3), ) ) elif constant_type is LpdConstants.FFMap: self.gain_amp_map_gpu.set( np.transpose( constant_data.astype(np.float32), - (2, 0, 1, 3), + (2, 1, 0, 3), ) ) elif constant_type is LpdConstants.RelativeGain: @@ -126,17 +126,9 @@ class LpdGpuRunner(base_gpu.BaseGpuRunner): self.rel_gain_slopes_map_gpu.set( np.transpose( constant_data.astype(np.float32), - (2, 0, 1, 3), + (2, 1, 0, 3), ) ) - """ - self.rel_gain_intercept_map_gpu.set( - np.transpose( - constant_data.astype(np.float32), - (2, 0, 1, 3), - ) - ) - """ def _init_kernels(self): kernel_source = self._kernel_template.render( @@ -323,12 +315,25 @@ class LpdCorrection(BaseCorrection): return ( self.unsafe_get("dataFormat.memoryCells"), 1, - self.unsafe_get("dataFormat.pixelsY"), self.unsafe_get("dataFormat.pixelsX"), + self.unsafe_get("dataFormat.pixelsY"), ) def _load_constant_to_runner(self, constant, constant_data): self.kernel_runner.load_constant(constant, constant_data) + correction_step = { + LpdConstants.Offset: "offset", + LpdConstants.GainAmpMap: "gainAmp", + LpdConstants.RelativeGain: "relGain", + LpdConstants.FFMap: "flatfield", + LpdConstants.BadPixelsDark: "badPixels", + LpdConstants.BadPixelsFF: "badPixels", + }[constant] + correction_node = f"corrections.{correction_step}" + if not self.get(f"{correction_node}.available"): + self.set(f"{correction_node}.available", True) + self._update_correction_flags() + self.log_status_info(f"Done loading {constant.name} to GPU") def process_data( self, -- GitLab