From ce397af9cca0e4fd1f5d833d091b3703b3456081 Mon Sep 17 00:00:00 2001 From: Carlo Ferrigno Date: Thu, 5 Sep 2024 10:15:12 +0200 Subject: [PATCH] add test to read Poissonian uncertainties --- tests/test_spectra.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_spectra.py b/tests/test_spectra.py index 8af2aa8..bae1e16 100644 --- a/tests/test_spectra.py +++ b/tests/test_spectra.py @@ -171,3 +171,14 @@ def model_gen(p): # TODO: check that it all looks the same plt.savefig("unf_png.png") + +def test_read_poisson(): + import ogip.spec + pha = ogip.spec.PHAI.from_file_name("tests/data/MOS1source_spectrum_150_rbn.pi") + from astropy.io import fits as pf + import numpy as np + ff = pf.open("tests/data/MOS1source_spectrum_150_rbn.pi") + counts = ff[1].data['COUNTS'] + + assert(np.abs(np.sum(counts - (pha._rate)*pha._exposure)) < 1e-12) + assert(np.sum(pha._rate*pha._exposure - (pha._stat_err*pha._exposure)**2))