• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python stingray.Lightcurve类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_truncate_by_time

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

        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]))
        np.testing.assert_almost_equal(lc1.gti[0][0], 0.5)

        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]))
        np.testing.assert_almost_equal(lc2.gti[-1][-1], 2.5)
开发者ID:usmanwardag,项目名称:stingray,代码行数:12,代码来源:test_lightcurve.py


示例17: test_lc_baseline_offset_fewbins

    def test_lc_baseline_offset_fewbins(self):
        times = np.arange(0, 4, 1)
        input_stdev = 0.1
        counts = np.random.normal(100, input_stdev, len(times)) + \
            0.001 * times
        gti = [[-0.005, 4.005]]
        lc = Lightcurve(times, counts, gti=gti)
        with pytest.warns(UserWarning) as record:
            lc.baseline(10000, 0.01, offset_correction=True)

        assert np.any(["Too few bins to perform baseline offset correction"
                       in r.message.args[0] for r in record])
开发者ID:abigailStev,项目名称:stingray,代码行数:12,代码来源:test_lightcurve.py


示例18: test_join_overlapping_time_arrays

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


示例19: test_rebin_with_gtis

    def test_rebin_with_gtis(self):
        times = np.arange(0, 100, 0.1)

        counts = np.random.normal(100, 0.1, size=times.shape[0])
        gti = [[0, 40], [60, 100]]

        good = create_gti_mask(times, gti)

        counts[np.logical_not(good)] = 0
        lc = Lightcurve(times, counts, gti=gti)

        lc_rebin = lc.rebin(1.0)

        assert (lc_rebin.time[39] - lc_rebin.time[38]) > 1.0
开发者ID:abigailStev,项目名称:stingray,代码行数:14,代码来源:test_lightcurve.py


示例20: test_shift

 def test_shift(self):
     times = [1, 2, 3, 4, 5, 6, 7, 8]
     counts = [1, 1, 1, 1, 2, 3, 3, 2]
     lc = Lightcurve(times, counts, input_counts=True)
     lc2 = lc.shift(1)
     assert np.all(lc2.time - 1 == times)
     lc2 = lc.shift(-1)
     assert np.all(lc2.time + 1 == times)
     assert np.all(lc2.counts == lc.counts)
     assert np.all(lc2.countrate == lc.countrate)
     lc = Lightcurve(times, counts, input_counts=False)
     lc2 = lc.shift(1)
     assert np.all(lc2.counts == lc.counts)
     assert np.all(lc2.countrate == lc.countrate)
开发者ID:abigailStev,项目名称:stingray,代码行数:14,代码来源:test_lightcurve.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python stingray.Powerspectrum类代码示例发布时间:2022-05-27
下一篇:
Python config.get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap