Registry / analytics / cf-units

cf-units

JSON →
library3.3.1pypypi✓ verified 34d ago

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.

analyticsdevops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Importing the package alone does not expose Unit directly; you must import the class.

from cf_units import Unit

Common function for converting dates to numeric values.

from cf_units import date2num

Basic usage: create Unit objects and perform conversions.

from cf_units import Unit # Define units speed = Unit('m/s') temperature = Unit('celsius') # Convert value value_in_kmh = speed.convert(10.0, 'km/h') print(f'10 m/s in km/h: {value_in_kmh}') # Check compatibility print(speed.is_convertible(Unit('knots'))) # True
Debug
Known footguns
breakingcf-units v3 requires Python >=3.11. Python 3.10 and older are not supported.
gotchaThe underlying UDUNITS-2 library must be installed at the system level. pip install cf-units does not install it automatically.
gotchaUnit strings are case-sensitive. For example, 'K' (kelvin) is different from 'k' (kilo prefix).
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
21 hits · last 30 days
gptbot
3
amazonbot
3
bytedance
2
mj12bot
1
ahrefsbot
1
Resources