bundles / scipy 1.17.1 / scipy / interpolate / _fitpack2 / SphereBivariateSpline / ev
function
scipy.interpolate._fitpack2:SphereBivariateSpline.ev
Signature
def ev ( self , theta , phi , dtheta = 0 , dphi = 0 ) Summary
Evaluate the spline at points
Extended Summary
Returns the interpolated value at (theta[i], phi[i]), i=0,...,len(theta)-1.
Parameters
theta, phi: array_likeInput coordinates. Standard Numpy broadcasting is obeyed. The ordering of axes is consistent with np.meshgrid(..., indexing="ij") and inconsistent with the default ordering np.meshgrid(..., indexing="xy").
dtheta: int, optionalOrder of theta-derivative
dphi: int, optionalOrder of phi-derivative
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) thetainterp = np.linspace(thetaarr[0], thetaarr[-1], 200) phiinterp = np.linspace(phiarr[0], phiarr[-1], 200) zinterp = rsbs.ev(thetainterp, phiinterp)✓
import matplotlib.pyplot as plt fig = plt.figure() ax1 = fig.add_subplot(1, 1, 1)✓
ax1.plot(np.sin(thetaarr) * np.sin(phiarr), np.diag(zdata), "or") ax1.plot(np.sin(thetainterp) * np.sin(phiinterp), zinterp, "-b")✗
plt.show()
✓
Aliases
-
scipy.interpolate._fitpack2.SphereBivariateSpline.ev