processing.units#
Functions
|
Convert units of a variable in a xr.Dataset or xr.DataTree to a target unit. |
- convert_units_to(data: Dataset | DataTree, var: str, target_unit: str, context: str = 'infer')[source]#
Convert units of a variable in a xr.Dataset or xr.DataTree to a target unit.
convert_units_to wraps
xclim.units.convert_units_to
to enable usage with xr.Dataset and xr.DataTree objects.- Parameters:
data (xr.Dataset or xr.DataTree) – The input dataset or data tree.
var (str) – The name of the variable to convert.
target_unit (str) – The target unit to convert to.
context (str, optional) – The context in which the conversion is made. Default is ‘infer’.
- Returns:
A new dataset or data tree with the variable converted to the target unit depending on the input type.
- Return type:
xr.Dataset or xr.DataTree
See also
xclim.units.convert_units_to