bundles / scipy latest / scipy / interpolate / _interpnd / CloughTocher2DInterpolator
class
scipy.interpolate._interpnd:CloughTocher2DInterpolator
source: /scipy/interpolate/_interpnd.cpython-314-x86_64-linux-gnu.so
Signature
class CloughTocher2DInterpolator ( points , values , fill_value = nan , tol = 1e-06 , maxiter = 400 , rescale = False ) Members
Summary
Piecewise cubic, C1 smooth, curvature-minimizing interpolator in N=2 dimensions.
Extended Summary
Parameters
points: ndarray of floats, shape (npoints, ndims); or Delaunay2-D array of data point coordinates, or a precomputed Delaunay triangulation.
values: ndarray of float or complex, shape (npoints, ...)N-D array of data values at
points. The length ofvaluesalong the first axis must be equal to the length ofpoints. Unlike some interpolators, the interpolation axis cannot be changed.fill_value: float, optionalValue used to fill in for requested points outside of the convex hull of the input points. If not provided, then the default is
nan.tol: float, optionalAbsolute/relative tolerance for gradient estimation.
maxiter: int, optionalMaximum number of iterations in gradient estimation.
rescale: bool, optionalRescale points to unit cube before performing interpolation. This is useful if some of the input dimensions have incommensurable units and differ by many orders of magnitude.
Methods
__call__
Notes
The interpolant is constructed by triangulating the input data with Qhull [1], and constructing a piecewise cubic interpolating Bezier polynomial on each triangle, using a Clough-Tocher scheme [CT]. The interpolant is guaranteed to be continuously differentiable.
The gradients of the interpolant are chosen so that the curvature of the interpolating surface is approximatively minimized. The gradients necessary for this are estimated using the global algorithm described in [Nielson83] and [Renka84].
Examples
We can interpolate values on a 2D plane:from scipy.interpolate import CloughTocher2DInterpolator import numpy as np import matplotlib.pyplot as plt rng = np.random.default_rng() x = rng.random(10) - 0.5 y = rng.random(10) - 0.5 z = np.hypot(x, y) X = np.linspace(min(x), max(x)) Y = np.linspace(min(y), max(y)) X, Y = np.meshgrid(X, Y) # 2D grid for interpolation interp = CloughTocher2DInterpolator(list(zip(x, y)), z) Z = interp(X, Y)✓
plt.pcolormesh(X, Y, Z, shading='auto') plt.plot(x, y, "ok", label="input point") plt.legend(loc="upper right") plt.colorbar() plt.axis("equal")✗
plt.show()
✓
See also
- LinearNDInterpolator
Piecewise linear interpolator in N > 1 dimensions.
- NearestNDInterpolator
Nearest-neighbor interpolator in N > 1 dimensions.
- RegularGridInterpolator
Interpolator on a regular or rectilinear grid in arbitrary dimensions (
interpnwraps this class).- griddata
Interpolate unstructured D-D data.
- interpn
Interpolation on a regular grid or rectilinear grid.
Aliases
-
scipy.interpolate.CloughTocher2DInterpolator