Plotting Sea Ice Concentration with Two Graphs Using Python

Visualizing sea ice concentration with scatter plot and heat map

Boriharn K
Towards Data Science

--

Photo by Danielle Barnes on Unsplash

Climate change, a global phenomenon, impacts Earth’s weather patterns. It produces consequences such as deserts expanding and heat waves becoming more frequent. The increased temperature in the Arctic has also contributed to melting permafrost and sea ice loss.

Let’s talk about the sea ice. Polar amplification is a phenomenon in which the temperature near the Earth’s pole is enhanced greater than the rest of the globe. This resulted in the loss of sea ice in the past decades.

To cope with the problems, there are efforts worldwide to slow down climate change. Monitoring and recording are methods that help us analyze the change process. This article will show two graphs, a scatter plot and a heat map, to visualize the sea ice concentration with Python.

Let’s get started

The first image: a scatter plot showing the average percentage concentration of sea ice above the Arctic circle in December 2021. The second image: a heat map showing the sea ice at the same time. Images by the author.

Data Source

The downloaded dataset is called “Sea ice concentration daily gridded data from 1979 to present derived from satellite observations” (link) Copyright © (2022) EUMETSAT. The time of the dataset is from January 2010 to December 2021, 12 years in total, from the Copernicus website.

The product used is the Global Sea Ice Concentration Climate Data Record produced by the European Organisation for the Exploitation of Meteorological Satellites Ocean and Sea Ice Satellite Application Facility (EUMETSAT OSI SAF).

To get the dataset, I followed the insightful steps from these 2 articles:

  • Read ERA5 Directly into Memory with Python (link)
  • Best free API for weather records: ERA5! (link)

All intellectual property rights of the OSI SAF products belong to EUMETSAT. More information about the dataset ownership, copyright, acknowledgment, and citation can be found here: link and here: link.

After downloading to your computer, I recommend saving the files in a folder for easily importing in the next step.

Import data

The netCDF4 library is for reading the downloaded files in NetCDF (Network Common Data Form) format. The total file size that we are going to work with is kind of huge. Thus, it will take some time to process. The tqdm library can show us progress bars.

To read the files, we need to know the files' names. The following code is used to get every file name in the folder where they are saved.

It can be noticed that the file names contain the date stamp. This can be used for assigning the dates to each dataset. Create a list of dates.

Explore data

Before continuing, let’s explore the variables that each file contains.

For more information, use the code below to get more detail from each variable.

To visualize the sea ice concentration, three variables will be used:

  • lat: latitude
  • lon: longitude
  • ice_conc: filterssea_ice_area_fraction; fully filtered concentration of sea ice using atmospheric correction of brightness temperatures and open water

Create DataFrame

We will read the NetCDF files and turn them into a DataFrame for working with Python. Define functions for quickly creating a DataFrame.

Apply the functions. Only the percentage concentrations above 50 are selected to avoid excessive data. By the way, the number can be modified.

Note: If an error about the memory shows up, I recommend doing a list slicing. Dividing the data into two or three parts to work with small data and saving the output DataFrame with DataFrame.to_csv. Repeat the process until complete the list. After that, read every DataFrame and concatenate them with pandas.concat.

Descriptive Analysis

This article will mainly focus on the ice sea above the Arctic Circle, 66°N approximately. If you are interested in the ice sea below the Antarctic Circle, the latitude value in the code below can be modified. Filter the DataFrame and group by the year and month.

Plot a Time-series graph from the DataFrame.

Time-series graph showing monthly average percentage concentration from 2010–2021. Image by the author.

The lines in the time-series graph show that August is the month when the average percentage concentration reaches the lowest point. This makes sense since it is Summer in the northern hemisphere.

Sea ice visualization

This article will guide how to visualize the data using a scatter plot on polar axis and a heat map.

Before continuing, the obtained DataFrame is not ready for plotting. The latitude is needed to be scaled from [66,90] to [0,1] to facilitate the data visualization. Moreover, the longitude range contains negative values from [-180,180], which are needed to turn into a positive range. Let’s define a function to convert the values.

Create a list of years and months to filter the DataFrame.

The next step is applying the function and filtering with the list of years and months.

Scatter plot on polar axis

The idea is to look from above the North Pole. Thus, we are going to plot the scatter plot on the polar axis to simulate the point of view. Note that the results will be saved to your computer for use later.

An example of a scatter plot on polar axis showing the average percentage concentration of sea ice above the Arctic circle in December 2021. Image by the author.

Create a GIF file

Making an animation is an alternative idea for making the plots look interesting. Thus, let’s combine the plots and turn them into a GIF file. For example, I will combine the scatter plots from every month in 2020 and 2021.

Voila!!….

A GIF file combining all the scatter plots on polar axis from January 2020 to December 2021.

From the saved output, we can create a GIF file selecting only the same month to compare each year's data. For example, the following code shows how to combine every plot of September.

A GIF file combining all the scatter plots on polar axis every September from 2010 to 2021. Image by the author.

Heat map

To create a heat map over the world map, Folium is a powerful Python library for working with geospatial data. Start with importing the libraries.

We need to prepare the data before applying with Folium. This time the whole data above the Equator line is selected. After that, perform groupby and calculate the monthly average. Then, choose the month to plot. For example, the dataset below is from December 2021.

From the DataFrame, create a list of data and colors for plotting.

Plot a Heat map with the Folium library.

An example of a heat map showing the average percentage concentration of sea ice above the Arctic circle in December 2021 using Folium. Image by the author.

Heat map with time

Folium also has a function called HeatMapWithTime for creating an animation by combining multiple heat maps. I will plot the heat maps from January 2019 to December 2021, 24 months.

Plot the data with HeatMapWithTime.

An animation of heat maps showing the average percentage concentration of sea ice above the Arctic circle from January 2019 to December 2021 using HeatMapWithTime from Folium. Image by the author.

Summary

This article has shown a sea ice data source and how to import and prepare the data. The two graphs for visualizing sea ice concentration are the scatter plot on polar axis and the heat map. The two graphs can be improved by creating animation to make the results look interesting.

This article mainly focuses on the sea ice above the Arctic circle. By the way, the method can be applied to the sea ice in the southern hemisphere, below the Antarctic circle.

If you have any suggestions or questions, please feel free to comment.

Thanks for reading

These are other articles about data visualization that you may find interesting.

· Visualizing the Invisible SO2 with NASA Data and Python (link)

· 8 Visualizations with Python to Handle Multiple Time-Series Data (link)

· Visualizing the Speed of Light with Python (link)

References

--

--

a data visualization enthusiast | I also care about environmental issues.