Scipy 插入 RectBivariateSpline 构造函数 returns 一个错误
Scipy Interpolate RectBivariateSpline constructor returns an error
我正在尝试实例化一个 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)
但是,它returns这个错误:
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 错误描述内容和解决方法的任何线索。
默认情况下,RectBivariateSpline 使用 3 阶样条。通过仅提供沿 y 轴的 3 个点,它无法做到这一点。将 ky=2 添加到参数列表可以解决问题,拥有更多数据也是如此。
我正在尝试实例化一个 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)
但是,它returns这个错误:
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 错误描述内容和解决方法的任何线索。
默认情况下,RectBivariateSpline 使用 3 阶样条。通过仅提供沿 y 轴的 3 个点,它无法做到这一点。将 ky=2 添加到参数列表可以解决问题,拥有更多数据也是如此。