Customizing VisIt: Scripts, Plugins, and Automation
VisIt is a powerful open-source visualization tool for exploring and analyzing large-scale scientific data. While its GUI is robust, customizing VisIt with scripts, plugins, and automation unlocks reproducible workflows, batch processing, and tailored visualizations. This article explains how to extend VisIt through Python scripting, plugin development, and automation strategies, with practical examples and best practices.
Why customize VisIt?
- Reproducibility: Scripts capture exact visualization steps for repeatable results.
- Scalability: Automation enables batch rendering of many time steps or parameter sweeps.
- Flexibility: Plugins and scripts let you add data readers, operators, or custom plots not available out of the box.
- Integration: Embedding VisIt into pipelines or HPC workflows enables end-to-end scientific processing.
1. Scripting VisIt with Python
VisIt exposes a Python interface (visitpy) that mirrors the GUI actions. Using Python you can create, modify, and export visualizations programmatically.
Basic script structure
- Import and launch VisIt
python
from visit import * Launch()
- Open data
python
OpenDatabase(“path/to/data.file”)
- Create plots and operators
python
AddPlot(“Pseudocolor”, “variablename”) AddOperator(“Slice”) DrawPlots()
- Adjust attributes
python
pc = PseudocolorAttributes() pc.minFlag = 1 pc.min = 0.0 pc.maxFlag = 1 pc.max = 1.0 SetPlotOptions(pc)
- Save output
python
SaveWindowAtts = SaveWindowAttributes() SaveWindowAtts.fileName = “frame000” SaveWindowAtts.format = SaveWindowAtts.PNG SetSaveWindowAttributes(SaveWindowAtts) SaveWindow()
Automating time-series rendering
Use loops to iterate over time states and export frames:
python
nt = TimeSliderGetNStates() for t in range(nt): SetTimeSliderState(t) DrawPlots() SaveWindow()
Tips
- Use Visit’s
GetAnnotationAttributes()and similar getters to capture current settings before modifying them. - Modularize common sequences into functions to reuse across scripts.
- Run scripts headless on servers with
visit -cli -s script.pyor via the visit module in Python.
2. Writing Plugins for VisIt
Plugins extend VisIt by adding new file readers, operators, or plot types. Plugins are typically written in C++ and follow VisIt’s plugin API and build system.
Plugin types
- Database plugins: read custom data formats and expose meshes/variables to VisIt.
- Operator plugins: implement custom data transformations (e.g., filtering, derived quantities).
- Plot plugins: render data with new visual representations.
Development workflow
- Set up the build environment: install VisIt’s development dependencies and checkout the source or plugin SDK.
- Use plugin templates: VisIt provides plugin templates (via visit-build or examples) to speed development.
- Implement API functions: define metadata, database query functions, and data access callbacks.
- Build and install: compile the plugin and place it in VisIt’s plugins directory.
- Test and iterate: load sample data and test through the GUI or scripts.
Example: simple database plugin outline (conceptual)
- Implement functions to:
- Return mesh and variable names.
- Provide extents and time states.
- Supply variable data for requested domains and time.
Best practices
- Keep plugin interfaces stable; document expected I/O and units.
- Provide sample data and unit tests where possible.
- Prefer minimal dependencies to ease portability across HPC systems.
3. Automation Strategies
Automation connects VisIt to batch systems, version control, and CI/CD for visualization tasks.
Batch rendering on HPC
- Create Python scripts that load data, loop over time steps, and save images.
- Use job schedulers (SLURM, PBS) to submit array jobs where each task renders a subset of frames.
- Run VisIt in headless mode to avoid X11 requirements:
- Use offscreen rendering with Mesa or VisIt’s OSMesa support.
- Ensure the VisIt build on the cluster includes offscreen rendering capabilities.
Sample SLURM array job snippet:
bash
#!/bin/bash #SBATCH –array=0-99 srun visit -cli -nowin -s render_frame.py – $SLURM_ARRAY_TASK_ID
Have the script read the task ID to determine which time step or frame to render.
Integration into pipelines
- Wrap VisIt scripts in command-line tools to accept parameters (input path, variable name, time range).
- Use configuration files (YAML/JSON) to declare visualization recipes and let a driver script execute them.
- Store scripts and configs in version control to track visualization changes.
Continuous visualization (CI)
- Trigger visualization runs on data or script updates in CI tools (GitHub Actions, GitLab CI).
- Use lightweight containers with VisIt and dependencies to produce checked outputs or thumbnails for PRs.
4. Useful Patterns and Examples
Reusable script template
- Argument parsing for input file, variable, output dir.
- Logging to track rendering progress.
- Error handling to skip corrupt time states.
Example: combining multiple variables
- Load multiple plots, assign different color maps, and synchronize color ranges with shared Min/Max.
- Use
CalcExpressionto define derived variables (e.g., vorticity magnitude) for plotting.
Performance tips
- Reduce data by subsampling or using LOD (level-of-detail) operators before rendering.
- Cache expensive derived variables where possible.
- Use parallel rendering builds of VisIt to distribute heavy computations.
5. Troubleshooting and Resources
Common issues
- Offscreen rendering fails: verify Mesa/OSMesa availability and VisIt build options.
- Plugins not found: check plugin install path and VisIt’s plugins directory permissions.
- Inconsistent plots between GUI and scripts: ensure scripts set all relevant attributes (annotations, view settings, time state).
Resources
- VisIt user manual and scripting reference (visitusers.org / visit.llnl.gov)
- VisIt source and plugin examples in the VisIt GitHub repository
- Community forums and mailing lists for debugging and feature requests
Conclusion
Customizing VisIt with scripts, plugins, and automation transforms it from an interactive explorer into a reproducible, scalable visualization engine. Start with Python scripts for quick automation, develop plugins when you need new IO or operators, and integrate VisIt into batch and CI pipelines to handle large-scale or recurring visualization tasks.
Leave a Reply