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)

Exemplo de como plotar perfil de CTD.

Primeiro importamos (carregamos) os módulos que vamos utilizar.


In [ ]:
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.axisartist as AA
from mpl_toolkits.axes_grid1 import host_subplot

Agora vamos ler um arquivo com dados de CTD.


In [ ]:
!cat dados/leia_me.txt

In [ ]:
PRS, TMP, SAL = np.loadtxt('dados/estacao15.dat', skiprows=1, usecols=(0, 3, 4), unpack=True)

Finalmente plotamos os dados.


In [ ]:
deg = u"\u00b0"

fig = plt.figure(figsize=(6, 8))
ax0 = host_subplot(111, axes_class=AA.Axes)
ax1 = ax0.twiny()

host_new_axis = ax0.get_grid_helper().new_fixed_axis
ax0.axis["bottom"] = host_new_axis(loc="top", axes=ax0, offset=(0, 0))
par_new_axis = ax1.get_grid_helper().new_fixed_axis
ax1.axis["top"] = par_new_axis(loc="bottom", axes=ax1, offset=(0, 0))

ax0.plot(TMP, PRS, linewidth=2.0, color='blue', label=r'Temperatura [%sC]' % deg)
ax1.plot(SAL, PRS, linewidth=2.0, color='grey', label=r'Salinidade [Kg g$^{-1}$]')

ax0.set_ylabel(u"Pressão [dbar]")
ax0.set_xlabel("Temperatura")
ax1.set_xlabel("Salinidade")
ax1.invert_yaxis()

title = r"Exemplo de perfil de CTD"
ax0.text(0.5, 0.99, title, horizontalalignment='center', verticalalignment='center', transform=fig.transFigure, rotation='horizontal')
_ = ax0.legend(shadow=True, fancybox=True, numpoints=1, loc='best')

In [ ]:
HTML(html)