本文整理汇总了Python中pycbc.types.TimeSeries.corrupted_samples方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeries.corrupted_samples方法的具体用法?Python TimeSeries.corrupted_samples怎么用?Python TimeSeries.corrupted_samples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycbc.types.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.corrupted_samples方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resample_to_delta_t
# 需要导入模块: from pycbc.types import TimeSeries [as 别名]
# 或者: from pycbc.types.TimeSeries import corrupted_samples [as 别名]
def resample_to_delta_t(timeseries, delta_t, method='butterworth'):
"""Resmple the time_series to delta_t
Resamples the TimeSeries instance time_series to the given time step,
delta_t. Only powers of two and real valued time series are supported
at this time. Additional restrictions may apply to particular filter
methods.
Parameters
----------
time_series: TimeSeries
The time series to be resampled
delta_t: float
The desired time step
Returns
-------
Time Series: TimeSeries
A TimeSeries that has been resampled to delta_t.
Raises
------
TypeError:
time_series is not an instance of TimeSeries.
TypeError:
time_series is not real valued
Examples
--------
>>> h_plus_sampled = resample_to_delta_t(h_plus, 1.0/2048)
"""
if not isinstance(timeseries,TimeSeries):
raise TypeError("Can only resample time series")
if timeseries.kind is not 'real':
raise TypeError("Time series must be real")
if timeseries.delta_t == delta_t:
return timeseries * 1
if method == 'butterworth':
lal_data = timeseries.lal()
_resample_func[timeseries.dtype](lal_data, delta_t)
data = lal_data.data.data
elif method == 'ldas':
factor = int(delta_t / timeseries.delta_t)
numtaps = factor * 20 + 1
# The kaiser window has been testing using the LDAS implementation
# and is in the same configuration as used in the original lalinspiral
filter_coefficients = scipy.signal.firwin(numtaps, 1.0 / factor,
window=('kaiser', 5))
# apply the filter and decimate
data = fir_zero_filter(filter_coefficients, timeseries)[::factor]
else:
raise ValueError('Invalid resampling method: %s' % method)
ts = TimeSeries(data, delta_t = delta_t,
dtype=timeseries.dtype,
epoch=timeseries._epoch)
# From the construction of the LDAS FIR filter there will be 10 corrupted samples
# explanation here http://software.ligo.org/docs/lalsuite/lal/group___resample_time_series__c.html
ts.corrupted_samples = 10
return ts