@@ -297,3 +297,93 @@ def test_get_darks_flats_different_file(preview_config: PreviewConfig):
297297
298298 np .testing .assert_array_equal (loaded_flats , flats )
299299 np .testing .assert_array_equal (loaded_darks , darks )
300+
301+
302+ def test_ignore_darks_get_separate_flats ():
303+ DARKS_CONFIG = DarksFlatsFileConfig (
304+ file = Path (__file__ ).parent / "" ,
305+ data_path = "" ,
306+ image_key_path = None ,
307+ ignore = True ,
308+ )
309+ FLATS_CONFIG = DarksFlatsFileConfig (
310+ file = Path (__file__ ).parent / "test_data/i12/separate_flats_darks/flat_field.h5" ,
311+ data_path = "/1-NoProcessPlugin-tomo/data" ,
312+ image_key_path = None ,
313+ ignore = False ,
314+ )
315+ PREVIEW_CONFIG = PreviewConfig (
316+ angles = PreviewDimConfig (start = 0 , stop = 180 ),
317+ detector_y = PreviewDimConfig (start = 0 , stop = 128 ),
318+ detector_x = PreviewDimConfig (start = 0 , stop = 160 ),
319+ )
320+
321+ loaded_darks , loaded_flats = get_darks_flats (
322+ DARKS_CONFIG ,
323+ FLATS_CONFIG ,
324+ PREVIEW_CONFIG ,
325+ )
326+
327+ expected_darks = np .zeros (
328+ (
329+ 1 ,
330+ PREVIEW_CONFIG .detector_y .stop - PREVIEW_CONFIG .detector_y .start ,
331+ PREVIEW_CONFIG .detector_x .stop - PREVIEW_CONFIG .detector_x .start ,
332+ ),
333+ dtype = np .uint16 ,
334+ )
335+
336+ with h5py .File (FLATS_CONFIG .file , "r" ) as f :
337+ expected_flats = f [FLATS_CONFIG .data_path ][
338+ :,
339+ PREVIEW_CONFIG .detector_y .start : PREVIEW_CONFIG .detector_y .stop ,
340+ PREVIEW_CONFIG .detector_x .start : PREVIEW_CONFIG .detector_x .stop ,
341+ ]
342+
343+ np .testing .assert_array_equal (loaded_flats , expected_flats )
344+ np .testing .assert_array_equal (loaded_darks , expected_darks )
345+
346+
347+ def test_ignore_flats_get_separate_darks ():
348+ DARKS_CONFIG = DarksFlatsFileConfig (
349+ file = Path (__file__ ).parent / "test_data/i12/separate_flats_darks/dark_field.h5" ,
350+ data_path = "/1-NoProcessPlugin-tomo/data" ,
351+ image_key_path = None ,
352+ ignore = False ,
353+ )
354+ FLATS_CONFIG = DarksFlatsFileConfig (
355+ file = Path (__file__ ).parent / "" ,
356+ data_path = "" ,
357+ image_key_path = None ,
358+ ignore = True ,
359+ )
360+ PREVIEW_CONFIG = PreviewConfig (
361+ angles = PreviewDimConfig (start = 0 , stop = 180 ),
362+ detector_y = PreviewDimConfig (start = 0 , stop = 128 ),
363+ detector_x = PreviewDimConfig (start = 0 , stop = 160 ),
364+ )
365+
366+ loaded_darks , loaded_flats = get_darks_flats (
367+ DARKS_CONFIG ,
368+ FLATS_CONFIG ,
369+ PREVIEW_CONFIG ,
370+ )
371+
372+ expected_flats = np .ones (
373+ (
374+ 1 ,
375+ PREVIEW_CONFIG .detector_y .stop - PREVIEW_CONFIG .detector_y .start ,
376+ PREVIEW_CONFIG .detector_x .stop - PREVIEW_CONFIG .detector_x .start ,
377+ ),
378+ dtype = np .uint16 ,
379+ )
380+
381+ with h5py .File (DARKS_CONFIG .file , "r" ) as f :
382+ expected_darks = f [DARKS_CONFIG .data_path ][
383+ :,
384+ PREVIEW_CONFIG .detector_y .start : PREVIEW_CONFIG .detector_y .stop ,
385+ PREVIEW_CONFIG .detector_x .start : PREVIEW_CONFIG .detector_x .stop ,
386+ ]
387+
388+ np .testing .assert_array_equal (loaded_flats , expected_flats )
389+ np .testing .assert_array_equal (loaded_darks , expected_darks )
0 commit comments