Skip to content

Commit

Permalink
DAS-2155: Updates to call out inherited coordinates and inherited flag
Browse files Browse the repository at this point in the history
  • Loading branch information
flamingbear committed Sep 12, 2024
1 parent ae8bb71 commit 9e179d2
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions doc/user-guide/data-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -775,16 +775,31 @@ Coordinate variables are inherited to descendent nodes, which means that
variables at different levels of a hierarchical DataTree are always
aligned. Placing the ``time`` variable at the root node automatically indicates
that it applies to all descendent nodes. Similarly, ``station`` is in the base
``weather`` node, because it applies to all weather variables, both directly
in ``weather`` and in the ``temperature`` sub-tree.
``weather`` node, because it applies to all weather variables, both directly in
``weather`` and in the ``temperature`` sub-tree. Notice the inherited coordinates are
explicitly shown in the tree representation under ``Inherited coordinates:``.

Accessing any of the lower level trees as an ``xarray.Dataset`` would
automatically include coordinates from higher levels (e.g., ``time`` and ``station``):
.. ipython:: python
dt2["/weather"]
Accessing any of the lower level trees through the :py:func:`.dataset <xarray.DataTree.dataset>` property
automatically includes coordinates from higher levels (e.g., ``time`` and
``station``):

.. ipython:: python
dt2["/weather/temperature"].dataset
Similarly, when you retrieve a Dataset through :py:func:`~xarray.DataTree.to_dataset` , the inherited coordinates are
included by default unless you exclude them with the ``inherited`` flag:

.. ipython:: python
dt2["/weather/temperature"].to_dataset()
dt2["/weather/temperature"].to_dataset(inherited=False)
.. _coordinates:

Expand Down

0 comments on commit 9e179d2

Please sign in to comment.