-
Notifications
You must be signed in to change notification settings - Fork 41
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
rewrite units for plotting #156
Comments
Yes, this could definitely be done with Pint (see the formatting options here: https://pint.readthedocs.io/en/stable/tutorial.html#string-formatting)! Though, in order to interpret CF/UDUNITS-style exponents, a custom preprocessor (like that in MetPy) is needed, which connects back to the larger issue of xarray-contrib/pint-xarray#26. |
Thanks. Another option is import cf_units
for string in ["degreeN", "m2/s4", "kg/m3", "degC"]:
print(cf_units.Unit(string).format(cf_units.UT_UTF8)) which looks good except for the reversed order for
|
One argument against cf_units is that it is not pip-installable. It requires the UDUNITS-2 library which is not on pypi. Works well with conda, but potential headaches otherwise! |
It would be nice if we could rewrite the
units
attribute when using.cf.plot()
sounits = "kg/m3"
becomesunits = "kg/m³"
. There must be some convenient way of doing this, maybe with pint?cc @keewis @jthielen
The text was updated successfully, but these errors were encountered: