Commit e269987d authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Add test with FlatField NaN handling

parent 10fe99e7
Pipeline #73795 passed with stage
in 5 minutes and 54 seconds
......@@ -286,8 +286,9 @@ class TestFlatField:
darks[dark_idx] = get_data(dark_url)
darks[dark_idx][0, 0] = 99
radios[:, 0, 0] = 99
radios0 = radios.copy()
# FlatField() without NaN handling yields NaN and raises RuntimeWarning
# 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
......@@ -298,6 +299,19 @@ class TestFlatField:
radios[:, 0, 0] = radios[:, 1, 1]
self.check_normalized_radios(radios, config["expected_result"])
# FlatField with NaN handling
nan_value = 50
radios = radios0.copy()
FF_with_nan_handling = FlatField(
radios.shape, flats, darks,
radios_indices=config["radios_indices"], nan_value=nan_value
)
with pytest.warns(RuntimeWarning):
FF_with_nan_handling.normalize_radios(radios)
assert np.all(np.isfinite(radios)), "No inf/nan value should be there"
assert np.allclose(radios[:, 0, 0], nan_value, atol=1e-7), "Handled NaN should have nan_value=%f" % nan_value
radios[:, 0, 0] = radios[:, 1, 1]
self.check_normalized_radios(radios, config["expected_result"])
# This test should be closer to the ESRF standard setting.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment