Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
221a0656
Commit
221a0656
authored
1 year ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
remove unneeded replace_pixels_wrong_gain_badpixel
parent
15367405
No related branches found
No related tags found
1 merge request
!916
[Jungfrau][Correct] Force replacement for gain value in Jungfrau correction
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cal_tools/jungfraulib.py
+2
-47
2 additions, 47 deletions
src/cal_tools/jungfraulib.py
tests/test_jungfraulib.py
+0
-18
0 additions, 18 deletions
tests/test_jungfraulib.py
with
2 additions
and
65 deletions
src/cal_tools/jungfraulib.py
+
2
−
47
View file @
221a0656
...
...
@@ -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
This diff is collapsed.
Click to expand it.
tests/test_jungfraulib.py
+
0
−
18
View file @
221a0656
...
...
@@ -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
,
)
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment