Published in


How to Create Interactive Climate Model Maps in Python

“El Niño is likely this winter,” the forecaster says. “El Niño typically brings above-normal winter cloudiness and rainfall across the southern U.S. and milder conditions to Canada…”

You may have heard something like this spoken on your TV, radio, or written on the Internet recently. Have you ever wondered how a meteorologist or climatologist comes to such conclusions?

In this post, we’ll show you how to create interactive climate maps using the Copernicus Data Store, where you can visualize, examine, and explore the same data that your local forecaster sees.

Keep reading to learn how to make an interactive version of this March 2019 precipitation anomaly map.

Copernicus is a game-changing project that “makes information about the past, present, and future climate freely available, and functions as a one-stop shop for users to explore climate data.” Access to data is open, free and unrestricted.

We have entered a golden age of freely available weather and climate data on the web — spanning time horizons from the next few hours or days and even into the coming weeks or months. NOAA’s NCEP NOMADS is a treasure trove of such information, and now the European Centre for Medium Range Weather ForecastsCopernicus Climate Data Store has burst onto the scene.

Before we start mapping, let’s get set up with Copernicus. We’ll use their API to get the climate data for our visualizations.

Getting started is easy:

  1. Make an account here.
  2. Navigate to the ‘data store’ portion of the site.
  3. In this post, we’ll look at ‘seasonal forecast’ data sets (access here).

For further weather and climate map inspiration, check out our post ‘How to Create 2D and 3D Interactive Weather Maps in Python and R’.

1. Download your first data set

In the climate forecasting space, anomalies (difference from average) are often the most frequently examined data. While looking at raw outputs can be useful in some circumstances, the end goal is to understand how much warmer, cooler, drier, or wetter than normal an area may be. For the purposes of this post, we’ll be looking at forecast anomalies.

In order to work with this climate data in Plotly, you’ll need to download the data in NetCDF format. To do this, you will have to install the Climate Data Store Application Program Interface (CDS API). For Python users, this step should be pretty straightforward:

  1. Install the CDS API key and store it in your home directory.

2. Install the CDS API client using `pip install cdsapi`.

Now let’s download some data 👌

We’ll start off with a sea surface temperature data set from the ECMWF model, often considered the gold standard when it comes to weather and climate prediction. Follow this link to the data and navigate to the “Download Data” tab in the page.

Under the “Download Data” tab, you’ll find a form where you can specify the data you’d like to download through the API. Selections in this form will create an API request for the desired data. To view this request, fill out the form and click the red “Show API request” button at the bottom-left beneath the form.

Fill out your form like this:

Then, click the “Show API request” to reveal your request. (“Hide API request” tucks it away again.)

Next, copy this API request and paste it into a Jupyter notebook. Remember when we mentioned that it needs to be in NetCDF format? This is where we’ll change the requested file format from GRIB to NetCDF:

Click HERE for an example Jupyter Notebook to download and process the climate data.

2. Your first plot: Sea Surface Temperature Anomaly

Now you should have your data set in your home directory. Next, we leverage the power of Python with Plotly to view and inspect climate data in a new, interactive format that enables you to zoom to low levels for greater detail.

Gone are the days of worrying about whether data for your country will show. In this case we’ll produce a world map with data that covers the Earth 👌 🗺️

The first plot shows sea surface temperature anomalies: essentially, how much warmer or cooler than average the sea surface temperature is at a given location (or grid box).

Sea surface temperature anomalies are particularly important in the tropical oceans, as anomalies help to modify the Walker Circulation, which plays a major role in precipitation and temperature patterns across the global tropics (and to a lesser extent the middle latitudes).

Early in 2019, there is an El Niño signature in the tropical Pacific Ocean. The warmest sea surface temperatures (and anomalies) are located across the west-central equatorial Pacific, to the east of Papua New Guinea and north of Fiji. This has been an area of consistent atmospheric lift, increased cloud cover, and precipitation.

You can download the Jupyter Notebook here and use it to make all the plots below.

Jupyter Notebook

3. Air Temperature Anomaly

This plot looks at the forecast air temperature anomaly, in Celsius, for the month of March 2019. These model data also come from the ECMWF, although the Copernicus data store hosts four additional models from institutions across Europe: UK Met Office (UKMO), Météo France, Deutscher Wetterdienst (DWD), and Centro Euro-Mediterraneo sui Cambiamenti Climatici (CMCC).

Red colors show warmer-than-average temperatures while blue indicates below-average temperatures.

4. Precipitation Anomaly

This plot examines precipitation rate anomaly in mm/second for the month of March 2019.

Precipitation is often considered one of the most challenging parameters to forecast. Generally speaking, precipitation outlooks have lower confidence than temperature outlooks.

This is because rain and snow can be irregular in coverage and intensity — there may be sharp differences in amounts over short distances, depending on the lay of the land (e.g. more in the mountain ranges, less in the valleys). Compared to temperature, it is generally much less uniform and therefore a more frequent forecast challenge.

In the chart below, negative values (blues) indicate below-normal monthly precipitation while positive values (yellows, oranges) indicate above-normal monthly precipitation.

So, with this wealth of climate data at your fingertips, get graphing with Plotly and start exploring your world in a new way!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


The leading front-end for ML & data science models in Python.