compute_derivative

DataSetFilters.compute_derivative(scalars=None, gradient=True, divergence=None, vorticity=None, qcriterion=None, faster=False, preference='point', progress_bar=False)

Compute derivative-based quantities of point/cell scalar field.

Utilize vtkGradientFilter to compute derivative-based quantities, such as gradient, divergence, vorticity, and Q-criterion, of the selected point or cell scalar field.

Parameters
scalarsstr, optional

String name of the scalars array to use when computing the derivative quantities. Defaults to the active scalars in the dataset.

gradientbool, str, optional

Calculate gradient. If a string is passed, the string will be used for the resulting array name. Otherwise, array name will be 'gradient'. Default True.

divergencebool, str, optional

Calculate divergence. If a string is passed, the string will be used for the resulting array name. Otherwise, array name will be 'divergence'. Default None.

vorticitybool, str, optional

Calculate vorticity. If a string is passed, the string will be used for the resulting array name. Otherwise, array name will be 'vorticity'. Default None.

qcriterionbool, str, optional

Calculate qcriterion. If a string is passed, the string will be used for the resulting array name. Otherwise, array name will be 'qcriterion'. Default None.

fasterbool, optional

Use faster algorithm for computing derivative quantities. Result is less accurate and performs fewer derivative calculations, increasing computation speed. The error will feature smoothing of the output and possibly errors at boundaries. Option has no effect if DataSet is not UnstructuredGrid. Default False.

preferencestr, optional

Data type preference. Either 'point' or 'cell'.

progress_barbool, optional

Display a progress bar to indicate progress.

Returns
pyvista.DataSet

Dataset with calculated derivative.

Examples

First, plot the random hills dataset with the active elevation scalars. These scalars will be used for the derivative calculations.

>>> from pyvista import examples
>>> hills = examples.load_random_hills()
>>> hills.plot(smooth_shading=True)
../../../_images/pyvista-DataSetFilters-compute_derivative-1_00_00.png

Compute and plot the gradient of the active scalars.

>>> from pyvista import examples
>>> hills = examples.load_random_hills()
>>> deriv = hills.compute_derivative()
>>> deriv.plot(scalars='gradient')
../../../_images/pyvista-DataSetFilters-compute_derivative-1_01_00.png

See the Compute Gradients of a Field for more examples using this filter.