Skip to content
Snippets Groups Projects
Commit 480057f9 authored by David Hammer's avatar David Hammer
Browse files

Slice down constant memory cells to expected number (big detectors)

parent eef8fa4e
Branches update_dep_calParrot_extradata
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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):
......
......@@ -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}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment