@@ -287,7 +287,7 @@ def test_copy_tool() -> None:
287
287
)
288
288
def test_momentum_correction_workflow (features : np .ndarray ) -> None :
289
289
"""Test for the momentum correction workflow"""
290
- config = {"core" : {"loader" : "mpes" }}
290
+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
291
291
processor = SedProcessor (
292
292
folder = df_folder ,
293
293
config = config ,
@@ -296,7 +296,7 @@ def test_momentum_correction_workflow(features: np.ndarray) -> None:
296
296
system_config = {},
297
297
verbose = True ,
298
298
)
299
- processor .bin_and_load_momentum_calibration (apply = True )
299
+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
300
300
assert processor .mc .slice is not None
301
301
assert processor .mc .pouter is None
302
302
if len (features ) == 5 or len (features ) == 7 :
@@ -339,7 +339,7 @@ def test_momentum_correction_workflow(features: np.ndarray) -> None:
339
339
340
340
def test_pose_adjustment () -> None :
341
341
"""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 } }
343
343
processor = SedProcessor (
344
344
folder = df_folder ,
345
345
config = config ,
@@ -351,7 +351,7 @@ def test_pose_adjustment() -> None:
351
351
# pose adjustment w/o loaded image
352
352
processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
353
353
354
- processor .bin_and_load_momentum_calibration (apply = True )
354
+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
355
355
# test pose adjustment
356
356
processor .pose_adjustment (** adjust_params , use_correction = False , apply = True )
357
357
@@ -365,7 +365,7 @@ def test_pose_adjustment() -> None:
365
365
)
366
366
with pytest .raises (ValueError ):
367
367
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 )
369
369
processor .define_features (
370
370
features = feature7 ,
371
371
rotation_symmetry = 6 ,
@@ -383,10 +383,72 @@ def test_pose_adjustment() -> None:
383
383
processor .pose_adjustment (** adjust_params , apply = True , illegal_kwd = True )
384
384
385
385
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
+
386
448
def test_pose_adjustment_save_load () -> None :
387
449
"""Test for the saving and loading of pose correction and application of momentum correction
388
450
workflow"""
389
- config = {"core" : {"loader" : "mpes" }}
451
+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
390
452
# pose adjustment w/ loaded image
391
453
processor = SedProcessor (
392
454
folder = df_folder ,
@@ -396,7 +458,7 @@ def test_pose_adjustment_save_load() -> None:
396
458
system_config = {},
397
459
verbose = True ,
398
460
)
399
- processor .bin_and_load_momentum_calibration (apply = True )
461
+ processor .bin_and_load_momentum_calibration (plane = 200 , width = 20 , apply = True )
400
462
processor .define_features (
401
463
features = feature7 ,
402
464
rotation_symmetry = 6 ,
@@ -458,7 +520,7 @@ def test_pose_adjustment_save_load() -> None:
458
520
459
521
def test_momentum_calibration_workflow () -> None :
460
522
"""Test the calibration of the momentum axes"""
461
- config = {"core" : {"loader" : "mpes" }}
523
+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
462
524
processor = SedProcessor (
463
525
folder = df_folder ,
464
526
config = config ,
@@ -471,7 +533,7 @@ def test_momentum_calibration_workflow() -> None:
471
533
processor .apply_momentum_calibration ()
472
534
with pytest .raises (ValueError ):
473
535
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 )
475
537
with pytest .raises (AssertionError ):
476
538
processor .calibrate_momentum_axes (point_a = point_a , apply = True )
477
539
processor .calibrate_momentum_axes (point_a = point_a , k_distance = k_distance , apply = True )
@@ -508,7 +570,7 @@ def test_momentum_calibration_workflow() -> None:
508
570
509
571
def test_energy_correction () -> None :
510
572
"""Test energy correction workflow."""
511
- config = {"core" : {"loader" : "mpes" }}
573
+ config = {"core" : {"loader" : "mpes" }, "dataframe" : { "tof_binning" : 2 } }
512
574
processor = SedProcessor (
513
575
folder = df_folder ,
514
576
config = config ,
0 commit comments