Total points: 30
Due: Friday 27th September, 7pm CEST
Format: IPython 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 was collected by the AMSR-E instrument Aqua satellite. The data consists of maps of the concentration of ice in the Arctic collected between 2006 and 2011. The data were downloaded and extracted from here and converted into a format that can be more easily used.
The data you should use is in here (use this link if you need a zip archive) and can also be accessed in
/local/py4sci/ice_data if you are using the CIP computers (no need to copy over that directory, just read the files from there). To use it, copy the tgz file into your day3 directory and type:
tar -xvzf ice.tgz
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('ice_data/20080415.npy')
which will give you a 2-d array. Just for information, this was created with:
>>> np.save('ice_data/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. followed by the name of the colormap). Note that you can make figures larger by specifying e.g.
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 (
200, etc.) since they are not useful.
We now want to make a plot of the ice concentration over time. Reading in a single map is easy, but since we have 137 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.
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.
You will likely notice that the ticks are in a strange format, where they are given in years since 2006, but you can change this with the following code:
>>> from matplotlib.ticker import ScalarFormatter >>> plt.gca().xaxis.set_major_formatter(ScalarFormatter(useOffset=False))
Describe what you see in the plot.
We now want something a little more quantitative than just the number of pixels, so we will try and compute the area where the ice concentration is above a given threshold. However, we first need to know the area of the pixels in the image, and since we are looking at a projection of a spherical surface, each pixel will be a different area. The areas (in km^2) are contained inside the file named
ice_data_area.npy (if you are using the CIP pool, this is
/local/py4sci/ice_data_area.npy). 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 99% or above. Make a new plot showing the area of >99% 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 99% 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 the 2006 and the 2011 data.
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).
Compute average ice concentration maps for 2006 and 2011, and plot them side by side.
The data that we have here only cover five years, so we cannot reliably extract information about long term trends. However, it is worth noting that the minimum ice coverage you found here was 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. In 2012, the record was again beaten, and most scientists believe that by ~2050, the Arctic will be completely ice-free for at least part of the summer.