Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Add note to docs on DataTree root-group naming conventions #9298

Merged
merged 7 commits into from
Aug 2, 2024
Merged
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
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.

Loading