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 numpy as np
import matplotlib.pyplot as plt

In [ ]:
g = 9.8
dt = 0.01
rel = np.arange(0.01, 0.6 + dt, dt)
err = 0.95


Cc = np.sqrt(np.tanh(2 * np.pi * rel))
Cl = np.sqrt((1 / (2 * np.pi * rel)) * np.tanh(2 * np.pi * rel))

fig, ax = plt.subplots()
ax.plot(rel, Cc, 'k')
ax.plot(rel, Cl, 'b')
ax.set_title('Velocity comparison by H/L [error > 5% in red]')
ax.set_xlabel('H/L')
ax.set_ylabel('C/Cc (preto) e C/Cl (Azul)')

errCc = Cc < err
errCl = Cl < err

ax.plot(rel[errCl], Cl[errCl], 'r')
ax.plot(rel[errCc], Cc[errCc], 'r')

a = rel[errCl].min()
b = rel[errCc].max()

In [ ]:
HTML(html)