Пример #1
0
    def test_fractional_rms_in_frac_norm_is_consistent(self):
        time = np.arange(0, 100, 1) + 0.5

        poisson_counts = np.random.poisson(100.0, size=time.shape[0])

        lc = Lightcurve(time, counts=poisson_counts, dt=1, gti=[[0, 100]])
        ps = Powerspectrum(lc=lc, norm="leahy")
        rms_ps_l, rms_err_l = ps.compute_rms(min_freq=ps.freq[1],
                                             max_freq=ps.freq[-1],
                                             white_noise_offset=0)

        ps = Powerspectrum(lc=lc, norm="frac")
        rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[1],
                                         max_freq=ps.freq[-1],
                                         white_noise_offset=0)
        assert np.allclose(rms_ps, rms_ps_l, atol=0.01)
        assert np.allclose(rms_err, rms_err_l, atol=0.01)
Пример #2
0
    def test_fractional_rms_in_frac_norm_is_consistent(self):
        time = np.arange(0, 100, 1) + 0.5

        poisson_counts = np.random.poisson(100.0,
                                           size=time.shape[0])

        lc = Lightcurve(time, counts=poisson_counts, dt=1,
                            gti=[[0, 100]])
        ps = Powerspectrum(lc=lc, norm="leahy")
        rms_ps_l, rms_err_l = ps.compute_rms(min_freq=ps.freq[1],
                                         max_freq=ps.freq[-1], white_noise_offset=0)

        ps = Powerspectrum(lc=lc, norm="frac")
        rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[1],
                                         max_freq=ps.freq[-1], white_noise_offset=0)
        assert np.allclose(rms_ps, rms_ps_l, atol=0.01)
        assert np.allclose(rms_err, rms_err_l, atol=0.01)
Пример #3
0
    def test_fractional_rms_in_leahy_norm(self):
        """
        fractional rms should only be *approximately* equal the standard
        deviation divided by the mean of the light curve. Therefore, we allow
        for a larger tolerance in np.isclose()
        """
        ps = Powerspectrum(lc=self.lc, norm="Leahy")
        rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[0],
                                         max_freq=ps.freq[-1])

        rms_lc = np.std(self.lc.counts) / np.mean(self.lc.counts)
        assert np.isclose(rms_ps, rms_lc, atol=0.01)
Пример #4
0
    def test_fractional_rms_in_leahy_norm(self):
        """
        fractional rms should only be *approximately* equal the standard
        deviation divided by the mean of the light curve. Therefore, we allow
        for a larger tolerance in np.isclose()
        """
        ps = Powerspectrum(lc=self.lc, norm="Leahy")
        rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[0],
                                         max_freq=ps.freq[-1])

        rms_lc = np.std(self.lc.counts) / np.mean(self.lc.counts)
        assert np.isclose(rms_ps, rms_lc, atol=0.01)
Пример #5
0
 def test_fractional_rms_fails_when_rms_not_leahy(self):
     with pytest.raises(Exception):
         ps = Powerspectrum(lc=self.lc, norm="rms")
         rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[0],
                                          max_freq=ps.freq[-1])
Пример #6
0
 def test_fractional_rms_in_frac_norm(self):
     ps = Powerspectrum(lc=self.lc, norm="frac")
     rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[1],
                                      max_freq=ps.freq[-1])
     rms_lc = np.std(self.lc.counts) / np.mean(self.lc.counts)
     assert np.isclose(rms_ps, rms_lc, atol=0.01)
Пример #7
0
 def test_compute_rms_wrong_norm(self):
     ps = Powerspectrum(self.lc)
     ps.norm = 'gibberish'
     with pytest.raises(TypeError):
         ps.compute_rms(0, 10)
Пример #8
0
 def test_fractional_rms_fails_when_rms_not_leahy(self):
     with pytest.raises(Exception):
         ps = Powerspectrum(lc=self.lc, norm="rms")
         rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[0],
                                          max_freq=ps.freq[-1])
 def test_fractional_rms_in_rms_norm(self):
     ps = Powerspectrum(lc=self.lc, norm="rms")
     rms_ps, rms_err = ps.compute_rms(min_freq=ps.freq[1],
                                      max_freq=ps.freq[-1])
     rms_lc = np.std(self.lc.counts) / np.mean(self.lc.counts)
     assert np.isclose(rms_ps, rms_lc, atol=0.01)