Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/user-guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,13 @@ For example:
compressor = BloscCodec(cname="zstd", clevel=3, shuffle="shuffle")
ds.to_zarr(zarr_filename, consolidated=False, encoding={"foo": {"compressors": [compressor]}})

For Zarr v3, xarray forwards codec configuration in each variable's
``encoding`` dictionary to zarr-python. Use ``compressors`` for bytes-to-bytes
codecs and ``serializer`` for array-to-bytes codecs, with codec objects and
configuration following zarr-python. Other Zarr v3 metadata options accepted by
xarray include ``filters``, ``shards``, ``fill_value``, and
``chunk_key_encoding``.

.. note::

Not all native zarr compression and filtering options have been tested with
Expand Down
4 changes: 4 additions & 0 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2263,6 +2263,10 @@ def to_zarr(
Nested dictionary with variable names as keys and dictionaries of
variable specific encodings as values, e.g.,
``{"my_variable": {"dtype": "int16", "scale_factor": 0.1,}, ...}``
Zarr-specific options such as ``chunks``, ``compressor``,
``compressors``, ``filters``, ``serializer``, ``shards``, and
``chunk_key_encoding`` may also be provided. See the Zarr encoding
section in the I/O user guide for details.
compute : bool, default: True
If True write array data immediately, otherwise return a
``dask.delayed.Delayed`` object that can be computed to write
Expand Down
Loading