本文整理汇总了Python中gwpy.timeseries.TimeSeries.data[length_generated:length]方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.data[length_generated:length]方法的具体用法?Python TimeSeries.data[length_generated:length]怎么用?Python TimeSeries.data[length_generated:length]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gwpy.timeseries.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.data[length_generated:length]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: noise_from_psd
# 需要导入模块: from gwpy.timeseries import TimeSeries [as 别名]
# 或者: from gwpy.timeseries.TimeSeries import data[length_generated:length] [as 别名]
def noise_from_psd(length, sample_rate, psd, seed=0, name=None, unit=u.m):
""" Create noise with a given psd.
Return noise with a given psd. Note that if unique noise is desired
a unique seed should be provided.
Parameters
----------
length : int
The length of noise to generate in seconds.
sample_rate : float
the sample rate of the data
stride : int
Length of noise segments in seconds
psd : FrequencySeries
The noise weighting to color the noise.
seed : {0, int}
The seed to generate the noise.
Returns
--------
noise : TimeSeries
A TimeSeries containing gaussian noise colored by the given psd.
"""
if name is None:
name='noise'
length *=sample_rate
noise_ts = TimeSeries(np.zeros(length),
sample_rate=sample_rate, name=name, unit=unit)
randomness = lal.gsl_rng("ranlux", seed)
N = int (sample_rate / psd.df.value)
n = N/2+1
stride = N/2
if n > len(psd):
raise ValueError("PSD not compatible with requested delta_t")
psd = (psd[0:n]).to_lal()
psd.data.data[n-1] = 0
segment = TimeSeries(np.zeros(N), sample_rate=sample_rate).to_lal()
length_generated = 0
SimNoise(segment, 0, psd, randomness)
while (length_generated < length):
if (length_generated + stride) < length:
noise_ts.data[length_generated:length_generated+stride] = segment.data.data[0:stride]
else:
noise_ts.data[length_generated:length] = segment.data.data[0:length-length_generated]
length_generated += stride
SimNoise(segment,stride, psd, randomness)
return noise_ts