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

Start handling slopes_ff

parent b7d900af
No related branches found
No related tags found
2 merge requests!12Snapshot: field test deployed version as of end of run 202201,!3Base correction device, CalCat interaction, DSSC and AGIPD devices
...@@ -92,10 +92,20 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner): ...@@ -92,10 +92,20 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner):
nan_bool = np.isnan(naughty_array) nan_bool = np.isnan(naughty_array)
nan_cell, _, _ = np.where(nan_bool) nan_cell, _, _ = np.where(nan_bool)
naughty_array[nan_bool] = medians[nan_cell] naughty_array[nan_bool] = medians[nan_cell]
# TODO: clamp values outside range (0.8 to 1.2) * median to median
# TODO: verify that this clamping should be done (as in agipdlib.py)
too_low_bool = naughty_array < 0.8 * medians[:, np.newaxis, np.newaxis]
too_low_cell, _, _ = np.where(too_low_bool)
naughty_array[too_low_bool] = medians[too_low_cell]
too_high_bool = naughty_array > 1.2 * medians[:, np.newaxis, np.newaxis]
too_high_cell, _, _ = np.where(too_high_bool)
naughty_array[too_high_bool] = medians[too_high_cell]
frac_hg_mg = hg_slope / mg_slope frac_hg_mg = hg_slope / mg_slope
md_additional_offset = (hg_intercept - mg_intercept * frac_hg_mg).astype(np.float32) md_additional_offset = (hg_intercept - mg_intercept * frac_hg_mg).astype(
np.float32
)
rel_gain_map = np.ones( rel_gain_map = np.ones(
(3, self.constant_memory_cells, self.pixels_y, self.pixels_x), (3, self.constant_memory_cells, self.pixels_y, self.pixels_x),
dtype=np.float32, dtype=np.float32,
...@@ -109,13 +119,23 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner): ...@@ -109,13 +119,23 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner):
def load_rel_gain_ff_map(self, slopes_ff_map): def load_rel_gain_ff_map(self, slopes_ff_map):
# constant shape: y, x, memory cell # constant shape: y, x, memory cell
if slopes_ff_map.shape[2] == 2: if slopes_ff_map.shape[2] == 2:
# old format, is per pixel only # old format, is per pixel only (shape is y, x, 2)
raise NotImplementedError("Old slopes FF map format") 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
...
# TODO: maybe clamp and replace NaNs like slopes_pc
self.rel_gain_xray_map_gpu.set(np.transpose(slopes_ff_map).astype(np.float32)) self.rel_gain_xray_map_gpu.set(np.transpose(slopes_ff_map).astype(np.float32))
def correct(self, flags): def correct(self, flags):
if flags & CorrectionFlags.BLSHIFT: if flags & CorrectionFlags.BLSHIFT:
raise NotImplementedError("Baseline shift not implemented yet") raise NotImplementedError("Baseline shift not implemented yet")
if flags & CorrectionFlags.BPMASK:
raise NotImplementedError("Bad pixel masking not implemented yet")
self.correction_kernel( self.correction_kernel(
self.full_grid, self.full_grid,
self.full_block, self.full_block,
......
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