Ejemplo n.º 1
0
    def test_lc_with_no_band_interest(self):
        c = Covariancespectrum(self.lcs,
                               ref_band_interest=None)

        band_interest = np.vstack([np.arange(len(self.lcs)),
                        np.arange(1, len(self.lcs) + 1, 1)]).T

        assert np.all(c.band_interest == band_interest)
Ejemplo n.º 2
0
    def test_creates_band_interest_correctly(self):
        c = Covariancespectrum(self.event_list, dt=1)
        energies = np.arange(1, 10, 1)
        band_low = np.zeros_like(energies)
        band_high = np.zeros_like(energies)
        ediff = np.diff(energies)

        band_low[:-1] = energies[:-1] - 0.5 * ediff
        band_high[:-1] = energies[:-1] + 0.5 * ediff
        band_low[-1] = energies[-1] - 0.5 * ediff[-1]
        band_high[-1] = energies[-1] + 0.5 * ediff[-1]

        band_interest = np.vstack([band_low, band_high]).T

        assert np.allclose(band_interest, c.band_interest)
Ejemplo n.º 3
0
 def test_with_separate_reference_band(self):
     c = Covariancespectrum(self.event_list,
                            dt=1,
                            band_interest=[(2, 6)],
                            ref_band_interest=((7, 10)))
Ejemplo n.º 4
0
 def test_covar_with_both_bands(self):
     c = Covariancespectrum(self.event_list,
                            dt=1,
                            band_interest=[(2, 6), (8, 9)],
                            ref_band_interest=(1, 10))
     assert len(c.covar) == 2
Ejemplo n.º 5
0
 def test_init_with_invalid_ref_band_interest(self):
     with pytest.raises(ValueError):
         c = Covariancespectrum(self.event_list,
                                dt=1,
                                ref_band_interest=(0))
Ejemplo n.º 6
0
 def test_covar_without_any_band_interest(self):
     c = Covariancespectrum(self.event_list, dt=1)
     assert len(c.covar) == 9
Ejemplo n.º 7
0
 def test_class_initializes_with_lightcurves(self):
     c = Covariancespectrum(self.lcs)
Ejemplo n.º 8
0
 def test_with_std_as_a_single_float(self):
     c = Covariancespectrum(self.event_list, dt=1, std=2.55)
Ejemplo n.º 9
0
 def test_with_full_segment(self):
     c = Covariancespectrum(self.event_list, 1)
     avg_c = AveragedCovariancespectrum(self.event_list,
                                        segment_size=10,
                                        dt=1)
     assert np.all(avg_c.unnorm_covar == c.unnorm_covar)
Ejemplo n.º 10
0
 def test_ref_band_interest_get_saved_correctly(self):
     with pytest.raises(AssertionError):
         c = Covariancespectrum(self.lcs, ref_band_interest=self.lcs[:-1])
Ejemplo n.º 11
0
 def test_class_fails_with_wrong_number_of_ref_band_interest_lcs(self):
     c = Covariancespectrum(self.lcs, ref_band_interest=self.lcs[::-1])
     assert len(c.lcs) == len(c.ref_band_lcs)
Ejemplo n.º 12
0
 def test_ref_band_interest_created_correctly(self):
     c = Covariancespectrum(self.lcs, ref_band_interest=None)
     assert len(c.ref_band_lcs) == len(self.lcs)
Ejemplo n.º 13
0
 def test_failure_without_valid_band_interest(self):
     with pytest.raises(ValueError):
         c = Covariancespectrum(self.lcs, band_interest=1.0)
Ejemplo n.º 14
0
 def test_single_lc_as_ref_band_interest(self):
     c = Covariancespectrum(self.lcs,
                            ref_band_interest=self.ref_band_interest)
Ejemplo n.º 15
0
 def test_set_lc_flag_correctly(self):
     c = Covariancespectrum(self.lcs)
     assert c.use_lc is True
     assert c.lcs == self.lcs
Ejemplo n.º 16
0
 def test_with_unsorted_event_list(self):
     event_list = np.array([[2, 1], [2, 3], [1, 2], [5, 2], [4, 1]])
     with warnings.catch_warnings(record=True) as w:
         c = Covariancespectrum(event_list, dt=1)
         assert np.any(["must be sorted" in str(wi.message) for wi in w])
Ejemplo n.º 17
0
 def test_with_std_as_iterable(self):
     c = Covariancespectrum(self.event_list, dt=1, std=[1, 2])
Ejemplo n.º 18
0
 def test_class_fails_if_events_is_set_but_dt_is_not(self):
     with pytest.raises(ValueError):
         c = Covariancespectrum(self.event_list)
Ejemplo n.º 19
0
    def test_with_eventlist_object(self):
        e = EventList(time=self.event_list[:, 0], energy=self.event_list[:, 1])

        c = Covariancespectrum(e, dt=1)
Ejemplo n.º 20
0
 def test_set_lc_flag_correctly(self):
     c = Covariancespectrum(self.event_list, dt=1)
     assert c.use_lc is False