本文整理汇总了Python中stingray.Lightcurve.rebin_lightcurve方法的典型用法代码示例。如果您正苦于以下问题:Python Lightcurve.rebin_lightcurve方法的具体用法?Python Lightcurve.rebin_lightcurve怎么用?Python Lightcurve.rebin_lightcurve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stingray.Lightcurve
的用法示例。
在下文中一共展示了Lightcurve.rebin_lightcurve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestLightcurveRebin
# 需要导入模块: from stingray import Lightcurve [as 别名]
# 或者: from stingray.Lightcurve import rebin_lightcurve [as 别名]
class TestLightcurveRebin(object):
def setUp(self):
#dt = 1.0
#n = 10
dt = 0.0001220703125
n = 1384132
mean_counts = 2.0
times = np.arange(dt/2, dt/2+n*dt, dt)
counts= np.zeros_like(times)+mean_counts
self.lc = Lightcurve(times, counts)
def test_rebin_even(self):
dt_new = 2.0
lc_binned = self.lc.rebin_lightcurve(dt_new)
assert np.isclose(lc_binned.dt, dt_new)
counts_test = np.zeros_like(lc_binned.time) + \
self.lc.counts[0]*dt_new/self.lc.dt
assert np.allclose(lc_binned.counts, counts_test)
def test_rebin_odd(self):
dt_new = 1.5
lc_binned = self.lc.rebin_lightcurve(dt_new)
assert np.isclose(lc_binned.dt, dt_new)
counts_test = np.zeros_like(lc_binned.time) + \
self.lc.counts[0]*dt_new/self.lc.dt
assert np.allclose(lc_binned.counts, counts_test)
def rebin_several(self, dt):
"""
TODO: Not sure how to write tests for the rebin method!
"""
lc_binned = self.lc.rebin_lightcurve(dt)
assert len(lc_binned.time) == len(lc_binned.counts)
def test_rebin_equal_numbers(self):
dt_all = [2, 3, np.pi, 5]
for dt in dt_all:
yield self.rebin_several, dt