[SciPy-user] arrays with units
Robert Kern
robert.kern at gmail.com
Tue Jun 27 21:05:55 EDT 2006
Alexander Ross wrote:
> I'm in need of a simple way to attach units of measurement to a numpy
> array. I've read some of the previous discussion on the topic, and
> found the constants module tucked away in the sandbox. While the
> constants package does a good job at providing access to the various
> physical constants it doesn't satisfy my needs.
Which are?
> The package Unum
> would require me to use object arrays, and I don't want to do that.
I don't think so.
http://home.tiscali.be/be052320/Unum_tutorial.html#_Toc68111433
> Ideally, I'd like an extended ndarray adding a new attribute
> `units'. The `units' attribute would be updated by the appropriate
> arithmetic operations, and I guess exceptions would be raised for
> operations which don't make sense.
>
> Is anything like this in the works? Should I strike out on my own?
Not particularly. Most unit packages work well with arrays; instead of
inheriting from ndarray, they simply hold an attribute that is assumed to be a
number-like object (like an array). Some may still need to be ported from
Numeric to numpy:
Konrad Hinsen's Scientific.Physics.PhysicalQuantities
Michael Aivazis's pyre.units
Enthought's enthought.units (mostly derived from Michael's work)
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list