Python griddata meshgrid

| 在Python中,我想使用scipy.interpolate.griddata(x,y,z,xi,yi)插值一些数据。 由于我希望在等距XI-YI网格上的X-Y网格图上不等间距的原始数据,因此必须使用meshgrid作为:
X, Y = numpy.meshgrid([1,2,3], [2,5,6,8])
XI,YI = numpy.meshgrid([1,2,3],[4,5,6,7])
print scipy.interpolate.griddata(X,Y,X**2+Y**2,XI,YI)
不幸的是,与Matlab的griddata函数相比,scipys的griddata似乎不接受矩阵作为x,y,z的输入。有人对我有提示如何解决问题吗?     
已邀请:
        您的情况下正确的通话顺序是
print scipy.interpolate.griddata((X.ravel(),Y.ravel()), (X**2+Y**2).ravel(), (XI, YI))
即,您需要将输入数据点转换为1-d。 (在下一版本的Scipy中,如果没有ѭ2可以解决此问题。)     
        我认为您需要重塑网格,griddata期望以列的形式列出具有坐标的点:
points = transpose(reshape((X,Y), (2,12)))
pointsI = transpose(reshape((XI,YI), (2,12)))
Z = reshape(X**2+Y**2, 12)

print scipy.interpolate.griddata(points, Z, pointsI)
    

要回复问题请先登录注册