Skip to main content

Units and constants in the HEP system of units

Project description

Scikit-HEP project package PyPI 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.

Installation

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
0.449688687
>>> print ctau_Bs / micrometer   # result in micrometers
449.688687

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.cm) / u.meter
1.05
>>> # the default result is, of course, in HEP units, so mm
>>> 1 * u.meter + 5 * u.cm
1050.0
>>> 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
0.1

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

hepunits-1.2.1.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

hepunits-1.2.1-py2.py3-none-any.whl (9.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file hepunits-1.2.1.tar.gz.

File metadata

  • Download URL: hepunits-1.2.1.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for hepunits-1.2.1.tar.gz
Algorithm Hash digest
SHA256 b05b0dda32bf797806d506d7508d4eb23b78f34d67bbba9348a2b4a9712666fa
MD5 4c49b2997dfd2352ca2358b9183262e9
BLAKE2b-256 11bfe774fefda6fb84ff7b565754011c54abdf761eea50367a48276a00d00fcc

See more details on using hashes here.

File details

Details for the file hepunits-1.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: hepunits-1.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for hepunits-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 03e788d6eca982a6588d5759ce326dc81b7366965bbe6066b50ae888a549999b
MD5 04c226eca4299f2948747d244e1d47d8
BLAKE2b-256 3b8d55d81e46988179d6513f5915bf326ff5adbc5ee2647d952f7df6d097425e

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