LoslegenKostenlos loslegen

Exploratory data analysis with xarray

Xarray makes working with multi-dimensional data easier, just like pandas makes working with tabular data easier. Best of all, Xarray can use Dask in the background to help you process the data quickly and efficiently.

You have been tasked with analyzing the European weather dataset further. Now that you know how to use Xarray, you will start by doing some exploratory data analysis.

xarray has been imported for you as xr.

Diese Übung ist Teil des Kurses

Parallel Programming with Dask in Python

Kurs anzeigen

Anleitung zur Übung

  • Using Xarray's open_zarr() function, open the "data/era_eu.zarr" dataset.
  • Using the DataSet's .isel() method select the zeroth index on the time coordinate.
  • Select the 'temp' variable from the zeroth index ds_sel and plot it on ax1.
  • Select the 'precip' variable from the zeroth index ds_sel and plot it on ax2.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Open the ERA5 dataset
ds = ____.____("____")

# Select the zeroth time in the DataSet
ds_sel = ds.____(____=____)

fig, (ax1, ax2) = plt.subplots(1,2, figsize=(8, 3))

# Plot the zeroth temperature field on ax1
____[____].____(ax=____)

# Plot the zeroth precipitation field on ax2
____[____].____(ax=____)
plt.show()
Code bearbeiten und ausführen