@@ -287,7 +287,7 @@ def test_copy_tool() -> None:
287287)
288288def test_momentum_correction_workflow (features : np .ndarray ) -> None :
289289 """Test for the momentum correction workflow"""
290- config = {"core" : {"loader" : "mpes" }}
290+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
291291 processor = SedProcessor (
292292 folder = df_folder ,
293293 config = config ,
@@ -296,7 +296,7 @@ def test_momentum_correction_workflow(features: np.ndarray) -> None:
296296 system_config = {},
297297 verbose = True ,
298298 )
299- processor .bin_and_load_momentum_calibration (apply = True )
299+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
300300 assert processor .mc .slice is not None
301301 assert processor .mc .pouter is None
302302 if len (features ) == 5 or len (features ) == 7 :
@@ -339,7 +339,7 @@ def test_momentum_correction_workflow(features: np.ndarray) -> None:
339339
340340def test_pose_adjustment () -> None :
341341 """Test for the pose correction and application of momentum correction workflow"""
342- config = {"core" : {"loader" : "mpes" }}
342+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
343343 processor = SedProcessor (
344344 folder = df_folder ,
345345 config = config ,
@@ -351,7 +351,7 @@ def test_pose_adjustment() -> None:
351351 # pose adjustment w/o loaded image
352352 processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
353353
354- processor .bin_and_load_momentum_calibration (apply = True )
354+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
355355 # test pose adjustment
356356 processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
357357
@@ -365,7 +365,7 @@ def test_pose_adjustment() -> None:
365365 )
366366 with pytest .raises (ValueError ):
367367 processor .apply_momentum_correction ()
368- processor .bin_and_load_momentum_calibration (apply = True )
368+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
369369 processor .define_features (
370370 features = feature7 ,
371371 rotation_symmetry = 6 ,
@@ -383,10 +383,72 @@ def test_pose_adjustment() -> None:
383383 processor .pose_adjustment (** adjust_params , apply = True , illegal_kwd = True )
384384
385385
386+ def test_pose_adjustment_use_correction () -> None :
387+ """Test for the use of momentum correction in the pose adjustment workflow"""
388+ config = {"core" : {"loader" : "mpes" }, "dataframe" : {"tof_binning" : 2 }}
389+ processor = SedProcessor (
390+ folder = df_folder ,
391+ config = config ,
392+ folder_config = {},
393+ user_config = {},
394+ system_config = {},
395+ verbose = True ,
396+ )
397+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
398+ # uncorrected reference
399+ processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
400+ uncorrected_slice = processor .mc .slice_transformed .copy ()
401+ uncorrected_cdeform_field = processor .mc .cdeform_field .copy ()
402+ uncorrected_rdeform_field = processor .mc .rdeform_field .copy ()
403+ # apply correction, and use pose adjustment without correction
404+ processor .define_features (
405+ features = feature7 ,
406+ rotation_symmetry = 6 ,
407+ include_center = True ,
408+ apply = True ,
409+ )
410+ processor .generate_splinewarp (use_center = True )
411+ processor .save_splinewarp (filename = "sed_config_pose_adjustments_use_corrections.yaml" )
412+ processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
413+ np .testing .assert_allclose (processor .mc .slice_transformed , uncorrected_slice )
414+ np .testing .assert_allclose (processor .mc .cdeform_field , uncorrected_cdeform_field )
415+ np .testing .assert_allclose (processor .mc .rdeform_field , uncorrected_rdeform_field )
416+ # apply correction, and use pose adjustment with correction
417+ processor .pose_adjustment (** adjust_params , use_correction = True , apply = True )
418+ assert not np .array_equal (processor .mc .slice_transformed , uncorrected_slice )
419+ assert not np .array_equal (processor .mc .cdeform_field , uncorrected_cdeform_field )
420+ assert not np .array_equal (processor .mc .rdeform_field , uncorrected_rdeform_field )
421+ corrected_cdeform_field = processor .mc .cdeform_field .copy ()
422+ corrected_rdeform_field = processor .mc .rdeform_field .copy ()
423+
424+ processor = SedProcessor (
425+ folder = df_folder ,
426+ config = config ,
427+ folder_config = "sed_config_pose_adjustments_use_corrections.yaml" ,
428+ user_config = {},
429+ system_config = {},
430+ verbose = True ,
431+ )
432+ # apply pose correction without loaded image
433+ # uncorrected reference
434+ processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
435+ np .testing .assert_allclose (processor .mc .cdeform_field , uncorrected_cdeform_field )
436+ np .testing .assert_allclose (processor .mc .rdeform_field , uncorrected_rdeform_field )
437+ # apply correction, and use pose adjustment with correction
438+ processor .generate_splinewarp (use_center = True )
439+ processor .pose_adjustment (** adjust_params , use_correction = True , apply = True )
440+ np .testing .assert_allclose (processor .mc .cdeform_field , corrected_cdeform_field )
441+ np .testing .assert_allclose (processor .mc .rdeform_field , corrected_rdeform_field )
442+ # apply correction, and use pose adjustment without correction
443+ processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
444+ np .testing .assert_allclose (processor .mc .cdeform_field , uncorrected_cdeform_field )
445+ np .testing .assert_allclose (processor .mc .rdeform_field , uncorrected_rdeform_field )
446+
447+
386448def test_pose_adjustment_save_load () -> None :
387449 """Test for the saving and loading of pose correction and application of momentum correction
388450 workflow"""
389- config = {"core" : {"loader" : "mpes" }}
451+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
390452 # pose adjustment w/ loaded image
391453 processor = SedProcessor (
392454 folder = df_folder ,
@@ -396,7 +458,7 @@ def test_pose_adjustment_save_load() -> None:
396458 system_config = {},
397459 verbose = True ,
398460 )
399- processor .bin_and_load_momentum_calibration (apply = True )
461+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
400462 processor .define_features (
401463 features = feature7 ,
402464 rotation_symmetry = 6 ,
@@ -458,7 +520,7 @@ def test_pose_adjustment_save_load() -> None:
458520
459521def test_momentum_calibration_workflow () -> None :
460522 """Test the calibration of the momentum axes"""
461- config = {"core" : {"loader" : "mpes" }}
523+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
462524 processor = SedProcessor (
463525 folder = df_folder ,
464526 config = config ,
@@ -471,7 +533,7 @@ def test_momentum_calibration_workflow() -> None:
471533 processor .apply_momentum_calibration ()
472534 with pytest .raises (ValueError ):
473535 processor .calibrate_momentum_axes (apply = True )
474- processor .bin_and_load_momentum_calibration (apply = True )
536+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
475537 with pytest .raises (AssertionError ):
476538 processor .calibrate_momentum_axes (point_a = point_a , apply = True )
477539 processor .calibrate_momentum_axes (point_a = point_a , k_distance = k_distance , apply = True )
@@ -508,7 +570,7 @@ def test_momentum_calibration_workflow() -> None:
508570
509571def test_energy_correction () -> None :
510572 """Test energy correction workflow."""
511- config = {"core" : {"loader" : "mpes" }}
573+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
512574 processor = SedProcessor (
513575 folder = df_folder ,
514576 config = config ,
0 commit comments