def test_lc_baseline_offset_fewbins(self): times = np.arange(0, 4, 1) input_stdev = 0.1 counts = np.random.normal(100, input_stdev, len(times)) + \ 0.001 * times gti = [[-0.005, 4.005]] lc = Lightcurve(times, counts, gti=gti) with pytest.warns(UserWarning) as record: lc.baseline(10000, 0.01, offset_correction=True) assert np.any(["Too few bins to perform baseline offset correction" in r.message.args[0] for r in record])
def test_lc_baseline(self): times = np.arange(0, 100, 0.01) counts = np.random.normal(100, 0.1, len(times)) + \ 0.001 * times gti = [[-0.005, 50.005], [59.005, 100.005]] good = create_gti_mask(times, gti) counts[np.logical_not(good)] = 0 lc = Lightcurve(times, counts, gti=gti) baseline = lc.baseline(10000, 0.01) assert np.all(lc.counts - baseline < 1)
def test_lc_baseline_offset(self): times = np.arange(0, 100, 0.01) input_stdev = 0.1 counts = np.random.normal(100, input_stdev, len(times)) + \ 0.001 * times gti = [[-0.005, 50.005], [59.005, 100.005]] good = create_gti_mask(times, gti) counts[np.logical_not(good)] = 0 lc = Lightcurve(times, counts, gti=gti) baseline = lc.baseline(10000, 0.01, offset_correction=True) assert np.isclose(np.std(lc.counts - baseline), input_stdev, rtol=0.1)