In [ ]:
from IPython.core.display import HTML
with open('../../common/creativecommons.html', 'r') as f:
html = f.read()
with open('../../common/custom.css', 'r') as f:
styles = f.read()
HTML(styles)
text = 'Check this post at'
uri = 'http://nbviewer.ipython.org/urls/raw.github.com/ocefpaf/python4oceanographers/master/content/downloads/notebooks'
name = get_notebook_name()
link = """<p>%s <a href="%s/%s"><em>nbviewer</em>.</a></p>""" % (text, uri, name)
html += str(link)
In [ ]:
import os
import brewer2mpl
import cartopy.crs as ccrs
import matplotlib.ticker as mticker
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
from pandas import Panel
from gsw.utilities import read_data
In [ ]:
dark2_colors = brewer2mpl.get_map('Dark2', 'Qualitative', 7).mpl_colors
rcParams['figure.figsize'] = (10, 6)
rcParams['figure.dpi'] = 75
rcParams['axes.color_cycle'] = dark2_colors
rcParams['lines.linewidth'] = 2
rcParams['axes.facecolor'] = 'white'
rcParams['font.size'] = 14
rcParams['patch.edgecolor'] = 'white'
rcParams['patch.facecolor'] = dark2_colors[0]
rcParams['font.family'] = 'StixGeneral'
cmap = brewer2mpl.get_map('RdYlGn', 'diverging', 9).mpl_colormap
In [ ]:
data = read_data("gsw_data_v3_0.npz")
In [ ]:
lon, lat, p = map(np.float_, (data.longs_ref, data.lats_ref, data.p_ref))
In [ ]:
# deltaSA.
dsa = np.ma.masked_invalid(data.deltaSA_ref.transpose((2, 1, 0)))
dsa.data[dsa.mask] = 0
# SAAR (Absolute Salinity Ratio).
SAAR = np.ma.masked_invalid(data.SAAR_ref.transpose((2, 1, 0)))
SAAR.data[SAAR.mask] = 0
dsa = Panel(dsa, items=lon, major_axis=lat, minor_axis=p)
SAAR = Panel(SAAR, items=lon, major_axis=lat, minor_axis=p)
Absolute Salinity anomaly $\delta_{\text{SA}}$ at p $\sim$ 2000 dbar.
In [ ]:
deltaSA = dsa.minor_xs(2025).values
In [ ]:
fig, ax = plt.subplots(figsize=(10, 8), subplot_kw=dict(projection=ccrs.PlateCarree()))
cs = ax.pcolormesh(lon, lat, deltaSA, transform=ccrs.PlateCarree(),
cmap=cmap, zorder=0, clim=(0, 0.03))
cbar = fig.colorbar(cs, orientation='vertical', shrink=0.5, extend='both')
cbar.ax.set_ylabel(r"g kg$^{-1}$")
gl = ax.gridlines()
dx, dy = 40, 20
_ = ax.set_xticks(range(-180, 180 + dx, dx))
_ = ax.set_yticks(range(-90, 90 + dy, dy))
In [ ]:
fname = "delta_SA.png"
fig.savefig(fname, transparent=True)
_ = os.system('convert -trim %s %s' % (fname, fname))
In [ ]:
HTML(html)