xarray.DataTree.to_zarr

xarray.DataTree.to_zarr#

DataTree.to_zarr(store, mode='w-', encoding=None, consolidated=True, group=None, write_inherited_coords=False, compute=True, **kwargs)[source]#

Write datatree contents to a Zarr store.

Parameters:
  • store (MutableMapping, str or Path, optional) – Store or path to directory in file system

  • mode ({{"w", "w-", "a", "r+", None}, default: "w-") – Persistence mode: “w” means create (overwrite if exists); “w-” means create (fail if exists); “a” means override existing variables (create if does not exist); “r+” means modify existing array values only (raise an error if any metadata or shapes would change). The default mode is “w-”.

  • encoding (dict, optional) – Nested dictionary with variable names as keys and dictionaries of variable specific encodings as values, e.g., {"root/set1": {"my_variable": {"dtype": "int16", "scale_factor": 0.1}, ...}, ...}. See xarray.Dataset.to_zarr for available options.

  • consolidated (bool) – If True, apply zarr’s consolidate_metadata function to the store after writing metadata for all groups.

  • group (str, optional) – Group path. (a.k.a. path in zarr terminology.)

  • write_inherited_coords (bool, default: False) – If true, replicate inherited coordinates on all descendant nodes. Otherwise, only write coordinates at the level at which they are originally defined. This saves disk space, but requires opening the full tree to load inherited coordinates.

  • compute (bool, default: True) – If true compute immediately, otherwise return a dask.delayed.Delayed object that can be computed later. Metadata is always updated eagerly. Currently, compute=False is not supported.

  • kwargs – Additional keyword arguments to be passed to xarray.Dataset.to_zarr

Note

Due to file format specifications the on-disk root group name is always "/" overriding any given DataTree root node name.