-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Following the discussion in SciTools/cf-units#446 (comment), it would be good to get some feedback on how the implementation here for dimensionality and conversion works out for you @ocefpaf.
The README.md has some info, but for your is_convertible and is_dimensionless cases you can use the following:
from pyudunits2 import UnitSystem
ut_system = UnitSystem.from_udunits2_xml()
unit1 = ut_system.unit('km/h')
unit2 = ut_system.unit('meters per second')
assert unit1.is_convertible_to(unit2)
assert not unit1.is_convertible_to(ut_system.unit('m'))
And:
assert ut_system.unit('radians mg/kilogram').is_dimensionless()
There is an example in the README if you want to do actual conversions, rather than just knowing if conversions are possible.
Metadata
Metadata
Assignees
Labels
No labels