pyvista.RectilinearGrid#

class RectilinearGrid(*args, check_duplicates=False, deep=False, **kwargs)[source]#

Dataset with variable spacing in the three coordinate directions.

Can be initialized in several ways:

  • Create empty grid

  • Initialize from a vtk.vtkRectilinearGrid object

  • Initialize directly from the point arrays

Parameters:
uinputstr, pathlib.Path, vtk.vtkRectilinearGrid, numpy.ndarray, optional

Filename, dataset, or array to initialize the rectilinear grid from. If a filename is passed, pyvista will attempt to load it as a RectilinearGrid. If passed a vtk.vtkRectilinearGrid, it will be wrapped. If a numpy.ndarray is passed, this will be loaded as the x range.

ynumpy.ndarray, optional

Coordinates of the points in y direction. If this is passed, uinput must be a numpy.ndarray.

znumpy.ndarray, optional

Coordinates of the points in z direction. If this is passed, uinput and y must be a numpy.ndarray.

check_duplicatesbool, optional

Check for duplications in any arrays that are passed. Defaults to False. If True, an error is raised if there are any duplicate values in any of the array-valued input arguments.

deepbool, optional

Whether to deep copy a vtk.vtkRectilinearGrid object. Default is False. Keyword only.

Examples

>>> import pyvista as pv
>>> import vtk
>>> import numpy as np

Create an empty grid.

>>> grid = pv.RectilinearGrid()

Initialize from a vtk.vtkRectilinearGrid object

>>> vtkgrid = vtk.vtkRectilinearGrid()
>>> grid = pv.RectilinearGrid(vtkgrid)

Create from NumPy arrays.

>>> xrng = np.arange(-10, 10, 2)
>>> yrng = np.arange(-10, 10, 5)
>>> zrng = np.arange(-10, 10, 1)
>>> grid = pv.RectilinearGrid(xrng, yrng, zrng)
>>> grid.plot(show_edges=True)
https://d33wubrfki0l68.cloudfront.net/2e85b2bfcaa36822b8cfbbed9a8b66ccc1ba03f7/1b3f5/_images/pyvista-rectilineargrid-1_00_00.png

Methods

RectilinearGrid.cast_to_structured_grid()

Cast this rectilinear grid to a structured grid.

Attributes

RectilinearGrid.dimensions

Return the grid's dimensions.

RectilinearGrid.meshgrid

Return a meshgrid of numpy arrays for this mesh.

RectilinearGrid.points

Return a copy of the points as an (n, 3) numpy array.

RectilinearGrid.x

Return or set the coordinates along the X-direction.

RectilinearGrid.y

Return or set the coordinates along the Y-direction.

RectilinearGrid.z

Return or set the coordinates along the Z-direction.