You can run this notebook in Binder, in Colab, in Deepnote or in Kaggle.

[1]:
!pip install --quiet climetlab

Retrieve ERA5 data from the CDS

[2]:
import climetlab as cml
[6]:
source = cml.load_source(
    "cds",
    "reanalysis-era5-single-levels",
    variable=["2t", "msl"],
    product_type="reanalysis",
    area=[50, -50, 20, 50],
    date="2012-12-12",
    time="12:00",
)
for s in source:
    cml.plot_map(s)
../_images/examples_03-source-cds_3_0.png
../_images/examples_03-source-cds_3_1.png
[8]:
source = cml.load_source(
    "cds",
    "reanalysis-era5-single-levels",
    variable=["2t", "msl"],
    product_type="reanalysis",
    area=[50, -50, 20, 50],
    date="2012-12-12",
    time="12:00",
    format="netcdf",
)
for s in source:
    cml.plot_map(s)
../_images/examples_03-source-cds_4_0.png
../_images/examples_03-source-cds_4_1.png
[10]:
source.to_xarray()
[10]:
<xarray.Dataset>
Dimensions:    (latitude: 121, longitude: 401, time: 1)
Coordinates:
  * longitude  (longitude) float32 -50.0 -49.75 -49.5 -49.25 ... 49.5 49.75 50.0
  * latitude   (latitude) float32 50.0 49.75 49.5 49.25 ... 20.5 20.25 20.0
  * time       (time) datetime64[ns] 2012-12-12T12:00:00
Data variables:
    t2m        (time, latitude, longitude) float32 274.3 274.4 ... 302.2 302.5
    msl        (time, latitude, longitude) float32 9.956e+04 ... 1.013e+05
Attributes:
    Conventions:  CF-1.6
    history:      2021-03-22 10:05:13 GMT by grib_to_netcdf-2.16.0: /opt/ecmw...
[12]:
cml.plot_map(source.to_xarray(), title=True)
../_images/examples_03-source-cds_6_0.png