[英]interpolate to larger 1D array using python
I have five 1D array with multiple length.I want all the arrays to have the same length as cD1
.我有五个具有多个长度的一维数组。我希望所有数组的长度与
cD1
相同。 I want to apply interpolation on the arrays to have the same length.我想对数组应用插值以具有相同的长度。 I've attempted to use
linear_interp = interp1d(cD5, cD1)
, but it doesn't work properly.我尝试使用
linear_interp = interp1d(cD5, cD1)
,但它不能正常工作。 Any help is appreciated!任何帮助表示赞赏!
from scipy.interpolate import interp1d
coeffs = wavedec(data, 'sym5', level=5)
cA5,cD5,cD4,cD3,cD2,cD1=coeffs
cD5.shape #(248,)
cD4.shape #(488,)
cD3.shape #(967,)
cD2.shape #(1926,)
cD1.shape #(3844,)
As far as I can tell you are missing an x
coordinate.据我所知,您缺少
x
坐标。
Try to add a common x
coordinate for your arrays:尝试为您的数组添加一个公共
x
坐标:
import numpy as np
from scipy.interpolate import interp1d
common_length_data = []
common_x = np.linspace(0, 1, len(cD1))
for c in [cA5,cD5,cD4,cD3,cD2,cD1]:
x = np.linspace(0, 1, len(c))
f = interp1d(x, c)
common_length_data.append(f(common_x))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.