Exemplo n.º 1
0
 def test_rebin_with_invalid_type_attribute(self):
     new_df = 2
     aps = AveragedPowerspectrum(lc=self.lc1, segment_size=1,
                                 norm='leahy')
     aps.type = 'invalid_type'
     with pytest.raises(AttributeError):
         assert aps.rebin(df=new_df)
Exemplo n.º 2
0
 def test_rebin_with_invalid_type_attribute(self):
     new_df = 2
     aps = AveragedPowerspectrum(lc=self.lc, segment_size=1,
                                 norm='leahy')
     aps.type = 'invalid_type'
     with pytest.raises(AttributeError):
         assert aps.rebin(df=new_df)
Exemplo n.º 3
0
    def test_rebin_factor(self, f):
        """
        TODO: Not sure how to write tests for the rebin method!
        """

        aps = AveragedPowerspectrum(self.lc, segment_size=1,
                                    norm="Leahy", dt=self.dt)
        bin_aps = aps.rebin(f=f)
        assert np.isclose(bin_aps.freq[1]-bin_aps.freq[0], bin_aps.df,
                          atol=1e-4, rtol=1e-4)
        assert np.isclose(bin_aps.freq[0],
                          (aps.freq[0]-aps.df*0.5+bin_aps.df*0.5),
                          atol=1e-4, rtol=1e-4)
Exemplo n.º 4
0
    def test_rebin_factor(self, f):
        """
        TODO: Not sure how to write tests for the rebin method!
        """

        aps = AveragedPowerspectrum(lc=self.lc, segment_size=1,
                                    norm="Leahy")
        bin_aps = aps.rebin(f=f)
        assert np.isclose(bin_aps.freq[1]-bin_aps.freq[0], bin_aps.df,
                          atol=1e-4, rtol=1e-4)
        assert np.isclose(bin_aps.freq[0],
                          (aps.freq[0]-aps.df*0.5+bin_aps.df*0.5),
                          atol=1e-4, rtol=1e-4)
Exemplo n.º 5
0
        def rebin_several_averagedps(self, df):
            """
            TODO: Not sure how to write tests for the rebin method!
            """

            aps = AveragedPowerspectrum(lc=self.lc,
                                        segment_size=1,
                                        norm="Leahy")
            bin_aps = aps.rebin(df)
            assert np.isclose(bin_aps.freq[1] - bin_aps.freq[0],
                              bin_aps.df,
                              atol=1e-4,
                              rtol=1e-4)
            assert np.isclose(bin_aps.freq[0],
                              (aps.freq[0] - aps.df * 0.5 + bin_aps.df * 0.5),
                              atol=1e-4,
                              rtol=1e-4)
Exemplo n.º 6
0
 def test_rebin_with_valid_type_attribute(self):
     new_df = 2
     aps = AveragedPowerspectrum(lc=self.lc1, segment_size=1,
                                 norm='leahy')
     assert aps.rebin(df=new_df)
import numpy as np
from stingray import Lightcurve, Powerspectrum, AveragedPowerspectrum
import matplotlib.pyplot as plt
from astropy.io import ascii
p, q= np.loadtxt("lxp2level2_t1_50_3-10kev.txt", unpack=True, usecols=[0,1])
lc = Lightcurve(p,q)
avg_ps_mode = AveragedPowerspectrum(lc, 198, norm='leahy')
log_rb_ps = avg_ps_mode.rebin_log(f=0.02)
lin_rb_ps = avg_ps_mode.rebin(10, method='mean')
#plt.plot(lc.time, lc.counts, lw=1, color='blue')
plt.plot(avg_ps_mode.freq, avg_ps_mode.power, lw=1, color='black')
plt.xlabel('Frequency (Hz)')
plt.ylabel('Power (Leahy)')
plt.show()

 def test_rebin_with_valid_type_attribute(self):
     new_df = 2
     aps = AveragedPowerspectrum(lc=self.lc1, segment_size=1, norm="leahy")
     assert aps.rebin(df=new_df)