$\eta = A \cos(kx - \omega t + \phi)$
$T = \frac{1}{f} = \frac{2\pi}{\omega} \rightarrow \left[\text{s} \right] $
$\text{L ou } \lambda = \frac{2\pi}{k} \rightarrow \left[ \text{m} \right]$
In [ ]:
import numpy as np
import matplotlib.pyplot as plt
def adjust_spines(ax,spines):
"""http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html"""
for loc, spine in ax.spines.items():
if loc in spines:
spine.set_position(('outward', 10))
spine.set_smart_bounds(True)
else:
spine.set_color('none')
if 'left' in spines:
ax.yaxis.set_ticks_position('left')
else:
ax.yaxis.set_ticks([])
if 'bottom' in spines:
ax.xaxis.set_ticks_position('bottom')
else:
ax.xaxis.set_ticks([])
In [ ]:
twopi = 2 * np.pi
n = 2 # Duas ondas.
A = 2 # Amplitude = 2 metros.
w = twopi / 10 # T = 10 segundos.
k = twopi / 200 # lambda = 200 metros.
phi = np.deg2rad(270) # Fase [rad]
t = np.arange(0, 10 * n, 0.01) # Vetor tempo [s]
x = np.arange(0, 200 * n) # Vetor espaço [m]
y1 = A * np.cos(w * t - k * 0 + phi) # Um ponto do oceano.
y2 = A * np.cos(w * 0 - k * x - phi) # Uma "foto" de um instante.
In [ ]:
fig, (ax0, ax1) = plt.subplots(nrows=2, sharey=True, figsize=(6, 4))
fig.tight_layout()
ax0.set_ylim([-2.1, 2.1])
ax0.plot(t, y1, linewidth='2', color='#CC9900')
ax0.axhline(color='grey')
adjust_spines(ax0, ['left','bottom'])
ax1.plot(x, y2, linewidth='2', color='#99CC33')
ax1.axhline(color='grey')
adjust_spines(ax1, ['left','bottom'])
fig.text(0, 0.5, 'Amplitude [m]', ha='right', va='center', rotation=90)
fig.text(1.01, 0.5, u'Período [s]', color='#CC9900')
_ = fig.text(1.01, 0.05, u'Distância [m]', color='#99CC33')