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)

Exemplo de ler e plotar os dados.


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))


               t       S    σ(θ)  δ(S,t,p)     <δ>  10e-5 ΔΦ
Pressure                                                    
0         25.698  35.221  23.296    457.24     NaN       NaN
1         25.698  35.221  23.296    457.28  457.26     0.046
10        26.763  36.106  23.658    423.15  440.22     0.396
20        26.678  36.106  23.658    423.66  423.41     0.423
30        26.676  36.107  23.659    423.98  423.82     0.424

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])


/home/filipe/miniconda/envs/SECOORA/lib/python2.7/site-packages/matplotlib/text.py:52: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if rotation in ('horizontal', None):
/home/filipe/miniconda/envs/SECOORA/lib/python2.7/site-packages/matplotlib/text.py:54: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  elif rotation == 'vertical':

In [7]:
HTML(html)


Out[7]:

"Aulas de Oceanografia Física Descritiva" by Filipe Fernandes is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Based on a work at http://ocefpaf.github.io/.

Check this post at nbviewer.