Skip to content

Commit 147a4f0

Browse files
committed
docs: add rectilinear chunks details
1 parent ba5b357 commit 147a4f0

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

doc/user-guide/io.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,33 @@ shape of each coordinate array in the ``encoding`` argument:
12411241
The number of chunks on Tair matches our dask chunks, while there is now only a single
12421242
chunk in the directory stores of each coordinate.
12431243

1244+
.. _io.zarr.rectilinear_chunks:
1245+
1246+
Variable-sized (rectilinear) chunks
1247+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1248+
1249+
Zarr v3 supports *rectilinear* chunk grids, where chunk sizes vary along one
1250+
or more dimensions. This is useful when natural data boundaries (yearly chunks
1251+
of a daily time series, per-tile spatial extents) don't align to a regular
1252+
grid. Requires ``zarr-python >= 3.2``, and the experimental feature must be
1253+
enabled for both reading and writing:
1254+
1255+
.. code-block:: python
1256+
1257+
import zarr
1258+
1259+
with zarr.config.set({"array.rectilinear_chunks": True}):
1260+
ds = xr.Dataset({"var": ("x", np.arange(60))}).chunk({"x": (10, 20, 30)})
1261+
ds.to_zarr("rectilinear.zarr", zarr_format=3, mode="w")
1262+
1263+
roundtrip = xr.open_zarr("rectilinear.zarr", zarr_format=3)
1264+
roundtrip.chunks["x"] # (10, 20, 30)
1265+
1266+
Rectilinear chunks can also be specified through the ``encoding`` argument
1267+
(one sequence per dimension), e.g. ``encoding={"var": {"chunks": ((10, 20, 30),)}}``.
1268+
Writing non-uniform chunks to a zarr v2 store raises ``ValueError`` because the
1269+
feature is Zarr Format 3-only.
1270+
12441271
Groups
12451272
~~~~~~
12461273

0 commit comments

Comments
 (0)