vtkmodules.numpy_interface.algorithms#

This module provides a number of algorithms that can be used with the dataset classes defined in the dataset_adapter module. See the documentation of the dataset_adapter for some examples. These algorithms work in serial and in parallel as long as the data is partitioned according to VTK data parallel execution guidelines. For details, see the documentation of individual algorithms.

Module Contents#

Functions#

_apply_func2

Apply a function to each member of a VTKCompositeDataArray. Returns a list of arrays.

apply_ufunc

Apply a function to each member of a VTKCompositeDataArray. VTKArray and numpy arrays are also supported.

_make_ufunc

Given a ufunc, creates a closure that applies it to each member of a VTKCompositeDataArray.

apply_dfunc

Apply a two argument function to each member of a VTKCompositeDataArray and another argument The second argument can be a VTKCompositeDataArray, in which case a one-to-one match between arrays is assumed. Otherwise, the function is applied to the composite array with the second argument repeated. VTKArray and numpy arrays are also supported.

_make_dfunc

Given a function that requires two arguments, creates a closure that applies it to each member of a VTKCompositeDataArray.

_make_dsfunc

Given a function that requires two arguments (one array, one dataset), creates a closure that applies it to each member of a VTKCompositeDataArray. Note that this function is mainly for internal use by this module.

_make_dsfunc2

Given a function that requires a dataset, creates a closure that applies it to each member of a VTKCompositeDataArray.

_lookup_mpi_type

_reduce_dims

_global_func

bitwise_or

Implements element by element or (bitwise, | in C/C++) operation. If one of the arrays is a NoneArray, this will return the array that is not NoneArray, treating NoneArray as 0 in the or operation.

make_point_mask_from_NaNs

This method will create a ghost array corresponding to an input with NaN values. For each NaN value, the output array will have a corresponding value of vtkmodules.vtkCommonDataModel.vtkDataSetAttributes.HIDDENPOINT. These values are also combined with any ghost values that the dataset may have.

make_cell_mask_from_NaNs

This method will create a ghost array corresponding to an input with NaN values. For each NaN value, the output array will have a corresponding value of vtkmodules.vtkCommonDataModel.vtkDataSetAttributes.HIDDENCELL. These values are also combined with any ghost values that the dataset may have.

make_mask_from_NaNs

This method will create a ghost array corresponding to an input with NaN values. For each NaN value, the output array will have a corresponding value of vtkmodules.vtkCommonDataModel.vtkDataSetAttributes.HIDDENPOINT or HIDDENCELL is the is_cell argument is true. If an input ghost_array is passed, the array is bitwise_or’ed with it, simply adding the new ghost values to it.

sum

Returns the sum of all values along a particular axis (dimension). Given an array of m tuples and n components:

max

Returns the max of all values along a particular axis (dimension). Given an array of m tuples and n components:

min

Returns the min of all values along a particular axis (dimension). Given an array of m tuples and n components:

_global_per_block

sum_per_block

Returns the sum of all values along a particular axis (dimension) for each block of an VTKCompositeDataArray.

count_per_block

Return the number of elements of each block in a VTKCompositeDataArray along an axis.

mean_per_block

Returns the mean of all values along a particular axis (dimension) for each block of a VTKCompositeDataArray.

max_per_block

Returns the max of all values along a particular axis (dimension) for each block of a VTKCompositeDataArray. Given an array of m tuples and n components:

min_per_block

Returns the min of all values along a particular axis (dimension) for each block of a VTKCompositeDataArray. Given an array of m tuples and n components:

all

Returns True if all values of an array evaluate to True, returns False otherwise. This is useful to check if all values of an array match a certain condition such as:

_local_array_count

_array_count

mean

Returns the mean of all values along a particular axis (dimension). Given an array of m tuples and n components:

var

Returns the variance of all values along a particular axis (dimension). Given an array of m tuples and n components:

std

Returns the standard deviation of all values along a particular axis (dimension). Given an array of m tuples and n components:

shape

Returns the shape (dimensions) of an array.

make_vector

Given 2 or 3 scalar arrays, returns a vector array. If only 2 scalars are provided, the third component will be set to 0.

unstructured_from_composite_arrays

Given a set of VTKCompositeDataArrays, creates a vtkUnstructuredGrid. The main goal of this function is to transform the output of XXX_per_block() methods to a single dataset that can be visualized and further processed. Here arrays is an iterable (e.g. list) of (array, name) pairs. Here is an example:

Data#

API#

vtkmodules.numpy_interface.algorithms._apply_func2(func, array, args)#

Apply a function to each member of a VTKCompositeDataArray. Returns a list of arrays.

Note that this function is mainly for internal use by this module.

vtkmodules.numpy_interface.algorithms.apply_ufunc(func, array, args=())#

Apply a function to each member of a VTKCompositeDataArray. VTKArray and numpy arrays are also supported.

vtkmodules.numpy_interface.algorithms._make_ufunc(ufunc)#

Given a ufunc, creates a closure that applies it to each member of a VTKCompositeDataArray.

Note that this function is mainly for internal use by this module.

vtkmodules.numpy_interface.algorithms.apply_dfunc(dfunc, array1, val2)#

Apply a two argument function to each member of a VTKCompositeDataArray and another argument The second argument can be a VTKCompositeDataArray, in which case a one-to-one match between arrays is assumed. Otherwise, the function is applied to the composite array with the second argument repeated. VTKArray and numpy arrays are also supported.

vtkmodules.numpy_interface.algorithms._make_dfunc(dfunc)#

Given a function that requires two arguments, creates a closure that applies it to each member of a VTKCompositeDataArray.

Note that this function is mainly for internal use by this module.

vtkmodules.numpy_interface.algorithms._make_dsfunc(dsfunc)#

Given a function that requires two arguments (one array, one dataset), creates a closure that applies it to each member of a VTKCompositeDataArray. Note that this function is mainly for internal use by this module.

vtkmodules.numpy_interface.algorithms._make_dsfunc2(dsfunc)#

Given a function that requires a dataset, creates a closure that applies it to each member of a VTKCompositeDataArray.

Note that this function is mainly for internal use by this module.

vtkmodules.numpy_interface.algorithms._lookup_mpi_type(ntype)#
vtkmodules.numpy_interface.algorithms._reduce_dims(array, comm)#
vtkmodules.numpy_interface.algorithms._global_func(impl, array, axis, controller)#
vtkmodules.numpy_interface.algorithms.bitwise_or(array1, array2)#

Implements element by element or (bitwise, | in C/C++) operation. If one of the arrays is a NoneArray, this will return the array that is not NoneArray, treating NoneArray as 0 in the or operation.

vtkmodules.numpy_interface.algorithms.make_point_mask_from_NaNs(dataset, array)#

This method will create a ghost array corresponding to an input with NaN values. For each NaN value, the output array will have a corresponding value of vtkmodules.vtkCommonDataModel.vtkDataSetAttributes.HIDDENPOINT. These values are also combined with any ghost values that the dataset may have.

vtkmodules.numpy_interface.algorithms.make_cell_mask_from_NaNs(dataset, array)#

This method will create a ghost array corresponding to an input with NaN values. For each NaN value, the output array will have a corresponding value of vtkmodules.vtkCommonDataModel.vtkDataSetAttributes.HIDDENCELL. These values are also combined with any ghost values that the dataset may have.

vtkmodules.numpy_interface.algorithms.make_mask_from_NaNs(array, ghost_array=dsa.NoneArray, is_cell=False)#

This method will create a ghost array corresponding to an input with NaN values. For each NaN value, the output array will have a corresponding value of vtkmodules.vtkCommonDataModel.vtkDataSetAttributes.HIDDENPOINT or HIDDENCELL is the is_cell argument is true. If an input ghost_array is passed, the array is bitwise_or’ed with it, simply adding the new ghost values to it.

vtkmodules.numpy_interface.algorithms.sum(array, axis=None, controller=None)#

Returns the sum of all values along a particular axis (dimension). Given an array of m tuples and n components:

  • Default is to return the sum of all values in an array.

  • axis=0: Sum values of all components and return a one tuple, n-component array.

  • axis=1: Sum values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will sum across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

sum(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.max(array, axis=None, controller=None)#

Returns the max of all values along a particular axis (dimension). Given an array of m tuples and n components:

  • Default is to return the max of all values in an array.

  • axis=0: Return the max values of all tuples and return a one tuple, n-component array.

  • axis=1: Return the max values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the max across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

max(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.min(array, axis=None, controller=None)#

Returns the min of all values along a particular axis (dimension). Given an array of m tuples and n components:

  • Default is to return the min of all values in an array.

  • axis=0: Return the min values of all tuples and return a one tuple, n-component array.

  • axis=1: Return the min values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the min across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

min(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms._global_per_block(impl, array, axis=None, controller=None)#
vtkmodules.numpy_interface.algorithms.sum_per_block(array, axis=None, controller=None)#

Returns the sum of all values along a particular axis (dimension) for each block of an VTKCompositeDataArray.

Given an array of m tuples and n components:

  • Default is to return the sum of all values in an array.

  • axis=0: Sum values of all components and return a one tuple, n-component array.

  • axis=1: Sum values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will sum across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

sum_per_block(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.count_per_block(array, axis=None, controller=None)#

Return the number of elements of each block in a VTKCompositeDataArray along an axis.

  • if axis is None, the number of all elements (ntuples * ncomponents) is returned.

  • if axis is 0, the number of tuples is returned.

vtkmodules.numpy_interface.algorithms.mean_per_block(array, axis=None, controller=None)#

Returns the mean of all values along a particular axis (dimension) for each block of a VTKCompositeDataArray.

Given an array of m tuples and n components:

  • Default is to return the mean of all values in an array.

  • axis=0: Return the mean values of all components and return a one tuple, n-component array.

  • axis=1: Return the mean values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the mean across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

mean(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.max_per_block(array, axis=None, controller=None)#

Returns the max of all values along a particular axis (dimension) for each block of a VTKCompositeDataArray. Given an array of m tuples and n components:

  • Default is to return the max of all values in an array.

  • axis=0: Return the max values of all components and return a one tuple, n-component array.

  • axis=1: Return the max values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the max across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

max_per_block(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.min_per_block(array, axis=None, controller=None)#

Returns the min of all values along a particular axis (dimension) for each block of a VTKCompositeDataArray. Given an array of m tuples and n components:

  • Default is to return the min of all values in an array.

  • axis=0: Return the min values of all components and return a one tuple, n-component array.

  • axis=1: Return the min values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the min across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

min_per_block(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.all(array, axis=None, controller=None)#

Returns True if all values of an array evaluate to True, returns False otherwise. This is useful to check if all values of an array match a certain condition such as:

algorithms.all(array > 5)

vtkmodules.numpy_interface.algorithms._local_array_count(array, axis)#
vtkmodules.numpy_interface.algorithms._array_count(array, axis, controller)#
vtkmodules.numpy_interface.algorithms.mean(array, axis=None, controller=None, size=None)#

Returns the mean of all values along a particular axis (dimension). Given an array of m tuples and n components:

  • Default is to return the mean of all values in an array.

  • axis=0: Return the mean values of all components and return a one tuple, n-component array.

  • axis=1: Return the mean values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the mean across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

mean(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.var(array, axis=None, controller=None)#

Returns the variance of all values along a particular axis (dimension). Given an array of m tuples and n components:

  • Default is to return the variance of all values in an array.

  • axis=0: Return the variance values of all components and return a one tuple, n-component array.

  • axis=1: Return the variance values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the variance across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

var(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.std(array, axis=None, controller=None)#

Returns the standard deviation of all values along a particular axis (dimension). Given an array of m tuples and n components:

  • Default is to return the standard deviation of all values in an array.

  • axis=0: Return the standard deviation values of all components and return a one tuple, n-component array.

  • axis=1: Return the standard deviation values of all components of each tuple and return an m-tuple, 1-component array.

When called in parallel, this function will compute the standard deviation across processes when a controller argument is passed or the global controller is defined. To disable parallel summing when running in parallel, pass a dummy controller as follows:

std(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).

vtkmodules.numpy_interface.algorithms.shape(array)#

Returns the shape (dimensions) of an array.

vtkmodules.numpy_interface.algorithms.make_vector(arrayx, arrayy, arrayz=None)#

Given 2 or 3 scalar arrays, returns a vector array. If only 2 scalars are provided, the third component will be set to 0.

vtkmodules.numpy_interface.algorithms.unstructured_from_composite_arrays(points, arrays, controller=None)#

Given a set of VTKCompositeDataArrays, creates a vtkUnstructuredGrid. The main goal of this function is to transform the output of XXX_per_block() methods to a single dataset that can be visualized and further processed. Here arrays is an iterable (e.g. list) of (array, name) pairs. Here is an example:

centroid = mean_per_block(composite_data.Points) T = mean_per_block(composite_data.PointData[‘Temperature’]) ug = unstructured_from_composite_arrays(centroid, (T, ‘Temperature’))

When called in parallel, this function makes sure that each array in the input dataset is represented only on 1 process. This is important because methods like mean_per_block() return the same value for blocks that are partitioned on all of the participating processes. If the same point were to be created across multiple processes in the output, filters like histogram would report duplicate values erroneously.

vtkmodules.numpy_interface.algorithms.in1d#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.isnan#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.sqrt#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.negative#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.reciprocal#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.square#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.exp#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.floor#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.ceil#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.rint#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.sin#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.cos#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.tan#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.arcsin#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.arccos#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.arctan#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.arctan2#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.sinh#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.cosh#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.tanh#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.arcsinh#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.arccosh#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.arctanh#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.where#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.flatnonzero#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.nonzero#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.expand_dims#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.abs#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.area#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.aspect#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.aspect_gamma#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.condition#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.cross#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.curl#

‘_make_dsfunc(…)’

vtkmodules.numpy_interface.algorithms.divergence#

‘_make_dsfunc(…)’

vtkmodules.numpy_interface.algorithms.det#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.determinant#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.diagonal#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.dot#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.eigenvalue#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.eigenvector#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.gradient#

‘_make_dsfunc(…)’

vtkmodules.numpy_interface.algorithms.inv#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.inverse#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.jacobian#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.laplacian#

‘_make_dsfunc(…)’

vtkmodules.numpy_interface.algorithms.ln#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.log#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.log10#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.max_angle#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.mag#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.matmul#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.min_angle#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.norm#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.shear#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.skew#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.strain#

‘_make_dsfunc(…)’

vtkmodules.numpy_interface.algorithms.surface_normal#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.trace#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.volume#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.vorticity#

‘_make_dsfunc(…)’

vtkmodules.numpy_interface.algorithms.vertex_normal#

‘_make_dsfunc2(…)’

vtkmodules.numpy_interface.algorithms.logical_not#

‘_make_ufunc(…)’

vtkmodules.numpy_interface.algorithms.divide#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.multiply#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.add#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.subtract#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.mod#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.remainder#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.power#

‘_make_dfunc(…)’

vtkmodules.numpy_interface.algorithms.hypot#

‘_make_dfunc(…)’