Python - Sea ice

by Pearse Buchanan

 

# -*- coding: utf-8 -*-
"""
Created on Fri Jun 17 15:27:37 2016

@author: pearseb
"""

#%% load necessary plotting packages

import numpy as np
import matplotlib.pyplot as plt
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import cartopy
import cartopy.crs as ccrs

#%% Make the figure

# create the figure panel 
fig = plt.figure(figsize=(10,10), facecolor='w')

# create the map using the cartopy Orthographic projection, selecting the South Pole
ax1 = plt.subplot(1,1,1, projection=ccrs.Orthographic(central_latitude=-90.0))

# add coastlines, gridlines, make sure the projection is maximised inside the plot, and fill in the land with colour
ax1.coastlines(resolution='110m', zorder=3) # zorder=3 makes sure that no other plots overlay the coastlines
ax1.gridlines()
ax1.set_global()
ax1.add_feature(cartopy.feature.LAND, zorder=1,facecolor=cartopy.feature.COLORS['land_alt1'])

# plot sea ice field (annual average) at zorder=0 (bottom layer) and with the reversed "Bone" colourmap
pp = plt.pcolormesh(lon,lat,LGMiceave, cmap='bone_r', vmin=0,vmax=1.01, zorder=0, transform=ccrs.PlateCarree())

# plot the maximum annual sea ice extent, where sea ice must be 15% cover, as a red line
plt.contour(lon,lat,LGMicemax, colors='firebrick', levels=[0.15], linewidth=2, transform=ccrs.PlateCarree())

# plot the minimum annual sea ice extent, where sea ice must be 15% cover, as a blue line
plt.contour(lon,lat,LGMicemin, colors='deepskyblue', levels=[0.15], linewidth=2, transform=ccrs.PlateCarree())

# plot the palaeo observations over the top of the sea ice
plt.scatter(Glon[Gice == 1],Glat[Gice == 1], s=40, c='deepskyblue', marker='o', transform=ccrs.PlateCarree())
plt.scatter(Glon[Gice == 0],Glat[Gice == 0], s=40, c='firebrick', marker='o', transform=ccrs.PlateCarree())

# add the colourbar to the bottom of the plot.
# The first moves the bottom of the map up to 15% of total figure height, 
# the second makes the new axes for the colourbar, 
# the third makes the colourbar, and the final adds the label

fig.subplots_adjust(bottom=0.15)
cbar_ax = fig.add_axes([0.2, 0.1, 0.625, 0.033])
cbar = plt.colorbar(pp, cax=cbar_ax, orientation='horizontal', ticks=np.arange(0,1.1,0.1))
cbar.set_label(label='Fractional sea ice cover',size=14, family='serif')

# save the figure
fig.savefig('Glacialseaice_SH.png',dpi=300,bbox_inches='tight')

UNSW logo ANU logo Monash logo UMelb logo UTAS logo