Closed paigem closed 2 years ago
While this may be surprising at first, this is actually the expected behavior! Since temperature units like degrees Celsius have an offset (i.e. 0 is not actually 0 in an absolute sense), they are non-multiplicative, or in other words, trying to multiply quantities in those units is not well-defined. To get around this, Pint (at least how it is configured by default in pint-xarray) automatically converts such non-multiplicative units to the corresponding absolute version--hence Kelvin here.
If you're interested in reading more about how these kinds of units work in Pint, I recommend this page of the documentation: https://pint.readthedocs.io/en/stable/nonmult.html
Thanks @jthielen - I see now why this is the expected behavior, and apologies that I didn't see that page in the docs before opening this issue. I'll go ahead and close this issue then!
I have just started to use
pint-xarray
and have found that there is an unexpected conversion from Celsius to Kelvin when I multiply twoxarray.DataArrays
together. Below I have included a reproducible example of this:Output:
Now if I try to square the quantity, I would expect to get units of degC^2, but instead it looks like the units have been converted to Kelvin and then squared:
Output:
This same behavior occurs when multiplying
data_quantified
with anyxarray.DataArray
that has different units as well. As far as I can tell, I haven't found the same behavior with any other unit exceptdegC
.I am using
pint-xarray
version 0.2.1 on Pangeo Cloud, installed via pip.As I am very new to this package, I'm not sure where to look for the source of this bug, so any help or input on this would be appreciated!