From 9e179d2a2bec06cb8412453e61f506609a8f9b76 Mon Sep 17 00:00:00 2001 From: Matt Savoie Date: Thu, 12 Sep 2024 15:30:59 -0600 Subject: [PATCH] DAS-2155: Updates to call out inherited coordinates and inherited flag --- doc/user-guide/data-structures.rst | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/doc/user-guide/data-structures.rst b/doc/user-guide/data-structures.rst index a14e9b2db27..b5e83789806 100644 --- a/doc/user-guide/data-structures.rst +++ b/doc/user-guide/data-structures.rst @@ -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 ` 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: