Total points: 30
Due: Thursday October 17th, 2024, 7pm CEST
Format: jupyter notebook or python program
The purpose of this problem set is to become familiar with working with image data, plotting it, and combining it in various ways for analysis.
The data used in this problem set were collected by the AMSR-E and AMSR2 instruments on the Aqua satellite and GCOM-W1 satellites. The data consists of maps of the concentration of ice in the Arctic collected between 2002 and 2023(=now). The concentration is defined the percentage of a given area covered with sea ice. The data were downloaded and extracted from here and converted into a format that can be more easily used.
The data you should use are situated in the data/ice_data_2022/ directory on the jupyter server.
If you are using your own laptop, you can dowload the data here. The archive size is 83MB.
The data is in 'Numpy' format, which means that you can read it as a Numpy array using:
>>> import numpy as np
>>> data = np.load('data/ice_data_2022/20080415.npy')
which will give you a 2-d array. Just for information, this was created with:
>>> np.save('data/ice_data_2022/20080415.npy', data)
Start off by reading in one of the maps as shown above, and plot it with Matplotlib. Note that to get the correct orientation, you will need to call the imshow
command with the origin='lower'
option, which ensures that the (0,0) pixels is on the bottom left, not the top left. You can try and use different colormaps if you like (set by the cmap
option) - see here for information on the available colormaps. You can specify a colormap to use with e.g. cmap=plt.cm.jet
(i.e. cmap=plt.cm.
followed by the name of the colormap). Note that you can make figures larger by specifying before the plot command for example
>>> plt.figure(figsize=(8,8))
where the size is given in inches. Try and find a way to plot a colorbar on the side, to show what color corresponds to what value. Examples can be found in the Matplotlib Gallery. You may also want to try to remove the tick labels (100
, 200
, etc.) since they are not useful.
2.1 We want to make a plot of the ice concentration over time. Reading in a single map is easy, but since we have 455 maps, we do not want to read them all in individually by hand. Write a loop over all the available files, and inside the loop, read in the data to a variable (e.g. data
), and also extract the year, month, and day as integer values (e.g. year
, month
, and day
). Then, also inside the loop, compute a variable time
which is essentially the fractional time in years (so 1st July 2012 is 2012.5). You can assume for simplicity that each month has 30 days - this will not affect the results later. Finally, also compute for each file the total number of pixels that have a value above 50%. After the loop, make a plot of the number of pixels with a concentration above 50% against time.
Describe what you see in the plot.
In some version of jupyter, the ticks are in a strange format. In this case you can change this with the following code:
>>> from matplotlib.ticker import ScalarFormatter
>>> plt.gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
In all other cases, you can ignore these lines.
2.2 To deal with a little more than just the number of pixels, so we will compute the area where the ice concentration is above a given threshold. However, we first need to know the effective area of the pixels in the image, as each pixel has a different area. The areas (in km^2) are contained inside the file named ice_data_2019_area.npy
(which remains the correct file despite the name). This file was downladed here (PolStereo_GridCellArea_n12.5km_Arctic.nc) and then converted.
Read in the areas and make a plot (with colorbar) to see how the pixel area is changing over the image.
Now, loop over the files again as before, but this time, for each file, compute the total area where the concentration of ice is 15% or above. Make a new plot showing the area of >15% ice concentration against time.
Describe what you see - how does the minimum change over time?
Find the date at which the area of the region where the ice concentration is above 15% is the smallest. What is the value of the minimum area?
Next, read in the map for this minimum, and the map for the same day and month but from 2006. Make a side-by-side plot showing both data sets.
Note: You can group together plots using the add_subplot() functionality of the matplotlib figure object, which creates Axes objects to plot in:
>>> fig = plt.figure(figsize=(10,5))
>>> ax1 = fig.add_subplot(1,2,1)
>>> ax2 = fig.add_subplot(1,2,2)
>>> im1 = ax1.imshow( ... )
>>> im2 = ax2.imshow( ... )
Compute the difference between the two maps so that a loss in ice over time will correspond to a negative value, and a gain in ice will correspond to a positive value. Make a plot of the difference, and use the RdBu
colormap to highlight the changes (include a colorbar).
Note 2: Sometimes ones needs to add a colour bar to a subplot-figure such as above. This can be done by creating an additional Axes object to the figure with the apropriate size and location:
>>> cax = fig.add_axes([0.95, 0.15, 0.025, 0.7])
>>> plt.colorbar(im1,cax=cax)
(then the colour mapping should be chosen identical for the two images).
Compute average ice concentration maps for 2006 and 2012, and plot them side by side.
The data that we have here cover ~21 years, so we cannot easily extract information about long term trends. However, it is worth noting that the minimum ice coverage you find here is a record minimum - never before (in recorded history) had the size of the ice shelf been so small. This is part of a long term trend due to global warming. Most scientists believe that by ~2050, the Arctic will be completely ice-free for at least part of the summer.