Commit 56adb16a authored by Pierre Paleo's avatar Pierre Paleo
Browse files

Starting test for flats with numerical issue

parent 8b5d3691
Pipeline #73053 failed with stage
in 5 minutes and 59 seconds
......@@ -3,10 +3,10 @@ import os
import numpy as np
import pytest
from silx.io.url import DataUrl
from silx.third_party.EdfFile import EdfFile
from silx.io import get_data
from silx.io.dictdump import dicttoh5
from nabu.cuda.utils import get_cuda_context, __has_pycuda__
from nabu.preproc.flatfield import FlatFieldDataUrls
from nabu.preproc.flatfield import FlatField, FlatFieldDataUrls
if __has_pycuda__:
import pycuda.gpuarray as garray
......@@ -121,7 +121,7 @@ def generate_test_flatfield_generalized(
darks_urls = {}
for i, dark_idx in enumerate(darks_indices):
darks["darks_%04d" % dark_idx] = np.zeros(img_shape, dtype=dtype) + darks_values[i]
darks_urls[flat_idx] = DataUrl(
darks_urls[dark_idx] = DataUrl(
file_path=testffname, data_path=str("/darks/darks_%04d" % dark_idx), scheme="silx"
)
......@@ -264,22 +264,37 @@ class TestFlatField:
# Linear interpolation, two flats, one dark
def test_twoflats_simple(self):
config = flatfield_tests_cases["two_flats_with_radios_indices"]
radios, flats, darks = generate_test_flatfield_generalized(
config["image_shape"],
config["radios_indices"],
config["radios_values"],
config["flats_indices"],
config["flats_values"],
config["darks_indices"],
config["darks_values"],
"test_twoflats.h5",
)
radios, flats, darks, config = self.get_test_elements("two_flats_with_radios_indices")
FF = FlatFieldDataUrls(radios.shape, flats, darks, radios_indices=config["radios_indices"])
FF.normalize_radios(radios)
self.check_normalized_radios(radios, config["expected_result"])
def test_twoflats_numerical_issue(self):
"""
Same as above, but for the first radio: I==Dark and Flat==Dark
For this radio, nan is replaced with 1.
"""
radios, flats, darks, config = self.get_test_elements("two_flats_with_radios_indices")
for flat_idx, flat_url in flats.items():
flats[flat_idx] = get_data(flat_url)
for dark_idx, dark_url in darks.items():
darks[dark_idx] = get_data(dark_url)
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!
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.
......
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