例如,我有一个二维数据数组,其中一个维度上带有误差条,如下所示:
In [1]: numpy as np
In [2]: x = np.linspace(0,10,5)
In [3]: y = np.sin...(x)
In [4]: y_er = (np.random.random(len(x))-0.5)*0.1
In [5]: data = np.vstack([x,y,y_er]).T
In [6]:...我想避免这种重复的方法:
In [7]: import scipy.interpolate as interpolate
In [8]: new_x = np.linspace(0,10,20)
In...(data[:,0], data[:,2], kind=’cubic’)
In [11]: data_int = np.vstack([new_x, interp_y(new_x), interp_y_er...np.vstack或np.hstack将new_x和内插数据合并在一行中的语法,但是这个post让我停止尝试,因为似乎更快地预分配了数组(例如,使用np.zeros)然后用新值填充它.