[SciPy-dev] physical quantities: udunits?

John Pye john@curioussymbols....
Tue Jul 29 18:35:04 CDT 2008


Hi Darren

Darren Dale wrote:
> I was wondering if anyone is familiar with the udunits package, would it be 
> suitable as the foundation for physical quantities support in python?
>
> http://www.unidata.ucar.edu/software/udunits/
>
> According to freshmeat, udunits is released under a BSD-style license.
FWIW I have a small units-of-measurement class that I've used a bit in
my own code.

Example of use is here:
http://freesteam.svn.sourceforge.net/viewvc/freesteam/freesteam/trunk/python/example.py?revision=441&view=markup

The implementation is here:
http://freesteam.svn.sourceforge.net/viewvc/freesteam/freesteam/trunk/measurement.cpp?view=markup

The interesting thing about this implementation is that it interfaces
with some C++ template-based code that performs units-of-measurement
checking at *compile time*, with no runtime overhead. So the idea is
that Python is used for a slightly 'heavy' system of storing values
(plus their dimension data, eg M L T^-1) and these values are
efficiently passed into C/C++ where units-checked calculations are done
with no overhead.

I'm not suggesting this is a 'mature' and 'complete' system but if
anyone's thinking about making some sort of official implementation for
this stuff, these ideas might be worth some thought.

Also might be worth thinking about efficient storing of arrays of values
with the same unit-dimensions eg via numpy.

Cheers
JP


More information about the Scipy-dev mailing list