Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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))
Exemplo n.º 6
0
    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))
Exemplo n.º 7
0
    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))
Exemplo n.º 8
0
    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))
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    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]))
Exemplo n.º 11
0
    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]))
Exemplo n.º 12
0
    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))
Exemplo n.º 13
0
    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
            ])
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
 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)