|
12 | 12 | raven_filter, |
13 | 13 | ) |
14 | 14 | from numpy.testing import assert_allclose |
15 | | -from .stripe_cpu_reference import raven_filter_numpy |
16 | 15 |
|
17 | 16 |
|
18 | 17 | def test_remove_stripe_ti_on_data(data, flats, darks): |
@@ -62,45 +61,17 @@ def test_stripe_removal_sorting_cupy(data, flats, darks): |
62 | 61 |
|
63 | 62 |
|
64 | 63 | def test_stripe_raven_cupy(data, flats, darks): |
65 | | - # --- testing the CuPy port of TomoPy's implementation ---# |
66 | | - |
67 | | - data = normalize(data, flats, darks, cutoff=10, minus_log=True) |
68 | | - |
69 | | - data_after_raven_gpu = raven_filter(cp.copy(data)).get() |
70 | | - data_after_raven_cpu = raven_filter_numpy(cp.copy(data).get()) |
71 | | - |
72 | | - assert_allclose(data_after_raven_cpu, data_after_raven_gpu, rtol=0, atol=4e-01) |
| 64 | + data_norm = dark_flat_field_correction(cp.copy(data), flats, darks, cutoff=10) |
| 65 | + data_norm = minus_log(data_norm) |
73 | 66 |
|
| 67 | + data_after_raven_gpu = cp.asnumpy(raven_filter(data_norm)) |
| 68 | + |
74 | 69 | data = None #: free up GPU memory |
| 70 | + assert_allclose(np.mean(data_after_raven_gpu), 0.2892464, rtol=1e-06) |
| 71 | + |
75 | 72 | # make sure the output is float32 |
76 | 73 | assert data_after_raven_gpu.dtype == np.float32 |
77 | | - assert data_after_raven_gpu.shape == data_after_raven_cpu.shape |
78 | | - |
79 | | - |
80 | | -@pytest.mark.parametrize("uvalue", [20, 50, 100]) |
81 | | -@pytest.mark.parametrize("nvalue", [2, 4, 6]) |
82 | | -@pytest.mark.parametrize("vvalue", [2, 4]) |
83 | | -@pytest.mark.parametrize("pad_x", [0, 10, 20]) |
84 | | -@pytest.mark.parametrize("pad_y", [0, 10, 20]) |
85 | | -@cp.testing.numpy_cupy_allclose(rtol=0, atol=3e-01) |
86 | | -def test_stripe_raven_parameters_cupy( |
87 | | - ensure_clean_memory, xp, uvalue, nvalue, vvalue, pad_x, pad_y |
88 | | -): |
89 | | - # because it's random, we explicitly seed and use numpy only, to match the data |
90 | | - np.random.seed(12345) |
91 | | - data = np.random.random_sample(size=(256, 5, 512)).astype(np.float32) * 2.0 + 0.001 |
92 | | - data = xp.asarray(data) |
93 | | - |
94 | | - if xp.__name__ == "numpy": |
95 | | - results = raven_filter_numpy( |
96 | | - data, uvalue=uvalue, nvalue=nvalue, vvalue=vvalue, pad_x=pad_x, pad_y=pad_y |
97 | | - ).astype(np.float32) |
98 | | - else: |
99 | | - results = raven_filter( |
100 | | - data, uvalue=uvalue, nvalue=nvalue, vvalue=vvalue, pad_x=pad_x, pad_y=pad_y |
101 | | - ).get() |
102 | | - |
103 | | - return xp.asarray(results) |
| 74 | + assert data_after_raven_gpu.shape == (180, 128, 160) |
104 | 75 |
|
105 | 76 |
|
106 | 77 | @pytest.mark.perf |
@@ -180,9 +151,11 @@ def test_raven_filter_performance(ensure_clean_memory): |
180 | 151 |
|
181 | 152 | def test_remove_all_stripe_on_data(data, flats, darks): |
182 | 153 | # --- testing the CuPy implementation from TomoCupy ---# |
183 | | - data = normalize(data, flats, darks, cutoff=10, minus_log=True) |
| 154 | + data_norm = dark_flat_field_correction(cp.copy(data), flats, darks, cutoff=10) |
| 155 | + data_norm = minus_log(data_norm) |
| 156 | + |
184 | 157 |
|
185 | | - data_after_stripe_removal = remove_all_stripe(cp.copy(data)).get() |
| 158 | + data_after_stripe_removal = cp.asnumpy(remove_all_stripe(data_norm)) |
186 | 159 |
|
187 | 160 | assert_allclose(np.mean(data_after_stripe_removal), 0.266914, rtol=1e-05) |
188 | 161 | assert_allclose( |
|
0 commit comments