我试图按如下方式实例化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)
但是,它会返回此错误:
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
对于dfitpack错误描述的内容以及解决方法的任何线索表示感谢。
答案 0 :(得分:5)
默认情况下,RectBivariateSpline使用3度样条曲线。通过沿y轴仅提供3个点,它不能做到这一点。将ky = 2添加到参数列表可以解决问题,就像拥有更多数据一样。