diff --git a/src/cal_tools/jungfraulib.py b/src/cal_tools/jungfraulib.py index c8f15c2469a30fb4cd7bfbfe38094c3be8b7d239..c27352e432b0b0cc03fa574be8a97b05b8f6db3a 100644 --- a/src/cal_tools/jungfraulib.py +++ b/src/cal_tools/jungfraulib.py @@ -211,50 +211,14 @@ def sort_runs_by_gain( return runs -def replace_pixels_wrong_gain_badpixel( - gain_arr, - new_gain_value, - badpixel_map, - memory_cells, -): - """Replace the gain value with the given new gain value for pixels - indicated as bad with WRONG_GAIN_VALUE bit. - - Args: - gain_arr (ndarray): The raw gain array to be updated. - new_gain_value (int): The new gain value to replace the gain value - for the pixels with WRONG_GAIN_VALUE badpixel. - badpixel_map (ndarray): The badpixel map for a cell. - memory_cells (int): Number of memory cells for the processed detector. - - Returns: - ndarray: The updated gain_arr - """ - import numpy as np - from cal_tools.enums import BadPixels - - # replace gain with WRONG_GAIN_VALUE pixels in the badpixel mask - wrong_gain_mask = BadPixels.WRONG_GAIN_VALUE.value - - # Create a boolean mask to identify the elements that meet the condition - condition_mask = (badpixel_map[..., new_gain_value] & wrong_gain_mask) == wrong_gain_mask - - if memory_cells == 1: - condition_mask = condition_mask[np.newaxis, :, :] # gain_arr.shape = [1, 512, 1024] - - gain_arr[condition_mask] = new_gain_value - return gain_arr - - def replace_pixels_gain_values( gain_arr, new_gain_value, wrong_gain_pixels, karabo_da, - badpixel_map, - memory_cells ): """Replace gain values with the chosen new gain value + for a single module. Args: gain_arr (ndarray): The raw gain array to be updated. @@ -262,7 +226,6 @@ def replace_pixels_gain_values( wrong_gain_pixels (list): [module_index, row1, row12, col1, col2]. e.g. [4, 0, 255, 896, 1024] for JNGFR04 slicing module [0:255, 896:1024]. karabo_da (str): _description_ - badpixel_map (ndarray): The badpixel map for one cell. memory_cells (int): Number of memory cells. Returns: @@ -278,12 +241,4 @@ def replace_pixels_gain_values( gain_arr[:, x1:x2, y1:y2] = new_gain_value return gain_arr else: # No gain replacement - return gain_arr - - else: # replace gain with WRONG_GAIN_VALUE pixels in the badpixel mask - return replace_pixels_wrong_gain_badpixel( - gain_arr, - new_gain_value, - badpixel_map, - memory_cells, - ) \ No newline at end of file + return gain_arr \ No newline at end of file diff --git a/tests/test_jungfraulib.py b/tests/test_jungfraulib.py index 90e4842f26fa0f0f936b5da73f9b5191d5636f3f..809976c7b9a1ebf9af446d2eecf273e9abf0ba70 100644 --- a/tests/test_jungfraulib.py +++ b/tests/test_jungfraulib.py @@ -86,18 +86,6 @@ REPLACE_WRONG_GAIN_VALUE = 0 WRONG_GAIN_PIXELS = [4, 0, 255, 896, 1024] -def test_replace_pixels_wrong_gain_badpixel(): - assert np.allclose( - NEW_GAIN, - replace_pixels_wrong_gain_badpixel( - gain_arr=GAIN, - new_gain_value=REPLACE_WRONG_GAIN_VALUE, - badpixel_map=BP, - memory_cells=MEM_CELLS, - ) - ) - - def test_replace_pixels_gain_values(): assert np.allclose( NEW_GAIN, @@ -106,8 +94,6 @@ def test_replace_pixels_gain_values(): new_gain_value=REPLACE_WRONG_GAIN_VALUE, wrong_gain_pixels=WRONG_GAIN_PIXELS, karabo_da=KARABO_DA, - badpixel_map=BP, - memory_cells=MEM_CELLS, ) ) assert np.allclose( @@ -117,8 +103,6 @@ def test_replace_pixels_gain_values(): new_gain_value=REPLACE_WRONG_GAIN_VALUE, wrong_gain_pixels=WRONG_GAIN_PIXELS, karabo_da=KARABO_DA, - badpixel_map=BP, - memory_cells=MEM_CELLS, ) ) assert np.allclose( @@ -128,7 +112,5 @@ def test_replace_pixels_gain_values(): new_gain_value=REPLACE_WRONG_GAIN_VALUE, wrong_gain_pixels=WRONG_GAIN_PIXELS, karabo_da="JNGFR01", - badpixel_map=BP, - memory_cells=MEM_CELLS, ) )