Skip to content

Commit 0bd69ca

Browse files
DOC: Add note to docs on DataTree root-group naming conventions (#9298)
* 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>
1 parent f15082c commit 0bd69ca

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

xarray/core/datatree.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,12 @@ def to_netcdf(
15511551
``dask.delayed.Delayed`` object that can be computed later.
15521552
Currently, ``compute=False`` is not supported.
15531553
kwargs :
1554-
Addional keyword arguments to be passed to ``xarray.Dataset.to_netcdf``
1554+
Additional keyword arguments to be passed to ``xarray.Dataset.to_netcdf``
1555+
1556+
Note
1557+
----
1558+
Due to file format specifications the on-disk root group name
1559+
is always ``"/"`` overriding any given ``DataTree`` root node name.
15551560
"""
15561561
from xarray.core.datatree_io import _datatree_to_netcdf
15571562

@@ -1607,6 +1612,11 @@ def to_zarr(
16071612
supported.
16081613
kwargs :
16091614
Additional keyword arguments to be passed to ``xarray.Dataset.to_zarr``
1615+
1616+
Note
1617+
----
1618+
Due to file format specifications the on-disk root group name
1619+
is always ``"/"`` overriding any given ``DataTree`` root node name.
16101620
"""
16111621
from xarray.core.datatree_io import _datatree_to_zarr
16121622

xarray/datatree_/docs/source/io.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ To open a whole netCDF file as a tree of groups use the :py:func:`open_datatree`
2424
To save a DataTree object as a netCDF file containing many groups, use the :py:meth:`DataTree.to_netcdf` method.
2525

2626

27+
.. _netcdf.root_group.note:
28+
29+
.. note::
30+
Due to file format specifications the on-disk root group name is always ``"/"``,
31+
overriding any given ``DataTree`` root node name.
32+
2733
.. _netcdf.group.warning:
2834

2935
.. warning::
@@ -52,3 +58,8 @@ To save a DataTree object as a zarr store containing many groups, use the :py:me
5258
.. note::
5359
Note that perfect round-tripping should always be possible with a zarr store (:ref:`unlike for netCDF files <netcdf.group.warning>`),
5460
as zarr does not support "unused" dimensions.
61+
62+
For the root group the same restrictions (:ref:`as for netCDF files <netcdf.root_group.note>`) apply.
63+
Due to file format specifications the on-disk root group name is always ``"/"``
64+
overriding any given ``DataTree`` root node name.
65+

0 commit comments

Comments
 (0)