【发布时间】:2017-02-28 09:33:39
【问题描述】:
我有一个常规的 2D X、Y 和 Z 数组,我有一个点 X0 和 Y0,我想知道网格上点 (X0, Y0) 中的 Z0 值。
我发现 scipy 有 interpolate 模块,但据我了解,它会插入 1D/2D 数组并返回 1D/2D 数组,但没有一种方法可以在某一点只返回一个值。
例如:
#My grid data
X = [ [X11, X12, X13, ..., X1N],
[X21, X22, X23, ..., X2N],
....
[XN1, XN2, XN3, ..., XNN]
Y = [ [Y11, Y12, Y13, ..., Y1N],
[Y21, Y22, Y23, ..., Y2N],
....
[YN1, YN2, YN3, ..., YNN] ]
Z = [ [Z11, Z12, Z13, ..., Z1N],
[Z21, Z22, Z23, ..., Z2N],
....
[ZN1, ZN2, ZN3, ..., ZNN] ]
#Point at which I want to know the value of the Z
X0, Y0 = ..., ...
#Now I want to call any function that'll return the value at point (X0, Y0), Z0 is float value, not array
Z0 = interpolation(X, Y, Z, X0, Y0)
据我了解,类似的函数是 scipy.interpolate.interpn,但它仅适用于 1D 数组,当我想使用 2D 数据时会出错
【问题讨论】:
标签: python arrays numpy scipy interpolation