classmatplotlib.tri.CubicTriInterpolator(triangulation, z, kind='min_E', trifinder=None, dz=None)[source]
 
Bases: matplotlib.tri.triinterpolate.TriInterpolator Cubic interpolator on a triangular grid. In one-dimension - on a segment - a cubic interpolating function is defined by the values of the function and its derivative at both ends. This is almost the same in 2D inside a triangle, except that the values of the function and its 2 derivatives have to be defined at each triangle node. The CubicTriInterpolator takes the value of the function at each node - provided by the user - and internally computes the value of the derivatives, resulting in a smooth interpolation. (As a special feature, the user can also impose the value of the derivatives at each node, but this is not supposed to be the common usage.)  Parameters 
 
triangulationTriangulation


The triangulation to interpolate over.  
z(npoints,) array-like


Array of values, defined at grid points, to interpolate between.  
kind{'min_E', 'geom', 'user'}, optional


Choice of the smoothing algorithm, in order to compute the interpolant derivatives (defaults to 'min_E'):  if 'min_E': (default) The derivatives at each node is computed to minimize a bending energy. if 'geom': The derivatives at each node is computed as a weighted average of relevant triangle normals. To be used for speed optimization (large grids). if 'user': The user provides the argument dz, no computation is hence needed.   
trifinderTriFinder, optional


If not specified, the Triangulation's default TriFinder will be used by calling Triangulation.get_trifinder.  
dztuple of array-likes (dzdx, dzdy), optional


Used only if kind ='user'. In this case dz must be provided as (dzdx, dzdy) where dzdx, dzdy are arrays of the same shape as z and are the interpolant first derivatives at the triangulation points.     Notes This note is a bit technical and details how the cubic interpolation is computed. The interpolation is based on a Clough-Tocher subdivision scheme of the triangulation mesh (to make it clearer, each triangle of the grid will be divided in 3 child-triangles, and on each child triangle the interpolated function is a cubic polynomial of the 2 coordinates). This technique originates from FEM (Finite Element Method) analysis; the element used is a reduced Hsieh-Clough-Tocher (HCT) element. Its shape functions are described in [1]. The assembled function is guaranteed to be C1-smooth, i.e. it is continuous and its first derivatives are also continuous (this is easy to show inside the triangles but is also true when crossing the edges). In the default case (kind ='min_E'), the interpolant minimizes a curvature energy on the functional space generated by the HCT element shape functions - with imposed values but arbitrary derivatives at each node. The minimized functional is the integral of the so-called total curvature (implementation based on an algorithm from [2] - PCG sparse solver):  \[E(z) = \frac{1}{2} \int_{\Omega} \left( \left( \frac{\partial^2{z}}{\partial{x}^2} \right)^2 + \left( \frac{\partial^2{z}}{\partial{y}^2} \right)^2 + 2\left( \frac{\partial^2{z}}{\partial{y}\partial{x}} \right)^2 \right) dx\,dy\] If the case kind ='geom' is chosen by the user, a simple geometric approximation is used (weighted average of the triangle normal vectors), which could improve speed on very large grids. References  1 
Michel Bernadou, Kamal Hassan, "Basis functions for general Hsieh-Clough-Tocher triangles, complete or reduced.", International Journal for Numerical Methods in Engineering, 17(5):784 - 789. 2.01.  2 
C.T. Kelley, "Iterative Methods for Optimization".   Methods  
`__call__` (x, y) (Returns interpolated values at (x, y) points.)  
`gradient` (x, y) (Returns interpolated derivatives at (x, y) points.)     gradient(x, y)[source]
 
Returns a list of 2 masked arrays containing interpolated derivatives at the specified (x, y) points.  Parameters 
 
x, yarray-like


x and y coordinates of the same shape and any number of dimensions.    Returns 
 
dzdx, dzdynp.ma.array


2 masked arrays of the same shape as x and y; values corresponding to (x, y) points outside of the triangulation are masked out. The first returned array contains the values of \(\frac{\partial z}{\partial x}\) and the second those of \(\frac{\partial z}{\partial y}\).