当前位置: 首页>>代码示例>>Python>>正文


Python stingray.Lightcurve类代码示例

本文整理汇总了Python中stingray.Lightcurve的典型用法代码示例。如果您正苦于以下问题:Python Lightcurve类的具体用法?Python Lightcurve怎么用?Python Lightcurve使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Lightcurve类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_io_with_pickle

 def test_io_with_pickle(self):
     lc = Lightcurve(self.times, self.counts)
     lc.write('lc.pickle', format_='pickle')
     lc.read('lc.pickle',format_='pickle')
     assert np.all(lc.time == self.times)
     assert np.all(lc.counts == self.counts)
     os.remove('lc.pickle')
开发者ID:OrkoHunter,项目名称:stingray,代码行数:7,代码来源:test_lightcurve.py

示例2: test_lightcurve_from_toa

 def test_lightcurve_from_toa(self):
     lc = Lightcurve.make_lightcurve(self.times, self.dt, use_hist=True,
                                     tstart=0.5)
     lc2 = Lightcurve.make_lightcurve(self.times, self.dt, use_hist=False,
                                     tstart=0.5)
     assert np.allclose(lc.time, lc2.time)
     assert np.all(lc.counts == lc2.counts)
开发者ID:abigailStev,项目名称:stingray,代码行数:7,代码来源:test_lightcurve.py

示例3: test_plot_wrong_label_type

    def test_plot_wrong_label_type(self):
        lc = Lightcurve(self.times, self.counts)

        with pytest.raises(TypeError):
            with warnings.catch_warnings(record=True) as w:
                lc.plot(labels=123)
                assert "must be either a list or tuple" in str(w[0].message)
开发者ID:abigailStev,项目名称:stingray,代码行数:7,代码来源:test_lightcurve.py

示例4: test_analyze_lc_chunks

    def test_analyze_lc_chunks(self):
        lc = Lightcurve(self.times, self.counts, gti=self.gti)

        def func(lc):
            return lc.time[0]
        start, stop, res = lc.analyze_lc_chunks(2, func)
        assert start[0] == 0.5
        assert np.all(start + lc.dt / 2 == res)
开发者ID:abigailStev,项目名称:stingray,代码行数:8,代码来源:test_lightcurve.py

示例5: test_io_with_pickle

 def test_io_with_pickle(self):
     lc = Lightcurve(self.times, self.counts)
     lc.write("lc.pickle", format_="pickle")
     lc.read("lc.pickle", format_="pickle")
     assert np.all(lc.time == self.times)
     assert np.all(lc.counts == self.counts)
     assert np.all(lc.gti == self.gti)
     os.remove("lc.pickle")
开发者ID:evandromr,项目名称:stingray,代码行数:8,代码来源:test_lightcurve.py

示例6: test_lightcurve_from_toa_random_nums

 def test_lightcurve_from_toa_random_nums(self):
     times = np.random.uniform(0, 10, 1000)
     lc = Lightcurve.make_lightcurve(times, self.dt, use_hist=True,
                                     tstart=0.5)
     lc2 = Lightcurve.make_lightcurve(times, self.dt, use_hist=False,
                                     tstart=0.5)
     assert np.allclose(lc.time, lc2.time)
     assert np.all(lc.counts == lc2.counts)
开发者ID:abigailStev,项目名称:stingray,代码行数:8,代码来源:test_lightcurve.py

示例7: test_lc_baseline

 def test_lc_baseline(self):
     times = np.arange(0, 100, 0.01)
     counts = np.random.normal(100, 0.1, len(times)) + \
         0.001 * times
     gti = [[-0.005, 50.005], [59.005, 100.005]]
     good = create_gti_mask(times, gti)
     counts[np.logical_not(good)] = 0
     lc = Lightcurve(times, counts, gti=gti)
     baseline = lc.baseline(10000, 0.01)
     assert np.all(lc.counts - baseline < 1)
开发者ID:abigailStev,项目名称:stingray,代码行数:10,代码来源:test_lightcurve.py

示例8: test_truncate_by_time

    def test_truncate_by_time(self):
        lc = Lightcurve(self.times, self.counts)

        lc1 = lc.truncate(start=1, method='time')
        assert np.all(lc1.time == np.array([1, 2, 3, 4]))
        assert np.all(lc1.counts == np.array([2, 2, 2, 2]))

        lc2 = lc.truncate(stop=3, method='time')
        assert np.all(lc2.time == np.array([1, 2]))
        assert np.all(lc2.counts == np.array([2, 2]))
开发者ID:OrkoHunter,项目名称:stingray,代码行数:10,代码来源:test_lightcurve.py

示例9: test_truncate_by_index

    def test_truncate_by_index(self):
        lc = Lightcurve(self.times, self.counts)

        lc1 = lc.truncate(start=1)
        assert np.all(lc1.time == np.array([2, 3, 4]))
        assert np.all(lc1.counts == np.array([2, 2, 2]))

        lc2 = lc.truncate(stop=2)
        assert np.all(lc2.time == np.array([1, 2]))
        assert np.all(lc2.counts == np.array([2, 2]))
开发者ID:OrkoHunter,项目名称:stingray,代码行数:10,代码来源:test_lightcurve.py

示例10: test_join_with_different_dt

    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)
开发者ID:abigailStev,项目名称:stingray,代码行数:10,代码来源:test_lightcurve.py

示例11: test_join_different_err_dist_disjoint_times

    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))
开发者ID:abigailStev,项目名称:stingray,代码行数:11,代码来源:test_lightcurve.py

示例12: test_join_different_err_dist_overlapping_times

    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))
开发者ID:abigailStev,项目名称:stingray,代码行数:11,代码来源:test_lightcurve.py

示例13: test_join_disjoint_time_arrays

    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)
开发者ID:usmanwardag,项目名称:stingray,代码行数:11,代码来源:test_lightcurve.py

示例14: test_plot_matplotlib_not_installed

    def test_plot_matplotlib_not_installed(self):
        try:
            import matplotlib.pyplot as plt
        except Exception as e:

            lc = Lightcurve(self.times, self.counts)
            try:
                lc.plot()
            except Exception as e:
                assert type(e) is ImportError
                assert str(e) == "Matplotlib required for plot()"
开发者ID:abigailStev,项目名称:stingray,代码行数:11,代码来源:test_lightcurve.py

示例15: test_lc_baseline_offset

 def test_lc_baseline_offset(self):
     times = np.arange(0, 100, 0.01)
     input_stdev = 0.1
     counts = np.random.normal(100, input_stdev, len(times)) + \
         0.001 * times
     gti = [[-0.005, 50.005], [59.005, 100.005]]
     good = create_gti_mask(times, gti)
     counts[np.logical_not(good)] = 0
     lc = Lightcurve(times, counts, gti=gti)
     baseline = lc.baseline(10000, 0.01, offset_correction=True)
     assert np.isclose(np.std(lc.counts - baseline), input_stdev, rtol=0.1)
开发者ID:abigailStev,项目名称:stingray,代码行数:11,代码来源:test_lightcurve.py


注:本文中的stingray.Lightcurve类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。