def test_find_center3(self): g = Generator(1, 4, 3, 7000) g.generate_freq() a = FFTMethod(*g.data) a.ifft() x, y = find_roi(a.x, a.y) x_peak, _ = find_center(x, y, n_largest=4) assert 6950 < x_peak < 7050
def test_fwhm_detection(self): g = Generator(1, 4, 3, 1000) g.generate_freq() a = FFTMethod(*g.data) a.ifft() x, y = find_roi(a.x, a.y) cent, win_size, order = predict_fwhm(x, y, 1000, 10, prefer_high_order=True, tol=1e-3) assert cent > 1000 assert win_size > 2000
def test_autorun(printing): g = Generator(1, 4, 3, 1000) g.generate() f = FFTMethod(*g.data) with pytest.raises(NotCalculatedException): f.get_pulse_shape_from_array(np.arange(10), np.arange(20)) with unittest.mock.patch("matplotlib.pyplot.show") as mck: phase = f.autorun(enable_printing=printing) assert isinstance(phase, pysprint.core.phase.Phase) mck.assert_called() with pytest.raises(ValueError): f.get_pulse_shape_from_array(np.arange(10), np.arange(20))
def test_ffts_advanced4(self): g = Generator( 2, 2.8, 2.4, delay=1500, GDD=2000, FOD=-100000, pulse_width=25, resolution=0.01, ) g.generate_freq() a, b = g.data f = FFTMethod(a, b) f.ifft() f.window(1500, 1490, window_order=8, plot=False) f.apply_window() f.fft() d, _, _ = f.calculate(order=4, reference_point=2.4) np.testing.assert_array_almost_equal( d, [1500.00, 1999.95, -0.21, -99995.00], decimal=1)
def test_ffts_advanced3(self): g = Generator(2, 2.8, 2.4, delay=1500, TOD=40000, pulse_width=25, resolution=0.01) g.generate_freq() a, b = g.data f = FFTMethod(a, b) f.ifft() f.window(2500, 4830, window_order=12, plot=False) f.apply_window() f.fft() d, _, _ = f.calculate(order=3, reference_point=2.4) np.testing.assert_array_almost_equal(d, [1500.03, 0.03, 39996.60], decimal=2)
def test_ffts_advanced1(self): g = Generator(2, 2.8, 2.4, delay=1500, GD=200, pulse_width=25, resolution=0.01) g.generate_freq() a, b = g.data f = FFTMethod(a, b) f.ifft() f.window(1700, 3300, plot=False) f.apply_window() f.fft() d, _, _ = f.calculate(order=1, reference_point=2.4) np.testing.assert_array_almost_equal(d, [1699.99], decimal=2)
def test_ffts_advanced5(self): g = Generator( 2, 2.8, 2.4, delay=1500, QOD=900000, pulse_width=25, resolution=0.01, ) g.generate_freq() a, b = g.data f = FFTMethod(a, b) f.ifft() f.window(1600, 2950, window_order=12, plot=False) f.apply_window() f.fft() d, _, _ = f.calculate(order=5, reference_point=2.4) np.testing.assert_array_almost_equal( d, [1499.9646, -0.1429, 7.893, 16.075, 898919.85], decimal=1)