agentleFS
SteadfastAsArtSteadfastAsArt/geoscience-skills/pyvista/SKILL.md

pyvista

Skill67 starsChanged 10 months agoMITView on GitHub

3D visualization and mesh analysis for geoscience data using PyVista/VTK. Use when the agent needs to: (1) Create 3D visualizations of geological models, (2) Render seismic volumes or voxel data, (3) Visualize point clouds or well paths, (4) Plot surfaces and meshes in 3D, (5) Read/write VTK, STL, OBJ files, (6) Create cross-sections through 3D models, (7) Export publication-quality figures or interactive HTML.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use off_screen=True for batch processing

    line 150
  2. Very specific:

    Add axes with plotter.add_axes() for publication

    line 151
  3. Distinctive:

    Use opacity to show internal structure

    line 153

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PyVista - 3D Visualization

Quick Reference

import pyvista as pv

mesh = pv.read('model.vtk')
plotter = pv.Plotter()
plotter.add_mesh(mesh, scalars='property', cmap='viridis')
plotter.show()

Key Classes

ClassPurpose
pv.PlotterMain visualization window
pv.PolyDataSurface meshes, point clouds
pv.StructuredGridRegular 3D grids
pv.UnstructuredGridIrregular meshes
pv.ImageData3D voxel data (seismic)

Essential Operations

Load and Display Mesh

mesh = pv.read('model.vtk')
plotter = pv.Plotter()
plotter.add_mesh(mesh, scalars='lithology', cmap='Set1')
plotter.show()

Create Structured Grid (Surface)

x, y = np.meshgrid(np.arange(-10, 10, 0.5), np.arange(-10, 10, 0.5))
z = np.sin(np.sqrt(x**2 + y**2))
grid = pv.StructuredGrid(x, y, z)
pv.Plotter().add_mesh(grid, scalars=z.ravel(), cmap='terrain').show()

Visualize Point Cloud

cloud = pv.PolyData(np.random.rand(1000, 3) * 100)
cloud['depth'] = cloud.points[:, 2]
pv.Plotter().add_mesh(cloud, scalars='depth', point_size=5,
                      render_points_as_spheres=True).show()

Volume Rendering (Seismic)

grid = pv.ImageData(dimensions=(nx+1, ny+1, nz+1), spacing=(25, 25, 10))
grid.cell_data['amplitude'] = data.ravel(order='F')
pv.Plotter().add_volume(grid, cmap='seismic', opacity='sigmoid').show()

Slice Through Volume

volume = pv.read('seismic.vti')
slice_x = volume.slice(normal='x', origin=volume.center)
pv.Plotter().add_mesh(slice_x, cmap='seismic').show()

Well Path Visualization

points = np.column_stack([x, y, z])  # Well trajectory
tube = pv.Spline(points, 500).tube(radius=5)
pv.Plotter().add_mesh(tube, color='brown', label='Well').add_legend().show()

Combine Multiple Surfaces

plotter = pv.Plotter()
plotter.add_mesh(horizon1, color='gold', opacity=0.7, label='Top')
plotter.add_mesh(horizon2, color='blue', opacity=0.7, label='Base')
plotter.add_mesh(fault, color='red', opacity=0.5, label='Fault')
plotter.add_legend().show()

Export for Publication

plotter = pv.Plotter(off_screen=True)
plotter.add_mesh(mesh, cmap='terrain')
plotter.screenshot('figure.png', scale=3)   # High-res image
plotter.export_html('model.html')           # Interactive HTML

Color Maps

MapUse Case
terrainTopography, elevation
seismicSeismic amplitudes (diverging)
viridisGeneral scientific
Set1, Set2Categorical (lithology)

Supported Formats

.vtk, .vtu, .vti, .vtp, .stl, .obj, .ply (read/write)

When to Use vs Alternatives

ToolBest ForLimitations
pyvistaPythonic 3D viz, VTK wrapper, mesh operations, scriptingRequires display or off-screen backend
MayaviScientific 3D visualization, volume renderingHeavier dependency, less active development
ParaViewInteractive GUI exploration of large 3D datasetsGUI-focused, scripting is secondary
matplotlib 3DSimple 3D scatter/surface plotsLimited interactivity, not true 3D engine

Use pyvista when you need programmatic 3D visualization of geological models, meshes, or point clouds with VTK power but a Pythonic API.

Consider alternatives when you need a full GUI for exploring large models (use ParaView), legacy scientific visualization (use Mayavi), or only need simple 3D scatter plots (use matplotlib 3D).

Common Workflows

Visualize 3D geological model with multiple surfaces

  • Load mesh files with pv.read() for each surface/horizon
  • Create plotter with pv.Plotter() (use off_screen=True for scripts)
  • Add each surface with plotter.add_mesh() and distinct colors/opacity
  • Add well paths as tubes with pv.Spline().tube()
  • Add axes and legend with plotter.add_axes() and plotter.add_legend()
  • Set camera position for desired view angle
  • Export screenshot with plotter.screenshot() or HTML with plotter.export_html()

Tips

  • Use off_screen=True for batch processing
  • Add axes with plotter.add_axes() for publication
  • Export to HTML for interactive sharing
  • Use opacity to show internal structure

References

  • Mesh Types - PyVista mesh classes and when to use each
  • Plotting Options - Plotter settings and rendering options

Scripts

  • scripts/visualize_surface.py - Visualize geological surfaces from file

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.