PyVista: contours and translucent volumes

Download the example bundle and run from the extracted directory. The small synthetic data files are generated by tests/generate_test_data.py and already included in the bundle. All coordinates and scalar amplitudes in these examples are dimensionless.

pyvista renders the same three-dimensional Gaussian with VTK. Contours highlight selected density levels; volume rendering shows the continuous interior. The examples save screenshots with no_show=True and disable camera rotation with no_spin=True. Omit no_show to open a local interactive window. The field occupies [-2, 2] in each coordinate; hide_axes=True keeps these views focused on the density structure. The volume example uses a linear opacity ramp to reveal the dense core.

An OpenGL context is required even for off-screen screenshots. The documentation CI uses Mesa/EGL software rendering. See the rendering dependencies in Installation for headless Linux setup. Failures are reported; a missing graphics backend does not silently remove these examples from the website.

Python script

python examples/scripts/09_pyvista.py
"""Render Gaussian isosurfaces and a translucent volume with PyVista."""

import postgkyl as pg
from _example_paths import TEST_DATA, prepare_output_dir

OUTPUT_DIR = prepare_output_dir()
data = pg.load(TEST_DATA / "generated/gaussian_volume.gkyl").interpolate()
data.pyvista(contour_levels=5,
             no_show=True,
             no_spin=True,
             hide_axes=True,
             title="Gaussian density isosurfaces",
             xlabel="x",
             ylabel="y",
             zlabel="z",
             clabel="Density",
             theme="document",
             camera_elevation=10.0,
             camera_azimuth=20.0,
             saveas=str(OUTPUT_DIR / "09_isosurfaces.png"))
data.pyvista(volume=True,
             opacity="linear",
             no_show=True,
             no_spin=True,
             hide_axes=True,
             title="Gaussian density volume",
             xlabel="x",
             ylabel="y",
             zlabel="z",
             clabel="Density",
             theme="document",
             camera_elevation=10.0,
             camera_azimuth=20.0,
             saveas=str(OUTPUT_DIR / "09_volume.png"))

Equivalent CLI commands

Run from the extracted example bundle (or repository root). Create an output directory first:

mkdir -p output
pgkyl tests/test_data/generated/gaussian_volume.gkyl interpolate pyvista --contour_levels 5 \
    --no_show --no_spin --title 'Gaussian density isosurfaces' --xlabel x --ylabel y \
    --zlabel z --clabel Density --theme document --saveas output/09_isosurfaces.png \
    --camera_elevation 10 --camera_azimuth 20 --hide_axes

09_isosurfaces.png: Identical pixels (1 frame(s)) and timing.

Python and CLI outputs
Python output for 09_isosurfaces.png CLI output for 09_isosurfaces.png
pgkyl tests/test_data/generated/gaussian_volume.gkyl interpolate pyvista --volume --no_show \
    --no_spin --title 'Gaussian density volume' --xlabel x --ylabel y --zlabel z --clabel \
    Density --theme document --saveas output/09_volume.png --camera_elevation 10 \
    --camera_azimuth 20 --hide_axes --opacity linear

09_volume.png: Identical pixels (1 frame(s)) and timing.

Python and CLI outputs
Python output for 09_volume.png CLI output for 09_volume.png