bundles / scipy 1.17.1 / scipy / interpolate / _fitpack2 / _BivariateSplineBase / __call__
function
scipy.interpolate._fitpack2:_BivariateSplineBase.__call__
Signature
def __call__ ( self , x , y , dx = 0 , dy = 0 , grid = True ) Summary
Evaluate the spline or its derivatives at given positions.
Parameters
x, y: array_likeInput coordinates.
If
gridis False, evaluate the spline at points(x[i], y[i]), i=0, ..., len(x)-1. Standard Numpy broadcasting is obeyed.If
gridis True: evaluate spline at the grid points defined by the coordinate arrays x, y. The arrays must be sorted to increasing order.The ordering of axes is consistent with
np.meshgrid(..., indexing="ij")and inconsistent with the default orderingnp.meshgrid(..., indexing="xy").dx: intOrder of x-derivative
dy: intOrder of y-derivative
grid: boolWhether to evaluate the results on a grid spanned by the input arrays, or at points specified by the input arrays.
Examples
Suppose that we want to bilinearly interpolate an exponentially decaying function in 2 dimensions.import numpy as np from scipy.interpolate import RectBivariateSpline✓
xarr = np.linspace(-3, 3, 100) yarr = np.linspace(-3, 3, 100) xgrid, ygrid = np.meshgrid(xarr, yarr, indexing="ij")✓
zdata = np.exp(-np.sqrt((xgrid / 2) ** 2 + ygrid**2))
✓rbs = RectBivariateSpline(xarr, yarr, zdata, kx=1, ky=1) xarr_fine = np.linspace(-3, 3, 200) yarr_fine = np.linspace(-3, 3, 200) xgrid_fine, ygrid_fine = np.meshgrid(xarr_fine, yarr_fine, indexing="ij") zdata_interp = rbs(xgrid_fine, ygrid_fine, grid=False)✓
import matplotlib.pyplot as plt fig = plt.figure() ax1 = fig.add_subplot(1, 2, 1, aspect="equal") ax2 = fig.add_subplot(1, 2, 2, aspect="equal")✓
ax1.imshow(zdata) ax2.imshow(zdata_interp)✗
plt.show()
✓
Aliases
-
scipy.interpolate._fitpack2._BivariateSplineBase.__call__