cupyx.scipy.interpolate.LinearNDInterpolator#
- class cupyx.scipy.interpolate.LinearNDInterpolator(points, values, fill_value=cupy.nan, rescale=False)[source]#
Piecewise linear interpolant in N > 1 dimensions.
- Parameters:
points (ndarray of floats, shape (npoints, ndims); or
Delaunay
) – 2-D array of data point coordinates, or a precomputed Delaunay triangulation.values (ndarray of float or complex, shape (npoints, ...), optional) – N-D array of data values at points. The length of values along the first axis must be equal to the length of points. Unlike some interpolators, the interpolation axis cannot be changed.
fill_value (float, optional) – Value used to fill in for requested points outside of the convex hull of the input points. If not provided, then the default is
nan
.rescale (bool, optional) – Rescale 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.
Notes
The interpolant is constructed by triangulating the input data with GDel2D [1], and on each triangle performing linear barycentric interpolation.
Note
For data on a regular grid use interpn instead.
Examples
We can interpolate values on a 2D plane:
>>> from scipy.interpolate import LinearNDInterpolator >>> 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 = LinearNDInterpolator(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() >>> plt.colorbar() >>> plt.axis("equal") >>> plt.show()
See also
griddata
Interpolate unstructured D-D data.
NearestNDInterpolator
Nearest-neighbor interpolation in N dimensions.
CloughTocher2DInterpolator
Piecewise cubic, C1 smooth, curvature-minimizing interpolant in 2D.
interpn
Interpolation on a regular grid or rectilinear grid.
RegularGridInterpolator
Interpolation on a regular or rectilinear grid in arbitrary dimensions (interpn wraps this class).
References
Methods
- __call__(*args)[source]#
interpolator(xi)
Evaluate interpolator at given points.
- Parameters:
x1 (array-like of float) – Points where to interpolate data at. x1, x2, … xn can be array-like of float with broadcastable shape. or x1 can be array-like of float with shape
(..., ndim)
x2 (array-like of float) – Points where to interpolate data at. x1, x2, … xn can be array-like of float with broadcastable shape. or x1 can be array-like of float with shape
(..., ndim)
xn (...) – Points where to interpolate data at. x1, x2, … xn can be array-like of float with broadcastable shape. or x1 can be array-like of float with shape
(..., ndim)
- __eq__(value, /)#
Return self==value.
- __ne__(value, /)#
Return self!=value.
- __lt__(value, /)#
Return self<value.
- __le__(value, /)#
Return self<=value.
- __gt__(value, /)#
Return self>value.
- __ge__(value, /)#
Return self>=value.