move_reserved_attrs_to_encoding#

mhm_tools.common.netcdf.move_reserved_attrs_to_encoding(obj: Dataset | DataArray, include_coords: bool = True, extra_reserved: Set[str] | None = None, encoding_in: dict | None = None)[source]#

Move reserved serialization attrs into xarray encoding.

Parameters:
  • obj (xr.Dataset or xr.DataArray) – Object to clean.

  • include_coords (bool, default True) – If True, also process coordinate variables.

  • extra_reserved (set[str], optional) – Additional keys to treat as reserved.

  • encoding_in (dict, optional) – Initial per-variable encoding to merge into the result.

Returns:

(cleaned_object, encoding) with reserved attrs moved.

Return type:

tuple