Nearest-neighbor interpolation in N > 1 dimensions.
Uses scipy.spatial.cKDTree
Data point coordinates.
Data values.
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.
Options passed to the underlying cKDTree
.
NearestNDInterpolator(x, y).
CloughTocher2DInterpolator
Piecewise cubic, C1 smooth, curvature-minimizing interpolant in 2D.
LinearNDInterpolator
Piecewise linear interpolant in N dimensions.
griddata
Interpolate unstructured D-D data.
We can interpolate values on a 2D plane:
>>> from scipy.interpolate import NearestNDInterpolatorSee :
... 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 = NearestNDInterpolator(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()
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.interpolate._interpolate.interpn
scipy.interpolate._ndgriddata.griddata
scipy.interpolate._interpolate.RegularGridInterpolator
scipy.interpolate.interpnd.LinearNDInterpolator
scipy.interpolate._rbfinterp.RBFInterpolator
scipy.interpolate._ndgriddata.NearestNDInterpolator
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them