Skip to content

Units

stormlore.units

Unit conversions.

The API serves SI values (kelvin, m/s, pascals, metres, millimetres) and the SDK hands them back untouched unless asked: Client(units="metric" | "imperial") sets the default for to_dataframe(), which to_dataframe(units=...) overrides, and every :class:~stormlore.results.ValueWithUnits has .to(...).

Every converter works on a float or a numpy array alike.

Example

from stormlore.units import convert convert(273.15, "K", "°C") 0.0 convert(10.0, "m/s", "imperial") 22.369362920544

convert

convert(value: Any, from_units: str, to: str) -> Any

Convert value from from_units to a system ("metric", "imperial", "native") or a unit ("°F", "degC", "kt", "hPa" …).

Converting to a system leaves a unit that system has no conversion for unchanged. None stays None.

Raises:

Type Description
UnitConversionError

to is a unit from_units cannot be converted to.

wind_speed

wind_speed(u: Any, v: Any) -> Any

Wind speed from its eastward (u) and northward (v) components.

wind_direction

wind_direction(u: Any, v: Any) -> Any

The direction the wind blows from, in degrees (0 = north, 90 = east).