def test_plot_profile(self): import matplotlib.pyplot as plt phase, prof, _ = fold_events(self.event_times, self.pulse_frequency) ax = plot_profile(phase, prof) plt.savefig('profile_direct.png') plt.close(plt.gcf())
def test_plot_profile_existing_ax(self): import matplotlib.pyplot as plt fig = plt.figure('Pulse profile') ax = plt.subplot() phase, prof, _ = fold_events(self.event_times, self.pulse_frequency, ax=ax) ax = plot_profile(phase, prof, ax=ax) plt.savefig('profile_existing_ax.png') plt.close(fig)
def test_plot_profile_errorbars(self): fig = plt.figure('Pulse profile') ax = plt.subplot() phase, prof, err = fold_events(self.event_times, self.pulse_frequency, ax=ax) ax = plot_profile(phase, prof, err=err, ax=ax) plt.savefig('profile_errorbars.png') plt.close(fig)
def test_pulse_profile1(self): nbin = 16 times = np.arange(0, 1, 1 / nbin) period = 1 with warnings.catch_warnings(): warnings.simplefilter("ignore", category=UserWarning) ph, p, pe = fold_events(times, 1, nbin=nbin) np.testing.assert_array_almost_equal(p, np.ones(nbin)) np.testing.assert_array_almost_equal( ph, np.arange(nbin) / nbin + 0.5 / nbin) np.testing.assert_array_almost_equal(pe, np.ones(nbin))
def test_pulse_profile2(self): nbin = 16 dt = 1 / nbin times = np.arange(0, 2, dt) gtis = np.array([[-0.5 * dt, 2 + 0.5 * dt]]) period = 1 with warnings.catch_warnings(): warnings.simplefilter("ignore", category=UserWarning) ph, p, pe = fold_events(times, 1, nbin=nbin, expocorr=True, gtis=gtis) np.testing.assert_array_almost_equal( ph, np.arange(nbin) / nbin + 0.5 / nbin) np.testing.assert_array_almost_equal(p, 2 * np.ones(nbin)) np.testing.assert_array_almost_equal(pe, 2**0.5 * np.ones(nbin))
def test_pulse_profile3(self): nbin = 16 dt = 1 / nbin times = np.arange(0, 2 - dt, dt) gtis = np.array([[-0.5 * dt, 2 - dt]]) with warnings.catch_warnings(): warnings.simplefilter("ignore", category=UserWarning) ph, p, pe = fold_events(times, 1, nbin=nbin, expocorr=True, gtis=gtis) np.testing.assert_array_almost_equal( ph, np.arange(nbin) / nbin + 0.5 / nbin) np.testing.assert_array_almost_equal(p, 2 * np.ones(nbin)) expected_err = 2**0.5 * np.ones(nbin) expected_err[-1] = 2 # Because of the change of exposure np.testing.assert_array_almost_equal(pe, expected_err)