Notebook that plots tides for different numbers of constituents at Cherry Point to show the importance of constituents beyond the top 8
# Basic Imports
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
# 25 Constituents from Cherry Point WA typed in from site :
# http://tidesandcurrents.noaa.gov/harcon.html?unit=0&timezone=0&id=9449424&name=Cherry+Point&state=WA
ncon = 25
a = np.zeros(ncon) # amplitudes (m)
p = np.zeros(ncon) # phases (GMT)
s = np.zeros(ncon) # speed (degrees/hour)
# the "Big" Eights
a[0] = 0.817; p[0] = 282.8; s[0] = 15.0410686 # K1
a[1] = 0.734; p[1] = 22.8; s[1] = 28.9841042 # M2
a[2] = 0.456; p[2] = 260.0; s[2] = 13.9430356 # O1
a[3] = 0.256; p[3] = 281.4; s[3] = 14.9589314 # P1
a[4] = 0.179; p[4] = 50.3; s[4] = 30.0 #S2
a[5] = 0.154; p[5] = 354.5; s[5] = 28.4397295 # N2
a[6] = 0.076; p[6] = 253.2; s[6] = 13.3986609 # Q1
a[7] = 0.05; p[7] = 50.5; s[7] = 30.0821373 # K2
# Lots more
a[8] = 0.05; p[8] = 280.1; s[8] = 0.0410686 # SA
a[9] = 0.045; p[9] = 316.1; s[9] = 15.5854433 # J1
a[10] = 0.032; p[10] = 329.5; s[10] = 16.1391017 # OO1
a[11] = 0.031; p[11] = 3.2; s[11] = 28.5125831 # NU2
a[12] = 0.027; p[12] = 37.8; s[12] = 15.0 # S1
a[13] = 0.027; p[13] = 310.9; s[13] = 14.4966939 # M1
a[14] = 0.025; p[14] = 58.6; s[14] = 29.5284789 # L2
a[15] = 0.024; p[15] = 132.4; s[15] = 1.0980331 # MF
a[16] = 0.023; p[16] = 236.5; s[16] = 0.0821373 # SSA
a[17] = 0.017; p[17] = 268.3; s[17] = 27.9682084 # MU2
a[18] = 0.017; p[18] = 323.7; s[18] = 27.8953548 # 2N2
a[19] = 0.015; p[19] = 245.6; s[19] = 13.4715145 # RHO
a[20] = 0.012; p[20] = 43.8; s[20] = 29.9589333 # T2
a[21] = 0.010; p[21] = 52.7; s[21] = 29.4556253 # LAM2
a[22] = 0.009; p[22] = 252.1; s[22] = 12.8542862 #2Q1
a[23] = 0.006; p[23] = 153.6; s[23] = 57.9682084 #M4
a[24] = 0.005; p[24] = 338.2; s[24] = 42.9271398 # 2MK3
# Not Included
# M6 a=0.003
# R2 a=0.002
# 2SM2 a=0.003
# MS4 a=0.003
# Now estimate the difference of using different numbers of consistuents
# Note that this does not take into account the astronomical corrections for the different
# constituents. Regardless this should give an estimate of the errors
tmax = 24*365. # one year in hours
npts = 20000 # number of points to cover the year
t = tmax*np.arange(0,1.,1./npts) # our time points
sum8 = np.zeros(npts) # initialize the total tidal amplitude for 8 constituents
diffy = np.zeros(ncon) # initialize the maximum difference between 8 and other numbers of constituents
amp = np.zeros(ncon) # initialize the maximum amplitude for each number of constituents
# a tide for 8 constituents
for i in range(8):
sum8 = sum8 + a[i]*np.cos(np.pi*(s[i]*t-p[i])/180.)
# for each number of constituents
for j in range(ncon):
# calculate the tide
sumall = np.zeros(npts)
for i in range(j):
sumall= sumall + a[i]*np.cos(np.pi*(s[i]*t-p[i])/180.)
# find the amplitude and difference from 8 constituents
amp[j] = 0.5*(sumall.max()-sumall.min())
diffy[j] = np.max(np.max(sumall-sum8),np.min(sumall-sum8))
# plot the tide with all constituents and the differece of using only 8
plt.figure(figsize=(10,8))
plt.subplot(2,1,1)
plt.plot(t/24., sumall)
plt.title("Tide using 25 Constituents")
plt.ylabel("Elevation (m)")
plt.xlim(0,365)
plt.subplot(2,1,2)
plt.plot(t/24.,sumall-sum8)
plt.title("Difference of only using 8 Constituents")
plt.ylabel("Elevation (m)")
plt.xlim(0,365)
plt.xlabel("Days")
<matplotlib.text.Text at 0x8ee4c10>
# plot how the amplitude and difference change as a function of number of constituents
plt.figure(figsize=(10,8))
plt.subplot(2,1,1)
plt.title("Half Range")
plt.ylabel("Half Range (m)")
plt.plot(amp,'*-')
plt.subplot(2,1,2)
plt.plot(diffy,'x-')
plt.title("Maximum Difference Compared to Using 8")
plt.ylabel("Difference (m)")
plt.xlabel("Number of Constituents")
plt.ylim(0,0.4)
(0, 0.4)