This notebook will use the tidal ellipse calculating functions on simple cases.
import os
import datetime
import matplotlib.pylab as plt
from matplotlib.patches import Ellipse
import numpy as np
import seaborn as sns
import netCDF4 as nc
from salishsea_tools import (viz_tools, tidetools as tt, ellipse)
from salishsea_tools.nowcast import research_VENUS
%matplotlib inline
phi = 0
w1 = 2
w2 = 4
t = np.arange(0,15,.2)
plt.xlim(-5,5)
plt.ylim(-5,5)
u = w1*np.cos(tt.M2FREQ*t-phi)
v = w2*np.sin(tt.M2FREQ*t-phi)
plt.plot(u,v)
[<matplotlib.lines.Line2D at 0x7fbbe214b450>]
uapparameters = ellipse.fittit(u,t, 2)
vapparameters= ellipse.fittit(v,t, 2)
print uapparameters['M2']['amp']
1.99999999799
CX, SX, CY, SY, ap, am, ep, em, majora, minora, thetaa, phasea= ellipse.ellipse_params(uapparameters['M2']['amp'], uapparameters['M2']['phase'], vapparameters['M2']['amp'], vapparameters['M2']['phase'])
plt.figure(figsize=(5,5))
plt.plot(u,v)
plt.xlim(-5,5)
plt.ylim(-5,5)
t=np.arange(0,95)
plt.plot(CX*np.cos(tt.M2FREQ*t-phi)+SX*np.sin(tt.M2FREQ*t-phi),
CY*np.cos(tt.M2FREQ*t-phi)+SY*np.sin(tt.M2FREQ*t-phi));
Let's look at Haro Strait for a long period of time to successfully seperate the harmonic constituents, however we cannot use velocity files from before November 26th 2014.
ih = [233]
jh = [312]
startdate = datetime.datetime(2014,11,26)
enddate = datetime.datetime(2015, 3, 10)
path = '/data/dlatorne/MEOPAR/SalishSea/nowcast/'
params, dep =ellipse.get_params_nowcast(startdate, enddate, ih, jh, path, 2)
print params
{'K1': {'Phase': array([[[ 200.49795871]], [[ 200.71975544]], [[ 200.98918907]], [[ 201.28815446]], [[ 201.57450383]], [[ 201.84744219]], [[ 202.11316128]], [[ 202.3615938 ]], [[ 202.59640018]], [[ 202.81331002]], [[ 203.02014214]], [[ 203.20824523]], [[ 203.39968501]], [[ 203.57352785]], [[ 203.75547297]], [[ 203.91949347]], [[ 204.10000599]], [[ 204.27496097]], [[ 204.48985287]], [[ 204.73804089]], [[ 205.06988977]], [[ 205.56221709]], [[ 206.2945956 ]], [[ 207.24090117]], [[ 209.06119526]], [[ 211.17020696]], [[ 212.53737261]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]], [[ 270. ]]]), 'Semi-Major Axis': array([[[ 0.40807359]], [[ 0.4067347 ]], [[ 0.40374123]], [[ 0.40042492]], [[ 0.39732416]], [[ 0.3942883 ]], [[ 0.39150682]], [[ 0.3890043 ]], [[ 0.38675255]], [[ 0.38482562]], [[ 0.38302706]], [[ 0.38145195]], [[ 0.37989318]], [[ 0.37848839]], [[ 0.37704947]], [[ 0.37572602]], [[ 0.37427585]], [[ 0.37282125]], [[ 0.37091668]], [[ 0.36869131]], [[ 0.36494207]], [[ 0.35960259]], [[ 0.34829585]], [[ 0.32961457]], [[ 0.29147059]], [[ 0.24254354]], [[ 0.18897117]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]]]), 'Semi-Minor Axis': array([[[ 0.09814517]], [[ 0.09766123]], [[ 0.09602464]], [[ 0.09357617]], [[ 0.09077078]], [[ 0.08760535]], [[ 0.08422768]], [[ 0.08072638]], [[ 0.07718469]], [[ 0.07366256]], [[ 0.07020546]], [[ 0.06678705]], [[ 0.06349895]], [[ 0.06025685]], [[ 0.05712024]], [[ 0.05402691]], [[ 0.05092058]], [[ 0.04770496]], [[ 0.04414913]], [[ 0.0400401 ]], [[ 0.03478629]], [[ 0.02848755]], [[ 0.02077598]], [[ 0.01461712]], [[ 0.01107521]], [[ 0.00942917]], [[-0.00240952]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]]]), 'Inclination': array([[[ 85.06807585]], [[ 85.11416202]], [[ 85.12419208]], [[ 85.14274504]], [[ 85.20772606]], [[ 85.29397083]], [[ 85.40495203]], [[ 85.54268324]], [[ 85.70210626]], [[ 85.88144659]], [[ 86.07026639]], [[ 86.274293 ]], [[ 86.48339244]], [[ 86.70479616]], [[ 86.92652165]], [[ 87.15686352]], [[ 87.38854888]], [[ 87.63950808]], [[ 87.90858989]], [[ 88.24265324]], [[ 88.63936746]], [[ 89.19478505]], [[ 89.81331184]], [[ 90.66839433]], [[ 90.69833001]], [[ 89.72848016]], [[ 88.6422957 ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]], [[ 90. ]]])}, 'M2': {'Phase': array([[[ 305.80632828]], [[ 305.66226496]], [[ 305.49310989]], [[ 305.31331385]], [[ 305.14713995]], [[ 304.98177548]], [[ 304.82814642]], [[ 304.6815768 ]], [[ 304.55040788]], [[ 304.42732979]], [[ 304.32046736]], [[ 304.22054092]], [[ 304.13476575]], [[ 304.05560951]], [[ 303.99041524]], [[ 303.92457286]], [[ 303.87287189]], [[ 303.81362119]], [[ 303.77281161]], [[ 303.70810608]], [[ 303.68448673]], [[ 303.60445925]], [[ 303.62378115]], [[ 303.44085315]], [[ 303.41430074]], [[ 302.33047502]], [[ 299.18857282]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]]]), 'Semi-Major Axis': array([[[ 0.8789502 ]], [[ 0.87536419]], [[ 0.86982953]], [[ 0.864128 ]], [[ 0.85858111]], [[ 0.85339536]], [[ 0.84850986]], [[ 0.84389884]], [[ 0.83945701]], [[ 0.83520749]], [[ 0.83108371]], [[ 0.82717841]], [[ 0.82333829]], [[ 0.8197051 ]], [[ 0.81606647]], [[ 0.81258689]], [[ 0.8089347 ]], [[ 0.80527487]], [[ 0.80087413]], [[ 0.79600686]], [[ 0.78860701]], [[ 0.7798667 ]], [[ 0.76545151]], [[ 0.74798573]], [[ 0.71768985]], [[ 0.64270735]], [[ 0.5846358 ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]]]), 'Semi-Minor Axis': array([[[ 0.10058271]], [[ 0.09956535]], [[ 0.09728948]], [[ 0.09460506]], [[ 0.09236964]], [[ 0.09063146]], [[ 0.08936019]], [[ 0.08839394]], [[ 0.08776772]], [[ 0.08735102]], [[ 0.08717878]], [[ 0.08713885]], [[ 0.08721936]], [[ 0.08735918]], [[ 0.08758245]], [[ 0.08778658]], [[ 0.08812845]], [[ 0.08835427]], [[ 0.08886567]], [[ 0.08915585]], [[ 0.09007229]], [[ 0.0901765 ]], [[ 0.09087813]], [[ 0.08676862]], [[ 0.08078194]], [[ 0.06241844]], [[ 0.04866439]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]]]), 'Inclination': array([[[ 80.27331614]], [[ 80.05193832]], [[ 79.7411418 ]], [[ 79.4737563 ]], [[ 79.27415042]], [[ 79.13352682]], [[ 79.04317816]], [[ 78.9857098 ]], [[ 78.95778413]], [[ 78.95011067]], [[ 78.96216212]], [[ 78.98879649]], [[ 79.02852423]], [[ 79.08121493]], [[ 79.1411757 ]], [[ 79.21401173]], [[ 79.29131318]], [[ 79.38883209]], [[ 79.49520739]], [[ 79.65329302]], [[ 79.83100564]], [[ 80.11678633]], [[ 80.38755687]], [[ 80.55761258]], [[ 80.19104918]], [[ 79.51659583]], [[ 76.41199193]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]], [[ 0. ]]])}}