scijit.interpolate.bisplev

scijit.interpolate.bisplev(x, y, tck, dx=0, dy=0)

Evaluate a bivariate spline on a grid.

Parameters:
xfloat or 1-D array_like of float

Grid abscissae, non-decreasing. A scalar or 0-d array is one point.

yfloat or 1-D array_like of float

Grid ordinates, non-decreasing. The spline is evaluated on the full CROSS PRODUCT.

tcktuple of (tx, ty, c, kx, ky)

Bivariate spline representation: knots in x and y, coefficients in FITPACK’s flat layout c[(ny-ky-1)*i + j], and the two degrees.

dx, dyint, optional

Orders of the partial derivatives in x and y. 0 <= dx < kx and 0 <= dy < ky. Both default to 0.

Returns:
zfloat, or 1-D or 2-D float64 ndarray

Spline values on the grid. A float when x and y are both a scalar or a 0-d array, a 1-D array of length len(y) when only x is, and the (len(x), len(y)) grid otherwise.

Raises:
ValueError

If dx or dy is out of range, if x or y has a rank above 1, is empty or is decreasing, or if len(c) != (len(tx)-kx-1) * (len(ty)-ky-1).

See also

scipy.interpolate.bisplev

The scipy routine this mirrors.

Notes

  • The return rank follows a squeeze as far as the argument TYPES settle it, which is the two cases named under Returns. scipy squeezes on the run-time LENGTHS, so it also returns a float where len(x) == len(y) == 1 and a 1-D array where len(x) == 1 < len(y). A compiled body fixes its return rank while it compiles and an array carries no length until it runs, so those two follow the length only when the coordinate is a scalar.

prange-safe: yes.

Examples

>>> import numpy as np
>>> from numba import njit
>>> from scijit.interpolate import RectBivariateSpline, bisplev
>>> x = np.linspace(0, 1, 12)
>>> y = np.linspace(0, 1, 15)
>>> z = np.outer(np.sin(3 * x), np.cos(2 * y))
>>> spl = RectBivariateSpline(x, y, z)
>>> tck = (spl.tx, spl.ty, spl.c, spl.kx, spl.ky)
>>> @njit
... def grid(tck, qx, qy):
...     return bisplev(qx, qy, tck)
>>> float(np.round(grid(tck, np.array([0.5]), np.array([0.5]))[0, 0], 8))
0.53894085