Scipy Interpolate RectBivariateSpline构造函数返回错误

son*_*olo 3 python interpolation numpy scipy

我试图实例化Scipy Interpolate RectBivariateSpline,如下所示:

import numpy as np
from scipy.interpolate import RectBivariateSpline

x = np.array([1,2,3,4])
y = np.array([1,2,3])
vals = np.array([
    [4,1,4],
    [4,2,3],
    [3,7,4],
    [2,4,5]
])

print(x.shape)  # (4,)
print(y.shape)  # (3,)
print(vals.shape)  # (4, 3)

rect_B_spline = RectBivariateSpline(x, y, vals)
Run Code Online (Sandbox Code Playgroud)

但是,它会返回此错误:

Traceback (most recent call last):
  File "path/file", line 15, in <module>
    rect_B_spline = RectBivariateSpline(x, y, vals)
  File "path/file", line 1061, in __init__
    ye, kx, ky, s)
dfitpack.error: (my>ky) failed for hidden my: regrid_smth:my=3
Run Code Online (Sandbox Code Playgroud)

将不胜感激任何关于dfitpack错误描述以及如何解决的线索.

Jon*_*ter 5

默认情况下,RectBivariateSpline使用3次样条曲线.通过沿y轴仅提供3个点,它不能做到这一点.将ky = 2添加到参数列表可以解决问题,就像拥有更多数据一样.