@@ -41,6 +41,8 @@ def test_grating_1d_fit():
4141
4242 cal .fit ()
4343
44+ import matplotlib as mpl
45+ mpl .use ('Agg' )
4446 cal .plot ()
4547
4648 assert np .isclose (cal .e0 , true_offset , atol = 1e-2 , rtol = 1e-2 )
@@ -66,6 +68,8 @@ def test_grating_2d_fit():
6668
6769 cal .fit ()
6870
71+ import matplotlib as mpl
72+ mpl .use ('Agg' )
6973 cal .plot ()
7074
7175 assert np .isclose (cal .e0 , true_offset , atol = 1e-2 , rtol = 1e-2 )
@@ -96,6 +100,16 @@ def test_reading_grating1d(mock_sqs_grating_calibration_run, tmp_path):
96100 final_photon_spectrometer = "SQS_EXP_GH2-2/CORR/RECEIVER:daqOutput"
97101
98102 monochromator_scan = Scan (mock_sqs_grating_calibration_run [monochromator_energy , "actualEnergy" ], resolution = 1 )
103+
104+ # fit without motor
105+ grating_calibration = Grating1DCalibration (min_pixel = 0 , max_pixel = 1000 )
106+ grating_calibration .setup (mock_sqs_grating_calibration_run [final_photon_spectrometer , "data.adc" ],
107+ monochromator_scan ,
108+ pulses = XrayPulses (mock_sqs_grating_calibration_run ),
109+ grating_mask = mock_sqs_grating_calibration_run [final_photon_spectrometer , "data.mask" ],
110+ )
111+
112+ # use motor information
99113 grating_calibration = Grating1DCalibration (min_pixel = 0 , max_pixel = 1000 )
100114 grating_calibration .setup (mock_sqs_grating_calibration_run [final_photon_spectrometer , "data.adc" ],
101115 monochromator_scan ,
@@ -109,9 +123,15 @@ def test_reading_grating1d(mock_sqs_grating_calibration_run, tmp_path):
109123 grating_calibration .to_file (fpath )
110124 grating_calibration = Grating1DCalibration .from_file (fpath )
111125
126+ # with motor
112127 calibrated = grating_calibration .apply (mock_sqs_grating_calibration_run .select_trains (np .s_ [10 :20 ]), assume_motor = 0.0 )
113128
114129 assert np .isclose (grating_calibration .e0 , 990.0 , atol = 1e-2 , rtol = 1e-2 )
115130 assert np .isclose (grating_calibration .slope , 20.0 / 1000.0 , atol = 1e-2 , rtol = 1e-2 )
116131
132+ # without motor
133+ calibrated = grating_calibration .apply (mock_sqs_grating_calibration_run .select_trains (np .s_ [10 :20 ]))
134+
135+ assert np .isclose (grating_calibration .e0 , 990.0 , atol = 1e-2 , rtol = 1e-2 )
136+ assert np .isclose (grating_calibration .slope , 20.0 / 1000.0 , atol = 1e-2 , rtol = 1e-2 )
117137
0 commit comments