diff --git a/README.md b/README.md index f8c2b7cd..5affbab9 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,39 @@ python -m pip install pylhe[viz] The visualization capabilities require external dependencies of [Graphviz](https://graphviz.org/) and LaTeX. +## Get started + +The example below provides a quick get-started. Full functionality can be inspected +from the functions provided in the `pylhe` module. + +```python +import itertools +import pylhe + +# You can use LHE files from our scikit-hep-testdata package +from skhep_testdata import data_path + +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 hold of 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 notebooks: +event + +# If not in a notebook, or wishing to save the DOT graph under one of the available formats, +# do for example (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