Scipy Interpolate RectBivariateSpline constructor returns error

I am trying to instantiate Scipy Interpolate RectBivariateSpline like this:

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)

      

However, it returns this error:

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

      

Any hints as to what the dfitpack error describes and how to resolve it would be needed.

+3


source to share


1 answer


By default, RectBivariateSpline uses a spline of degree 3. By providing only 3 points along the y-axis, it cannot. Adding ky = 2 to the argument list fixes the problem and also has more data.



+5


source







All Articles