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.
Pint has recently come onto the field. Anybody care to share their experiences? Looks good. FYI: It looks like Pint will be integrated with Uncertainties in the near future.
I think you should use quantities, because a quantity has some units associated with it.
Pressure, for example, will be a quantity that could be entered and converted in and to different units (Pa, psi, atm, etc). Probably you could create new quantities specifics for your application.
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?
Note that
quantities
has very bad support for temperature:0 degrees Celsius isn't 0 degrees Fahrenheit. Their framework doesn't support any kind of conversion that isn't just multiplying by a factor.
It looks like another package has come out for doing this as well, written by Massimo DiPierro of web2py fame, called Buckingham.
Also of note, Brian has had something like this for some time.
There is another package called unyt from the yt-project. The authors of unyt acknowledge the existence of Pint and astropy.units. Conversions from and to these other packages is supported.
The selling point of unyt is speed. It is faster than the other two. The unit packages are compared in several benchmarks in this paper.
The benchmarks are disappointing for anyone obsessed with performance. :-( The slowdown of calculations with any of these unit systems is large. The slowdown factor is 6-10 for arrays with 1000 entries (worse for smaller arrays).
Disclaimer: I am not affiliated with unyt, I just want to share what I learned about unit systems.