-
Notifications
You must be signed in to change notification settings - Fork 40
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
Consider using kelvin
instead if Kelvin
for units
#544
Comments
kelvin
instead if 'Kelvin`kelvin
instead if Kelvin
for units
No objections. Note that NIST spells kelvin with a lower case We should probably also replace "K" with "kelvin" in unit strings, for consistency ( Another compatibility issue: UDUNITS parses We should also replace "Celsius" with PS: UDUNITS appears to be case-insensitive. |
Replacements: - "Kelvin" -> "kelvin" - "K" -> "kelvin" - "Celsius" -> "degree_Celsius"
(See http://pint.readthedocs.org/ and #544.) Replace "kg m-2 year-1" with "kg m^-2 year^-1" and so on. Also: "Kelvin" -> "kelvin" throughout and replace "degree kelvin" -> "kelvin".
The modified test script import xarray as xr
import cf_xarray.units
import pint_xarray
import sys
ds = xr.open_dataset(sys.argv[1])
for v in ds.data_vars:
if v == "hardav":
continue
print(da.pint.quantify()) works with PISM from the The "hardav" variable has units Fractional powers are not supported by UDUNITS, so I'm not sure what to do about that. Setting units to |
I did not notice “Celsius” not being support because I had `cf_xarray` loaded, which supports `Celsius`.
But the default seems to be
$ cf_xarray.units.units.Celsius
$ degree_Celsius
I don’t have a strong opinion if we should go with “pure” pint, or CF units but I’m tending to CF. Since we are in the climate modeling community, CF would be OK, IMHO. “degree_east” and similar are also only defined in `cf_xarray`.
… On Apr 24, 2024, at 19:49, Constantine Khrulev ***@***.***> wrote:
No objections. Note that NIST <https://www.nist.gov/si-redefinition/kelvin-introduction> spells kelvin with a lower case k and UDUNITS supports both "kelvin" and "Kelvin" (and degree_Kelvin, which, according to NIST, is wrong).
We should probably also replace "K" with "kelvin" in unit strings, for consistency (pint does recognize "K" as "kelvin", though.)
Another compatibility issue: UDUNITS parses m s-2 as "m/s^2", i.e. a unit followed by an integer is interpreted as unit raised to a power. We should replace m s-2 with m s^-2 and so on. (UDUNITS recognizes m2, m^2 and m**2, so this would not break anything. pint recognizes m^2, m**2, m^-2, etc, but not m-2.)
We should also replace "Celsius" with degC or degree_Celsius since pint does supports the latter two and not the first one.
PS: UDUNITS appears to be case-insensitive.
—
Reply to this email directly, view it on GitHub <#544 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAA5O6UFFQUPZCKQY6UKBVDY67WCJAVCNFSM6AAAAABGXBKJQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZVGUYDSNRYGE>.
You are receiving this because you authored the thread.
|
@aaschwanden CF conventions allow most units supported by UDUNITS (with some exceptions), so
(See section 3.1. Units for more.) This works:
And this works too, so I think we're okay here.
|
Description
cf_xarray.units
which implements CF conforming units, hasCelsius
, but notKelvin
. Switching PISM's default fromKelvin
tokelvin
would allow seamless use ofXarray
in combination withpint_xarray
andcf_xarray
.PISM version
PISMR (basic evolution run mode) 2.1.99-d7dc90a06
To Reproduce
In a shell:
pismr -EisII A -o_size big_2d -o pism_test_pint_xarray.nc
pip install xarray cf_xarray pint_xarray
In python:
The text was updated successfully, but these errors were encountered: