Skip to main content

Units and constants in the HEP system of units

Project description

Scikit-HEP project package PyPI conda-forge Build Status Coverage

hepunits collects the most commonly used units and constants in the HEP System of Units, as derived from the basic units originally defined by the CLHEP project, which are not the same as the SI system of units:

Quantity Name Unit
Length millimeter mm
Time nanosecond ns
Energy Mega electron Volt MeV
Positron charge eplus  
Temperature kelvin K
Amount of substance mole mol
Luminous intensity candela cd
Plane angle radian rad
Solid angle steradian sr

It is largely based on the international system of units (SI)

Quantity Name Unit
Length meter m
Time second s
Mass kilogram kg
Electric current ampere A
Temperature kelvin K
Amount of substance mole mol
Luminous intensity candela cd

but augments it with handy definitions, changing the basic length and time units.

Note that many units are now exact, such as the speed of light in vacuum. The package is in agreement with the values in the 2020 Particle Data Group review.


Install hepunits like any other Python package:

pip install hepunits

or similar (use e.g. virtualenv if you wish).

Getting started

The package contains 2 modules - constants and units, whose names are self-explanatory. It may be more readable to import quantities explicitly from each of the modules though everything is available from the top-level as from hepunits import ....

The module hepunits.constants contains 2 sorts of constants: physical constants and commonly used constants.

The typical usage is the following:

>>> from hepunits.constants import c_light
>>> from hepunits.units     import picosecond, micrometer
>>> tau_Bs = 1.5 * picosecond    # a particle lifetime, say the Bs meson's
>>> ctau_Bs = c_light * tau_Bs   # ctau of the particle, ~450 microns
>>> print ctau_Bs                # result in HEP units, so mm
>>> print ctau_Bs / micrometer   # result in micrometers

Typical usage of the hepunits.units module:

>>> # add two quantities with length units and get the result in meters
>>> from hepunits import units as u
>>> (1 * u.meter + 5 * / u.meter
>>> # the default result is, of course, in HEP units, so mm
>>> 1 * u.meter + 5 *
>>> from hepunits.units import MeV, GeV
>>> massWindow = 100 * MeV    # define a 100 MeV mass window
>>> def energy_resolution():
...    # returns the energy resolution of 100 MeV
...    return 100 * MeV
>>> energy_resolution() / GeV # get the energy resolution in GeV

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hepunits, version 2.1.0
Filename, size File type Python version Upload date Hashes
Filename, size hepunits-2.1.0-py2.py3-none-any.whl (10.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size hepunits-2.1.0.tar.gz (13.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page