interpolate
EdgeEquidistantDivider
Add points and values by uniformly dividing edges.
Attributes:
| Name | Type | Description |
|---|---|---|
edges_length |
ndarray[K]
|
Length of edges. |
edge_length_max |
float
|
Maximal edge length. |
edge_length_max = None
instance-attribute
edges_length = None
instance-attribute
__init__()
apply(values, edges)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values |
ndarray[N, M] or [N]
|
Input array(s) to interpolate. |
required |
edges |
ndarray[K, 2]
|
Connected pairs of nodes. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Input array with interpolated values. |
EdgeSubdivInterpolator
edge_divider = EdgeEquidistantDivider()
instance-attribute
__init__()
apply_to_graph(graph, edge_length_max, node_attr='scalars')
Subdivides edges in a graph whose lengths are greater than a specified maximum length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph |
Graph
|
Dgm graph object. |
required |
edge_length_max |
float
|
The maximum length allowed for graph edges. |
required |
node_attr |
str
|
Graph node attribute that will be also interpolated. Defaults to "scalars". |
'scalars'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
ndarray[N, 3]: Array containing the node coordinates. |
ndarray
|
ndarray[N, ]: Array containing the node attribute (scalars). |
get_edge_divider()
interpolate(nodes_coords, nodes_scalars, edges, edges_length, edge_length_max)
Introduce new points and scalar value using edge subdivition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes_coords |
ndarray[N, 3]
|
Coords of the points. |
required |
nodes_scalars |
ndarray[N] or [N, M]
|
Scalar or multiple scalars. |
required |
edges |
ndarray[K, 2]
|
Connections. |
required |
edges_length |
ndarray[K]
|
Edges length. |
required |
edge_length_max |
float
|
Max allowed edge length. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[ndarray, ndarray]
|
Coords and scalars of old and new points. |
set_edge_divider(divider)
EdgeUniformDivider
Add points and values by uniformly dividing edges.
Attributes:
| Name | Type | Description |
|---|---|---|
num_div |
int
|
Number of divition per edges |
num_div = num_div
instance-attribute
__init__(num_div)
apply(values, edges)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values |
ndarray[N, M] or [N]
|
Input array(s) to interpolate. |
required |
edges |
ndarray[K, 2]
|
Connected pairs of nodes. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Input array with interpolated values. |
InterpolationKernels
A collection of interpolation kernels for VTK interpolators.
__init__()
gaussian_kernel(radius=10, sharpness=6)
staticmethod
Initizlize and return gaussian interpolation kernel.
For more info see
https://vtk.org/doc/nightly/html/classvtkGaussianKernel.html#details
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius |
float
|
Kernel radius. Defaults to 10. |
10
|
sharpness |
int
|
Kernel sharpness. Defaults to 6. |
6
|
Returns:
| Name | Type | Description |
|---|---|---|
vtkGaussianKernel |
vtkGaussianKernel
|
Initialized gaussian interpolation kernel. |
linear_kernel(radius=5)
staticmethod
Initizlize and return linear interpolation kernel.
For more info see
https://vtk.org/doc/nightly/html/classvtkLinearKernel.html#details
Returns:
| Name | Type | Description |
|---|---|---|
vtkLinearKernel |
vtkLinearKernel
|
Initialized linear interpolation kernel. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius |
int
|
Kernel radius. Defaults to 5. |
5
|
shepard_kernel(radius=10, power=5)
staticmethod
Initizlize and return shepard interpolation kernel.
For more info see
https://vtk.org/doc/nightly/html/classvtkShepardKernel.html#details
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius |
float
|
Kernel radius. |
10
|
power |
int
|
Kernel positive exponent. |
5
|
Returns:
| Name | Type | Description |
|---|---|---|
vtkShepardKernel |
vtkShepardKernel
|
initialized shepard interpolation kernel. |
voronoi_kernel()
staticmethod
Initizlize and return voronoi interpolation kernel.
For more info see
https://vtk.org/doc/nightly/html/classvtkVoronoiKernel.html#details
Returns:
| Name | Type | Description |
|---|---|---|
vtkVoronoiKernel |
vtkVoronoiKernel
|
Initialized voronoi interpolation kernel. |
ScalarInterpolator
Preprocessing of the LAT values of the input.
cluster_scalars(coords, mesh_coords, mesh_scalars, distance=10, vocal=False)
staticmethod
Interpolate the scalar values based on the neighborhood.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords |
ndarray
|
Coordinates of the points you want to smooth. |
required |
mesh_coords |
list
|
Coordinates of the mesh. |
required |
mesh_scalars |
list
|
Scalars of the mesh. |
required |
distance |
int
|
Smoothing distance. Defaults to 10. |
10
|
vocal |
bool
|
Print progress. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
ndarray
|
Array of smoothed values for all coords. |
stitch_scalars(triangles, scalars, threshold=95)
staticmethod
Remove the triangles where the vertices of the triangles have a big differences in scalars and stitch the mesh back toghether using the scalars of the neighboring vertices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
triangles |
ndarray
|
Triangles of the mesh. |
required |
scalars |
ndarray
|
Scalars of all mesh vertices. |
required |
threshold |
float
|
Percentile of all LAT differences between the vertices in a triangle that are considered good. Defaults to 95. |
95
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
triangles, scalars (tuple): Stitched triangles and scalars of the improved mesh. |
VTKInterpolator
Class for polydata interpolation. Uses polydata points to apply one of selected kernels over it.
Following kernel are available
- Shepard kernel
- Gaussian kernel
- Voronoi kernel
- Linear kernel
For more info see
https://vtk.org/doc/nightly/html/classvtkPointInterpolator.html#details
Attributes:
| Name | Type | Description |
|---|---|---|
kernel |
The kernel used for interpolation. |
|
point_locator |
The point locator used for interpolation. |
kernel = InterpolationKernels.voronoi_kernel()
instance-attribute
point_locator = vtkPointLocator()
instance-attribute
__init__()
interpolate(input_data, source_data=None, pass_arrays=False)
Interpolate point data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data |
vtkPolyData
|
Input polydata |
required |
source_data |
vtkPolyData
|
Source polydata which will be used for interpolation. If None input_data will be used. |
None
|
pass_arrays |
bool
|
If True all point arrays will be passed to output. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPointInterpolator
|
vtkPolydata with interpolated data. |
interpolator(pass_arrays=False)
Return point interpolator with selected kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pass_arrays |
bool
|
If True all point arrays will be passed to output. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
vtkPointInterpolator |
vtkPointInterpolator
|
vtkPointInterpolator object. |