From af722f01c91ade023f0c828b886fcb1b0c3d3355 Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:34:30 -0700 Subject: [PATCH] Improve `to_zarr` docs (#9139) Promoted `region='auto'`, refine the langague slightly --- xarray/core/dataset.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 0923c5d4822..0b8be674675 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -2458,24 +2458,26 @@ def to_zarr( If set, the dimension along which the data will be appended. All other dimensions on overridden variables must remain the same size. region : dict or "auto", optional - Optional mapping from dimension names to integer slices along - dataset dimensions to indicate the region of existing zarr array(s) - in which to write this dataset's data. For example, - ``{'x': slice(0, 1000), 'y': slice(10000, 11000)}`` would indicate - that values should be written to the region ``0:1000`` along ``x`` - and ``10000:11000`` along ``y``. - - Can also specify ``"auto"``, in which case the existing store will be - opened and the region inferred by matching the new data's coordinates. - ``"auto"`` can be used as a single string, which will automatically infer - the region for all dimensions, or as dictionary values for specific - dimensions mixed together with explicit slices for other dimensions. + Optional mapping from dimension names to either a) ``"auto"``, or b) integer + slices, indicating the region of existing zarr array(s) in which to write + this dataset's data. + + If ``"auto"`` is provided the existing store will be opened and the region + inferred by matching indexes. ``"auto"`` can be used as a single string, + which will automatically infer the region for all dimensions, or as + dictionary values for specific dimensions mixed together with explicit + slices for other dimensions. + + Alternatively integer slices can be provided; for example, ``{'x': slice(0, + 1000), 'y': slice(10000, 11000)}`` would indicate that values should be + written to the region ``0:1000`` along ``x`` and ``10000:11000`` along + ``y``. Two restrictions apply to the use of ``region``: - If ``region`` is set, _all_ variables in a dataset must have at least one dimension in common with the region. Other variables - should be written in a separate call to ``to_zarr()``. + should be written in a separate single call to ``to_zarr()``. - Dimensions cannot be included in both ``region`` and ``append_dim`` at the same time. To create empty arrays to fill in with ``region``, use a separate call to ``to_zarr()`` with