pyxx.units#

Objects for performing unit conversions

The pyxx.units module provides unit conversion capabilities. It allows users to define customized systems of units and add associated, arbitrary units and convert quantities between such units.

Note

For more information on terminology definitions and a conceptual overview of units and systems of units, refer to the Unit Conversion Concepts page.

Unit Converters#

These classes handle unit conversions at the “highest” level, providing a simple-to-use interface to convert units, specified as strings. Most of the lower-level details of parsing units and performing unit conversions are abstracted away from the user for simplicity.

Inheritance diagram of UnitConverter, UnitConverterEntry, UnitConverterSI

UnitConverter(unit_system)

Data structure for storing units and performing unit conversions

UnitConverterEntry(unit[, tags, name, ...])

Data structure for storing information about a unit in a unit converter

UnitConverterSI()

A unit converter using the SI system of units, pre-filled with common units

Systems of Units#

The classes in this section are intended to represent a system of units, which must be defined prior to setting up custom units or performing unit conversions.

Inheritance diagram of UnitSystem, UnitSystemSI

UnitSystem(num_base_units[, name, description])

Base class representing a system of units

UnitSystemSI([name, description])

Class representing the SI system of units

Units#

The classes in this section can be used to define custom units associated with a given system of units.

Inheritance diagram of Unit, UnitLinear, UnitLinearSI

Unit(unit_system, base_unit_exps, ...[, ...])

Base class for representing a unit

UnitLinear(unit_system, base_unit_exps, ...)

Class for representing units with linear transformations to/from the base units

UnitLinearSI(base_unit_exps, scale, offset)

Class for representing units with linear transformations to/from the base units and using the International System of Units (SI)

ConstantUnitMathConventions(value[, names, ...])

Options for defining what happens when a Unit object is multiplied by a constant

Unit-Parsing#

The objects in this section can be used to parse strings containing units (such as 'kg/m/(s*m^2)'), separating the component units in the string. This is an essential precursor to performing unit conversions with complex units.

parse_unit(unit[, max_iterations])

Parses a string of simple or compound units, separating it into fully-simplified component units