Skip to main content

Units and constants in the HEP system of units

Project description

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 --user, virtualenv, etc. if you wish).

Getting started

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-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: hepunits-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 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 hepunits-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a42021629a5142f51292116442cc17068f6fcb6c3ae6ba0915a6e79c51f4e45c
MD5 4d09c7c27b4eb18aead803a5fe98c0f4
BLAKE2b-256 1ef07560a770c05d82d8ca36234f80c2c8c14c773a7d1bfa2ce178bd3e369c8e

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