climate.utils.conversions¶
Utilities to bridge Earthkit data objects and xarray structures.
Module Contents¶
- climate.utils.conversions.EarthkitData¶
- climate.utils.conversions.MetadataDict¶
- climate.utils.conversions.to_xarray_dataset(earthkit_input, metadata=None)¶
Convert Earthkit-like data to an
xarray.Datasetand gather metadata.- Parameters:
earthkit_input (
EarthkitData | xarray.Dataset) – Input data in any supported Earthkit or xarray representation.metadata (
Mapping[str,Any], optional) – Existing metadata to propagate and enrich during the conversion.
- Returns:
Dataset ready to be consumed by xclim and an updated metadata mapping.
- Return type:
tuple[xr.Dataset,dict[str,Any]]- Raises:
TypeError – If the input cannot be converted to an
xarray.Dataset.
- climate.utils.conversions.to_earthkit_field(output, metadata=None)¶
Convert an xarray result back into an Earthkit representation.
- Parameters:
output (
xarray.Datasetorxarray.DataArray) – Resulting data returned by an xclim indicator.metadata (
Mapping[str,Any], optional) – Provenance metadata gathered during the conversion and call workflow.
- Returns:
The indicator output converted to the closest possible Earthkit type.
- Return type: