Skip to main content

Utilities to deal with PDG data tables and particle IDs

Project description

particle

Particle: PDG particle data and identification codes

PyPI https://zenodo.org/badge/DOI/10.5281/zenodo.2552429.svg Build Status Coverage Tests

Particle provides a pythonic interface to the Particle Data Group (PDG) particle data tables and particle identification codes.

The PDG defines the standard particle identification (ID) numbering scheme. The package provides the PDGID class implementing queries on those PDG IDs. The queries are also accessible through free standing functions mimicking the HepPID C++ interface.

The Particle class wraps the information in the PDG particle data tables and provides an object-oriented interface and powerful search and look-up utilities.

The current version of the package reflects a pythonic version of the utility functions defined in HepPID and HepPDT versions 3.04.01, see http://lcgapp.cern.ch/project/simu/HepPDT/.

Installation

Install particle like any other Python package:

pip install particle

or similar (use --user, virtualenv, etc. if you wish).

Strict dependencies

Getting started: PDGIDs

>>> from particle.pdgid import PDGID
>>>
>>> pid = PDGID(211)
>>> pid
<PDGID: 211>
>>> pid.is_meson
True
>>> pid = PDGID(99999999)
>>> pid
<PDGID: 99999999 (is_valid==False)>

For convenience, all properties of the PDGID class are available as standalone functions:

>>> from particle.pdgid import is_meson
>>>
>>> is_meson(211)
True

PDGID literals provide (PDGID class) aliases for the most common particles, with easily recognisable names. For example:

>>> from particle.pdgid import literals as lid
>>>
>>> lid.pi_plus
<PDGID: 211>
>>>
>>> from particle.pdgid.literals import Lambdab0
>>>> Lambdab0
<PDGID: 5122>
>>> Lambdab0.has_bottom
True

You can quickly display PDGID info from the command line with:

$ python -m particle pdgid 323
<PDGID: 323>
A              None
J              1.0
L              0
S              1
Z              None
abspid         323
charge         1.0
has_bottom     False
...

Getting started: Particles

You can use a variety of methods to get particles. If you know the PDGID number you can get a particle directly, or you can use a search:

>>> from particle import Particle
>>> Particle.from_pdgid(211)
<Particle: pdgid=211, fullname='pi+', mass=139.57061 ± 0.00024 MeV>
>>>
>>> Particle.from_search_list('pi')[0]
<Particle: pdgid=111, fullname='pi0', mass=134.9770 ± 0.0005 MeV>

You can search for the properties using keyword arguments, which are name, mass, width, charge, anti, rank, I, J, G, P, quarks, status, latex, mass_upper, mass_lower, width_upper, and width_lower (some of those don't make sense). The alternative .from_search() requires only one match returned by the search. You can also use the first two arguments, called name_s and latex_s to do a loose search, and name_re and latex_re to do a regular expression search.

Once you have a particle, any of the properties can be accessed, along with several methods. Though they are not real properties, you can access bar, radius, and spin_type. You can also .invert() a particle.

There are lots of printing choices for particles: describe(), programmatic_name, html_name, HTML printing outs in notebooks, and of course repr and str support.

You can get the .pdgid from a particle, as well. Sorting particles will put lowest abs(PDGID) first.

Particle literals provide (Particle class) aliases for the most common particles, with easily recognisable names. For example:

>>> from particle.particle import literals as lp
>>> lp.pi_plus
<Particle: pdgid=211, fullname='pi+', mass=139.57061 ± 0.00024 MeV>
>>>
>>> from particle.particle.literals import Lambdab0
>>>> Lambdab0
<Particle: pdgid=5122, fullname='Lambda(b)0', mass=5619.60 ± 0.17 MeV>
>>> Lambdab0.J
0.5

You can quickly search for particles from the command line with:

$ python -m particle search 'K*0'
<Particle: pdgid=313, fullname='K*(892)0', mass=895.55 ± 0.20 MeV>
<Particle: pdgid=30313, fullname='K*(1680)0', mass=1718 ± 18 MeV>
<Particle: pdgid=100313, fullname='K*(1410)0', mass=1421 ± 9 MeV>

If you only select one particle, either by a search or by giving the PDGID number, you can see more information about the particle:

$ python -m particle search 311
Name: K          ID: 311          Fullname: K0             Latex: $K^{0}$
Mass  = 497.611 ± 0.013 MeV
Width = -1.0 MeV
I (isospin)       = 1/2    G (parity)        = 0      Q (charge)       = 0
J (total angular) = 0.0    C (charge parity) = 0      P (space parity) = ?
    Quarks: dS
    Antiparticle status: Full (antiparticle name: K~0)

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

particle-0.2.2.tar.gz (69.5 kB view details)

Uploaded Source

File details

Details for the file particle-0.2.2.tar.gz.

File metadata

  • Download URL: particle-0.2.2.tar.gz
  • Upload date:
  • Size: 69.5 kB
  • 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 particle-0.2.2.tar.gz
Algorithm Hash digest
SHA256 dc24ce6b21d9d833af088921ddc2dd0a71257ba8f872b8b48f1c2772b62bad9d
MD5 7dc67043598c4af7e7ef99f33e6115c4
BLAKE2b-256 1acd2a0fd0709aa359253d58c4d387ab1f035edb7279e5389a6f4959adfd9f02

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