def test_sech(self): """Test sech pulse.""" amp = 0.5 center = 20 sigma = 2 times, dt = np.linspace(0, 40, 1001, retstep=True) sech_arr = continuous.sech(times, amp, center, sigma) sech_arr_zeroed = continuous.sech(np.array([-1, 20]), amp, center, sigma) self.assertEqual(sech_arr.dtype, np.complex_) center_time = np.argmax(sech_arr) self.assertAlmostEqual(times[center_time], center) self.assertAlmostEqual(sech_arr[center_time], amp) self.assertAlmostEqual(sech_arr_zeroed[0], 0., places=2) self.assertAlmostEqual(sech_arr_zeroed[1], amp) self.assertAlmostEqual(np.sum(sech_arr*dt), amp*np.pi*sigma, places=3)
def test_sech(self): """Test sech pulse.""" amp = 0.5 sigma = 2 duration = 10 center = duration/2 times = np.arange(0, duration) + 0.5 sech_ref = continuous.sech(times, amp, center, sigma, zeroed_width=2*(center+1), rescale_amp=True) sech_pulse = library.sech(duration, amp, sigma) self.assertIsInstance(sech_pulse, Waveform) np.testing.assert_array_almost_equal(sech_pulse.samples, sech_ref)