Skip to content

Commit

Permalink
Improve to_zarr docs (#9139)
Browse files Browse the repository at this point in the history
Promoted `region='auto'`, refine the langague slightly
  • Loading branch information
max-sixty authored Jun 21, 2024
1 parent 3fd162e commit af722f0
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af722f0

Please sign in to comment.