Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Tutorial on total precipitation using CARRA and ERA5 data

logo

Tutorial on total precipitation using CARRA and ERA5 data

About

In this tutorial we will access data from the Climate Data Store (CDS) of the Copernicus Climate Change Service (C3S) and analyse total precipitation. The tutorial comprises the following steps:

  1. Download precipitation data for June 2023 for CARRA and ERA5

  2. Calculate total monthly precipitation accumulations

  3. Visualize the total CARRA monthly precipitation over the CARRA-West domain (around Greenland)

  4. Visualise the total ERA5 monthly precipitation in a region around the CARRA-West domain (around the Greenland region)

  5. Visualise the differences in monthly precipitation sums between ERA5 and CARRA over CARRA-West (around Greenland)

logo
To run the notebooks in the cloud environment click on the icons for "binder" or "kaggle" or "colab" in the menubar below.

Install CDS API

Before we begin we must prepare our environment. This includes installing the Application Programming Interface (API) of the CDS, and importing the various python libraries that we will need.

To install the CDS API, run the following command. We use an exclamation mark to pass the command to the shell (not to the Python interpreter).

Enter your CDS API key

We will request data from the Climate Data Store (CDS) programmatically with the help of the CDS API. Let us make use of the option to manually set the CDS API credentials. First, you have to define two variables: URL and KEY which build together your CDS API key. The string of characters that make up your KEY include your personal User ID and CDS API key. To obtain these, first register or login to the CDS (http://cds.climate.copernicus.eu), then visit https://cds.climate.copernicus.eu/api-how-to and copy the string of characters listed after “key:”. Replace the ######### below with this string.

Computation of daily accumulations

The computation of the daily accumulations of precipitation follows the guidelines provided in the CARRA user documentation. In this procedure, daily accumulations of total precipitation are computed first from 00 UTC - 00 UTC following example 2 in the documentation. We use the CDO package to carry out the computations.

We define first a helper function to download the data.

Also note that the values for precipitation can turn negative if you take the difference between different forecasts lengths. That’s a consequence of the grib encoding and details are explained here. These very small negative values can be ignored or they could be set to zero.

Using the function defined above

CARRA data will be fetched for the dates specified below. Note that the specific dates have been hardcoded for this specific case study. The data will be stored in the specified directory.

2024-08-23 07:51:01,704 INFO Welcome to the CDS.
 As per our announcements on the Forum, this instance of CDS will soon be decommissioned.
 Please update your cdsapi package to a version >=0.7.0, create an account on CDS-Beta and update your .cdsapirc file. We strongly recommend users to check our Guidelines at https://confluence.ecmwf.int/x/uINmFw
 The current legacy system will be kept for a while, but we will reduce resources gradually until full decommissioning in September 2024.
2024-08-23 07:51:01,705 WARNING MOVE TO CDS-Beta
2024-08-23 07:51:01,705 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-carra-single-levels
2024-08-23 07:51:01,822 INFO Request is completed
2024-08-23 07:51:01,823 INFO Downloading https://download-0000-clone.copernicus-climate.eu/cache-compute-0000/cache/data9/adaptor.mars.external-1724165418.4330251-22252-11-2eb645a8-a13c-4214-a3ee-f1c55dd11fc6.grib to CARRA/Precipitation_fc_2023053112.grb (7.8M)
Fetching the CARRA data...
2024-08-23 07:51:02,140 INFO Download rate 24.5M/s
2024-08-23 07:51:02,153 INFO Welcome to the CDS.
 As per our announcements on the Forum, this instance of CDS will soon be decommissioned.
 Please update your cdsapi package to a version >=0.7.0, create an account on CDS-Beta and update your .cdsapirc file. We strongly recommend users to check our Guidelines at https://confluence.ecmwf.int/x/uINmFw
 The current legacy system will be kept for a while, but we will reduce resources gradually until full decommissioning in September 2024.
2024-08-23 07:51:02,153 WARNING MOVE TO CDS-Beta
2024-08-23 07:51:02,154 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-carra-single-levels
2024-08-23 07:51:02,245 INFO Downloading https://download-0014-clone.copernicus-climate.eu/cache-compute-0014/cache/data6/adaptor.mars.external-1724165465.4064248-19963-8-267204f4-8121-46af-a170-fda3a6ba0ee2.grib to CARRA/Precipitation_fc_2023060112.grb (349.3M)
2024-08-23 07:51:06,467 INFO Download rate 82.7M/s 
2024-08-23 07:51:06,480 INFO Welcome to the CDS.
 As per our announcements on the Forum, this instance of CDS will soon be decommissioned.
 Please update your cdsapi package to a version >=0.7.0, create an account on CDS-Beta and update your .cdsapirc file. We strongly recommend users to check our Guidelines at https://confluence.ecmwf.int/x/uINmFw
 The current legacy system will be kept for a while, but we will reduce resources gradually until full decommissioning in September 2024.
2024-08-23 07:51:06,481 WARNING MOVE TO CDS-Beta
2024-08-23 07:51:06,481 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-carra-single-levels
2024-08-23 07:51:06,609 INFO Downloading https://download-0020.copernicus-climate.eu/cache-compute-0020/cache/data4/adaptor.mars.external-1724165666.7828567-14954-5-b4272b0a-16e2-4375-922a-2b2158ad9b5e.grib to CARRA/Precipitation_fc_2023060100.grb (232.9M)
2024-08-23 07:51:10,077 INFO Download rate 67.2M/s 

Now we downloaded the data for CARRA we can calculate daily accumulations using CDO

Note that the file names have been hardcoded below

'CARRA/Daily_accumulations/Precipitation_202306_daysum.grb'

Now we download ERA5 precipitation and compute daily accumulations

Note that the file names have been hardcoded below

2024-08-23 07:51:39,997 INFO Welcome to the CDS.
 As per our announcements on the Forum, this instance of CDS will soon be decommissioned.
 Please update your cdsapi package to a version >=0.7.0, create an account on CDS-Beta and update your .cdsapirc file. We strongly recommend users to check our Guidelines at https://confluence.ecmwf.int/x/uINmFw
 The current legacy system will be kept for a while, but we will reduce resources gradually until full decommissioning in September 2024.
2024-08-23 07:51:39,998 WARNING MOVE TO CDS-Beta
2024-08-23 07:51:39,998 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-era5-single-levels
2024-08-23 07:51:40,122 INFO Downloading https://download-0006-clone.copernicus-climate.eu/cache-compute-0006/cache/data8/adaptor.mars.internal-1724167728.6012428-27967-17-86ccf828-d503-42fc-8d88-b90c3168e637.grib to ERA5/ERA5_tp_202306_hourly.grb (108.7M)
2024-08-23 07:51:41,330 INFO Download rate 90M/s  
'ERA5/Daily_accumulations/ERA5_tp_202306_daysum.grb'

Now all the data is downloaded we start inspecting it by producing a simple plot of the CARRA precipitation.

<Figure size 640x480 with 2 Axes>

Now, we plot ERA5 precipitation with a somewhat more advanced plotting routine.

<Figure size 1600x800 with 2 Axes>

In order to enable a more detailed comparison between CARRA and ERA5, we interpolate ERA5 onto the CARRA grid again, using CDO.

Finally we plot the difference between ERA5 and CARRA

<Figure size 1600x800 with 2 Axes>