def test_analyze_lc_chunks(self):
        lc = Lightcurve(self.times, self.counts, gti=self.gti)

        def func(lc):
            return lc.time[0]
        start, stop, res = lc.analyze_lc_chunks(2, func)
        assert start[0] == 0.5
        assert np.all(start + lc.dt / 2 == res)
Exemple #2
0
    def test_analyze_lc_chunks(self):
        lc = Lightcurve(self.times, self.counts, gti=self.gti)

        def func(lc):
            return lc.time[0]
        start, stop, res = lc.analyze_lc_chunks(2, func)
        assert start[0] == 0.5
        assert np.all(start + lc.dt / 2 == res)
Exemple #3
0
    def test_analyze_lc_chunks_fvar_fracstep(self):
        dt = 0.1
        tstart = 0
        tstop = 100
        times = np.arange(tstart, tstop, dt)
        gti = np.array([[tstart - dt / 2, tstop - dt / 2]])
        # Simulate something *clearly* non-constant
        counts = np.random.poisson(10000 + 2000 * np.sin(2 * np.pi * times))

        lc = Lightcurve(times, counts, gti=gti)

        def excvar(lc):
            from stingray.utils import excess_variance
            return excess_variance(lc, normalization='fvar')

        start, stop, res = lc.analyze_lc_chunks(20, excvar, fraction_step=0.5)
        # excess_variance returns fvar and fvar_err
        res, res_err = res

        assert np.allclose(start[0], gti[0, 0])
        assert np.all(res > 0)
        # This must be a clear measurement of fvar
        assert np.all(res > res_err)
Exemple #4
0
    def test_analyze_lc_chunks_fvar_fracstep(self):
        dt = 0.1
        tstart = 0
        tstop = 100
        times = np.arange(tstart, tstop, dt)
        gti = np.array([[tstart - dt/2, tstop - dt/2]])
        # Simulate something *clearly* non-constant
        counts = np.random.poisson(
            10000 + 2000 * np.sin(2 * np.pi * times))

        lc = Lightcurve(times, counts, gti=gti)

        def excvar(lc):
            from stingray.utils import excess_variance
            return excess_variance(lc, normalization='fvar')

        start, stop, res = lc.analyze_lc_chunks(20, excvar, fraction_step=0.5)
        # excess_variance returns fvar and fvar_err
        res, res_err = res

        assert np.allclose(start[0], gti[0, 0])
        assert np.all(res > 0)
        # This must be a clear measurement of fvar
        assert np.all(res > res_err)