I'm working on a project that lets users track different data types over time. Part of the base idea is that a user should be able to enter data using any units that they need to. I've been looking at both units:
http://pypi.python.org/pypi/units/
and quantities:
http://pypi.python.org/pypi/quantities/
However I'm not sure the best way to go. From what I can tell, quantities is more complex, but includes a better initial list of units.
Units is a "zero overhead" system with no runtime cost, all python quantity implementations, including SimTK units, probably exact a runtime cost. I want dimensioned Quantities that are compatible with numpy arrays, but do not necessarily require the python numpy package.
For example, the appropriate conversion value, to convert inches to feet, is 12 inches = 1 foot, and for temperature conversions, we use C/5=F-32/9=K-273/5. Listed below are a few topics that are related to conversion of unit.
Pint is a Python package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units. It is distributed with a comprehensive list of physical units, prefixes and constants.
I applaud use of explicit units in scientific computing applications. Using explicit units is analogous brushing your teeth. It adds some tedium up front, but the type safety you get can save a lot of trouble in the long run. Like, say, not crashing $125 million orbiters into planets.
You should also probably check out these two other python unit/quantity packages:
Unum
Scientific.Physics.PhysicalQuantity
I once investigated Scientific.Physics.PhysicalQuantity. It did not quite meet my needs, but might satisfy yours. It's hard to tell what features you need from your brief description.
I ended up writing my own python package for unit conversion and dimensional analysis, but it is not properly packaged for release yet. We are using my unit system in the python bindings for our OpenMM system for GPU accelerated molecular mechanics. You can browse the svn repository of my python units code at:
SimTK python units
Eventually I intend to package it for distribution. If you find it interesting, please let me know. That might motivate me to package it up sooner. The features I was looking for when I was designing the SimTK python units system included the following:
What features are important to you?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With