bundles / scipy 1.17.1 / scipy / interpolate / _fitpack2 / SphereBivariateSpline / __call__
function
scipy.interpolate._fitpack2:SphereBivariateSpline.__call__
Signature
def __call__ ( self , theta , phi , dtheta = 0 , dphi = 0 , grid = True ) Summary
Evaluate the spline or its derivatives at given positions.
Parameters
theta, phi: array_likeInput coordinates.
If
gridis False, evaluate the spline at points(theta[i], phi[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 theta, phi. The arrays must be sorted to increasing order. The ordering of axes is consistent withnp.meshgrid(..., indexing="ij")and inconsistent with the default orderingnp.meshgrid(..., indexing="xy").dtheta: int, optionalOrder of theta-derivative
dphi: intOrder of phi-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 use splines to interpolate a bivariate function on a sphere. The value of the function is known on a grid of longitudes and colatitudes.import numpy as np from scipy.interpolate import RectSphereBivariateSpline def f(theta, phi): return np.sin(theta) * np.cos(phi)✓
thetaarr = np.linspace(0, np.pi, 22)[1:-1] phiarr = np.linspace(0, 2 * np.pi, 21)[:-1] thetagrid, phigrid = np.meshgrid(thetaarr, phiarr, indexing="ij") zdata = f(thetagrid, phigrid)✓
rsbs = RectSphereBivariateSpline(thetaarr, phiarr, zdata) thetaarr_fine = np.linspace(0, np.pi, 200) phiarr_fine = np.linspace(0, 2 * np.pi, 200) zdata_fine = rsbs(thetaarr_fine, phiarr_fine)✓
import matplotlib.pyplot as plt fig = plt.figure() ax1 = fig.add_subplot(1, 2, 1) ax2 = fig.add_subplot(1, 2, 2)✓
ax1.imshow(zdata) ax2.imshow(zdata_fine)✗
plt.show()
✓
Aliases
-
scipy.interpolate._fitpack2.SphereBivariateSpline.__call__