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


Python Powerspectrum.rebin方法代码示例

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


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

示例1: rebin_several

# 需要导入模块: from stingray import Powerspectrum [as 别名]
# 或者: from stingray.Powerspectrum import rebin [as 别名]
 def rebin_several(self, df):
     """
     TODO: Not sure how to write tests for the rebin method!
     """
     ps = Powerspectrum(lc=self.lc, norm="Leahy")
     bin_ps = ps.rebin(df)
     assert np.isclose(bin_ps.freq[0], bin_ps.df, atol=1e-4, rtol=1e-4)
开发者ID:AbhishekKumarSingh,项目名称:stingray,代码行数:9,代码来源:test_powerspectrum.py

示例2: test_rebin_makes_right_attributes

# 需要导入模块: from stingray import Powerspectrum [as 别名]
# 或者: from stingray.Powerspectrum import rebin [as 别名]
    def test_rebin_makes_right_attributes(self):
        ps = Powerspectrum(lc=self.lc, norm="Leahy")
        # replace powers
        ps.ps = np.ones_like(ps.ps) * 2.0
        rebin_factor = 2.0
        bin_ps = ps.rebin(rebin_factor*ps.df)

        assert bin_ps.freq is not None
        assert bin_ps.ps is not None
        assert bin_ps.df == rebin_factor * 1.0 / self.lc.tseg
        assert bin_ps.norm.lower() == "leahy"
        assert bin_ps.m == 2
        assert bin_ps.n == self.lc.time.shape[0]
        assert bin_ps.nphots == np.sum(self.lc.counts)
开发者ID:AbhishekKumarSingh,项目名称:stingray,代码行数:16,代码来源:test_powerspectrum.py

示例3: test_ccf

# 需要导入模块: from stingray import Powerspectrum [as 别名]
# 或者: from stingray.Powerspectrum import rebin [as 别名]
    def test_ccf(self):
        # to make testing faster, fitting is not done.
        ref_ps = Powerspectrum(self.ref_lc, norm='abs')

        ci_counts_0 = self.ci_counts[0]
        ci_times = np.arange(0, self.n_seconds * self.n_seg, self.dt)
        ci_lc = Lightcurve(ci_times, ci_counts_0, dt=self.dt)

        # rebinning factor used in `rebin_log`
        rebin_log_factor = 0.4

        acs = AveragedCrossspectrum(lc1=ci_lc, lc2=self.ref_lc,
                                    segment_size=self.n_seconds, norm='leahy',
                                    power_type="absolute")
        acs = acs.rebin_log(rebin_log_factor)

        # parest, res = fit_crossspectrum(acs, self.model, fitmethod="CG")
        acs_result_model = self.model

        # using optimal filter
        optimal_filter = Optimal1D(acs_result_model)
        optimal_filter_freq = optimal_filter(acs.freq)
        filtered_acs_power = optimal_filter_freq * np.abs(acs.power)

        # rebinning power spectrum
        new_df = spec.get_new_df(ref_ps, self.n_bins)
        ref_ps_rebinned = ref_ps.rebin(df=new_df)

        # parest, res = fit_powerspectrum(ref_ps_rebinned, self.model)
        ref_ps_rebinned_result_model = self.model

        # calculating rms from power spectrum
        ref_ps_rebinned_rms = spec.compute_rms(ref_ps_rebinned,
                                               ref_ps_rebinned_result_model,
                                               criteria="optimal")

        # calculating normalized ccf
        ccf_norm = spec.ccf(filtered_acs_power, ref_ps_rebinned_rms,
                            self.n_bins)

        # calculating ccf error
        meta = {'N_SEG': self.n_seg, 'NSECONDS': self.n_seconds, 'DT': self.dt,
                'N_BINS': self.n_bins}
        error_ccf, avg_seg_ccf = spec.ccf_error(self.ref_counts, ci_counts_0,
                                                acs_result_model,
                                                rebin_log_factor,
                                                meta, ref_ps_rebinned_rms,
                                                filter_type="optimal")

        assert np.all(np.isclose(ccf_norm, avg_seg_ccf, atol=0.01))
        assert np.all(np.isclose(error_ccf, np.zeros(shape=error_ccf.shape),
                                 atol=0.01))

        # using window function
        tophat_filter = Window1D(acs_result_model)
        tophat_filter_freq = tophat_filter(acs.freq)
        filtered_acs_power = tophat_filter_freq * np.abs(acs.power)

        ref_ps_rebinned_rms = spec.compute_rms(ref_ps_rebinned,
                                               ref_ps_rebinned_result_model,
                                               criteria="window")

        ccf_norm = spec.ccf(filtered_acs_power, ref_ps_rebinned_rms,
                            self.n_bins)

        error_ccf, avg_seg_ccf = spec.ccf_error(self.ref_counts, ci_counts_0,
                                                acs_result_model,
                                                rebin_log_factor,
                                                meta, ref_ps_rebinned_rms,
                                                filter_type="window")

        assert np.all(np.isclose(ccf_norm, avg_seg_ccf, atol=0.01))
        assert np.all(np.isclose(error_ccf, np.zeros(shape=error_ccf.shape),
                                 atol=0.01))
开发者ID:abigailStev,项目名称:stingray,代码行数:76,代码来源:test_spectroscopy.py


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