且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在网格中对点列表进行二维插值

更新时间:2023-11-26 10:41:04

这应该适用于您所描述的情况.(更新)

This should work for what you describe. (Updated)

from scipy.interpolate import interp2d
import numpy as np

xx, yy = np.meshgrid(np.arange(100), np.arange(100))
zz = some_function(xx,yy)

f = interp2d(xx, yy, zz, kind='cubic')

xs = np.random.rand(10) * 100
ys = np.random.rand(10) * 100
zs = np.zeros_like(xs)

for i in range(xs.shape[0]):
    zs[i]=f(xs[i],ys[i])