From 06394458a816fcaaa11679baadf5151bea3bed2d Mon Sep 17 00:00:00 2001 From: mccloskey Date: Tue, 11 Apr 2023 17:05:18 -0400 Subject: [PATCH 1/2] Clarify vectorized indexing documentation --- doc/user-guide/indexing.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/user-guide/indexing.rst b/doc/user-guide/indexing.rst index 492316f898f..3d66816d02f 100644 --- a/doc/user-guide/indexing.rst +++ b/doc/user-guide/indexing.rst @@ -352,7 +352,6 @@ dimensions: ind_x = xr.DataArray([0, 1], dims=["x"]) ind_y = xr.DataArray([0, 1], dims=["y"]) da[ind_x, ind_y] # orthogonal indexing - da[ind_x, ind_x] # vectorized indexing Slices or sequences/arrays without named-dimensions are treated as if they have the same dimension which is indexed along: @@ -399,6 +398,12 @@ These methods may also be applied to ``Dataset`` objects Vectorized indexing may be used to extract information from the nearest grid cells of interest, for example, the nearest climate model grid cells to a collection specified weather station latitudes and longitudes. +Note that to trigger vectorized indexing behavior (not orthogonal) +you will need to provide the selection dimensions with a new +shared output dimension name. In the example below, the selections +of the closest latitude and longitude are renamed to an output +dimension named "points": + .. ipython:: python From 7243b7dceab162dad4df735d5591baeb73b50865 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Tue, 11 Apr 2023 15:09:44 -0600 Subject: [PATCH 2/2] Update doc/user-guide/indexing.rst --- doc/user-guide/indexing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user-guide/indexing.rst b/doc/user-guide/indexing.rst index 3d66816d02f..90b7cbaf2a9 100644 --- a/doc/user-guide/indexing.rst +++ b/doc/user-guide/indexing.rst @@ -398,7 +398,7 @@ These methods may also be applied to ``Dataset`` objects Vectorized indexing may be used to extract information from the nearest grid cells of interest, for example, the nearest climate model grid cells to a collection specified weather station latitudes and longitudes. -Note that to trigger vectorized indexing behavior (not orthogonal) +To trigger vectorized indexing behavior you will need to provide the selection dimensions with a new shared output dimension name. In the example below, the selections of the closest latitude and longitude are renamed to an output