spharpy.interpolate#
Classes:
|
Smooth bivariate spline approximation in spherical coordinates. |
- class spharpy.interpolate.SmoothSphereBivariateSpline(sampling, data, w=None, s=0.0001, eps=1e-16)[source]#
Bases:
SmoothSphereBivariateSpline
Smooth bivariate spline approximation in spherical coordinates. The implementation uses the method proposed by Dierckx [1].
- Parameters:
sampling (
spharpy.samplings.Coordinates
, pf.Coordinates) – Coordinates object containing the positions for which the data is sampleddata (array, float) – Array containing the data at the sampling positions. Has to be real-valued.
w (array, float) – Weighting coefficients
s (float, 1e-4) – Smoothing factor > 0 Positive smoothing factor defined for estimation condition:
sum((w(i)*(r(i) - s(theta(i), phi(i))))**2, axis=0) <= s
Defaults=len(w)
which should be a good value if1/w[i]
is an estimate of the standard deviation ofr[i]
. The default value is1e-4
eps (float, 1e-16) – The eps valued to be considered for interpolator estimation. Depends on the used data type and numerical precision. The default is 1e-16.
Note
This is a wrapper for scipy’s SmoothSphereBivariateSpline only using Coordinates objects as container for the azimuth and elevation angles. For detailed information see scipy’s documentation.
References
Examples
>>> n_max = 10 >>> sampling = spharpy.samplings.equalarea( ... n_max, n_points=500, condition_num=np.inf) >>> Y = spharpy.spherical.spherical_harmonic_basis_real(n_max, sampling) >>> y_vec = spharpy.spherical.spherical_harmonic_basis_real( ... n_max, Coordinates(1, 0, 0)) >>> data = Y @ y_vec.T >>> data = np.sin(sampling.elevation)*np.sin(2*sampling.azimuth) >>> interp_grid = spharpy.samplings.hyperinterpolation(35) >>> data_grid = np.sin(interp_grid.elevation)*np.sin(2*interp_grid.azimuth) >>> interpolator = interpolate.SmoothSphereBivariateSpline( ... sampling, data, s=1e-4) ... >>> interp_data = interpolator(interp_grid)
Methods:
__call__
(interp_grid[, dtheta, dphi])Evaluate the spline on a new sampling grid.
Return spline coefficients.
Return a tuple (tx,ty) where tx,ty contain knots positions of the spline with respect to x-, y-variable, respectively.
Return weighted sum of squared residuals of the spline approximation: sum ((w[i]*(z[i]-s(x[i],y[i])))**2,axis=0)
- __call__(interp_grid, dtheta=0, dphi=0)[source]#
Evaluate the spline on a new sampling grid.
- Parameters:
interp_grid (
spharpy.samplings.Coordinates
, pf.Coordinates) – Coordinates object containing a new set of points for which data is to be interpolated.dtheta (int, optional) – Order of theta derivative
dphi (int, optional) – Order of phi derivative