def test_load_and_save_pds(self): pds = Powerspectrum() pds.freq = np.linspace(0, 10, 15) pds.power = np.random.poisson(30, 15) pds.mjdref = 54385.3254923845 pds.gti = np.longdouble([[-0.5, 3.5]]) save_pds(pds, self.dum) pds2 = load_pds(self.dum) assert np.allclose(pds.gti, pds2.gti) assert np.allclose(pds.mjdref, pds2.mjdref) assert pds.m == pds2.m
def test_load_and_save_xps_no_all(self): lcurve1 = Lightcurve(np.linspace(0, 10, 150), np.random.poisson(30, 150), mjdref=54385.3254923845, gti=np.longdouble([[-0.5, 3.5]])) lcurve2 = Lightcurve(np.linspace(0, 10, 150), np.random.poisson(30, 150), mjdref=54385.3254923845, gti=np.longdouble([[-0.5, 3.5]])) xps = AveragedCrossspectrum(lcurve1, lcurve2, 1) outfile = 'small_xps' + HEN_FILE_EXTENSION save_pds(xps, outfile, save_all=False) xps2 = load_pds(outfile) assert np.allclose(xps.gti, xps2.gti) assert xps.m == xps2.m assert not hasattr(xps2, 'pds1')
def test_load_and_save_xps_quick(self): lcurve1 = Lightcurve(np.linspace(0, 10, 150), np.random.poisson(30, 150), mjdref=54385.3254923845, gti=np.longdouble([[-0.5, 3.5]])) lcurve2 = Lightcurve(np.linspace(0, 10, 150), np.random.poisson(30, 150), mjdref=54385.3254923845, gti=np.longdouble([[-0.5, 3.5]])) xps = AveragedCrossspectrum(lcurve1, lcurve2, 1) save_pds(xps, self.dum) xps2 = load_pds(self.dum, nosub=True) assert np.allclose(xps.gti, xps2.gti) assert xps.m == xps2.m assert not hasattr(xps2, 'pds1')
def test_load_and_save_xps(self): lcurve1 = Lightcurve(np.linspace(0, 10, 150), np.random.poisson(30, 150), mjdref=54385.3254923845, gti = np.longdouble([[-0.5, 3.5]])) lcurve2 = Lightcurve(np.linspace(0, 10, 150), np.random.poisson(30, 150), mjdref=54385.3254923845, gti = np.longdouble([[-0.5, 3.5]])) xps = AveragedCrossspectrum(lcurve1, lcurve2, 1) save_pds(xps, self.dum) xps2 = load_pds(self.dum) assert np.allclose(xps.gti, xps2.gti) assert xps.m == xps2.m lag, lag_err = xps.time_lag() lag2, lag2_err = xps2.time_lag() assert np.allclose(lag, lag2)