Notebook to compare DFO tides with my tides
import matplotlib.pyplot as plt
import pandas as pd
from salishsea_tools import stormtools
import datetime
from dateutil import tz
import numpy as np
%matplotlib inline
def date_parser(s):
PST=tz.tzoffset("PST",-28800)
unaware =datetime.datetime.strptime(s, '%Y-%m-%d %H:%M')
aware = unaware.replace(tzinfo=tz.tzutc())
return aware
DFO_file='/data/nsoontie/MEOPAR/tools/SalishSeaNowcast/tidal_predictions/Observed_Jan.csv'
DFO=pd.read_csv(DFO_file,parse_dates=[1],header=0,names=['station','time','tides','e1','e2'],date_parser=date_parser)
my_file='/data/nsoontie/MEOPAR/analysis/Nancy/tides/Point Atkinson_t_tide_compare8_31-Dec-2013_02-Dec-2015.csv'
ttide1,msl=stormtools.load_tidal_predictions(my_file)
my_file='Point Atkinson_t_tide_compare8_31-Dec-2013_02-Dec-2015.csv'
ttide2,msl=stormtools.load_tidal_predictions(my_file)
ms1=3.10
fig,ax=plt.subplots(1,1,figsize=(10,5))
ax.plot(DFO.time,DFO.tides,'-o',label='DFO')
ax.plot(ttide1.time,ttide1.pred_all+3.10,'-o',label='no synthesis')
ax.plot(ttide1.time,ttide1.pred_8+3.10,label='pred_8')
ax.plot(ttide2.time,ttide2.pred_all+3.10,'-o',label='synthesis 2')
ax.set_xlim(datetime.datetime(2015,1,3),datetime.datetime(2015,1,10))
ax.legend(loc=0)
ax.grid()
Zoom on Dec 27
fig,ax=plt.subplots(1,1,figsize=(10,5))
ax.plot(DFO.time,DFO.tides,'-o',label='DFO')
ax.plot(ttide1.time,ttide1.pred_all+3.10,'-o',label='no synthesis')
ax.plot(ttide1.time,ttide1.pred_8+3.10,label='pred_8')
ax.plot(ttide2.time,ttide2.pred_all+3.10,'-o',label='synthesis 2')
ax.set_xlim(datetime.datetime(2015,1,4),datetime.datetime(2015,1,5))
ax.legend(loc=0)
ax.grid()
ax.set_ylim([4,5])
(4, 5)
Zoom on Dec 8 highs
fig,ax=plt.subplots(1,1,figsize=(10,5))
ax.plot(DFO.time,DFO.tides,'-o',label='DFO')
ax.plot(ttide1.time,ttide1.pred_all+3.10,'-o',label='no synthesis')
ax.plot(ttide1.time,ttide1.pred_8+3.10,label='pred_8')
ax.plot(ttide2.time,ttide2.pred_all+3.10,'-o',label='synthesis 2')
ax.set_xlim(datetime.datetime(2015,1,4),datetime.datetime(2015,1,5))
ax.legend(loc=0)
ax.grid()
ax.set_ylim([0,1])
(0, 1)
Zoom on Dec 8 middles
Looks like we are shifted in our tidal predictions. Eyeballing, we are 10-15cm low (pred_all)
How do means, maxes and mins compare for Dec 8-12?
PST=tz.tzoffset("PST",-28800)
t1=datetime.datetime(2015,1,4); t2=datetime.datetime(2015,1,5)
t1 = t1.replace(tzinfo=tz.tzutc())
t2 = t2.replace(tzinfo=tz.tzutc())
subDFO=np.array(DFO.tides)
timDFO=np.array(DFO.time)
indices = np.where(np.logical_and(timDFO >= t1, timDFO <= t2))
subDFO=subDFO[indices];
timDFO=timDFO[indices];
meanDFO=np.nanmean(subDFO); maxDFO=np.nanmax(subDFO); minDFO=np.nanmin(subDFO)
submine=np.array(ttide2.pred_all);
timmine=np.array(ttide2.time);
indices = np.where(np.logical_and(timmine >= t1, timmine <= t2))
submine=submine[indices] +msl;
timmine=timmine[indices];
meanmine=np.nanmean(submine); maxmine=np.nanmax(submine); minmine=np.nanmin(submine)
print 'DFO: Mean {}, Max {}, Min {}'.format(meanDFO,maxDFO,minDFO)
print 'Mine: Mean {}, Max {}, Min {}'.format(meanmine,maxmine,minmine)
DFO: Mean 3.13533217993, Max 4.627, Min 0.722 Mine: Mean 3.01864288, Max 4.475835, Min 0.605545
print 'Differences: Mean {}, Max {}, Min {}'.format(meanDFO-meanmine,maxDFO-maxmine,minDFO-minmine)
Differences: Mean 0.116689299931, Max 0.151165, Min 0.116455