Intermezzo: ERA5 and xarray

Intermezzo: ERA5 and xarray#

In this exercise we are going to start exploring ERA5 data using xarray, which we will both need again later in our term project. You can download a sample ERA5 file from here. To open the file with xarray, you need to install both xarray and netcdf4.

A) Open the file with xarray and explore the content of the Dataset (Hint: xarray.open_dataset]. Which variables does the file contain? What is the type of the whole Dataset and of an individual variable within the Dataset?

B) Global attributes are used to store general information about the dataset, i.e., so-called metadata. Look at the global attributes to find out which variable naming and metadata convention is used here?

C) One of the variables in the file is called z. What is it and what are its units? The information is stored together with the variable (as attributes). What are the dimensions of the variable?

D) Apply the isel method to extract the last time step and the sel method to extract the 500-hPa level to the whole dataset. What are the dimensions of this new dataset? Plot z using the plot method.

E) [Optional] Add wind arrows to the plot (variables u and v).

F) Calculate the wind speed from u and v and assign the result to a new variable. What is the type of this new variable? Add your new variable to the existing Dataset.