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
vtk.vtkRectilinearGrid
objectInitialize directly from the point arrays
- Parameters:
- uinput
str
,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 avtk.vtkRectilinearGrid
, it will be wrapped. If anumpy.ndarray
is passed, this will be loaded as the x range.- y
numpy.ndarray
,optional
Coordinates of the points in y direction. If this is passed,
uinput
must be anumpy.ndarray
.- z
numpy.ndarray
,optional
Coordinates of the points in z direction. If this is passed,
uinput
andy
must 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
vtk.vtkRectilinearGrid
object. Default isFalse
. Keyword only.
- uinput
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)
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.