From 0d9c484f645ff73981d8fb88b3e758b7e39524b0 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Wed, 26 Nov 2025 13:42:45 -0700 Subject: [PATCH 1/2] Advanced Indexing - Update Exercise solution The small exercise at the bottom of the page declared two DataArrays, but only used one. The solution was still correct but confusing, so I reduced the needed variable declaration to the required one and renamed. --- intermediate/indexing/advanced-indexing.ipynb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/intermediate/indexing/advanced-indexing.ipynb b/intermediate/indexing/advanced-indexing.ipynb index 9870db21..a97e36fc 100644 --- a/intermediate/indexing/advanced-indexing.ipynb +++ b/intermediate/indexing/advanced-indexing.ipynb @@ -374,10 +374,9 @@ "\n", "indices = np.array([0, 2, 4])\n", "\n", - "xs_da = xr.DataArray(indices, dims=\"points\")\n", - "ys_da = xr.DataArray(indices, dims=\"points\")\n", + "index_da = xr.DataArray(indices, dims=\"points\")\n", "\n", - "subset_da = da.sel(x=xs_da, y=xs_da)\n", + "subset_da = da.sel(x=index_da, y=index_da)\n", "subset_da\n", "```\n", ":::\n", From b38cf8f14dc0bcb0b539dd4bb84bae77c70e9817 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Wed, 26 Nov 2025 14:13:15 -0700 Subject: [PATCH 2/2] Advanced Indexing - Update exercise Vary the showcase x and y coords as suggested by @ianhi --- intermediate/indexing/advanced-indexing.ipynb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/intermediate/indexing/advanced-indexing.ipynb b/intermediate/indexing/advanced-indexing.ipynb index a97e36fc..c4118d50 100644 --- a/intermediate/indexing/advanced-indexing.ipynb +++ b/intermediate/indexing/advanced-indexing.ipynb @@ -366,17 +366,19 @@ "::::{admonition} Exercise\n", ":class: tip\n", "\n", - "In the simple 2D 5x5 Xarray data array above, select the sub-array containing (0,0),(2,2),(4,4):\n", + "In the simple 2D 5x5 Xarray data array above, select the sub-array containing (0,4),(2,2),(4,0):\n", "\n", ":::{admonition} Solution\n", ":class: dropdown\n", "```python\n", "\n", - "indices = np.array([0, 2, 4])\n", + "x_indices = np.array([0, 2, 4])\n", + "y_indices = np.array([4, 2, 0])\n", "\n", - "index_da = xr.DataArray(indices, dims=\"points\")\n", + "da_x = xr.DataArray(x_indices, dims=\"points\")\n", + "da_y = xr.DataArray(y_indices, dims=\"points\")\n", "\n", - "subset_da = da.sel(x=index_da, y=index_da)\n", + "subset_da = da.sel(x=da_x, y=da_y)\n", "subset_da\n", "```\n", ":::\n",