← Back to team overview

python-quantities-developers team mailing list archive

Re: Temperature conversion bug and known issues

 

Hi Tony,

On Fri, Jul 10, 2009 at 5:04 PM, Tony S Yu <tonyyu@xxxxxxx> wrote:

> I'm surprised I didn't notice this before: temperature conversions between
> Celsius and Kelvin don't work correctly.
>
> >>> T = 20 * pq.degC
> >>> T.units = pq.K
> >>> print T
> 20.0 K
>
> I'm not sure how to fix this conversion problem, since it requires an
> offset during conversion (which is not yet possible, as far as I can tell).
> In any case, I don't think the above error should pass silently. Until, this
> conversion error is fixed, it'd be nice to remove the capability of
> converting between temperatures (except between Rankine and Kelvin, which
> works fine). Below is a patch that does this.
>

Please take a moment to consider the following, which is included in the
tutorial at http://packages.python.org/quantities/user/tutorial.html :

---
One final note: Quantities is not a package for describing coordinate
systems that require a point of reference, like positions on a map or
absolute temperature scales. Proper support of coordinate systems would be a
fairly large undertaking and is outside the scope of this project.
---

I would argue that the current behavior is correct, because quantities
assumes that degC (for example) is a temperature difference, not an absolute
temperature. So I would opt not to apply this patch.

I suppose Quantities could be used as the basis for a project that supports
coordinate systems and transforms thereof, but I don't think I will be the
one to attempt such an undertaking. We could consider implementing a
conversion function for quantities that treats temperature as a measure on
an absolute scale, but I want to keep the core unit transformations simple,
no coordinate systems.


> Also, I wanted to follow up on my suggestion for a known issues page. I've
> attached a rough draft of what I had in mind. (Side note: I emailed the
> numpy list about the interpolation issue with zero-rank arrays, but it
> hasn't shown up on the list yet; I'll try again at some latter point).


Thank you for submitting this. I am modifying the discussion of temperature
and will include it in the trunk. I would rather not include the discussion
about interpolation, since this does not seem specific to quantities.

Darren

Follow ups

References