如何填充数组内的插值,使它们等距
How to fill in the interpolated values inside the array so that they are equidistant
我用过这个例子How to generate equispaced interpolating values
在数据中制作等距点并得到以下图
我已经获取了这个散点图的值并对它们进行了插值,但是当我检查它时,点之间的差异并不相同。怎样才能让点之间的差异相同
old_indices_yn = np.arange(0,len(yn))
new_length = 50
new_indices_yn = np.linspace(0,len(yn)-1,new_length)
spl = UnivariateSpline(old_indices_yn,yn,k=3,s=0)
new_array_yn = spl(new_indices_yn)
old_indices_xn = np.arange(0,len(xn))
new_length = 50
new_indices_xn = np.linspace(0,len(xn)-1,new_length)
spl = UnivariateSpline(old_indices_xn,xn,k=3,s=0)
new_array_xn = spl(new_indices_xn)
plt.scatter(new_array_xn,new_array_yn, s=8)
plt.scatter(x,y,s=8)
这是我从插值中得到的图。
x=Field.columns.astype('float64')
y=Field.index.to_numpy()
plt.figure(0)
plt.scatter(x,y,s=0.5)
plt.title("points are not equidistant")
z=Field.to_numpy()
X,Y = np.meshgrid(x, y)
plt.figure(1)
plt.plot(X,Y)
plt.title('grid before')
plt.figure(2)
plt.contourf(X, Y, z, alpha = 1, cmap=plt.cm.inferno) #change of scale
plt.title('field before')
x1 = np.linspace(min(x),max(x),128);
y1 = np.linspace(min(y),max(y),128);
plt.figure(3)
plt.scatter(x1,y1,s=0.5)
plt.title("scatter of equidistant points")
X11,Y11 = np.meshgrid(x1, x1)
scale = (max(y)-min(y)/(max(x)-min(x)));#scale because x and y differ
plt.figure(4)
plt.plot(X11,Y11)
plt.title('new gird')
zi1 = interpolate.griddata((x*scale,y),z,(x1*scale,y1), method='nearest')
plt.figure(5)
plt.contourf(X11, Y11, zi1, alpha = 1, cmap=plt.cm.inferno) #change of scale
plt.title('Interpolated fied nearest with scale')
我用过这个例子How to generate equispaced interpolating values 在数据中制作等距点并得到以下图
我已经获取了这个散点图的值并对它们进行了插值,但是当我检查它时,点之间的差异并不相同。怎样才能让点之间的差异相同
old_indices_yn = np.arange(0,len(yn))
new_length = 50
new_indices_yn = np.linspace(0,len(yn)-1,new_length)
spl = UnivariateSpline(old_indices_yn,yn,k=3,s=0)
new_array_yn = spl(new_indices_yn)
old_indices_xn = np.arange(0,len(xn))
new_length = 50
new_indices_xn = np.linspace(0,len(xn)-1,new_length)
spl = UnivariateSpline(old_indices_xn,xn,k=3,s=0)
new_array_xn = spl(new_indices_xn)
plt.scatter(new_array_xn,new_array_yn, s=8)
plt.scatter(x,y,s=8)
这是我从插值中得到的图。
x=Field.columns.astype('float64')
y=Field.index.to_numpy()
plt.figure(0)
plt.scatter(x,y,s=0.5)
plt.title("points are not equidistant")
z=Field.to_numpy()
X,Y = np.meshgrid(x, y)
plt.figure(1)
plt.plot(X,Y)
plt.title('grid before')
plt.figure(2)
plt.contourf(X, Y, z, alpha = 1, cmap=plt.cm.inferno) #change of scale
plt.title('field before')
x1 = np.linspace(min(x),max(x),128);
y1 = np.linspace(min(y),max(y),128);
plt.figure(3)
plt.scatter(x1,y1,s=0.5)
plt.title("scatter of equidistant points")
X11,Y11 = np.meshgrid(x1, x1)
scale = (max(y)-min(y)/(max(x)-min(x)));#scale because x and y differ
plt.figure(4)
plt.plot(X11,Y11)
plt.title('new gird')
zi1 = interpolate.griddata((x*scale,y),z,(x1*scale,y1), method='nearest')
plt.figure(5)
plt.contourf(X11, Y11, zi1, alpha = 1, cmap=plt.cm.inferno) #change of scale
plt.title('Interpolated fied nearest with scale')