Skip to content

Commit

Permalink
remove content about non-inherited coords for a follow-up PR
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Oct 12, 2024
1 parent d2918bb commit 6cab6f8
Showing 1 changed file with 0 additions and 55 deletions.
55 changes: 0 additions & 55 deletions doc/user-guide/hierarchical-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -798,58 +798,3 @@ We can also still perform all the same operations on the whole tree:
dt.std(dim="time")
(TODO: The second one fails due to https://github.com/pydata/xarray/issues/8949)

.. _overriding-inherited-coordinates:

Overriding Inherited Coordinates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We can override inherited coordinates with newly-defined ones on child nodes, as long as those newly-defined coordinates also align with the parent nodes.

You may want to do this if some child dataset follows the same pattern as its siblings but contains different specific values of a coordinate.

Let's image we had three different datasets, on two different lat-lon grids:

.. ipython:: python
lon1, lat1 = np.meshgrid(np.linspace(-20, 20, 5), np.linspace(0, 30, 4))
grid1 = xr.Coordinates({'lat': lat1, 'lon': lon1})

# a different grid with the same sizes
lon2 = lat1 + (lat1 / 10)
lat2 = lon1 + (lon1 / 10)
grid1 = xr.Coordinates({'lat': lat2, 'lon': lon2})

# model_ds1 = xr.Dataset()
# model_ds2 = xr.Dataset()
# model_ds3 = xr.Dataset()

We could arrange these in a datatree

.. ipython:: python
dt = xr.DataTree.from_dict(
{
"/": Dataset(coords=grid1),
"model1": None,
"model2": None,
"model3": Dataset(coords=grid2),
}
)
dt
However in this you could also have reprented this without overriding, by using an extra layer of nodes in the tree:


.. _overriding-inherited-coordinates:

Non-Inherited Coordinates
~~~~~~~~~~~~~~~~~~~~~~~~~

Only coordinates which are backed by an index are inherited. This is because index-backed coordinates can be efficiently de-duplicated between parents and children, preventing ambiguity



EXAMPLE OF INHERITING FROM A GRANDPARENT?

EXPLAIN DEDUPLICATION?

0 comments on commit 6cab6f8

Please sign in to comment.