Radiocarbon.py - oceanographic colour-maps

by Pearse Buchanan

Oceanographich colour map

 

# -*- coding: utf-8 -*-
"""
Created on Fri May 26 10:38:19 2017

    Collect 14C records and read them in for analysis against modelled values

@author: pearseb
"""

 

#%% import neccesary packages for plotting

import numpy as np
import matplotlib.pyplot as plt

from matplotlib import gridspec

 

# this package is great for oceanographic colourmaps
import cmocean

#%% Create the top row of the figure
# These are the basin scale zonal plots of Atlantic, Pacific and Indian Ocean radiocarbon, and a direct overlay with historical observations

''' NOTE

The following code has been commented fully for only panel (a) and panel (d).
This is beacuse the panels (b) and (c) == panel (a) in their command set up
This is beacuse the panels (e) and (f) == panel (d) in their command set up

'''

# First, define the colour-filled and line contours for the plots
levs = np.arange(-250,25,25); contlevs = np.arange(-250,0,50)

# Define the latitudes and longitudes in text for the tick labels
latitudes = ['80$^{\circ}$S', ' ', '40$^{\circ}$S', ' ', '0$^{\circ}$', ' ', '40$^{\circ}$S', ' ', '80$^{\circ}$N']
longitudes = ['0$^{\circ}$', '60$^{\circ}$E', '120$^{\circ}$E', '180$^{\circ}$E', '240$^{\circ}$E', '300$^{\circ}$E']

### here, we begin the figure, and then define that it will have 2x3 subplots
fig = plt.figure(facecolor='w',figsize=(25,10))
gs = gridspec.GridSpec(2,3)

### Panel (a) --> The Atlantic Ocean radiocarbon pre-industrial distribution

# select the first subplot
ax1 = plt.subplot(gs[0,0])

# make the title
plt.title('Atlantic', family='serif', fontsize=12)

# set the background colour of the figure to be silver grey
ax1.set_axis_bgcolor('silver')

# produce filled and line contour plots using the c14_Atl 2D array in latitude and depth space 
plot = plt.contourf(lats, deps, c14_Atl, cmap=cmocean.cm.ice_r, levels=levs, corner_mask=False, vmin=np.min(levs), vmax=np.max(levs), extend='both')
CS1 = plt.contour(lats, deps, c14_Atl, levels=contlevs, colors='black')

# Overlay the historical observations of radiocarbon using latitude (second column), depth (third column), and colouring the markers according to the radiocarbon values (fourth column)
scat = plt.scatter(c14_h_Atl[:,1], c14_h_Atl[:,2], s=50, c=c14_h_Atl[:,3], cmap=cmocean.cm.ice_r, marker='o', vmin=np.min(levs), vmax=np.max(levs))

# set the range for the x and y axes
plt.ylim(4400,0)
plt.xlim(-85,85)

# make the axis tick labels look nice
plt.xticks(np.arange(-80,90,20), latitudes, family='serif', fontsize=12)
plt.yticks(np.arange(4000,0,-500), np.arange(4000,0,-500), family='serif', fontsize=12)

 

### make panel (b) --> The Pacific Ocean radiocarbon pre-industrial distribution
ax1 = plt.subplot(gs[0,1])
plt.tick_params(axis='both', which='both', labelleft='off')
plt.title('Pacific', family='serif', fontsize=12)
ax1.set_axis_bgcolor('silver')
plt.contourf(lats, deps, c14_Pac, cmap=cmocean.cm.ice_r, levels=levs, corner_mask=False, vmin=np.min(levs), vmax=np.max(levs), extend='both')
CS2 = plt.contour(lats, deps, c14_Pac, levels=contlevs, colors='black')
plt.scatter(c14_h_Pac[:,1], c14_h_Pac[:,2], s=50, c=c14_h_Pac[:,3], cmap=cmocean.cm.ice_r, marker='o', vmin=np.min(levs), vmax=np.max(levs))
plt.ylim(4400,0)
plt.xlim(-85,85)
plt.xticks(np.arange(-80,90,20), latitudes, family='serif', fontsize=12)
plt.yticks(np.arange(4000,0,-500), np.arange(4000,0,-500), family='serif', fontsize=12)

 

### make panel (c) --> The Indian Ocean radiocarbon pre-industrial distribution
ax1 = plt.subplot(gs[0,2])
plt.tick_params(axis='both', which='both', labelleft='off')
plt.title('Indian', family='serif', fontsize=12)
ax1.set_axis_bgcolor('silver')
plt.contourf(lats, deps, c14_Ind, cmap=cmocean.cm.ice_r, levels=levs, corner_mask=False, vmin=np.min(levs), vmax=np.max(levs), extend='both')
CS3 = plt.contour(lats, deps, c14_Ind, levels=contlevs, colors='black')
plt.scatter(c14_h_Ind[:,1], c14_h_Ind[:,2], s=50, c=c14_h_Ind[:,3], cmap=cmocean.cm.ice_r, marker='o', vmin=np.min(levs), vmax=np.max(levs))
plt.ylim(4400,0)
plt.xlim(-85,85)
plt.xticks(np.arange(-80,90,20), latitudes, family='serif', fontsize=12)
plt.yticks(np.arange(4000,0,-500), np.arange(4000,0,-500), family='serif', fontsize=12)

#%% Now we plot the three lower subplots, which are radiocarbon values at particular depths

### Panel (d) --> The global radiocarbon pre-industrial distribution @ 500 metres

# select the fourth subplot
ax1 = plt.subplot(gs[1,0])

# set title
plt.title('500 m', family='serif', fontsize=12)

# set the background colour of the figure to be grey, but do so using a pre-made bathymetry array called kmt10
plt.contourf(lons, lats, kmt10, cmap='Greys')

# produce filled and line contour plots using the c14_Atl 2D array in latitude and depth space 
plt.contourf(lons, lats, c14_500, cmap=cmocean.cm.ice_r, levels=levs, vmin=np.min(levs), vmax=np.max(levs), corner_mask=False, extend='both')
CS4 = plt.contour(lons, lats, c14_500, levels=contlevs, colors='black')
 

# Overlay the historical observations of radiocarbon using longitude (first column), latitude (second column), and colouring the markers according to the radiocarbon values (fourth column)
plt.scatter(c14_h_500[:,0], c14_h_500[:,1], s=50, c=c14_h_500[:,3], cmap=cmocean.cm.ice_r, marker='o', vmin=np.min(levs), vmax=np.max(levs))

# set the range for the x and y axes
plt.ylim(-90,90)
plt.xlim(-3,357)

# make the axis tick labels look nice
plt.yticks(np.arange(-80,90,20), latitudes, family='serif', fontsize=12)
plt.xticks(np.arange(0,360,60), longitudes, family='serif', fontsize=12)

 

### Panel (e) --> The global radiocarbon pre-industrial distribution @ 1000 metres
ax1 = plt.subplot(gs[1,1])
plt.title('1000 m', family='serif', fontsize=12)
plt.tick_params(axis='both', which='both', labelleft='off')
plt.contourf(lons, lats, kmt13, cmap='Greys')
plt.contourf(lons, lats, c14_1000, cmap=cmocean.cm.ice_r, levels=levs, vmin=np.min(levs), vmax=np.max(levs), corner_mask=False, extend='both')
CS5 = plt.contour(lons, lats, c14_1000, levels=contlevs, colors='black')
plt.scatter(c14_h_1000[:,0], c14_h_1000[:,1], s=50, c=c14_h_1000[:,3], cmap=cmocean.cm.ice_r, marker='o', vmin=np.min(levs), vmax=np.max(levs))
plt.ylim(-90,90)
plt.xlim(-3,357)
plt.yticks(np.arange(-80,90,20), latitudes, family='serif', fontsize=12)
plt.xticks(np.arange(0,360,60), longitudes, family='serif', fontsize=12)

 

### Panel (f) --> The global radiocarbon pre-industrial distribution @ 3000 metres
ax1 = plt.subplot(gs[1,2])
plt.title('3000 m', family='serif', fontsize=12)
plt.tick_params(axis='both', which='both', labelleft='off')
plt.contourf(lons, lats, kmt18, cmap='Greys')
plt.contourf(lons, lats, c14_3000, cmap=cmocean.cm.ice_r, levels=levs, vmin=np.min(levs), vmax=np.max(levs), corner_mask=False, extend='both')
CS6 = plt.contour(lons, lats, c14_3000, levels=contlevs, colors='black')
plt.scatter(c14_h_3000[:,0], c14_h_3000[:,1], s=50, c=c14_h_3000[:,3], cmap=cmocean.cm.ice_r, marker='o', vmin=np.min(levs), vmax=np.max(levs))
plt.ylim(-90,90)
plt.xlim(-3,357)
plt.yticks(np.arange(-80,90,20), latitudes, family='serif', fontsize=12)
plt.xticks(np.arange(0,360,60), longitudes, family='serif', fontsize=12)

 

#%% Here, we create the colourbar so that it fits nicely within the plot

# this package is required to make the "per mil" sign in the label
from __future__ import unicode_literals

# move the subplots around the figure so that the colourbar can fit on the right
plt.subplots_adjust(left=0.05, hspace=0.2, wspace=0.075, right=0.9)

# create a new axes within the figure for the colourbar
cax = fig.add_axes([0.92, 0.1, 0.02, 0.8])

# make the colourbar, label it, and set the tick labels
cbar = fig.colorbar(scat, cax=cax, orientation='vertical', extend='both')
cbar.set_label('$\delta^{14}$C (\u2030)',family='serif', fontsize=14)
cbar.ax.set_yticklabels(np.arange(-250,25,25), family='serif', fontsize=12)

#%% Here, each line contour plot on each of the six subplots is labeled manually

plt.clabel(CS1, fontsize=11, inline_spacing=6, fmt='%i', colors='black', manual=True)
plt.clabel(CS2, fontsize=11, inline_spacing=6, fmt='%i', colors='black', manual=True)
plt.clabel(CS3, fontsize=11, inline_spacing=6, fmt='%i', colors='black', manual=True)
plt.clabel(CS4, fontsize=11, inline_spacing=6, fmt='%i', colors='black', manual=True)
plt.clabel(CS5, fontsize=11, inline_spacing=6, fmt='%i', colors='black', manual=True)
plt.clabel(CS6, fontsize=11, inline_spacing=6, fmt='%i', colors='black', manual=True)

# and finally, we save the figure.
fig.savefig('radiocarbon.png', dpi=300, bbox_inches='tight')

 

UNSW logo ANU logo Monash logo UMelb logo UTAS logo