pdg.units module

Constants and utilities for handling HEP units.

pdg.units.convert(value: float, old_units: str | None = None, new_units: str | None = None) float[source]

Convert a value to a different unit.

The following units are supported (in some cases under multiple names):

Quantity

Units

Energy

meV, eV, keV, MeV, GeV, TeV, PeV, u

Time

s, yr, year, years

Parameters:
  • value – Value to be converted.

  • old_units – Units in which value is currently specified. If None, then new_units must be None as well.

  • new_units – Units into which value is to be converted. If None, no unit conversion will be applied.

Returns:

Value after the specified unit conversion (if any) has been applied.

Raises:
  • AssertionError – If old_units is None but new_units is not.

  • PdgApiError – If the unit conversion is invalid or unsupported.