[SciPy-user] Units in SciPy
Robert Kern
rkern at ucsd.edu
Wed Mar 30 18:15:19 CST 2005
Duncan Child wrote:
> 1) any interest out there in us putting a units package into scipy?
Sure, but not any of the current ones.
> 2) any preference for a particular implementation? Unum, etc.
Unum is GPL.
I don't think any of the current offerings (Unum, ScientificPython's
PhysicalQuantities, and pyre.units) do particularly well with this
issue, although, as I note below, PhysicalQuantities gets closest.
> 3) does anyone have input or suggestions regarding the temperature issue?
Personally: computing absolute "degrees Fahrenheit" from absolute
"degrees Celsius" is not a unit conversion; it is a calculation built on
top of unit conversions. Converting "feet" from "meters" is a unit
conversion. Computing "feet from my house" from "meters from the North
Pole" is a calculation. I think that it is unwise to expect a unit
conversion system to handle such a computation the same way it handles
everything else.
That said, ScientificPython hacks around this creditably: "K" and "degR"
are both the absolute (referenced to absolute zero) and the differential
units. "degC" and "degF" are the absolute units referenced to their
respective zeros.
It's limited, though. You can't add a "degR" differential temperature to
a "degC" absolute temperature, but you can add a "K" differential
temperature. You can add "degC" to a "degC", but that's inconsistent.
Frink[1], which I hold as the gold standard for computer unit
conversions (and whose "Sample Calculations"[2] ought to be repeated for
any proposed unit package), sorta gets this right. Celsius[x] and
Fahrenheit[x] are functions that go back and forth between systems. Give
them an unadorned number, they'll interpret as, e.g. "10 degrees
Celsius", and convert to absolute Kelvin. Give it an absolute
temperature (in Kelvin or Rankine), and it will spit out the numerical
value of the temperature in its own scale (although unadorned by any
unit). "degC" and "degF" are the differential units.
It would be useful to have a system that would handle the general case
of referenced measurements like the Celsius and Fahrenheit scales and
"meters from my house". The appropriate distinctions should be made when
operations mix referenced measurements and "differential" quantities.
Oh, and any system should yoink the contents of Frink's database.
[1] http://futureboy.homeip.net/frinkdocs/
[2] http://futureboy.homeip.net/frinkdocs/#SampleCalculations
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the SciPy-user
mailing list