Skip to main content

A local visualizer for HEP data

Project description

hep-viz

A local visualizer for High Energy Physics (HEP) data.

hep-viz is a lightweight, high-performance tool designed to visualize high-dimensional particle tracking and calorimeter data directly from your local machine or Python environment. It bridges the gap between massive local datasets and fluid web-based visualization.

Features

  • 🚀 Local & Fast: Runs a local web server to stream data on demand—no cloud upload required.
  • 🐍 Python API: Seamlessly integrates with Jupyter Notebooks and Python scripts.
  • 💻 CLI Support: Quickly visualize datasets from your terminal.
  • ✨ 3D Visualization: Interactive 3D view of particles, tracks, and calorimeter hits.
  • 📂 Parquet Support: Optimized for reading large datasets stored in Parquet format.

Installation

Requires Python 3.8+.

Option 1: Install from PyPI

pip install hep-viz

Option 2: Install from Conda

conda install finnbarwilson::hep-viz

Option 3: Install from Source

git clone https://github.com/FinnbarWilson/hep-viz.git
cd hep-viz
pip install .

Usage

1. Command Line Interface (CLI)

Visualize a directory containing your Parquet data files:

hep-viz view /path/to/data/directory

Options:

  • --port <int>: Specify the port to run the server on (default: 8000).
  • --no-browser: Prevent the browser from opening automatically.

2. Python API

Use hep-viz directly within your Python scripts or Jupyter Notebooks. This is perfect for visualizing in-memory data (e.g., from Hugging Face Datasets).

Example with Hugging Face Datasets:

import hep_viz
from datasets import load_dataset

# Load a compatible dataset (e.g., OpenDataDetector)
dataset = load_dataset("OpenDataDetector/ColliderML_higgs_pu0")

# Launches the server and opens the visualization
hep_viz.view(dataset)

Example with Custom Dictionary:

import hep_viz

# Data should be a dictionary of lists
data = {
    "particles": [...],
    "tracks": [...],
    "tracker_hits": [...],
    "calo_hits": [...]
}

hep_viz.view(data)

Data Format

hep-viz expects data to be organized into four main categories. If using the CLI, these should be Parquet files in your target directory. If using the Python API, these should be keys in your dictionary.

Required Categories

  1. particles: Truth-level particle information.
    • Columns: event_id, particle_id, pdg_id, px, py, vx, vy
  2. tracks: Reconstructed track information (optional, or derived from hits).
    • Columns: event_id, particle_id, pT, pdg_id
  3. tracker_hits: Individual hits in the tracker layers.
    • Columns: event_id, particle_id, x, y, z, volume_id
  4. calo_hits: Energy deposits in the calorimeter.
    • Columns: event_id, cell_id, x, y, z, total_energy, contrib_particle_ids (list), contrib_energies (list)

File Naming (CLI)

For the CLI to automatically detect files, they should contain the category name (e.g., my_particles.parquet). You can split data across multiple files using the pattern events<start>-<end> (e.g., particles.events0-999.parquet).

Development

To contribute or modify hep-viz:

  1. Clone the repository:

    git clone https://github.com/yourusername/hep-viz.git
    cd hep-viz
    
  2. Install in editable mode:

    pip install -e .
    
  3. Run Tests:

    # Install test dependencies
    pip install pytest httpx
    
    # Run the test suite
    pytest
    

License

This project is licensed under the MIT License.

Copyright (c) 2025 Finnbar Wilson

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

hep_viz-0.1.1.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hep_viz-0.1.1-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file hep_viz-0.1.1.tar.gz.

File metadata

  • Download URL: hep_viz-0.1.1.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for hep_viz-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9fd8f69dd9f6919ac6c5b05c72234f4d48d0cbe5b04a22b964f7251217e4fb67
MD5 d3fff86fb36bec8440c0358d63f29a2f
BLAKE2b-256 7658a3af640642d6a4b6f73d5f135efd1b7624307f1f1b20958d1afbc54c8260

See more details on using hashes here.

File details

Details for the file hep_viz-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hep_viz-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for hep_viz-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a416c9910845c9e7dddb094f238a603d64d98172aa10910a30584ae1e2e29d09
MD5 2be099e088bfea9cc0737053e1b61a04
BLAKE2b-256 9f48cb019f5bbd7f9cea48ea371f734a287768dd82fcf8f93f7301ba0a97d29a

See more details on using hashes here.

Supported by

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