@@ -219,16 +219,16 @@ Let's see how :py:meth:`~xarray.DataArray.interp` works on real data.
219
219
.. ipython :: python
220
220
221
221
# Raw data
222
- ds = xr.tutorial.load_dataset(' air_temperature' )
222
+ ds = xr.tutorial.load_dataset(' air_temperature' ).isel( time = 0 )
223
223
fig, axes = plt.subplots(ncols = 2 , figsize = (10 , 4 ))
224
- ds.air.isel( time = 0 ). plot(ax = axes[0 ])
224
+ ds.air.plot(ax = axes[0 ])
225
225
axes[0 ].set_title(' Raw data' )
226
226
227
227
# Interpolated data
228
228
new_lon = np.linspace(ds.lon[0 ], ds.lon[- 1 ], ds.dims[' lon' ] * 4 )
229
229
new_lat = np.linspace(ds.lat[0 ], ds.lat[- 1 ], ds.dims[' lat' ] * 4 )
230
230
dsi = ds.interp(lat = new_lat, lon = new_lon)
231
- dsi.air.isel( time = 0 ). plot(ax = axes[1 ])
231
+ dsi.air.plot(ax = axes[1 ])
232
232
@savefig interpolation_sample3.png width =8in
233
233
axes[1 ].set_title(' Interpolated data' )
234
234
@@ -247,7 +247,7 @@ The remapping can be done as follows
247
247
dims = [' x' , ' z' ], coords = {' x' : x, ' z' : z})
248
248
249
249
fig, axes = plt.subplots(ncols = 2 , figsize = (10 , 4 ))
250
- ds.air.isel( time = 0 ). plot(ax = axes[0 ])
250
+ ds.air.plot(ax = axes[0 ])
251
251
# draw the new coordinate on the original coordinates.
252
252
for idx in [0 , 33 , 66 , 99 ]:
253
253
axes[0 ].plot(lon.isel(x = idx), lat, ' --k' )
@@ -256,6 +256,6 @@ The remapping can be done as follows
256
256
axes[0 ].set_title(' Raw data' )
257
257
258
258
dsi = ds.interp(lon = lon, lat = lat)
259
- dsi.air.isel( time = 0 ). plot(ax = axes[1 ])
259
+ dsi.air.plot(ax = axes[1 ])
260
260
@savefig interpolation_sample4.png width =8in
261
261
axes[1 ].set_title(' Remapped data' )
0 commit comments