-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Take a conversion from electron temperature to thermal velocity as an example:
from pint import application_registry as u
import numpy as np
np.sqrt(100 * u.eV / u.m_e).to("km/s")
# <Quantity(4193.82881, 'kilometer / second')>
If we then import cf_xarray.units
to enable CF units, per this page, we get the following error:
import cf_xarray.units
np.sqrt(100 * u.eV / u.m_e).to("km/s")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/quantity.py", line 536, in to
magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/quantity.py", line 480, in _convert_magnitude_not_inplace
return self._REGISTRY.convert(self._magnitude, self._units, other)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 1041, in convert
return self._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/context/registry.py", line 405, in _convert
return super()._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/nonmultiplicative/registry.py", line 259, in _convert
return super()._convert(value, src, dst, inplace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/tvo/.local/share/mamba/envs/test_xarray_units/lib/python3.12/site-packages/pint/facets/plain/registry.py", line 1076, in _convert
raise factor
pint.errors.DimensionalityError: Cannot convert from 'electron_volt ** 0.5 / electron_mass ** 0.5' ([temperature] ** 0.5 * [length] / [time] ** 1.5 / [current] ** 0.5) to 'kilometer / second' ([length] / [time])
Metadata
Metadata
Assignees
Labels
No labels