In [1]:
%matplotlib inline
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 = "plot_profiles"
link = """<p>%s <a href="%s/%s"><em>nbviewer</em>.</a></p>""" % (text, uri, name)
html += str(link)
In [2]:
import gsw
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import style
from pandas import read_csv
style.use('dark_background')
In [3]:
lon, lat = -(70. + 59.59 / 60.), 36. + 40.03 / 60.
st61 = read_csv('Endeavor_Cruise-88_Station-61.csv', comment='#',
header=1, index_col=0)
In [4]:
print(st61.head(5))
In [5]:
kw = dict(linewidth=2)
fig, (ax0, ax1) = plt.subplots(ncols=2, sharey=True, figsize=(10, 6))
ax0.plot(st61['t'], st61.index, color='#FF6600', **kw)
ax0.set_ylabel(u"Pressão [dbar]")
ax0.set_xlabel(u"Temperatura [°C]")
ax0.grid()
ax0.invert_yaxis()
ax1.plot(st61['S'], st61.index, color='#00FFFF', **kw)
ax1.set_xlabel(r"Salinidade [g kg$^{-1}$]")
ax1.grid()
In [6]:
Te = np.arange(0, 32, 2)
Se = np.arange(32, 38.25, 0.25)
Sg, Tg = np.meshgrid(Se, Te)
cnt = np.arange(20, 34)
sigma_theta = gsw.sigma0_pt0_exact(Sg, Tg)
fig, ax = plt.subplots(figsize=(6, 6))
ax.plot(st61['S'], st61['t'], marker='o', markeredgecolor='w', markerfacecolor='#FF6600', linestyle='none')
ax.set_ylabel(u"Temperatura \u00b0C")
ax.set_xlabel(r"Salinidade [g kg$^{-1}$]")
cs = ax.contour(Se, Te, sigma_theta, colors='white', levels=cnt)
ax.clabel(cs, fontsize=9, inline=1, fmt='%2.1f')
_ = ax.axis([31.8, 37.2, 0.0, 30.0])
In [7]:
HTML(html)
Out[7]: