/ERCA

Primary LanguageJupyter Notebook

ERCA

http://erca-school.eu/

Binder

We will download the Copernicus ERA5 reanalysis data from the European Centre for Medium-Range Weather Forecasts (ECMWF) and analyze the Earth's near-surface temperature from 1979 to the present. For this we will use several classic Python packages:

  • xarray: is an open-source project and Python package that makes working with labelled multi-dimensional arrays simple, efficient, and fun! (Xarray Tutorial / Xarray | SciPy 2020)
  • dask: provides advanced parallelism for analytics (jacobtomlinson/dask-video-tutorial-2020 / Dask | SciPy 2020)
  • jupyter: for using jupyter-notebook / lab
  • matplotlib: back-end for making plots
  • cartopy: replace basemap, back-end for map projections
  • proplot: a lightweight matplotlib wrapper for making beautiful, publication-quality graphics (still in development)
  • xesmf: Universal Regridder for Geospatial Data (only for Linux and Mac, an alternative is the interp function from xarray)
  • intake-esm: an intake plugin for parsing an Earth System Model (ESM) catalog and loading assets into xarray datasets

Check the Environment section at the end of this README if you want to know more about the environment and/or to install it on your local machine.

1. Getting started with xarray

Before we start and get to the heart of the matter, we will begin with a simple example notebook to get to know xarray. Click on the Binder button to start a session (or launch it on your personal machine if you installed the environment), then open the notebook: 01_xarray_get_started.ipynb.

  • Load an example dataset
  • Plot with xarray
  • Select data / Make mask
  • Resample / Groupby
  • Computation (climatology, seasons, etc.)
  • Weighted average
  • Make projected plots (cartopy / proplot)
  • Check versions

2. Exploring ERA5 data

Now that we've got the hang of xarray, let's apply it to real data! Open the notebook 02_ERA5.ipynb and follow the instructions.

  • Download ERA5 / Read file
  • Check size / Make chunks
  • Compute and plot climatology
  • Seasonal and regional plots
  • Compute trends

3. ERA5 comparison with CMIP6 models

In this part, we will compare ERA5 to CMIP6 model outputs: 03_intake_CMIP6.ipynb

  • Get CMIP6 model with intake-esm
  • Visualize data
  • Compare to ERA5 (regrid)
  • Plot global bias
  • Plot time series with projections

3 bis. Data analysis with pandas

Our objective here is to introduce you to pandas as this library has become the python workhorse for analysing any dataset that most chemists (or biologists) would naturally handle in excel: 03bis_pandas_for_beginners.ipynb

4. Show Dask parallel (optional, if time)

Environment

Note that we will be working with an already pre-installed environment with binder. If you want to install the same environment on your machine, you can do it directly by typing the command conda env create -f environment.yml using the environment file environment.yml from this repository (only functional under Linux, otherwise you can remove the xesmf package from the file for Windows). You need to have Anaconda or Minconda already pre-installed on your machine. If not, for Linux users, you can check this (steps 2, 3, and 4; the rest is to install it on a server — to adapt for non-Linux machines): https://mickaellalande.github.io/post/tutorial/how-to-install-jupyter-notebook-on-a-server/. For managing your conda environments always come back to the official documentation: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file.

The package versions can be found in the environment.yml file. Be careful if you want to upgrade this environment, because there are often conflicts between some packages (e.g., version 0.6.4 of proplot does not work with version 3.3 of matplotlib, or cartopy does not work with the latest version 3.9 of python... but this can have already evolved at the time of this session). Be particularly careful with Proplot which is a package under development and which evolves very quickly, including changes of syntax, thus refer to version 0.6.4 for these practical works: https://proplot.readthedocs.io/en/v0.6.4/.

Some issues related with this environment: