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
8c596c0a
Commit
8c596c0a
authored
1 year ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
add tests for the new gain replacement functions
parent
cfd8e2bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!916
[Jungfrau][Correct] Force replacement for gain value in Jungfrau correction
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_jungfraulib.py
+69
-1
69 additions, 1 deletion
tests/test_jungfraulib.py
with
69 additions
and
1 deletion
tests/test_jungfraulib.py
+
69
−
1
View file @
8c596c0a
import
numpy
as
np
import
pytest
from
extra_data
import
RunDirectory
from
cal_tools.jungfraulib
import
JungfrauCtrl
,
sort_runs_by_gain
from
cal_tools.enums
import
BadPixels
from
cal_tools.jungfraulib
import
(
JungfrauCtrl
,
replace_pixels_gain_values
,
replace_pixels_wrong_gain_badpixel
,
sort_runs_by_gain
,
)
# TODO: replace with mocked RAW data as in tests/test_agipdlib.py
JF
=
JungfrauCtrl
(
...
...
@@ -64,3 +71,64 @@ def test_sort_runs_by_gain(original_runs, sorted_runs):
runs
=
original_runs
,
ctrl_src
=
"
FXE_XAD_JF1M/DET/CONTROL
"
)
assert
validated_runs
==
sorted_runs
GAIN
=
np
.
zeros
((
1
,
512
,
1024
),
dtype
=
np
.
uint8
)
NEW_GAIN
=
GAIN
.
copy
()
# all pixels in high gain.
GAIN
[:,
0
:
255
,
896
:
1024
]
=
3
# subsection of a chip is stuck in gain bit = 3
BP
=
np
.
zeros
((
512
,
1024
,
3
),
dtype
=
np
.
uint32
)
for
i
in
range
(
3
):
BP
[
0
:
255
,
896
:
1024
,
i
]
=
BadPixels
.
WRONG_GAIN_VALUE
.
value
MEM_CELLS
=
1
KARABO_DA
=
"
JNGFR04
"
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
,
replace_pixels_gain_values
(
gain_arr
=
GAIN
,
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
(
NEW_GAIN
,
replace_pixels_gain_values
(
gain_arr
=
GAIN
,
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
(
GAIN
,
# No replacement for non-selected module.
replace_pixels_gain_values
(
gain_arr
=
GAIN
,
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