@@ -299,6 +299,81 @@ def test_get_darks_flats_different_file(preview_config: PreviewConfig):
299299 np .testing .assert_array_equal (loaded_darks , darks )
300300
301301
302+ @pytest .mark .parametrize (
303+ "preview_config" ,
304+ [
305+ PreviewConfig (
306+ angles = PreviewDimConfig (start = 0 , stop = 180 ),
307+ detector_y = PreviewDimConfig (start = 0 , stop = 128 ),
308+ detector_x = PreviewDimConfig (start = 0 , stop = 160 ),
309+ ),
310+ PreviewConfig (
311+ angles = PreviewDimConfig (start = 0 , stop = 180 ),
312+ detector_y = PreviewDimConfig (start = 0 , stop = 10 ),
313+ detector_x = PreviewDimConfig (start = 0 , stop = 160 ),
314+ ),
315+ PreviewConfig (
316+ angles = PreviewDimConfig (start = 0 , stop = 180 ),
317+ detector_y = PreviewDimConfig (start = 10 , stop = 20 ),
318+ detector_x = PreviewDimConfig (start = 0 , stop = 160 ),
319+ ),
320+ PreviewConfig (
321+ angles = PreviewDimConfig (start = 0 , stop = 180 ),
322+ detector_y = PreviewDimConfig (start = 0 , stop = 128 ),
323+ detector_x = PreviewDimConfig (start = 0 , stop = 10 ),
324+ ),
325+ PreviewConfig (
326+ angles = PreviewDimConfig (start = 0 , stop = 180 ),
327+ detector_y = PreviewDimConfig (start = 0 , stop = 128 ),
328+ detector_x = PreviewDimConfig (start = 10 , stop = 20 ),
329+ ),
330+ ],
331+ ids = [
332+ "no_cropping" ,
333+ "crop_det_y_start_0" ,
334+ "crop_det_y_start_10" ,
335+ "crop_det_x_start_0" ,
336+ "crop_det_x_start_10" ,
337+ ],
338+ )
339+ def test_get_darks_flats_different_file_and_paths (preview_config : PreviewConfig ):
340+ DARKS_CONFIG = DarksFlatsFileConfig (
341+ file = Path (__file__ ).parent
342+ / "test_data/i12/separate_flats_darks/dark_field_different_path.h5" ,
343+ data_path = "/tomo/data" ,
344+ image_key_path = None ,
345+ )
346+ FLATS_CONFIG = DarksFlatsFileConfig (
347+ file = Path (__file__ ).parent / "test_data/i12/separate_flats_darks/flat_field.h5" ,
348+ data_path = "/1-NoProcessPlugin-tomo/data" ,
349+ image_key_path = None ,
350+ )
351+
352+ loaded_darks , loaded_flats = get_darks_flats (
353+ DARKS_CONFIG ,
354+ FLATS_CONFIG ,
355+ preview_config ,
356+ np .uint16 ,
357+ )
358+
359+ with h5py .File (DARKS_CONFIG .file , "r" ) as f :
360+ darks = f [DARKS_CONFIG .data_path ][
361+ :,
362+ preview_config .detector_y .start : preview_config .detector_y .stop ,
363+ preview_config .detector_x .start : preview_config .detector_x .stop ,
364+ ]
365+
366+ with h5py .File (FLATS_CONFIG .file , "r" ) as f :
367+ flats = f [FLATS_CONFIG .data_path ][
368+ :,
369+ preview_config .detector_y .start : preview_config .detector_y .stop ,
370+ preview_config .detector_x .start : preview_config .detector_x .stop ,
371+ ]
372+
373+ np .testing .assert_array_equal (loaded_flats , flats )
374+ np .testing .assert_array_equal (loaded_darks , darks )
375+
376+
302377def test_ignore_darks_get_separate_flats ():
303378 DARKS_CONFIG = None
304379 FLATS_CONFIG = DarksFlatsFileConfig (
0 commit comments