Skip to main content

The interface between PYTHIA and NumPy

Project description

https://img.shields.io/pypi/v/numpythia.svg https://coveralls.io/repos/github/scikit-hep/numpythia/badge.svg?branch=master

numpythia provides an interface between PYTHIA and NumPy allowing you to generate events as NumPy arrays of particle four-momenta. By default numpythia only depends on NumPy and builds internal copies of the PYTHIA and HepMC source code.

Python versions supported:

https://img.shields.io/badge/python-2.7-blue.svg https://img.shields.io/badge/python-3.4-blue.svg https://img.shields.io/badge/python-3.5-blue.svg https://img.shields.io/badge/python-3.6-blue.svg

Getting started

from numpythia import Pythia, hepmc_write, hepmc_read
from numpythia import STATUS, HAS_END_VERTEX, ABS_PDG_ID
from numpythia.testcmnd import get_cmnd
from numpy.testing import assert_array_equal

pythia = Pythia(get_cmnd('w'), random_state=1)

selection = ((STATUS == 1) & ~HAS_END_VERTEX &
            (ABS_PDG_ID != 12) & (ABS_PDG_ID != 14) & (ABS_PDG_ID != 16))

# generate events while writing to ascii hepmc
for event in hepmc_write('events.hepmc', pythia(events=1)):
   array1 = event.all(selection)

# read the same event back from ascii hepmc
for event in hepmc_read('events.hepmc'):
   array2 = event.all(selection)

assert_array_equal(array1, array2)

The dtype of any array of particle information is:

np.dtype([('E', 'f8'), ('px', 'f8'), ('py', 'f8'), ('pz', 'f8'), ('mass', 'f8'),
          ('prodx', 'f8'), ('prody', 'f8'), ('prodz', 'f8'), ('prodt', 'f8'),
          ('pdgid', 'i4'), ('status', 'i4')])

Also see pyjet for jet clustering.

Standalone Installation

To simply use the built-in PYTHIA and HepMC:

pip install --user -v numpythia

And you’re good to go!

Support for building against an external PYTHIA, Delphes, and much more will come soon.

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

numpythia-1.0.0.tar.gz (6.5 MB view details)

Uploaded Source

File details

Details for the file numpythia-1.0.0.tar.gz.

File metadata

  • Download URL: numpythia-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.15

File hashes

Hashes for numpythia-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ad4a522cc4df72f6627105ef827bbe469a7b0d2c38e56dc48e4a7dc4a1b1cb14
MD5 99f23b62eb8e6688b9eb8220586ca141
BLAKE2b-256 303373c9cb2e401495a2067f09e5155ec046a23c8ff181bf62695696f5a5b7b2

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