Skip to main content

A lightweight, Python-based visualization tool for Geant4.

Project description

GeViewer

PyPI - Version GitHub Actions Workflow Status Last Commit GitHub License

A lightweight, Python-based visualization tool for Geant4. GeViewer provides a convenient way to view detector geometries, particle trajectories, and hits, with smooth rendering in an interactive window.

Getting started

Dependencies

The following packages are required:

  • numpy
  • tqdm
  • pyvista

Installation

GeViewer can be installed using pip as follows:

pip install geviewer

To uninstall:

pip uninstall geviewer

Usage

This package is intended to be used primarily as a command line tool. Following installation, the program can be run using:

geviewer /path/to/file.wrl

This will load the meshes described in /path/to/file.wrl and display them in an interactive window. The viewing perspective can be changed by clicking, dragging, and scrolling in the window, while other options can be toggled on and off using key presses. More specific instructions for use will print in the terminal window when the program is launched.

Instructions for Geant4

To produce Geant4 outputs that can be read by GeViewer, you must use /vis/open VRML2FILE to tell Geant4 to save the visualization as a VRML file. The following sample macro shows how this could be implemented.

# tell Geant4 we want a VRML file rather than to use an interactive viewer
/vis/open VRML2FILE

# the main content of your Geant4 macro goes here

# if you want to see particle tracks and hits
/run/beamOn 1

# by default, the file will be saved as g4_00.wrl
# but it can easily be renamed from within the macro
/control/shell mv g4_00.wrl /new/path/to/file.wrl

# the output can be piped directly to geviewer
/control/shell geviewer /new/path/to/file.wrl

exit

Note that if you are running Geant4 on a remote machine over ssh, piping the simulation outputs directly to GeViewer may not work as expected. If this is the case, you can download the VRML files and run GeViewer on your local machine instead.

Safe mode

By default, GeViewer relies on its own VRML parser to extract the meshes to be plotted, however this has only been tested on a small sample set of Geant4 simulation results. If you encounter file parsing errors, try using the --safe-mode command line argument (and let me know what caused the error so I can update the parser). This will use a VRML parsing tool from vtk which should be more robust, but which does not allow the program to distinguish trajectories, hits, and detector geometry. In this mode, some features will not be available.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Clarke Hardy - cahardy@stanford.edu

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geviewer-0.0.8.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

geviewer-0.0.8-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file geviewer-0.0.8.tar.gz.

File metadata

  • Download URL: geviewer-0.0.8.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for geviewer-0.0.8.tar.gz
Algorithm Hash digest
SHA256 0d90edbc0f571a5032e5cd3a6e6b60f9c7285c88a677ab41b7496e93bb3bce21
MD5 e022cbc600e65bc48b3a915b24db1bbc
BLAKE2b-256 39b4cdcc7c3659953f0b55beba7a08f41e630139cbb8d40812cde0ea047660ea

See more details on using hashes here.

File details

Details for the file geviewer-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: geviewer-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for geviewer-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 463e1e8ca26be9634ba71ce2df7a85e0a8720700498cc4a2e1e071d31d7b35a7
MD5 7937305f3f43151b600ad40f8e5dea1a
BLAKE2b-256 8e80f8ac93f2b071407bcf7b8f4f8e7b7460b47e9ba9860da9d8ff37e8a7026e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page