def test_join_with_different_dt(self): _times = [5, 5.5, 6] _counts = [2, 2, 2] lc1 = Lightcurve(self.times, self.counts) lc2 = Lightcurve(_times, _counts) with warnings.catch_warnings(record=True) as w: lc1.join(lc2) assert "different bin widths" in str(w[0].message)
def test_join_with_different_mjdref(self): shift = 86400. # day lc1 = Lightcurve(self.times + shift, self.counts, gti=self.gti + shift, mjdref=57000) lc2 = Lightcurve(self.times, self.counts, gti=self.gti, mjdref=57001) newlc = lc1.join(lc2) # The join operation *averages* the overlapping arrays assert np.allclose(newlc.counts, lc1.counts)
def test_join_disjoint_time_arrays(self): _times = [5, 6, 7, 8] _counts = [2, 2, 2, 2] lc1 = Lightcurve(self.times, self.counts) lc2 = Lightcurve(_times, _counts) lc = lc1.join(lc2) assert len(lc.counts) == len(lc.time) == 8 assert np.all(lc.counts == 2)
def test_join_different_err_dist_overlapping_times(self): _times = [3, 4, 5, 6] _counts = [4, 4, 4, 4] lc1 = Lightcurve(self.times, self.counts, err_dist="poisson") lc2 = Lightcurve(_times, _counts, err_dist="gauss") with warnings.catch_warnings(record=True) as w: lc3 = lc1.join(lc2) assert "We are setting the errors to zero." in str(w[1].message) assert np.all(lc3.counts_err == np.zeros_like(lc3.time))
def test_join_different_err_dist_disjoint_times(self): _times = [5 , 6, 7, 8] _counts =[2, 2, 2, 2] lc1 = Lightcurve(self.times, self.counts, err_dist = "poisson") lc2 = Lightcurve(_times, _counts, err_dist = "gauss") lc3 = lc1.join(lc2) assert np.all(lc3.counts_err[:len(self.times)] == lc1.counts_err) assert np.all(lc3.counts_err[len(self.times):] == np.zeros_like(lc2.counts))
def test_join_different_err_dist_overlapping_times(self): _times = [3, 4, 5, 6] _counts = [4, 4, 4, 4] lc1 = Lightcurve(self.times, self.counts, err_dist = "poisson") lc2 = Lightcurve(_times, _counts, err_dist = "gauss") with warnings.catch_warnings(record=True) as w: lc3 = lc1.join(lc2) assert "We are setting the errors to zero." in str(w[1].message) assert np.all(lc3.counts_err == np.zeros_like(lc3.time))
def test_join_overlapping_time_arrays(self): _times = [3, 4, 5, 6] _counts = [4, 4, 4, 4] lc1 = Lightcurve(self.times, self.counts) lc2 = Lightcurve(_times, _counts) with warnings.catch_warnings(record=True) as w: lc = lc1.join(lc2) assert "overlapping time ranges" in str(w[0].message) assert len(lc.counts) == len(lc.time) == 6 assert np.all(lc.counts == np.array([2, 2, 3, 3, 4, 4]))
def test_join_different_err_dist_disjoint_times(self): _times = [5, 6, 7, 8] _counts = [2, 2, 2, 2] lc1 = Lightcurve(self.times, self.counts, err_dist="poisson") with warnings.catch_warnings(): warnings.simplefilter("ignore", category=UserWarning) lc2 = Lightcurve(_times, _counts, err_dist="gauss") lc3 = lc1.join(lc2) assert np.allclose(lc3.counts_err[:len(self.times)], lc1.counts_err) assert np.allclose(lc3.counts_err[len(self.times):], np.zeros_like(lc2.counts))
def test_join_with_different_mjdref(self): shift = 86400. # day lc1 = Lightcurve(self.times + shift, self.counts, gti=self.gti + shift, mjdref=57000) lc2 = Lightcurve(self.times, self.counts, gti=self.gti, mjdref=57001) with warnings.catch_warnings(record=True) as w: newlc = lc1.join(lc2) # The join operation *averages* the overlapping arrays assert np.allclose(newlc.counts, lc1.counts) assert np.any([ "MJDref is different in the two light curves" in str(wi.message) for wi in w ]) assert np.any([ "The two light curves have overlapping time ranges" in str(wi.message) for wi in w ])
def test_join_with_different_mjdref(self): lc1 = Lightcurve(self.times, self.counts, gti=self.gti, mjdref=57000) lc2 = Lightcurve(self.times, self.counts, gti=self.gti, mjdref=57001) with pytest.raises(ValueError): lc1.join(lc2)