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
from mpltools import style
style.use('dark_background')

In [ ]:
# Constants.
x, y = 0, 0
n0 = 0.5
g = 9.8
rho = 1025
K = 0.02
l = 0.014
k = 0.014
w = 0.43
H = 100

X = np.arange(1, 21)
t = np.arange(1, 21)

Equations:


In [ ]:
N = n0 * np.cos((k * x) + (l * y) - (w * t))
P0 = (rho * g * n0) / (np.cosh(K * H)) * np.cosh(K * (0 + H)) * np.cos((k * x) + (l * y)-(w * t))
U0 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (0 + H)) * np.cos((k * x) + (l * y)-(w * t))
V0 = ((l * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (0 + H)) * np.cos((k * x) + (l * y)-(w * t))
W0 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.sinh(K * (0 + H)) * np.sin((k * x) + (l * y)-(w * t))

P10 = (rho * g * n0) / (np.cosh(K * H)) * np.cosh(K * (-10 + H)) * np.cos((k * x) + (l * y)-(w * t))
U10 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (-10 + H)) * np.cos((k * x) + (l * y)-(w * t))
V10 = ((l * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (-10 + H)) * np.cos((k * x) + (l * y)-(w * t))
W10 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.sinh(K * (-10 + H)) * np.sin((k * x) + (l * y)-(w * t))

P50 = (rho * g * n0) / (np.cosh(K * H)) * np.cosh(K * (-50 + H)) * np.cos((k * x) + (l * y)-(w * t))
U50 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (-50 + H)) * np.cos((k * x) + (l * y)-(w * t))
V50 = ((l * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (-50 + H)) * np.cos((k * x) + (l * y)-(w * t))
W50 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.sinh(K * (-50 + H)) * np.sin((k * x) + (l * y)-(w * t))

P100 = (rho * g * n0) / (np.cosh(K * H)) * np.cosh(K * (-100 + H)) * np.cos((k * x) + (l * y)-(w * t))
U100 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (-100 + H)) * np.cos((k * x) + (l * y)-(w * t))
V100 = ((l * g * n0) / w  * (np.cosh(K * H))) * np.cosh(K * (-100 + H)) * np.cos((k * x) + (l * y)-(w * t))
W100 = ((k * g * n0) / w  * (np.cosh(K * H))) * np.sinh(K * (-100 + H)) * np.sin((k * x) + (l * y)-(w * t))

In [ ]:
fig, ax = plt.subplots()
ax.plot(N)
ax.set_ylabel(r'$\eta$ [m]')
ax.set_xlabel('Time [s]')

fig, ax = plt.subplots()
ax.plot(X, U0, X, U10, X, U50, X, U100)
ax.set_ylabel(r'U [m s$^{-1}$]')
ax.set_xlabel('Time [s]')
ax.legend(('0 m', '10 m', '50 m', '100 m'))

fig, ax = plt.subplots()
plot(X, V0, X, V10, X, V50, X, V100)
ax.set_ylabel(r'V [m s$^{-1}$]')
ax.set_xlabel('Time [s]')
ax.legend(('0 m', '10 m', '50 m', '100 m'))

fig, ax = plt.subplots()
ax.plot(X, W0, X, W10, X, W50, X, W100)
ax.set_ylabel(r'W [m s$^{-1}$]')
ax.set_xlabel('Time [s]')
ax.legend(('0 m', '10 m', '50 m', '100 m'))

fig, ax = plt.subplots()
ax.plot(X, P0, X, P10, X, P50, X, P100)
ylabel('Pressure [Pa]')
ax.set_xlabel('Time [s]')
ax.legend(('0 m', '10 m', '50 m', '100 m'))

In [ ]:
HTML(html)