【问题标题】:Scipy Interpolate RectBivariateSpline constructor returns an errorScipy Interpolate RectBivariateSpline 构造函数返回错误
【发布时间】:2015-05-06 15:55:31
【问题描述】:

我正在尝试按如下方式实例化 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 错误描述和解决方法的线索。

【问题讨论】:

    标签: python numpy scipy interpolation


    【解决方案1】:

    默认情况下,RectBivariateSpline 使用 3 次样条。通过沿 y 轴仅提供 3 个点,它无法做到这一点。将 ky=2 添加到参数列表可以解决问题,拥有更多数据也是如此。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-17
      • 2016-10-02
      • 1970-01-01
      • 2018-01-20
      • 2019-11-23
      • 2012-08-07
      • 2013-10-03
      • 1970-01-01
      相关资源
      最近更新 更多