StructuredGrid.extract_subset

StructuredGrid.extract_subset#

StructuredGrid.extract_subset(voi, rate=(1, 1, 1), boundary: bool = False)[source]#

Select piece (for example, volume of interest).

To use this filter set the VOI ivar which are i-j-k min/max indices that specify a rectangular region in the data. (Note that these are 0-offset.) You can also specify a sampling rate to subsample the data.

Typical applications of this filter are to extract a slice from a volume for image processing, subsampling large volumes to reduce data size, or extracting regions of a volume with interesting data.

Parameters:
voisequence[int]

Length 6 iterable of ints: (x_min, x_max, y_min, y_max, z_min, z_max). These bounds specify the volume of interest in i-j-k min/max indices.

ratesequence[int], default: (1, 1, 1)

Length 3 iterable of ints: (xrate, yrate, zrate).

boundarybool, default: False

Control whether to enforce that the “boundary” of the grid is output in the subsampling process. (This only has effect when the rate in any direction is not equal to 1). When this is on, the subsampling will always include the boundary of the grid even if the sample rate is not an even multiple of the grid dimensions.

Returns:
pyvista.StructuredGrid

StructuredGrid with extracted subset.

Examples#

Download Python source code | Download Jupyter notebook

Split a grid in half.

>>> import numpy as np
>>> import pyvista as pv
>>> from pyvista import examples
>>> grid = examples.load_structured()
>>> voi_1 = grid.extract_subset([0, 80, 0, 40, 0, 1], boundary=True)
>>> voi_2 = grid.extract_subset([0, 80, 40, 80, 0, 1], boundary=True)

For fun, add the two grids back together and show they are identical to the original grid.