A Python library for handling units of measure as required by the Climate and Forecast (CF) metadata conventions. It supports unit parsing, conversion, and computation, and is built on top of the UDUNITS-2 library. Current version is 3.3.1, with a stable release cadence.
pip install cf-unitsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage: create Unit objects and perform conversions.
Upgrade Python to 3.11+.
Install UDUNITS-2 via conda (conda install -c conda-forge udunits2) or your system package manager (e.g., apt-get install libudunits2-dev on Debian/Ubuntu).
Ensure unit strings follow UDUNITS-2 conventions; double-check case, especially for prefixes.
Use 'import cf_units' (underscore) in your code.
Check the unit string for typos and ensure it adheres to UDUNITS definitions. Use cf_units.Unit.is_udunits() to validate.
Install UDUNITS-2 system-wide (e.g., conda install -c conda-forge udunits2 on Linux, or use conda environment).