Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
Nabu
Commits
10fe99e7
Commit
10fe99e7
authored
May 02, 2022
by
Pierre Paleo
Browse files
Add test for unhandled NaN values
parent
530807b9
Pipeline
#73792
passed with stage
in 6 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nabu/preproc/tests/test_flatfield.py
View file @
10fe99e7
...
...
@@ -277,25 +277,29 @@ class TestFlatField:
"""
radios
,
flats
,
darks
,
config
=
self
.
get_test_elements
(
"two_flats_with_radios_indices"
)
# Retrieve the actual data for radios/darks/flats to use FlatField instead of FlatFieldDataUrl.
# Create a setting yielding "0/0": one pixel such that flat==dark and radio==dark
for
flat_idx
,
flat_url
in
flats
.
items
():
flats
[
flat_idx
]
=
get_data
(
flat_url
)
flats
[
flat_idx
][
0
,
0
]
=
99
for
dark_idx
,
dark_url
in
darks
.
items
():
darks
[
dark_idx
]
=
get_data
(
dark_url
)
darks
[
dark_idx
][
0
,
0
]
=
99
radios
[:,
0
,
0
]
=
99
radios
[
0
]
==
darks
[
0
]
flats
[
list
(
flats
.
keys
())[
0
]]
=
darks
[
0
]
FF
=
FlatField
(
radios
.
shape
,
flats
,
darks
,
radios_indices
=
config
[
"radios_indices"
])
FF
.
normalize_radios
(
radios
)
# TODO adapt expected results to account for modified radios[0] and flats[0]. The interpolation is different!
# FlatField() without NaN handling yields NaN and raises RuntimeWarning
FF_no_nan_handling
=
FlatField
(
radios
.
shape
,
flats
,
darks
,
radios_indices
=
config
[
"radios_indices"
],
nan_value
=
None
)
with
pytest
.
warns
(
RuntimeWarning
):
FF_no_nan_handling
.
normalize_radios
(
radios
)
assert
np
.
alltrue
(
np
.
logical_not
(
np
.
isfinite
(
radios
[:,
0
,
0
]))),
"First pixel should be nan or inf"
radios
[:,
0
,
0
]
=
radios
[:,
1
,
1
]
self
.
check_normalized_radios
(
radios
,
config
[
"expected_result"
])
# This test should be closer to the ESRF standard setting.
# There are 2 flats, one dark, 4000 radios.
# dark : indice=0 value=10
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment