pyevtk is a Python library for exporting numerical data (like structured grids, unstructured grids, and points) into binary VTK (Visualization Toolkit) files, enabling visualization in tools like ParaView or VisIt. As of version 1.6.0, it supports various data types and has an active, albeit slow, release cadence.
pip install pyevtkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to export a structured grid with both cell-centered and point-centered data to a VTK Structured Grid (.vts) file using `gridToVTK`.
Always use `from pyevtk.hl import ...` for all imports, e.g., `from pyevtk.hl import gridToVTK`.
Ensure all array inputs are `numpy.ndarray` objects. Convert them using `numpy.asarray()` if necessary.
Be mindful of whether your data is node-centered or cell-centered. If your data is node-centered on an `(Nx, Ny, Nz)` grid, the data array passed to `gridToVTK` for cell data should typically have dimensions `(Nx-1, Ny-1, Nz-1)` to align correctly. Alternatively, explicitly define point data if appropriate.
Change all imports from `evtk` to `pyevtk`, e.g., `from pyevtk.hl import gridToVTK`.
Convert the input data to a NumPy array before passing it to `pyevtk` functions, e.g., `import numpy as np; data = np.asarray(my_list)`.
Carefully check the expected dimensions for the specific VTK export function being used. For cell data on an `(nx, ny, nz)` grid, the data array should typically have shape `(nx-1, ny-1, nz-1)`. For point data, it should be `(nx, ny, nz)`.
No dependency data recorded yet.