1- import time
21import cupy as cp
32import numpy as np
4- from cupy .cuda import nvtx
5- import pytest
6- from numpy .testing import assert_allclose
73from httomolibgpu .misc .morph import sino_360_to_180
8- from httomolibgpu .prep .normalize import normalize
4+ from httomolibgpu .prep .normalize import dark_flat_field_correction
95from conftest import force_clean_gpu_memory
106
117
128def test_sino_360_to_180_i13_dataset1 (i13_dataset1 ):
139 projdata = i13_dataset1 [0 ]
1410 flats = i13_dataset1 [2 ]
1511 darks = i13_dataset1 [3 ]
16- del i13_dataset1
12+ del i13_dataset1
13+
14+ data_normalised = dark_flat_field_correction (projdata , flats , darks , cutoff = 10 )
1715
18- data_normalised = normalize (projdata , flats , darks , minus_log = True )
1916 del flats , darks , projdata
2017 force_clean_gpu_memory ()
2118
2219 stiched_data_180degrees = sino_360_to_180 (
2320 data_normalised , overlap = 473.822265625 , side = "right"
2421 )
25- stiched_data_180degrees = stiched_data_180degrees . get ( )
22+ stiched_data_180degrees = cp . asnumpy ( stiched_data_180degrees )
2623
27- assert_allclose (np .sum (stiched_data_180degrees ), 28512826.0 , rtol = 1e-07 , atol = 1e-6 )
2824 assert stiched_data_180degrees .shape == (3000 , 10 , 4646 )
2925 assert stiched_data_180degrees .dtype == np .float32
3026 assert stiched_data_180degrees .flags .c_contiguous
@@ -36,16 +32,15 @@ def test_sino_360_to_180_i13_dataset3(i13_dataset3):
3632 darks = i13_dataset3 [3 ]
3733 del i13_dataset3
3834
39- data_normalised = normalize (projdata , flats , darks , minus_log = True )
35+ data_normalised = dark_flat_field_correction (projdata , flats , darks , cutoff = 10 )
4036 del flats , darks , projdata
4137 force_clean_gpu_memory ()
4238
4339 stiched_data_180degrees = sino_360_to_180 (
4440 data_normalised , overlap = 438.173828 , side = "left"
4541 )
46- stiched_data_180degrees = stiched_data_180degrees . get ( )
42+ stiched_data_180degrees = cp . asnumpy ( stiched_data_180degrees )
4743
48- assert_allclose (np .sum (stiched_data_180degrees ), 24865750.0 , rtol = 1e-07 , atol = 1e-6 )
4944 assert stiched_data_180degrees .shape == (3000 , 3 , 4682 )
5045 assert stiched_data_180degrees .dtype == np .float32
5146 assert stiched_data_180degrees .flags .c_contiguous
@@ -57,16 +52,15 @@ def test_sino_360_to_180_i12_dataset5(i12_dataset5):
5752 darks = i12_dataset5 [3 ]
5853 del i12_dataset5
5954
60- data_normalised = normalize (projdata , flats , darks , minus_log = True )
55+ data_normalised = dark_flat_field_correction (projdata , flats , darks , cutoff = 10 )
6156 del flats , darks , projdata
6257 force_clean_gpu_memory ()
6358
6459 stiched_data_180degrees = sino_360_to_180 (
6560 data_normalised , overlap = 186.66 , side = "left"
6661 )
67- stiched_data_180degrees = stiched_data_180degrees . get ( )
62+ stiched_data_180degrees = cp . asnumpy ( stiched_data_180degrees )
6863
69- assert_allclose (np .sum (stiched_data_180degrees ), 145920580.0 , rtol = 1e-07 , atol = 1e-6 )
7064 assert stiched_data_180degrees .shape == (1800 , 15 , 4933 )
7165 assert stiched_data_180degrees .dtype == np .float32
72- assert stiched_data_180degrees .flags .c_contiguous
66+ assert stiched_data_180degrees .flags .c_contiguous
0 commit comments