[英]Irregular sample frequency to regular sample frequency in Python
Example:例子:
x1 = [0.0, 0.3, 0.8, 1.1]
y1 = [5, 6 , 4, 1]
period = 0.4
To:到:
x2 = [0.0, 0.4, 0.8, 1.2]
y2 = [...,..,..,..]
Of course this will be an estimation.当然,这将是一个估计。 Tried different things with no luck.
在没有运气的情况下尝试了不同的事情。 The sample frequency is very high, so some down sampling is not a problem.
采样频率非常高,所以一些下采样不是问题。
>>> 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. ])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.