Skip to content

Commit

Permalink
DOC: Add note to docs on DataTree root-group naming conventions (#9298)
Browse files Browse the repository at this point in the history
* DOC: Add note to docs on DataTree root-group naming conventions (root group name is always "/").

* Update xarray/core/datatree.py

* Update xarray/core/datatree.py

Co-authored-by: Matt Savoie <github@flamingbear.com>

* Update xarray/core/datatree.py

Co-authored-by: Matt Savoie <github@flamingbear.com>

* Update xarray/datatree_/docs/source/io.rst

Co-authored-by: Matt Savoie <github@flamingbear.com>

* Update xarray/datatree_/docs/source/io.rst

Co-authored-by: Matt Savoie <github@flamingbear.com>

---------

Co-authored-by: Matt Savoie <github@flamingbear.com>
  • Loading branch information
kmuehlbauer and flamingbear authored Aug 2, 2024
1 parent f15082c commit 0bd69ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion xarray/core/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,12 @@ def to_netcdf(
``dask.delayed.Delayed`` object that can be computed later.
Currently, ``compute=False`` is not supported.
kwargs :
Addional keyword arguments to be passed to ``xarray.Dataset.to_netcdf``
Additional keyword arguments to be passed to ``xarray.Dataset.to_netcdf``
Note
----
Due to file format specifications the on-disk root group name
is always ``"/"`` overriding any given ``DataTree`` root node name.
"""
from xarray.core.datatree_io import _datatree_to_netcdf

Expand Down Expand Up @@ -1607,6 +1612,11 @@ def to_zarr(
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.
"""
from xarray.core.datatree_io import _datatree_to_zarr

Expand Down
11 changes: 11 additions & 0 deletions xarray/datatree_/docs/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ To open a whole netCDF file as a tree of groups use the :py:func:`open_datatree`
To save a DataTree object as a netCDF file containing many groups, use the :py:meth:`DataTree.to_netcdf` method.


.. _netcdf.root_group.note:

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

.. _netcdf.group.warning:

.. warning::
Expand Down Expand Up @@ -52,3 +58,8 @@ To save a DataTree object as a zarr store containing many groups, use the :py:me
.. note::
Note that perfect round-tripping should always be possible with a zarr store (:ref:`unlike for netCDF files <netcdf.group.warning>`),
as zarr does not support "unused" dimensions.

For the root group the same restrictions (:ref:`as for netCDF files <netcdf.root_group.note>`) apply.
Due to file format specifications the on-disk root group name is always ``"/"``
overriding any given ``DataTree`` root node name.

0 comments on commit 0bd69ca

Please sign in to comment.