diff --git a/src/calng/corrections/AgipdCorrection.py b/src/calng/corrections/AgipdCorrection.py index 994428d6bce801b1fdfec7f5447f7fd25e2c5eb5..7857c8ed88b7803988c2a1d7f4d99d2e336b562f 100644 --- a/src/calng/corrections/AgipdCorrection.py +++ b/src/calng/corrections/AgipdCorrection.py @@ -138,12 +138,12 @@ class AgipdBaseRunner(base_kernel_runner.BaseKernelRunner): # note: the gain values are something like means used to derive thresholds self.gain_thresholds[:] = self._xp.asarray( constant_data[..., :2], dtype=np.float32 - ).transpose((2, 1, 0, 3)) + ).transpose((2, 1, 0, 3))[:self.constant_memory_cells] elif constant is Constants.Offset: # shape: y, x, memory cell, gain stage self.offset_map[:] = self._xp.asarray( constant_data, dtype=np.float32 - ).transpose((2, 1, 0, 3)) + ).transpose((2, 1, 0, 3))[:self.constant_memory_cells] elif constant is Constants.SlopesPC: # pc has funny shape (11, 352, 128, 512) from file # this is (fi, memory cell, y, x) @@ -178,14 +178,14 @@ class AgipdBaseRunner(base_kernel_runner.BaseKernelRunner): rel_gain_map[2] = rel_gain_map[1] * 4.48 self.rel_gain_pc_map[:] = self._xp.asarray( rel_gain_map.transpose((1, 3, 2, 0)), dtype=np.float32 - ) + )[:self.constant_memory_cells] if self._md_additional_offset_value is None: md_additional_offset = ( hg_intercept - mg_intercept * frac_hg_mg ).astype(np.float32) self.md_additional_offset[:] = self._xp.asarray( md_additional_offset.transpose((0, 2, 1)), dtype=np.float32 - ) + )[:self.constant_memory_cells] elif constant is Constants.SlopesFF: # constant shape: y, x, memory cell if constant_data.shape[2] == 2: @@ -198,7 +198,7 @@ class AgipdBaseRunner(base_kernel_runner.BaseKernelRunner): ) self.rel_gain_xray_map[:] = self._xp.asarray( constant_data.transpose(), dtype=np.float32 - ) + )[:self.constant_memory_cells] else: assert constant in bad_pixel_constants # will simply OR with already loaded, does not take into account which ones @@ -231,7 +231,7 @@ class AgipdBaseRunner(base_kernel_runner.BaseKernelRunner): else: # gain mapped constants seem consistent constant_data = constant_data.transpose((2, 1, 0, 3)) - self.bad_pixel_map |= constant_data + self.bad_pixel_map |= constant_data[:self.constant_memory_cells] def override_md_additional_offset(self, override_value): self._md_additional_offset_value = override_value diff --git a/src/calng/corrections/DsscCorrection.py b/src/calng/corrections/DsscCorrection.py index 7d22253b1cf1d8e0f81f2ed0ef2ab6628190b1b5..2ee61b848e74c6a6fe3fd9e28a52d25b1f6c353d 100644 --- a/src/calng/corrections/DsscCorrection.py +++ b/src/calng/corrections/DsscCorrection.py @@ -75,7 +75,7 @@ class DsscBaseRunner(base_kernel_runner.BaseKernelRunner): offset_map = offset_map[..., 0] # shape (now): x, y, memory cell offset_map = self._xp.asarray(offset_map, dtype=np.float32).transpose() - self.offset_map[:] = offset_map + self.offset_map[:] = offset_map[:self.constant_memory_cells] class DsscCpuRunner(DsscBaseRunner): diff --git a/src/calng/corrections/LpdCorrection.py b/src/calng/corrections/LpdCorrection.py index 886e99e644e66622c4404c73c25271d4ddb15877..1e8ab80b0d9cac5e9a55d22a46369268244a0570 100644 --- a/src/calng/corrections/LpdCorrection.py +++ b/src/calng/corrections/LpdCorrection.py @@ -157,14 +157,14 @@ class LpdGpuRunner(base_kernel_runner.BaseKernelRunner): self.bad_pixel_map |= self._xp.asarray( constant_data.transpose(bad_pixel_loading[constant_type]), dtype=np.uint32, - ) + )[:self.constant_memory_cells] elif constant_type in other_constant_loading: transpose_order, gpu_buffer = other_constant_loading[constant_type] gpu_buffer.set( np.transpose( constant_data.astype(np.float32), transpose_order, - ) + )[:self.constant_memory_cells] ) else: raise ValueError(f"Unhandled constant type {constant_type}")