I have five 1D array with multiple length.I want all the arrays to have the same length as 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. 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.
Try to add a common x
coordinate for your arrays:
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))