QuantiPhy - Physical QuantitiesΒΆ

A light-weight package that allows numbers to be combined with units into physical quantities. Once a physical quantity is created, it can be used just as if it were a conventional real number, however when it comes time to display the value, the units and SI scale factors are used to make the value more informative and easier to read. For example, imagine trying to determine the rise time and bandwidth of a simple RC circuit:

>>> from quantiphy import Quantity
>>> from math import pi

>>> r = Quantity('R = 1kOhm')
>>> c = Quantity('C = 1nF')
>>> tau = Quantity(r*c, 'Tau s')
>>> bw = Quantity(1/(2*pi*tau), 'BW Hz')
>>> print('Given: {0:Q}, {1:Q}.'.format(r, c))
Given: R = 1kOhm, C = 1nF.

>>> print('Computed: {0:Q}, {1:Q}.'.format(tau, bw))
Computed: Tau = 1us, BW = 159.15kHz.

A quantity is the pairing of a real number and units, though the units are optional. The Quantity class is used to combine the pair into a single object, and then provides methods to provide access to the pair in useful ways. It is very flexible in how the information can be provided to create the quantity, and once created, it is very flexible in how it can be accessed and displayed.

You can find the latest version of the source code on Github.

Enjoy,
-Ken

The documentation contained on this site is for the development version. If you prefer the documentation for the stable version (the one on PyPi), visit QuantiPhy.

Contents: