Download various datasets (ERA 5, CMIP5, etc) from CDS

Download_ERA5_data

This post aims to shed light on how to download on python environment various climatic datasets from the Climate Data Store (CDS). This includes ERA5, CMIP5, CRU+GPCC bias corrected data and others.

Installation of CDS API

In [1]:
#pip install cdsapi

The following packages are needed for running the next instructions.

In [2]:
import cdsapi
import xarray as xr
import pandas as pd
import numpy as np
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.geoaxes import GeoAxes
from mpl_toolkits.axes_grid1 import AxesGrid
import matplotlib.pyplot as plt
import seaborn as sns
import tarfile

%matplotlib inline

Download monthly average temperature 1979-2020 from ERA5

ERA 5 is the recent climate reanalysis produced by ECMWF, providing hourly data on many atmospheric, land-surface and sea-state parameters together with estimates of uncertainty. ERA5 combines vast amounts of historical observations into global estimates using advanced modelling and data assimilation systems. It provides various weather parmeters from 1979 to present. ERA 5 is widely used as alternative in areas with low or limited number of weather observations. More information can be found from: https://climate.copernicus.eu/climate-reanalysis

In this example, the datasets will be downloaded over West-Africa (20W, 20E,0,25N) from 1979-2020. Depending of the internet connection the operation below can take some few minutes.

The request code below to download the ERA5 data is automatically generated from CDS website based on the datasets choosed, variables, spatial and temporal scale. Registration to access freely the data is required (https://cds.climate.copernicus.eu/user/register).

In [3]:
import cdsapi
c = cdsapi.Client()

c.retrieve(
    'reanalysis-era5-single-levels-monthly-means',
    {
        'format': 'netcdf',
        'product_type': 'monthly_averaged_reanalysis',
        'variable': '2m_temperature',
        'year': [
            '1979', '1980', '1981',
            '1982', '1983', '1984',
            '1985', '1986', '1987',
            '1988', '1989', '1990',
            '1991', '1992', '1993',
            '1994', '1995', '1996',
            '1997', '1998', '1999',
            '2000', '2001', '2002',
            '2003', '2004', '2005',
            '2006', '2007', '2008',
            '2009', '2010', '2011',
            '2012', '2013', '2014',
            '2015', '2016', '2017',
            '2018', '2019', '2020',
        ],
        'month': [
            '01', '02', '03',
            '04', '05', '06',
            '07', '08', '09',
            '10', '11', '12',
        ],
        'time': '00:00',
        'area': [
            25, -20, 0,
            25,
        ],
    },
    'Monthly_averaged_temp_ERA5_1979_2020.nc')
Out[3]:
Result(content_length=36493168,content_type=application/x-netcdf,location=http://136.156.133.42/cache-compute-0014/cache/data4/adaptor.mars.internal-1597353912.6649415-23497-3-fd4a8415-7a9a-426f-ac7b-95dc6a71688f.nc)

Download CMIP5 monthly outputs precipitation flux

In [5]:
import cdsapi

c = cdsapi.Client()

c.retrieve(
    'projections-cmip5-monthly-single-levels',
    {
        'experiment': 'historical',
        'variable': 'mean_precipitation_flux',
        'model': 'gfdl_cm2p1',
        'ensemble_member': 'r10i1p1',
        'period': '199601-200012',
        'format': 'tgz',
    },
    'preflux_cmip5_gfdl_cm2p1_1996_2000.tar.gz')
tf = tarfile.open("preflux_cmip5_gfdl_cm2p1_1996_2000.tar.gz")
tf.extractall()

Hourly rainfall flux from Near surface meteorological variables from 1979 to 2018 derived from bias-corrected reanalysis datasets

In [6]:
import cdsapi
c = cdsapi.Client()

c.retrieve(
    'derived-near-surface-meteorological-variables',
    {
        'variable': 'rainfall_flux',
        'reference_dataset': 'cru_and_gpcc',
        'year': '2016',
        'month': '08',
        'format': 'tgz',
    },
    'hourly_rainfall_flux_cru_gpcc_2016_08.tar.gz')
tf = tarfile.open("hourly_rainfall_flux_cru_gpcc_2016_08.tar.gz")
tf.extractall()

Import datasets

In [5]:
# import datasets
df_temp= xr.open_dataset('Monthly_averaged_temp_ERA5_1979_2020.nc')
df_prcp= xr.open_dataset('pr_Amon_GFDL-CM2p1_historical_r10i1p1_199601-200012.nc')
In [6]:
df_temp
Out[6]:
Show/Hide data repr Show/Hide attributes
xarray.Dataset
    • expver: 2
    • latitude: 101
    • longitude: 181
    • time: 499
    • longitude
      (longitude)
      float32
      -20.0 -19.75 -19.5 ... 24.75 25.0
      units :
      degrees_east
      long_name :
      longitude
      array([-20.  , -19.75, -19.5 , -19.25, -19.  , -18.75, -18.5 , -18.25, -18.  ,
             -17.75, -17.5 , -17.25, -17.  , -16.75, -16.5 , -16.25, -16.  , -15.75,
             -15.5 , -15.25, -15.  , -14.75, -14.5 , -14.25, -14.  , -13.75, -13.5 ,
             -13.25, -13.  , -12.75, -12.5 , -12.25, -12.  , -11.75, -11.5 , -11.25,
             -11.  , -10.75, -10.5 , -10.25, -10.  ,  -9.75,  -9.5 ,  -9.25,  -9.  ,
              -8.75,  -8.5 ,  -8.25,  -8.  ,  -7.75,  -7.5 ,  -7.25,  -7.  ,  -6.75,
              -6.5 ,  -6.25,  -6.  ,  -5.75,  -5.5 ,  -5.25,  -5.  ,  -4.75,  -4.5 ,
              -4.25,  -4.  ,  -3.75,  -3.5 ,  -3.25,  -3.  ,  -2.75,  -2.5 ,  -2.25,
              -2.  ,  -1.75,  -1.5 ,  -1.25,  -1.  ,  -0.75,  -0.5 ,  -0.25,   0.  ,
               0.25,   0.5 ,   0.75,   1.  ,   1.25,   1.5 ,   1.75,   2.  ,   2.25,
               2.5 ,   2.75,   3.  ,   3.25,   3.5 ,   3.75,   4.  ,   4.25,   4.5 ,
               4.75,   5.  ,   5.25,   5.5 ,   5.75,   6.  ,   6.25,   6.5 ,   6.75,
               7.  ,   7.25,   7.5 ,   7.75,   8.  ,   8.25,   8.5 ,   8.75,   9.  ,
               9.25,   9.5 ,   9.75,  10.  ,  10.25,  10.5 ,  10.75,  11.  ,  11.25,
              11.5 ,  11.75,  12.  ,  12.25,  12.5 ,  12.75,  13.  ,  13.25,  13.5 ,
              13.75,  14.  ,  14.25,  14.5 ,  14.75,  15.  ,  15.25,  15.5 ,  15.75,
              16.  ,  16.25,  16.5 ,  16.75,  17.  ,  17.25,  17.5 ,  17.75,  18.  ,
              18.25,  18.5 ,  18.75,  19.  ,  19.25,  19.5 ,  19.75,  20.  ,  20.25,
              20.5 ,  20.75,  21.  ,  21.25,  21.5 ,  21.75,  22.  ,  22.25,  22.5 ,
              22.75,  23.  ,  23.25,  23.5 ,  23.75,  24.  ,  24.25,  24.5 ,  24.75,
              25.  ], dtype=float32)
    • latitude
      (latitude)
      float32
      25.0 24.75 24.5 ... 0.5 0.25 0.0
      units :
      degrees_north
      long_name :
      latitude
      array([25.  , 24.75, 24.5 , 24.25, 24.  , 23.75, 23.5 , 23.25, 23.  , 22.75,
             22.5 , 22.25, 22.  , 21.75, 21.5 , 21.25, 21.  , 20.75, 20.5 , 20.25,
             20.  , 19.75, 19.5 , 19.25, 19.  , 18.75, 18.5 , 18.25, 18.  , 17.75,
             17.5 , 17.25, 17.  , 16.75, 16.5 , 16.25, 16.  , 15.75, 15.5 , 15.25,
             15.  , 14.75, 14.5 , 14.25, 14.  , 13.75, 13.5 , 13.25, 13.  , 12.75,
             12.5 , 12.25, 12.  , 11.75, 11.5 , 11.25, 11.  , 10.75, 10.5 , 10.25,
             10.  ,  9.75,  9.5 ,  9.25,  9.  ,  8.75,  8.5 ,  8.25,  8.  ,  7.75,
              7.5 ,  7.25,  7.  ,  6.75,  6.5 ,  6.25,  6.  ,  5.75,  5.5 ,  5.25,
              5.  ,  4.75,  4.5 ,  4.25,  4.  ,  3.75,  3.5 ,  3.25,  3.  ,  2.75,
              2.5 ,  2.25,  2.  ,  1.75,  1.5 ,  1.25,  1.  ,  0.75,  0.5 ,  0.25,
              0.  ], dtype=float32)
    • expver
      (expver)
      int32
      1 5
      long_name :
      expver
      array([1, 5])
    • time
      (time)
      datetime64[ns]
      1979-01-01 ... 2020-07-01
      long_name :
      time
      array(['1979-01-01T00:00:00.000000000', '1979-02-01T00:00:00.000000000',
             '1979-03-01T00:00:00.000000000', ..., '2020-05-01T00:00:00.000000000',
             '2020-06-01T00:00:00.000000000', '2020-07-01T00:00:00.000000000'],
            dtype='datetime64[ns]')
    • t2m
      (time, expver, latitude, longitude)
      float32
      ...
      units :
      K
      long_name :
      2 metre temperature
      [18244438 values with dtype=float32]
  • Conventions :
    CF-1.6
    history :
    2020-08-13 21:27:57 GMT by grib_to_netcdf-2.16.0: /opt/ecmwf/eccodes/bin/grib_to_netcdf -S param -o /cache/data4/adaptor.mars.internal-1597353912.6649415-23497-3-fd4a8415-7a9a-426f-ac7b-95dc6a71688f.nc /cache/tmp/fd4a8415-7a9a-426f-ac7b-95dc6a71688f-adaptor.mars.internal-1597353912.6655145-23497-2-tmp.grib
In [7]:
df_prcp.pr
Out[7]:
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'pr'
  • time: 60
  • lat: 90
  • lon: 144
  • ...
    [777600 values with dtype=float32]
    • lat
      (lat)
      float64
      -89.49 -87.98 ... 87.98 89.49
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      axis :
      Y
      bounds :
      lat_bnds
      array([-89.494382, -87.977528, -85.955056, -83.932584, -81.910112, -79.88764 ,
             -77.865169, -75.842697, -73.820225, -71.797753, -69.775281, -67.752809,
             -65.730337, -63.707865, -61.685393, -59.662921, -57.640449, -55.617978,
             -53.595506, -51.573034, -49.550562, -47.52809 , -45.505618, -43.483146,
             -41.460674, -39.438202, -37.41573 , -35.393258, -33.370787, -31.348315,
             -29.325843, -27.303371, -25.280899, -23.258427, -21.235955, -19.213483,
             -17.191011, -15.168539, -13.146067, -11.123596,  -9.101124,  -7.078652,
              -5.05618 ,  -3.033708,  -1.011236,   1.011236,   3.033708,   5.05618 ,
               7.078652,   9.101124,  11.123596,  13.146067,  15.168539,  17.191011,
              19.213483,  21.235955,  23.258427,  25.280899,  27.303371,  29.325843,
              31.348315,  33.370787,  35.393258,  37.41573 ,  39.438202,  41.460674,
              43.483146,  45.505618,  47.52809 ,  49.550562,  51.573034,  53.595506,
              55.617978,  57.640449,  59.662921,  61.685393,  63.707865,  65.730337,
              67.752809,  69.775281,  71.797753,  73.820225,  75.842697,  77.865169,
              79.88764 ,  81.910112,  83.932584,  85.955056,  87.977528,  89.494382])
    • lon
      (lon)
      float64
      1.25 3.75 6.25 ... 356.2 358.8
      long_name :
      longitude
      units :
      degrees_east
      standard_name :
      longitude
      axis :
      X
      bounds :
      lon_bnds
      array([  1.25,   3.75,   6.25,   8.75,  11.25,  13.75,  16.25,  18.75,  21.25,
              23.75,  26.25,  28.75,  31.25,  33.75,  36.25,  38.75,  41.25,  43.75,
              46.25,  48.75,  51.25,  53.75,  56.25,  58.75,  61.25,  63.75,  66.25,
              68.75,  71.25,  73.75,  76.25,  78.75,  81.25,  83.75,  86.25,  88.75,
              91.25,  93.75,  96.25,  98.75, 101.25, 103.75, 106.25, 108.75, 111.25,
             113.75, 116.25, 118.75, 121.25, 123.75, 126.25, 128.75, 131.25, 133.75,
             136.25, 138.75, 141.25, 143.75, 146.25, 148.75, 151.25, 153.75, 156.25,
             158.75, 161.25, 163.75, 166.25, 168.75, 171.25, 173.75, 176.25, 178.75,
             181.25, 183.75, 186.25, 188.75, 191.25, 193.75, 196.25, 198.75, 201.25,
             203.75, 206.25, 208.75, 211.25, 213.75, 216.25, 218.75, 221.25, 223.75,
             226.25, 228.75, 231.25, 233.75, 236.25, 238.75, 241.25, 243.75, 246.25,
             248.75, 251.25, 253.75, 256.25, 258.75, 261.25, 263.75, 266.25, 268.75,
             271.25, 273.75, 276.25, 278.75, 281.25, 283.75, 286.25, 288.75, 291.25,
             293.75, 296.25, 298.75, 301.25, 303.75, 306.25, 308.75, 311.25, 313.75,
             316.25, 318.75, 321.25, 323.75, 326.25, 328.75, 331.25, 333.75, 336.25,
             338.75, 341.25, 343.75, 346.25, 348.75, 351.25, 353.75, 356.25, 358.75])
    • time
      (time)
      object
      1996-01-16 12:00:00 ... 2000-12-16 12:00:00
      long_name :
      time
      cartesian_axis :
      T
      calendar_type :
      julian
      bounds :
      time_bnds
      standard_name :
      time
      axis :
      T
      array([cftime.DatetimeJulian(1996-01-16 12:00:00),
             cftime.DatetimeJulian(1996-02-15 12:00:00),
             cftime.DatetimeJulian(1996-03-16 12:00:00),
             cftime.DatetimeJulian(1996-04-16 00:00:00),
             cftime.DatetimeJulian(1996-05-16 12:00:00),
             cftime.DatetimeJulian(1996-06-16 00:00:00),
             cftime.DatetimeJulian(1996-07-16 12:00:00),
             cftime.DatetimeJulian(1996-08-16 12:00:00),
             cftime.DatetimeJulian(1996-09-16 00:00:00),
             cftime.DatetimeJulian(1996-10-16 12:00:00),
             cftime.DatetimeJulian(1996-11-16 00:00:00),
             cftime.DatetimeJulian(1996-12-16 12:00:00),
             cftime.DatetimeJulian(1997-01-16 12:00:00),
             cftime.DatetimeJulian(1997-02-15 00:00:00),
             cftime.DatetimeJulian(1997-03-16 12:00:00),
             cftime.DatetimeJulian(1997-04-16 00:00:00),
             cftime.DatetimeJulian(1997-05-16 12:00:00),
             cftime.DatetimeJulian(1997-06-16 00:00:00),
             cftime.DatetimeJulian(1997-07-16 12:00:00),
             cftime.DatetimeJulian(1997-08-16 12:00:00),
             cftime.DatetimeJulian(1997-09-16 00:00:00),
             cftime.DatetimeJulian(1997-10-16 12:00:00),
             cftime.DatetimeJulian(1997-11-16 00:00:00),
             cftime.DatetimeJulian(1997-12-16 12:00:00),
             cftime.DatetimeJulian(1998-01-16 12:00:00),
             cftime.DatetimeJulian(1998-02-15 00:00:00),
             cftime.DatetimeJulian(1998-03-16 12:00:00),
             cftime.DatetimeJulian(1998-04-16 00:00:00),
             cftime.DatetimeJulian(1998-05-16 12:00:00),
             cftime.DatetimeJulian(1998-06-16 00:00:00),
             cftime.DatetimeJulian(1998-07-16 12:00:00),
             cftime.DatetimeJulian(1998-08-16 12:00:00),
             cftime.DatetimeJulian(1998-09-16 00:00:00),
             cftime.DatetimeJulian(1998-10-16 12:00:00),
             cftime.DatetimeJulian(1998-11-16 00:00:00),
             cftime.DatetimeJulian(1998-12-16 12:00:00),
             cftime.DatetimeJulian(1999-01-16 12:00:00),
             cftime.DatetimeJulian(1999-02-15 00:00:00),
             cftime.DatetimeJulian(1999-03-16 12:00:00),
             cftime.DatetimeJulian(1999-04-16 00:00:00),
             cftime.DatetimeJulian(1999-05-16 12:00:00),
             cftime.DatetimeJulian(1999-06-16 00:00:00),
             cftime.DatetimeJulian(1999-07-16 12:00:00),
             cftime.DatetimeJulian(1999-08-16 12:00:00),
             cftime.DatetimeJulian(1999-09-16 00:00:00),
             cftime.DatetimeJulian(1999-10-16 12:00:00),
             cftime.DatetimeJulian(1999-11-16 00:00:00),
             cftime.DatetimeJulian(1999-12-16 12:00:00),
             cftime.DatetimeJulian(2000-01-16 12:00:00),
             cftime.DatetimeJulian(2000-02-15 12:00:00),
             cftime.DatetimeJulian(2000-03-16 12:00:00),
             cftime.DatetimeJulian(2000-04-16 00:00:00),
             cftime.DatetimeJulian(2000-05-16 12:00:00),
             cftime.DatetimeJulian(2000-06-16 00:00:00),
             cftime.DatetimeJulian(2000-07-16 12:00:00),
             cftime.DatetimeJulian(2000-08-16 12:00:00),
             cftime.DatetimeJulian(2000-09-16 00:00:00),
             cftime.DatetimeJulian(2000-10-16 12:00:00),
             cftime.DatetimeJulian(2000-11-16 00:00:00),
             cftime.DatetimeJulian(2000-12-16 12:00:00)], dtype=object)
  • long_name :
    Precipitation
    units :
    kg m-2 s-1
    cell_methods :
    time: mean
    interp_method :
    conserve_order1
    standard_name :
    precipitation_flux
    original_units :
    kg/m2/s
    original_name :
    precip
    cell_measures :
    area: areacella
    associated_files :
    baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation areacella: areacella_fx_GFDL-CM2p1_historical_r0i0p0.nc
In [8]:
# Converts Temperature data into Degree celsius
# Converts Convect
df_temp_deg=df_temp.t2m-273.15
df_temp_deg.attrs = df_temp.t2m.attrs
df_temp_deg["units"] = "deg C"
df_temp_deg

# Converts Precipitation flux data into mm/month
df_pre=df_prcp.pr*86400*30

Monthly variation

In [9]:
#Monthly mean
monmean_temp=df_temp_deg.groupby('time.month').mean().mean('expver')
monmean_prcp=df_pre.groupby('time.month').mean()
In [10]:
monmean_temp
Out[10]:
Show/Hide data repr Show/Hide attributes
xarray.DataArray
't2m'
  • month: 12
  • latitude: 101
  • longitude: 181
  • 19.459515 19.402676 19.349266 ... 24.146114 24.143108 24.182295
    array([[[19.459515, 19.402676, 19.349266, ..., 12.472196, 12.406059,
             12.195735],
            [19.476082, 19.425175, 19.36608 , ..., 12.557512, 12.533112,
             12.322335],
            [19.491032, 19.438953, 19.378153, ..., 12.667668, 12.64963 ,
             12.367939],
            ...,
            [25.669855, 25.668772, 25.681147, ..., 25.35469 , 25.089317,
             25.151743],
            [25.661617, 25.663542, 25.672226, ..., 25.063383, 24.904612,
             24.926668],
            [25.652592, 25.65918 , 25.661093, ..., 24.84355 , 24.806673,
             24.813072]],
    
           [[19.041773, 18.986746, 18.937069, ..., 14.832914, 14.741072,
             14.502769],
            [19.055363, 19.004635, 18.95459 , ..., 14.945574, 14.882777,
             14.643938],
            [19.074734, 19.02246 , 18.970638, ..., 15.086884, 15.029762,
             14.714428],
            ...,
            [26.06387 , 26.061497, 26.071434, ..., 25.890602, 25.643822,
             25.722967],
            [26.063137, 26.065569, 26.071701, ..., 25.610567, 25.467619,
             25.482567],
            [26.062532, 26.06951 , 26.07139 , ..., 25.400475, 25.379173,
             25.35477 ]],
    
           [[19.132423, 19.090738, 19.051548, ..., 19.325277, 19.163895,
             18.83218 ],
            [19.159231, 19.120358, 19.082499, ..., 19.490042, 19.365427,
             19.032986],
            [19.18339 , 19.14299 , 19.10802 , ..., 19.719084, 19.59824 ,
             19.165232],
            ...,
            [26.4108  , 26.411665, 26.421087, ..., 25.614952, 25.364645,
             25.437782],
            [26.413252, 26.418535, 26.42234 , ..., 25.34583 , 25.188156,
             25.200445],
            [26.413069, 26.421715, 26.4231  , ..., 25.171503, 25.130215,
             25.112055]],
    
           ...,
    
           [[23.346653, 23.298193, 23.244207, ..., 24.039116, 23.827065,
             23.422663],
            [23.350233, 23.296486, 23.246052, ..., 24.163004, 23.955858,
             23.550438],
            [23.350525, 23.293549, 23.248718, ..., 24.414051, 24.203   ,
             23.5614  ],
            ...,
            [25.278856, 25.255222, 25.24053 , ..., 24.246641, 23.993631,
             24.060722],
            [25.221806, 25.201332, 25.182632, ..., 23.992266, 23.834198,
             23.849821],
            [25.167755, 25.15064 , 25.132133, ..., 23.840273, 23.794193,
             23.798567]],
    
           [[22.103554, 22.053696, 22.00463 , ..., 18.229355, 18.132904,
             17.819672],
            [22.119658, 22.078438, 22.03133 , ..., 18.353975, 18.271889,
             17.958178],
            [22.142084, 22.100183, 22.05672 , ..., 18.519663, 18.440529,
             18.008188],
            ...,
            [25.498981, 25.471275, 25.451841, ..., 24.164244, 23.94415 ,
             24.011208],
            [25.46201 , 25.438732, 25.4148  , ..., 23.931093, 23.812767,
             23.83459 ],
            [25.43031 , 25.412169, 25.38677 , ..., 23.799809, 23.776972,
             23.795095]],
    
           [[20.670494, 20.615007, 20.56244 , ..., 13.576151, 13.536121,
             13.311953],
            [20.690548, 20.643211, 20.585676, ..., 13.687827, 13.690589,
             13.465993],
            [20.712288, 20.664698, 20.60644 , ..., 13.816371, 13.825675,
             13.540453],
            ...,
            [25.439802, 25.418617, 25.409447, ..., 24.597958, 24.400179,
             24.485268],
            [25.414398, 25.398003, 25.384586, ..., 24.326359, 24.229868,
             24.277784],
            [25.390995, 25.380154, 25.361595, ..., 24.146114, 24.143108,
             24.182295]]], dtype=float32)
    • longitude
      (longitude)
      float32
      -20.0 -19.75 -19.5 ... 24.75 25.0
      units :
      degrees_east
      long_name :
      longitude
      array([-20.  , -19.75, -19.5 , -19.25, -19.  , -18.75, -18.5 , -18.25, -18.  ,
             -17.75, -17.5 , -17.25, -17.  , -16.75, -16.5 , -16.25, -16.  , -15.75,
             -15.5 , -15.25, -15.  , -14.75, -14.5 , -14.25, -14.  , -13.75, -13.5 ,
             -13.25, -13.  , -12.75, -12.5 , -12.25, -12.  , -11.75, -11.5 , -11.25,
             -11.  , -10.75, -10.5 , -10.25, -10.  ,  -9.75,  -9.5 ,  -9.25,  -9.  ,
              -8.75,  -8.5 ,  -8.25,  -8.  ,  -7.75,  -7.5 ,  -7.25,  -7.  ,  -6.75,
              -6.5 ,  -6.25,  -6.  ,  -5.75,  -5.5 ,  -5.25,  -5.  ,  -4.75,  -4.5 ,
              -4.25,  -4.  ,  -3.75,  -3.5 ,  -3.25,  -3.  ,  -2.75,  -2.5 ,  -2.25,
              -2.  ,  -1.75,  -1.5 ,  -1.25,  -1.  ,  -0.75,  -0.5 ,  -0.25,   0.  ,
               0.25,   0.5 ,   0.75,   1.  ,   1.25,   1.5 ,   1.75,   2.  ,   2.25,
               2.5 ,   2.75,   3.  ,   3.25,   3.5 ,   3.75,   4.  ,   4.25,   4.5 ,
               4.75,   5.  ,   5.25,   5.5 ,   5.75,   6.  ,   6.25,   6.5 ,   6.75,
               7.  ,   7.25,   7.5 ,   7.75,   8.  ,   8.25,   8.5 ,   8.75,   9.  ,
               9.25,   9.5 ,   9.75,  10.  ,  10.25,  10.5 ,  10.75,  11.  ,  11.25,
              11.5 ,  11.75,  12.  ,  12.25,  12.5 ,  12.75,  13.  ,  13.25,  13.5 ,
              13.75,  14.  ,  14.25,  14.5 ,  14.75,  15.  ,  15.25,  15.5 ,  15.75,
              16.  ,  16.25,  16.5 ,  16.75,  17.  ,  17.25,  17.5 ,  17.75,  18.  ,
              18.25,  18.5 ,  18.75,  19.  ,  19.25,  19.5 ,  19.75,  20.  ,  20.25,
              20.5 ,  20.75,  21.  ,  21.25,  21.5 ,  21.75,  22.  ,  22.25,  22.5 ,
              22.75,  23.  ,  23.25,  23.5 ,  23.75,  24.  ,  24.25,  24.5 ,  24.75,
              25.  ], dtype=float32)
    • latitude
      (latitude)
      float32
      25.0 24.75 24.5 ... 0.5 0.25 0.0
      units :
      degrees_north
      long_name :
      latitude
      array([25.  , 24.75, 24.5 , 24.25, 24.  , 23.75, 23.5 , 23.25, 23.  , 22.75,
             22.5 , 22.25, 22.  , 21.75, 21.5 , 21.25, 21.  , 20.75, 20.5 , 20.25,
             20.  , 19.75, 19.5 , 19.25, 19.  , 18.75, 18.5 , 18.25, 18.  , 17.75,
             17.5 , 17.25, 17.  , 16.75, 16.5 , 16.25, 16.  , 15.75, 15.5 , 15.25,
             15.  , 14.75, 14.5 , 14.25, 14.  , 13.75, 13.5 , 13.25, 13.  , 12.75,
             12.5 , 12.25, 12.  , 11.75, 11.5 , 11.25, 11.  , 10.75, 10.5 , 10.25,
             10.  ,  9.75,  9.5 ,  9.25,  9.  ,  8.75,  8.5 ,  8.25,  8.  ,  7.75,
              7.5 ,  7.25,  7.  ,  6.75,  6.5 ,  6.25,  6.  ,  5.75,  5.5 ,  5.25,
              5.  ,  4.75,  4.5 ,  4.25,  4.  ,  3.75,  3.5 ,  3.25,  3.  ,  2.75,
              2.5 ,  2.25,  2.  ,  1.75,  1.5 ,  1.25,  1.  ,  0.75,  0.5 ,  0.25,
              0.  ], dtype=float32)
    • units
      ()
      <U5
      'deg C'
      array('deg C', dtype='<U5')
    • month
      (month)
      int64
      1 2 3 4 5 6 7 8 9 10 11 12
      array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12], dtype=int64)
In [11]:
monmean_prcp
Out[11]:
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'pr'
  • month: 12
  • lat: 90
  • lon: 144
  • 8.356 8.352 8.352 8.353 8.353 8.353 ... 11.14 11.12 11.13 11.14 11.14
    array([[[ 8.3555083 ,  8.3522111 ,  8.35187187, ...,  8.35300402,
              8.35197289,  8.34925409],
            [10.08693443,  9.75632462,  9.61691999, ..., 10.54878859,
             10.38827571, 10.30024718],
            [14.74496684, 14.16918742, 13.35303501, ..., 16.62172909,
             15.82603653, 15.32422309],
            ...,
            [14.42240145, 14.39256442, 14.51423119, ..., 14.21431403,
             14.44626929, 14.71282449],
            [10.40745937, 10.46381774, 10.41015412, ..., 10.58237355,
             10.53274889, 10.63470181],
            [ 7.92854364,  7.92791503,  7.92037433, ...,  7.92848028,
              7.92903545,  7.92859403]],
    
           [[ 3.77032293,  3.77061336,  3.76830581, ...,  3.76700317,
              3.76711956,  3.76929009],
            [ 6.04133388,  5.91978887,  5.83608471, ...,  6.41085069,
              6.28089064,  6.16242125],
            [ 9.9408423 ,  9.32402367,  8.77163176, ..., 11.94359351,
             11.21493167, 10.57109971],
            ...,
            [11.15544808, 10.49963352, 10.03762955, ..., 13.44708884,
             12.70676925, 12.28412484],
            [ 8.09135317,  7.95730198,  7.73507469, ...,  9.24145054,
              8.84333074,  8.67831202],
            [ 6.05533265,  6.0554484 ,  6.05668963, ...,  6.05633137,
              6.05537066,  6.05537638]],
    
           [[ 7.44299792,  7.44325895,  7.4435749 , ...,  7.44161825,
              7.44180991,  7.44253357],
            [ 8.17064396,  8.05624208,  7.96992904, ...,  8.52831018,
              8.41311574,  8.29902162],
            [10.65136876, 10.16542641,  9.75303291, ..., 12.66128803,
             11.95735277, 11.28054712],
            ...,
            [15.14533431, 15.79922346, 16.5145802 , ..., 13.08463171,
             13.85882929, 14.81996867],
            [12.49075321, 12.671756  , 12.92021395, ..., 11.9455903 ,
             12.13723102, 12.38191034],
            [ 8.62353052,  8.62338908,  8.62046306, ...,  8.62101399,
              8.623378  ,  8.62348962]],
    
           ...,
    
           [[ 4.76187362,  4.76192536,  4.76199679, ...,  4.76261025,
              4.76260565,  4.76318251],
            [ 4.43610074,  4.35045608,  4.27731849, ...,  4.7365479 ,
              4.63162582,  4.52823711],
            [ 5.45895718,  5.12881354,  4.84968123, ...,  6.88759825,
              6.38305205,  5.92104991],
            ...,
            [29.02477114, 29.00891449, 28.6140089 , ..., 28.06992969,
             28.54073022, 28.85756781],
            [24.78977553, 24.7231504 , 24.8002165 , ..., 24.59693914,
             24.70042685, 24.79518155],
            [19.02345855, 19.02243803, 19.01606996, ..., 19.0213515 ,
             19.02336331, 19.02345502]],
    
           [[ 3.52398543,  3.5239715 ,  3.52402218, ...,  3.52265273,
              3.52278999,  3.5222965 ],
            [ 2.33981907,  2.30439165,  2.28405268, ...,  2.4777441 ,
              2.43240358,  2.39144853],
            [ 3.8679195 ,  3.66747689,  3.43821853, ...,  4.44902671,
              4.26925552,  4.05733144],
            ...,
            [18.77781027, 20.15298327, 21.66013483, ..., 14.85547988,
             15.95146584, 17.75085659],
            [16.92624414, 17.60292037, 18.14028662, ..., 15.5248189 ,
             16.02470681, 16.57633232],
            [11.34372277, 11.34342456, 11.33580741, ..., 11.34016956,
             11.34406424, 11.34378395]],
    
           [[ 5.20026347,  5.2001252 ,  5.20068916, ...,  5.19915536,
              5.19905105,  5.19727521],
            [ 4.41278987,  4.3177039 ,  4.25314454, ...,  4.47581405,
              4.45402333,  4.43559112],
            [ 6.51391413,  6.12531503,  5.69832013, ...,  7.41450332,
              7.03305618,  6.87111282],
            ...,
            [16.65495549, 16.42581557, 16.17149897, ..., 17.05154616,
             17.03126701, 17.12881582],
            [19.01371278, 18.94054643, 18.6641323 , ..., 19.89301762,
             19.71637027, 19.56744205],
            [11.13901634, 11.13739232, 11.12461834, ..., 11.13147298,
             11.13898523, 11.13903214]]])
    • lat
      (lat)
      float64
      -89.49 -87.98 ... 87.98 89.49
      long_name :
      latitude
      units :
      degrees_north
      standard_name :
      latitude
      axis :
      Y
      bounds :
      lat_bnds
      array([-89.494382, -87.977528, -85.955056, -83.932584, -81.910112, -79.88764 ,
             -77.865169, -75.842697, -73.820225, -71.797753, -69.775281, -67.752809,
             -65.730337, -63.707865, -61.685393, -59.662921, -57.640449, -55.617978,
             -53.595506, -51.573034, -49.550562, -47.52809 , -45.505618, -43.483146,
             -41.460674, -39.438202, -37.41573 , -35.393258, -33.370787, -31.348315,
             -29.325843, -27.303371, -25.280899, -23.258427, -21.235955, -19.213483,
             -17.191011, -15.168539, -13.146067, -11.123596,  -9.101124,  -7.078652,
              -5.05618 ,  -3.033708,  -1.011236,   1.011236,   3.033708,   5.05618 ,
               7.078652,   9.101124,  11.123596,  13.146067,  15.168539,  17.191011,
              19.213483,  21.235955,  23.258427,  25.280899,  27.303371,  29.325843,
              31.348315,  33.370787,  35.393258,  37.41573 ,  39.438202,  41.460674,
              43.483146,  45.505618,  47.52809 ,  49.550562,  51.573034,  53.595506,
              55.617978,  57.640449,  59.662921,  61.685393,  63.707865,  65.730337,
              67.752809,  69.775281,  71.797753,  73.820225,  75.842697,  77.865169,
              79.88764 ,  81.910112,  83.932584,  85.955056,  87.977528,  89.494382])
    • lon
      (lon)
      float64
      1.25 3.75 6.25 ... 356.2 358.8
      long_name :
      longitude
      units :
      degrees_east
      standard_name :
      longitude
      axis :
      X
      bounds :
      lon_bnds
      array([  1.25,   3.75,   6.25,   8.75,  11.25,  13.75,  16.25,  18.75,  21.25,
              23.75,  26.25,  28.75,  31.25,  33.75,  36.25,  38.75,  41.25,  43.75,
              46.25,  48.75,  51.25,  53.75,  56.25,  58.75,  61.25,  63.75,  66.25,
              68.75,  71.25,  73.75,  76.25,  78.75,  81.25,  83.75,  86.25,  88.75,
              91.25,  93.75,  96.25,  98.75, 101.25, 103.75, 106.25, 108.75, 111.25,
             113.75, 116.25, 118.75, 121.25, 123.75, 126.25, 128.75, 131.25, 133.75,
             136.25, 138.75, 141.25, 143.75, 146.25, 148.75, 151.25, 153.75, 156.25,
             158.75, 161.25, 163.75, 166.25, 168.75, 171.25, 173.75, 176.25, 178.75,
             181.25, 183.75, 186.25, 188.75, 191.25, 193.75, 196.25, 198.75, 201.25,
             203.75, 206.25, 208.75, 211.25, 213.75, 216.25, 218.75, 221.25, 223.75,
             226.25, 228.75, 231.25, 233.75, 236.25, 238.75, 241.25, 243.75, 246.25,
             248.75, 251.25, 253.75, 256.25, 258.75, 261.25, 263.75, 266.25, 268.75,
             271.25, 273.75, 276.25, 278.75, 281.25, 283.75, 286.25, 288.75, 291.25,
             293.75, 296.25, 298.75, 301.25, 303.75, 306.25, 308.75, 311.25, 313.75,
             316.25, 318.75, 321.25, 323.75, 326.25, 328.75, 331.25, 333.75, 336.25,
             338.75, 341.25, 343.75, 346.25, 348.75, 351.25, 353.75, 356.25, 358.75])
    • month
      (month)
      int64
      1 2 3 4 5 6 7 8 9 10 11 12
      array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12], dtype=int64)
In [12]:
projection = ccrs.PlateCarree()
axes_class = (GeoAxes,dict(map_projection=projection))

longitude=monmean_temp.longitude.values #longitude
latitude=monmean_temp.latitude.values #latitude
month=monmean_temp.month.values
months=['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'] #

fig = plt.figure()
fig.set_size_inches(18.5, 10.5)
axgrid = AxesGrid(fig, 111, axes_class=axes_class,
                  nrows_ncols=(3, 4), 
                  axes_pad=0.3,
                  cbar_location='right',
                  cbar_mode='single',
                  cbar_pad=0.2,
                  cbar_size='3%',
                  label_mode='')

for n, ax in enumerate(axgrid):
    ax.set_xlim(-20,25)
    ax.set_ylim(0,25)
    ax.set_xticks(np.linspace(-20,25,4), crs=projection)
    ax.set_yticks(np.linspace(0,25, 4), crs=projection)
    ax.coastlines()
    p = ax.contourf(longitude, latitude, monmean_temp[n],
                        transform=projection,
                        cmap='RdBu_r')
    ax.text(20,20, str(months[n]),fontsize=18, ha='center')

d=axgrid.cbar_axes[0].colorbar(p)
d.set_label_text('Deg C')

# Make ticklabels on inner axes invisible
axes = np.reshape(axgrid, axgrid.get_geometry())
for ax in axes[:-1, :].flatten():
    ax.xaxis.set_tick_params(which='both', 
                             labelbottom=False, labeltop=False)
    
for ax in axes[:, 1:].flatten():
    ax.yaxis.set_tick_params(which='both', 
                             labelbottom=False, labeltop=False)
#plt.suptitle('Monthly Temperatuve over West-Africa',fontsize=20,y=1.04)
plt.show()

Temperature standardised anomaly with base climatology (1979-2008)

In [34]:
interan_temp=df_temp.groupby('time.year').mean().mean('expver') #Annual mean
df = interan_temp.t2m.to_dataframe()
dd=df.t2m.groupby('year').mean() # Yearly mean
clim_temp=df.loc[1979:2008,].t2m.groupby('year').mean().mean() # climatology mean
clim_sd=df.loc[1979:2008,].t2m.groupby('year').mean().std()# climatology standard deviation

temp_anom=(dd-clim_temp)/clim_sd # anomaly compuatation
In [35]:
fig = plt.figure(figsize=(10,5))
cols=['red' if x <0 else 'blue' for x in temp_anom]
plt.bar(temp_anom.index[1:41],temp_anom[1:41],color=cols)
plt.xlabel('Years'),plt.ylabel('Anomaly')
plt.title('Temperature standardised anomaly', loc='left', fontsize=15)
plt.title('1979-2020',loc='right', fontsize=15)
plt.show()

Interannual variability of precipitation per climatic Zones

West African domain is divided into three climatic zones: Guinea (4°N–8°N), Savanna (8°N–11°N), and Sahel (11°N–16°N).

In [36]:
#Annual mean
interan_prcp=df_pre.groupby('time.year').sum()
 # extract datasets coordinate extent (longitude,latitude)
lats=interan_prcp.lat.values
lonts=interan_prcp.lon.values
In [37]:
df_pre['time']=pd.date_range('1/1/1996', '31/12/2000', freq='M') #fix time series dimensions
In [38]:
#Mean across climatic zone
lat_guinne=lats[(lats>4) & (lats<8)] #Guinea zone
lat_savanna=lats[(lats>8) & (lats<11)] # Savanna zone 
lat_sahel=lats[(lats>11) & (lats<16)] # Sahel Zone
In [39]:
guinee=df_pre.sel(lat=lat_guinne).mean('lat').mean('lon').to_dataframe().reset_index()
savanna=df_pre.sel(lat=lat_savanna).mean('lat').mean('lon').to_dataframe().reset_index()
sahel=df_pre.sel(lat=lat_sahel).mean('lat').mean('lon').to_dataframe().reset_index()
In [49]:
#Ploting
fig, ax= plt.subplots(1, 3, figsize=(20,7),sharey=True)
ax[0].plot(guinee.time,guinee.pr,color='green',marker='p',markersize=10)
ax[0].legend(['Guinee'],loc='upper right', frameon=True)
ax[0].set_xlabel('Years')
ax[0].set_ylabel('mm/momth',fontsize=15)
ax[1].plot(savanna.time,savanna.pr,marker='p',color='orange',markersize=10)
ax[1].legend(['Savanna'],loc='upper right', frameon=True)
ax[2].plot(sahel.time,sahel.pr,marker='p',color='blue',markersize=10)
ax[2].legend(['Sahel'],loc='upper right')

plt.axis(aspect='equal')
plt.suptitle('Precipitation per climatic zone',y=1.04,fontsize=20)
plt.tight_layout()
plt.show()

Daily variation of rainfall in August across climatic zones in West-Africa

In [29]:
CRU_GPCC_RAIN=xr.open_dataset('Rainf_WFDE5_CRU+GPCC_201608_v1.0.nc')
CRU_GPCC_RAIN
Out[29]:
Show/Hide data repr Show/Hide attributes
xarray.Dataset
    • lat: 360
    • lon: 720
    • time: 744
    • lat
      (lat)
      float64
      -89.75 -89.25 ... 89.25 89.75
      long_name :
      Latitude
      units :
      degrees_north
      standard_name :
      latitude
      axis :
      Y
      array([-89.75, -89.25, -88.75, ...,  88.75,  89.25,  89.75])
    • lon
      (lon)
      float64
      -179.8 -179.2 ... 179.2 179.8
      long_name :
      Longitude
      units :
      degrees_east
      standard_name :
      longitude
      axis :
      X
      array([-179.75, -179.25, -178.75, ...,  178.75,  179.25,  179.75])
    • time
      (time)
      datetime64[ns]
      2016-08-01 ... 2016-08-31T23:00:00
      standard_name :
      time
      long_name :
      Time
      axis :
      T
      array(['2016-08-01T00:00:00.000000000', '2016-08-01T01:00:00.000000000',
             '2016-08-01T02:00:00.000000000', ..., '2016-08-31T21:00:00.000000000',
             '2016-08-31T22:00:00.000000000', '2016-08-31T23:00:00.000000000'],
            dtype='datetime64[ns]')
    • Rainf
      (time, lat, lon)
      float32
      ...
      units :
      kg m-2 s-1
      long_name :
      Rainfall Flux
      standard_name :
      rainfall_flux
      [192844800 values with dtype=float32]
  • title :
    WATCH Forcing Data methodology applied to ERA5 data
    institution :
    Copernicus Climate Change Service
    contact :
    http://copernicus-support.ecmwf.int
    summary :
    ERA5 data regridded to half degree regular lat-lon; Genuine land points from CRU grid and ERA5 land-sea mask only; Rainf bias-corrected using CRU TS4.03 wet days & GPCCv2018 precip totals, catch correction, and precip phase correction according to elevation and bias-corrected Tair
    Conventions :
    CF-1.7
    comment :
    Methodology implementation for ERA5 and dataset production by B-Open Solutions for the Copernicus Climate Change Service in the context of contract C3S_25c
    licence :
    The dataset is distributed under the Licence to Use Copernicus Products. The corrections applied are based upon CRU TS4.03, distributed under the Open Database License (ODbL), and GPCCv2018, distributed under the Creative Commons Attribution 4.0 International License (CC BY 4.0)
    reference :
    Cucchi et al., 2020, Earth Syst. Sci. Data Discuss., doi:10.5194/essd-2020-28, in review; Weedon et al., 2014, Water Resources Res., 50, 7505-7514, doi:10.1002/2014WR015638; Harris et al., 2020, Scientific Data, 7(1), doi:10.1038/s41597-020-0453-3; Schneider, U., Becker, A., Finger, P., Meyer-Christoffer, A., Ziese, M., 2018 GPCC Full Data Product version 2018 at 0.5o: Monthly land-surface precipitation from rain-gauges built on GTS-based and historical data, doi:10.5676/DWD_GPCC/FD_M_V2018_050; Schneider et al. 2017 Atmosphere 8, 52 doi:10.3390/atmos8030052; Schneider et al. 2013 Theor. Appl. Climatol.115, 15-40, doi:10.1007/s00704-013-08600-x
In [30]:
# Latitude and Longitude extent of the study area
lat_slice = slice(5,30)
lon_slice = slice(-15,30)
# Extract the datasets over West-Africa
Rain_new=CRU_GPCC_RAIN['Rainf'].sel(lat=lat_slice,lon=lon_slice)

dat=pd.to_datetime(Rain_new.time.values) #retrieved 'time' dimensions in datetime format
ts=dat.strftime('%Y-%m-%d') #convert from datetime  to time dimension
Rain_new['time']=ts # force 'time' dimension with the daily time series

Rain_new
Out[30]:
Show/Hide data repr Show/Hide attributes
xarray.DataArray
'Rainf'
  • time: 744
  • lat: 50
  • lon: 90
  • ...
    [3348000 values with dtype=float32]
    • lat
      (lat)
      float64
      5.25 5.75 6.25 ... 29.25 29.75
      long_name :
      Latitude
      units :
      degrees_north
      standard_name :
      latitude
      axis :
      Y
      array([ 5.25,  5.75,  6.25,  6.75,  7.25,  7.75,  8.25,  8.75,  9.25,  9.75,
             10.25, 10.75, 11.25, 11.75, 12.25, 12.75, 13.25, 13.75, 14.25, 14.75,
             15.25, 15.75, 16.25, 16.75, 17.25, 17.75, 18.25, 18.75, 19.25, 19.75,
             20.25, 20.75, 21.25, 21.75, 22.25, 22.75, 23.25, 23.75, 24.25, 24.75,
             25.25, 25.75, 26.25, 26.75, 27.25, 27.75, 28.25, 28.75, 29.25, 29.75])
    • lon
      (lon)
      float64
      -14.75 -14.25 ... 29.25 29.75
      long_name :
      Longitude
      units :
      degrees_east
      standard_name :
      longitude
      axis :
      X
      array([-14.75, -14.25, -13.75, -13.25, -12.75, -12.25, -11.75, -11.25, -10.75,
             -10.25,  -9.75,  -9.25,  -8.75,  -8.25,  -7.75,  -7.25,  -6.75,  -6.25,
              -5.75,  -5.25,  -4.75,  -4.25,  -3.75,  -3.25,  -2.75,  -2.25,  -1.75,
              -1.25,  -0.75,  -0.25,   0.25,   0.75,   1.25,   1.75,   2.25,   2.75,
               3.25,   3.75,   4.25,   4.75,   5.25,   5.75,   6.25,   6.75,   7.25,
               7.75,   8.25,   8.75,   9.25,   9.75,  10.25,  10.75,  11.25,  11.75,
              12.25,  12.75,  13.25,  13.75,  14.25,  14.75,  15.25,  15.75,  16.25,
              16.75,  17.25,  17.75,  18.25,  18.75,  19.25,  19.75,  20.25,  20.75,
              21.25,  21.75,  22.25,  22.75,  23.25,  23.75,  24.25,  24.75,  25.25,
              25.75,  26.25,  26.75,  27.25,  27.75,  28.25,  28.75,  29.25,  29.75])
    • time
      (time)
      object
      '2016-08-01' ... '2016-08-31'
      array(['2016-08-01', '2016-08-01', '2016-08-01', ..., '2016-08-31',
             '2016-08-31', '2016-08-31'], dtype=object)
  • units :
    kg m-2 s-1
    long_name :
    Rainfall Flux
    standard_name :
    rainfall_flux
In [31]:
lats=Rain_new.lat.values #get latitude  extent of the datasets
lat_guinne=lats[(lats>4) & (lats<8)] #retrieved Guinea zone latitude
lat_savanna=lats[(lats>8) & (lats<11)] #retrieved Savanna zone latitude
lat_sahel=lats[(lats>11) & (lats<16)] #retrieved Guinea zone latitude
In [32]:
#Mean across climatic zone
guinee=Rain_new.sel(lat=lat_guinne).mean('lat').mean('lon').to_dataframe().reset_index() 
savanna=Rain_new.sel(lat=lat_savanna).mean('lat').mean('lon').to_dataframe().reset_index()
sahel=Rain_new.sel(lat=lat_sahel).mean('lat').mean('lon').to_dataframe().reset_index()

#daily mean of precipiatation in mm/day
interan_guinee=guinee.groupby('time').sum()*86400
interan_savan=savanna.groupby('time').sum()*86400
interan_sahel=sahel.groupby('time').sum()*86400
In [33]:
#Ploting
fig = plt.figure(figsize=(10,5))
ax = plt.axes()
ax.plot(interan_guinee, '--',marker='o')
ax.plot(interan_savan, '--',marker='o')
ax.plot(interan_sahel, '--',marker='o')
ax.set_xticklabels(range(1,32))
ax.set_xlabel('Years')
ax.set_ylabel('mm')
ax.legend(['Guinee','Savanna','Sahel'],loc='upper right', frameon=True)
ax.set_title('Precipitation per climatic zone - daily variation', loc='left',Fontsize=15)
ax.set_title('Time: 2016',loc='right', fontsize=10)
plt.tight_layout()
plt.show()