Package resokit.units
The ResoKit.units package includes tools for unit manipulation.
- resokit.units.convert(*values, from_units: None | str | Tuple[str, ...] | List[str] = None, to_units: None | str | Tuple[str, ...] | List[str] = None, power: int | Tuple[int, ...] | List[int] = 1) float | List[float][source]
Convert between compound units (e.g. km^2/s → m^2/s).
- Parameters:
from_units (str or list of str) – Units to convert from.
to_units (str or list of str) – Units to convert to.
power (int or list of int, optional) – Power(s) for each unit (default = 1). Must match length if list.
Examples
To convert 5 km s^{-2} to au yr^{-2}:
>>> resokit.units.convert( ... 5, ... from_units=("km", "s"), ... to_units=("au", "yr"), ... power=(1, -2) ... ) 33247713.903743323
- Returns:
Converted value, or list of converted values.
- Return type:
float or list of float