【发布时间】:2018-11-21 19:18:40
【问题描述】:
以下代码应生成网格数据。但如果我选择插值类型“立方”或“线性”,我会在 z 网格中得到 nan。温我选择'最近'一切运行良好。 这是一个示例代码:
import numpy as np
from scipy.interpolate import griddata
x = np.array([0.03,0.05,0033])
y = np.array([0.004,0.01,0.02])
z = np.array([1,2,3])
xy = np.zeros((2,np.size(x)))
xy[0] = x
xy[1] = y
xy = xy.T
grid_x, grid_y = np.mgrid[0.0:0.09:250*1j, 0.0:0.03:250*1j] #generating the grid
i_type= 'cubic' #nearest, linear, cubic
grid_z = griddata(xy, z, (grid_x, grid_y), method=i_type)
#check if there is a nan in the z grid:
print np.isnan(grid_z).any()
我不知道为什么这不起作用..
【问题讨论】:
标签: python numpy scipy interpolation