Skip to content

Commit 0163088

Browse files
authored
Merge pull request #323 from wmvanvliet/xarray1
Small improvement to xarray
2 parents 7e0a18a + de52cb6 commit 0163088

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

content/xarray.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ Xarray allows you to select data using the ``.sel()`` method, which uses the lab
160160

161161
>>> ds['Temperature_isobaric'].sel(x='-3292.0078')
162162

163+
By default, you need to enter the exact coordinate, but often we want to select the closest value to some number. For this, you can use ``method='nearest'``: ::
164+
165+
>>> ds['Temperature_isobaric'].sel(x='-3292', method='nearest')
166+
163167
Output: ::
164168

165169
<xarray.DataArray 'Temperature_isobaric' (time1: 1, isobaric1: 29, y: 119)> Size: 14kB
@@ -187,7 +191,7 @@ Output: ::
187191
Grib1_Level_Desc: Isobaric surface
188192

189193

190-
We can still access the same data by index using the ``.isel()`` method: ::
194+
We can also access the same data by index using the ``.isel()`` method: ::
191195

192196
>>> ds['Temperature_isobaric'].isel(x=1)
193197

0 commit comments

Comments
 (0)