Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should gallileanRaise really be dropping the offset? #82

Open
pelson opened this issue Jan 24, 2019 · 0 comments
Open

Should gallileanRaise really be dropping the offset? #82

pelson opened this issue Jan 24, 2019 · 0 comments

Comments

@pelson
Copy link

pelson commented Jan 24, 2019

In https://github.com/Unidata/UDUNITS-2/blob/v2.2.27.6/lib/unitcore.c#L1784-L1822 offsets are dropped when raising a unit to the given power. This is demonstrated succinctly with:

$ udunits -H "K" -W "degC"
    1 K = -272.15 degC
    x/degC = (x/K) - 273.15

Clearly we can subtract 273.15 from our Kelvins to reach Celsius. But,

$ udunits2 -H "K^2" -W "degC^2"
    1 K^2 = 1 degC^2
    x/degC^2 = (x/K^2)

Suggests that if we have Kelvins² and want Celcius² we don't need to do anything to our numbers, which seems quite incorrect.

This behaviour is adopted by ut_convert, and can -in my opinion- lead to some unexpected results.

I confess I don't have the background to really have a strong physical sense of what the operation should do, but a better default behaviour would surely to honour the offset...

x/K² = x/degC² + 2 · 273.15 (x/degC)⁻² + 273.15²

And

(x/degC²) = (x/K²) - 2 · 273.15 (x/K)⁻² + 273.15²

And to raise in ut_convert if x is a negative quantity (to keep the results in ℝ+).

Have I overlooked some reason why offset units behave in the way they do, or is it just something that hasn't yet been needed/implemented?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant