diff --git a/src/calng/agipd_gpu.py b/src/calng/agipd_gpu.py index f6080742f953bd49af7570896cf45975aaf11be8..b03ad918821bcd7bff70a80a7b83b0d15c84193e 100644 --- a/src/calng/agipd_gpu.py +++ b/src/calng/agipd_gpu.py @@ -151,14 +151,40 @@ class AgipdGpuRunner(base_gpu.BaseGpuRunner): def load_badpixels_map(self, badpixels_map): print(f"Loading bad pixels with shape: {badpixels_map.shape}") # will simply OR with already loaded, does not take into account which ones - # TODO: simple loading # TODO: allow configuring subset of bad pixels to care about # TODO: allow configuring value for masked pixels # TODO: inquire what "mask for double size pixels" means if len(badpixels_map.shape) == 3: - # BadPixelsFF is not per gain stage... - # TODO: broadcast? - ... + if badpixels_map.shape == ( + self.pixels_y, + self.pixels_x, + self.constant_memory_cells, + ): + # BadPixelsFF is not per gain stage - broadcasting along gain dimension + self.badpixel_map_gpu |= cupy.asarray( + np.broadcast_to( + np.transpose(badpixels_map)[..., np.newaxis], + self.gm_map_shape, + ), + dtype=np.uint32, + ) + elif badpixels_map.shape == ( + self.constant_memory_cells, + self.pixels_y, + self.pixels_x, + ): + # oh, can also be old bad pixels pc? + self.badpixel_map_gpu |= cupy.asarray( + np.broadcast_to( + np.transpose(badpixels_map, (0, 2, 1))[..., np.newaxis], + self.gm_map_shape, + ), + dtype=np.uint32, + ) + else: + raise ValueError( + f"What in the world is this shape? {badpixels_map.shape}" + ) else: self.badpixel_map_gpu |= cupy.asarray( np.transpose(badpixels_map, (2, 1, 0, 3)), dtype=np.uint32 @@ -221,24 +247,24 @@ class BadPixelValues(enum.IntFlag): Straight from pycalibration's enum.py""" - OFFSET_OUT_OF_THRESHOLD = 0b000000000000000000001 # bit 1 - NOISE_OUT_OF_THRESHOLD = 0b000000000000000000010 # bit 2 - OFFSET_NOISE_EVAL_ERROR = 0b000000000000000000100 # bit 3 - NO_DARK_DATA = 0b000000000000000001000 # bit 4 - CI_GAIN_OF_OF_THRESHOLD = 0b000000000000000010000 # bit 5 - CI_LINEAR_DEVIATION = 0b000000000000000100000 # bit 6 - CI_EVAL_ERROR = 0b000000000000001000000 # bit 7 - FF_GAIN_EVAL_ERROR = 0b000000000000010000000 # bit 8 - FF_GAIN_DEVIATION = 0b000000000000100000000 # bit 9 - FF_NO_ENTRIES = 0b000000000001000000000 # bit 10 - CI2_EVAL_ERROR = 0b000000000010000000000 # bit 11 - VALUE_IS_NAN = 0b000000000100000000000 # bit 12 - VALUE_OUT_OF_RANGE = 0b000000001000000000000 # bit 13 - GAIN_THRESHOLDING_ERROR = 0b000000010000000000000 # bit 14 - DATA_STD_IS_ZERO = 0b000000100000000000000 # bit 15 - ASIC_STD_BELOW_NOISE = 0b000001000000000000000 # bit 16 - INTERPOLATED = 0b000010000000000000000 # bit 17 - NOISY_ADC = 0b000100000000000000000 # bit 18 - OVERSCAN = 0b001000000000000000000 # bit 19 - NON_SENSITIVE = 0b010000000000000000000 # bit 20 - NON_LIN_RESPONSE_REGION = 0b100000000000000000000 # bit 21 + OFFSET_OUT_OF_THRESHOLD = 2 ** 0 + NOISE_OUT_OF_THRESHOLD = 2 ** 1 + OFFSET_NOISE_EVAL_ERROR = 2 ** 2 + NO_DARK_DATA = 2 ** 3 + CI_GAIN_OF_OF_THRESHOLD = 2 ** 4 + CI_LINEAR_DEVIATION = 2 ** 5 + CI_EVAL_ERROR = 2 ** 6 + FF_GAIN_EVAL_ERROR = 2 ** 7 + FF_GAIN_DEVIATION = 2 ** 8 + FF_NO_ENTRIES = 2 ** 9 + CI2_EVAL_ERROR = 2 ** 10 + VALUE_IS_NAN = 2 ** 11 + VALUE_OUT_OF_RANGE = 2 ** 12 + GAIN_THRESHOLDING_ERROR = 2 ** 13 + DATA_STD_IS_ZERO = 2 ** 14 + ASIC_STD_BELOW_NOISE = 2 ** 15 + INTERPOLATED = 2 ** 16 + NOISY_ADC = 2 ** 17 + OVERSCAN = 2 ** 18 + NON_SENSITIVE = 2 ** 19 + NON_LIN_RESPONSE_REGION = 2 ** 20