pyvista.RectilinearGrid#
- class RectilinearGrid(*args, **kwargs)[source]#
Dataset with variable spacing in the three coordinate directions.
Can be initialized in several ways:
Create empty grid
Initialize from a vtkRectilinearGrid object
Initialize directly from the point arrays
- Parameters:
- uinput
str,pathlib.Path, 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 vtkRectilinearGrid, it will be wrapped. If anumpy.ndarrayis passed, this will be loaded as the x range.- y
numpy.ndarray,optional Coordinates of the points in y direction. If this is passed,
uinputmust be anumpy.ndarray.- z
numpy.ndarray,optional Coordinates of the points in z direction. If this is passed,
uinputandymust be anumpy.ndarray.- check_duplicatesbool,
optional Check for duplications in any arrays that are passed. Defaults to
False. IfTrue, 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 vtkRectilinearGrid object. Default is
False. Keyword only.
- uinput
Examples
>>> import pyvista as pv >>> import vtk >>> import numpy as np
Create an empty grid.
>>> grid = pv.RectilinearGrid()
Initialize from a 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)
Methods
Cast this rectilinear grid to a structured grid.
Attributes
Return the grid's dimensions.
Return a meshgrid of numpy arrays for this mesh.
Return a copy of the points as an
(n, 3)numpy array.Return or set the coordinates along the X-direction.
Return or set the coordinates along the Y-direction.
Return or set the coordinates along the Z-direction.