Python中常规采样频率的不规则采样频率

时间:2014-05-28 14:23:02

标签: python transformation frequency

示例:

x1 = [0.0, 0.3, 0.8, 1.1]

y1 = [5, 6 , 4, 1]

period = 0.4

要:

x2 = [0.0, 0.4, 0.8, 1.2]

y2 = [...,..,..,..]

当然这将是一个估计。尝试了不同的事情,没有运气。采样频率非常高,因此一些下采样不是问题。

1 个答案:

答案 0 :(得分:1)

>>> import numpy as np
>>> y1 = np.array([5, 6 , 4, 1])
>>> x1 = np.array([0.0, 0.3, 0.8, 1.1])
>>> period = 0.4

>>> x2 = period * np.arange(len(x1)) 
>>> x2
array([ 0. ,  0.4,  0.8,  1.2])

>>> np.interp(x2, x1, y1)
array([ 5. ,  5.6,  4. ,  1. ])