[1]:
import earthkit.data
import earthkit.plots
[2]:
from datetime import datetime
[3]:
YEARS = {
    1993: "Normal conditions",
    1997: "El Niño",
    1998: "La Niña",
}

DOMAIN = [100, 300, -20, 20]
[4]:
data = earthkit.data.from_source(
    "cds", "reanalysis-era5-single-levels-monthly-means",
    {
        "product_type": "monthly_averaged_reanalysis",
        "variable": "sea_surface_temperature",
        "year": list(YEARS),
        "month": "12",
        "time": "00:00",
        "area": [20, 100, -20, -60],
        "grid": [0.25, 0.25],
    },
)
2024-06-16 19:09:09,322 INFO Welcome to the CDS
2024-06-16 19:09:09,322 INFO Sending request to https://cds.climate.copernicus.eu/api/v2/resources/reanalysis-era5-single-levels-monthly-means
2024-06-16 19:09:09,434 INFO Request is completed
2024-06-16 19:09:09,434 INFO Downloading https://download-0006-clone.copernicus-climate.eu/cache-compute-0006/cache/data6/adaptor.mars.internal-1718561324.1581435-27236-17-ac702269-b7ec-4519-8881-446cccecdc6d.grib to /var/folders/vt/7j2c2tmx4m14gn_sg3zpf5l00000gn/T/tmpcn2ozd_0/cds-retriever-648ba78d96b1a50a3af06f46c2ad55dfc9915a50822c7ac66404e1b21b12b1eb.cache.tmp (701.8K)
2024-06-16 19:09:09,886 INFO Download rate 1.5M/s
[5]:
data.ls()
[5]:
centre shortName typeOfLevel level dataDate dataTime stepRange dataType number gridType
0 ecmf sst surface 0 19931201 0 0 an 0 regular_ll
1 ecmf sst surface 0 19971201 0 0 an 0 regular_ll
2 ecmf sst surface 0 19981201 0 0 an 0 regular_ll
[6]:
STYLE = earthkit.plots.styles.Style(
    colors="Spectral_r",
    levels=range(15, 33),
    units="celsius",
    ticks=range(15, 33),
)
[7]:
figure = earthkit.plots.Figure(rows=3, size=(8, 7.5))

for i, year in enumerate(YEARS):
    subplot = figure.add_map(domain=DOMAIN)
    subplot.contourf(data[i], style=STYLE)
    subplot.title(f"{YEARS[year]} - ERA5 {{short_name!u}} monthly mean: {{time:%B %Y}}")

figure.land(color="#555", zorder=2)
figure.gridlines(xstep=20, ystep=10, sharex=True)

figure.title("{variable_name} in {time:%B} of {time:%Y}", fontsize=14)

figure.legend(label="{variable_name!l} ({units})")

figure.show()
../../../_images/examples_gallery_gridded-data_el-nino_6_0.png