scikit-hep / pylhe

Lightweight Python interface to read Les Houches Event (LHE) files

Home Page:https://pypi.org/project/pylhe/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pylhe: Python LHE interface

pylhe logo

GitHub Project DOI Scikit-HEP

PyPI version Conda-forge version Supported Python versions

GitHub Actions Status Code Coverage pre-commit.ci status Code style: black

Small and thin Python interface to read Les Houches Event (LHE) files

Install

To install pylhe from PyPI you can just do

python -m pip install pylhe

The visualization capabilities require the external dependency of Graphviz.

Get started

The example below provides a simple overview. Full functionality can be inspected from the functions provided in the pylhe module.

import itertools

# You can use LHE files from scikit-hep-testdata
from skhep_testdata import data_path

import pylhe

lhe_file = data_path("pylhe-testlhef3.lhe")
events = pylhe.read_lhe_with_attributes(lhe_file)
print(f"Number of events: {pylhe.read_num_events(lhe_file)}")

# Get event 1
event = next(itertools.islice(events, 1, 2))

# A DOT language graph of the event can be inspected as follows
print(event.graph.source)

# The graph is nicely displayed as SVG in Jupyter notebooks
event

# To save a DOT graph render the graph to a supported image format
# (refer to the Graphviz documentation for more)
event.graph.render(filename="test", format="png", cleanup=True)
event.graph.render(filename="test", format="pdf", cleanup=True)

Citation

The preferred BibTeX entry for citation of pylhe is

@software{pylhe,
  author = {Lukas Heinrich and Matthew Feickert and Eduardo Rodrigues},
  title = "{pylhe: v0.8.0}",
  version = {v0.8.0},
  doi = {10.5281/zenodo.1217031},
  url = {https://github.com/scikit-hep/pylhe},
}

Contributors

We hereby acknowledge the contributors that made this project possible (emoji key):

Matthew Feickert
Matthew Feickert

🚧 🎨 πŸ’» πŸ“–
Lukas
Lukas

🚧 🎨 πŸ’» πŸ“–
Eduardo Rodrigues
Eduardo Rodrigues

🚧 πŸ’» πŸ“–
Johannes Schumann
Johannes Schumann

πŸ’»
Henry Schreiner
Henry Schreiner

πŸ’»
ariaradick
ariaradick

πŸ’»
Junghwan John Goh
Junghwan John Goh

πŸ’»
fuenfundachtzig
fuenfundachtzig

πŸ’»
Shantanu Gontia
Shantanu Gontia

πŸ’»
Tom Eichlersmith
Tom Eichlersmith

πŸ’»
Alexander Puck Neuwirth
Alexander Puck Neuwirth

πŸ’»

This project follows the all-contributors specification.

About

Lightweight Python interface to read Les Houches Event (LHE) files

https://pypi.org/project/pylhe/

License:Apache License 2.0


Languages

Language:Python 97.9%Language:Dockerfile 2.1%