Notebook to compare Tofino water levels to previous years.
import matplotlib.pyplot as plt
from salishsea_tools.nowcast import figures, residuals
import numpy as np
import datetime
from dateutil import tz
from salishsea_tools import stormtools
import arrow
import pandas as pd
import requests
from cStringIO import StringIO
import matplotlib
%matplotlib inline
start = '01-Jan-2014'; end = '31-Dec-2014'
wlev_2014 = figures.load_archived_observations('Tofino',start,end )
mean_2014 = wlev_2014.wlev.mean()
start = '01-Jan-2005'; end = '31-Dec-2014'
wlev_10yr = figures.load_archived_observations('Tofino',start,end )
mean_10yr = wlev_10yr.wlev.mean()
fig,ax=plt.subplots(1,1,figsize=(10,5))
s=wlev_2014['time'][wlev_2014.index[0]]
e=wlev_2014['time'][wlev_2014.index[-1]]
ax.plot(wlev_2014.time,wlev_2014.wlev,'g', label='2014 water levels')
ax.plot([s,e],[mean_2014,mean_2014],'-b',lw=2, label='2014 mean')
ax.plot([s,e],[mean_10yr,mean_10yr],'--k',lw=2,label='10yr mean')
ax.set_xlabel('metres')
plt.legend()
print 'mean 2014', mean_2014
print 'mean 10yr', mean_10yr
mean 2014 2.12706077601 mean 10yr 2.08611675446
2014 mean is about 4 cm higher than 10 yr mean.
Other years
means_ann={}
means_winter={}
means_summer={}
means=[]
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 1,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,12,31); ed=ed.replace(tzinfo=tz.tzutc())
mean = wlev_10yr[(wlev_10yr.time <= ed) & (wlev_10yr.time >= st)]['wlev'].mean()
means.append(mean)
print '{} Mean: {}'.format(yr, mean)
print 'Cummulative mean:', np.mean(np.mean(means))
means_ann['Tofino']=np.array(means)
2005 Mean: 2.10024250086 2006 Mean: 2.10803021632 2007 Mean: 2.0597378963 2008 Mean: 2.0437769661 2009 Mean: 2.0755643315 2010 Mean: 2.13724504979 2011 Mean: 2.07849358974 2012 Mean: 2.11923744292 2013 Mean: 2.00888221709 2014 Mean: 2.12601236122 Cummulative mean: 2.08572225719
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 11,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr+1,1,31); ed=ed.replace(tzinfo=tz.tzutc())
year = wlev_10yr[(wlev_10yr.time <= ed) & (wlev_10yr.time >= st)]
winter_mean = year['wlev'].mean()
means.append(winter_mean)
print '{} to {} Mean: {}'.format(st.strftime('%d-%b-%Y'), ed.strftime('%d-%b-%Y'),winter_mean)
print 'Cummulative Mean:', np.mean(np.array(means))
means_winter['Tofino']=np.array(means)
01-Nov-2005 to 31-Jan-2006 Mean: 2.23816849817 01-Nov-2006 to 31-Jan-2007 Mean: 2.20092906178 01-Nov-2007 to 31-Jan-2008 Mean: 2.16491075515 01-Nov-2008 to 31-Jan-2009 Mean: 2.11303113553 01-Nov-2009 to 31-Jan-2010 Mean: 2.31651258581 01-Nov-2010 to 31-Jan-2011 Mean: 2.23461327231 01-Nov-2011 to 31-Jan-2012 Mean: 2.10429487179 01-Nov-2012 to 31-Jan-2013 Mean: 2.23285583524 01-Nov-2013 to 31-Jan-2014 Mean: 2.01351487414 01-Nov-2014 to 31-Jan-2015 Mean: 2.29385783299 Cummulative Mean: 2.19126887229
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 6,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,8,31); ed=ed.replace(tzinfo=tz.tzutc())
year = wlev_10yr[(wlev_10yr.time <= ed) & (wlev_10yr.time >= st)]
summer_mean = year['wlev'].mean()
means.append(summer_mean)
print '{} to {} Mean: {}'.format(st.strftime('%d-%b-%Y'), ed.strftime('%d-%b-%Y'),summer_mean)
print '10yr Mean:', np.mean(np.array(means))
means_summer['Tofino']=np.array(means)
01-Jun-2005 to 31-Aug-2005 Mean: 2.00887395737 01-Jun-2006 to 31-Aug-2006 Mean: 1.9906819222 01-Jun-2007 to 31-Aug-2007 Mean: 2.01298855835 01-Jun-2008 to 31-Aug-2008 Mean: 2.00680091533 01-Jun-2009 to 31-Aug-2009 Mean: 2.02556064073 01-Jun-2010 to 31-Aug-2010 Mean: 1.96096567506 01-Jun-2011 to 31-Aug-2011 Mean: 1.99928604119 01-Jun-2012 to 31-Aug-2012 Mean: 2.018003663 01-Jun-2013 to 31-Aug-2013 Mean: 1.99447139588 01-Jun-2014 to 31-Aug-2014 Mean: 2.010201373 10yr Mean: 2.00278341421
def get_NOAA(station_no, start_date, end_date, product):
"""Retrieves recent NOAA water levels from a station in a given date range.
NOAA water levels are at 6 minute intervals and are relative to
mean sea level.
See: http://tidesandcurrents.noaa.gov/stations.html?type=Water+Levels.
:arg station_no: NOAA station number.
:type station_no: int
:arg start_date: The start of the date range; e.g. 01-Jan-2014.
:type start_date: str
:arg end_date: The end of the date range; e.g. 02-Jan-2014.
:type end_date: str
:returns: DataFrame object (obs) with time and wlev columns,
among others that are irrelevant.
"""
# Time range
st_ar = arrow.Arrow.strptime(start_date, '%d-%b-%Y')
end_ar = arrow.Arrow.strptime(end_date, '%d-%b-%Y')
base_url = (
'http://tidesandcurrents.noaa.gov/api/datagetter?')
params = {
'product': product,
'application': 'NOS.COOPS.TAC.WL',
'begin_date': st_ar.format('YYYYMMDD'),
'end_date': end_ar.format('YYYYMMDD'),
'datum': 'STND',
'station': str(station_no),
'time_zone': 'GMT',
'units': 'metric',
'format': 'csv',
}
response = requests.get(base_url, params=params)
fakefile = StringIO(response.content)
try:
obs = pd.read_csv(
fakefile, parse_dates=[0], date_parser=figures.dateparse_NOAA)
except ValueError:
data = {'Date Time': st_ar.datetime, ' Water Level': float('NaN')}
obs = pd.DataFrame(data=data, index=[0])
obs = obs.rename(columns={'Date Time': 'time', ' Water Level': 'wlev'})
return obs
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 1,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,12,31); ed=ed.replace(tzinfo=tz.tzutc())
wlev_NB =get_NOAA(figures.SITES['Neah Bay']['stn_no'],st.strftime('%d-%b-%Y'),ed.strftime('%d-%b-%Y'),'hourly_height')
mean = wlev_NB.wlev.mean()
means.append(mean)
print '{} Mean: {}'.format(yr, mean)
print '10yr mean', np.mean(np.array(means))
means_ann['Neah Bay']=np.array(means)
2005 Mean: 1.90511152968 2006 Mean: 1.91054315068 2007 Mean: 1.84638929498 2008 Mean: 1.84311372951 2009 Mean: 1.85891335616 2010 Mean: 1.93104486301 2011 Mean: 1.86976210046 2012 Mean: 1.91248258197 2013 Mean: 1.79901723744 2014 Mean: 1.91986472603 10yr mean 1.87962425699
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 11,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr+1,1,31); ed=ed.replace(tzinfo=tz.tzutc())
wlev_NB =get_NOAA(figures.SITES['Neah Bay']['stn_no'],st.strftime('%d-%b-%Y'),ed.strftime('%d-%b-%Y'),'hourly_height')
mean = wlev_NB.wlev.mean()
means.append(mean)
print '{} to {} Mean: {}'.format(st.strftime('%d-%b-%Y'), ed.strftime('%d-%b-%Y'),mean)
print 'Cummulative mean', np.mean(np.array(means))
means_winter['Neah Bay'] = np.array(means)
01-Nov-2005 to 31-Jan-2006 Mean: 2.02779302536 01-Nov-2006 to 31-Jan-2007 Mean: 2.00450724638 01-Nov-2007 to 31-Jan-2008 Mean: 1.95591802536 01-Nov-2008 to 31-Jan-2009 Mean: 1.91240217391 01-Nov-2009 to 31-Jan-2010 Mean: 2.08869791667 01-Nov-2010 to 31-Jan-2011 Mean: 2.02478985507 01-Nov-2011 to 31-Jan-2012 Mean: 1.89351494565 01-Nov-2012 to 31-Jan-2013 Mean: 2.02927853261 01-Nov-2013 to 31-Jan-2014 Mean: 1.81285869565 01-Nov-2014 to 31-Jan-2015 Mean: 2.03355978261 Cummulative mean 1.97833201993
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 6,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,8,31); ed=ed.replace(tzinfo=tz.tzutc())
wlev_NB =get_NOAA(figures.SITES['Neah Bay']['stn_no'],st.strftime('%d-%b-%Y'),ed.strftime('%d-%b-%Y'),'hourly_height')
mean = wlev_NB.wlev.mean()
means.append(mean)
print '{} to {} Mean: {}'.format(st.strftime('%d-%b-%Y'), ed.strftime('%d-%b-%Y'),mean)
print 'Cummulative mean', np.mean(np.array(means))
means_summer['Neah Bay']=np.array(means)
01-Jun-2005 to 31-Aug-2005 Mean: 1.80663360507 01-Jun-2006 to 31-Aug-2006 Mean: 1.7936861413 01-Jun-2007 to 31-Aug-2007 Mean: 1.79255932971 01-Jun-2008 to 31-Aug-2008 Mean: 1.80103577899 01-Jun-2009 to 31-Aug-2009 Mean: 1.79492798913 01-Jun-2010 to 31-Aug-2010 Mean: 1.76126721014 01-Jun-2011 to 31-Aug-2011 Mean: 1.78460643116 01-Jun-2012 to 31-Aug-2012 Mean: 1.79932971014 01-Jun-2013 to 31-Aug-2013 Mean: 1.78000543478 01-Jun-2014 to 31-Aug-2014 Mean: 1.79429393116 Cummulative mean 1.79083455616
fig,axs=plt.subplots(3,1,figsize=(10,10))
yrs = np.arange(2005,2015,1)
for key, c in zip(['Tofino','Neah Bay'], ['b','g']):
ax=axs[0]
ax.plot(yrs,means_ann[key], c=c,label =key)
ax.plot([yrs[0],yrs[-1]],[np.mean(means_ann[key]), np.mean(means_ann[key])], '--',c=c)
ax.set_title('Annual Mean Water Level')
ax=axs[1]
ax.plot(yrs,means_winter[key], c=c,label =key)
ax.plot([yrs[0],yrs[-1]],[np.mean(means_winter[key]), np.mean(means_winter[key])], '--',c=c)
ax.set_title('Nov-Jan Mean water level')
ax=axs[2]
ax.plot(yrs,means_summer[key], c=c,label =key)
ax.plot([yrs[0],yrs[-1]],[np.mean(means_summer[key]), np.mean(means_summer[key])], '--',c=c)
ax.set_title('Jun-Aug Mean water level')
x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
for ax in axs:
ax.xaxis.set_major_formatter(x_formatter)
ax.set_ylim([1.7,2.4])
ax.legend()
from salishsea_tools.nowcast import residuals
t_orig=datetime.datetime(2014,1,1)
t_final = datetime.datetime(2014,12,31)
start_date = t_orig.strftime('%d-%b-%Y')
end_date = t_final.strftime('%d-%b-%Y')
stn_no = figures.SITES['Neah Bay']['stn_no']
obs = get_NOAA(stn_no, start_date, end_date,'hourly_height')
tides = get_NOAA(stn_no, start_date, end_date, 'predictions')
res_obs_NB = residuals.calculate_residual(obs.wlev, obs.time, tides[' Prediction'], tides.time)
fig,ax = plt.subplots(1,1,figsize=(20,5))
ax.plot(obs.time,res_obs_NB)
mean = res_obs_NB.mean()
#ax.plot([obs.time.index[0], obs.time.index[-1]], [mean,mean],'--b')
ax.set_title('Time series for forcing and observed residuals')
print 'Annual mean residual', mean
Annual mean residual -0.00449372146119
If 2014 is a high water level year, then why is the mean residual negative?
from salishsea_tools.nowcast import residuals
t_orig=datetime.datetime(2013,1,1)
t_final = datetime.datetime(2013,12,31)
start_date = t_orig.strftime('%d-%b-%Y')
end_date = t_final.strftime('%d-%b-%Y')
stn_no = figures.SITES['Neah Bay']['stn_no']
obs = get_NOAA(stn_no, start_date, end_date,'hourly_height')
tides = get_NOAA(stn_no, start_date, end_date, 'predictions')
res_obs_NB = residuals.calculate_residual(obs.wlev, obs.time, tides[' Prediction'], tides.time)
fig,ax = plt.subplots(1,1,figsize=(20,5))
ax.plot(obs.time,res_obs_NB)
mean = res_obs_NB.mean()
#ax.plot([obs.time.index[0], obs.time.index[-1]], [mean,mean],'--b')
ax.set_title('Time series for forcing and observed residuals')
print 'Annual mean residual', mean
Annual mean residual -0.126170547945
2013 was a low water level year. Mean residual is negative
res={}
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 1,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,12,31); ed=ed.replace(tzinfo=tz.tzutc())
start_date = st.strftime('%d-%b-%Y')
end_date = ed.strftime('%d-%b-%Y')
stn_no = figures.SITES['Neah Bay']['stn_no']
obs = get_NOAA(stn_no, start_date, end_date,'hourly_height')
tides = get_NOAA(stn_no, start_date, end_date, 'predictions')
res_obs_NB = residuals.calculate_residual(obs.wlev, obs.time, tides[' Prediction'], tides.time)
mean = np.mean(res_obs_NB)
means.append(mean)
print '{} to {} Mean: {}'.format(st.strftime('%d-%b-%Y'), ed.strftime('%d-%b-%Y'),mean)
print 'Cummulative mean', np.mean(np.array(means))
res['annual'] = means
01-Jan-2005 to 31-Dec-2005 Mean: -0.0203574200913 01-Jan-2006 to 31-Dec-2006 Mean: -0.0138042237443 01-Jan-2007 to 31-Dec-2007 Mean: -0.0747854279651 01-Jan-2008 to 31-Dec-2008 Mean: -0.0826446948998 01-Jan-2009 to 31-Dec-2009 Mean: -0.0664906392694 01-Jan-2010 to 31-Dec-2010 Mean: 0.00672659817352 01-Jan-2011 to 31-Dec-2011 Mean: -0.054851369863 01-Jan-2012 to 31-Dec-2012 Mean: -0.0132654826958 01-Jan-2013 to 31-Dec-2013 Mean: -0.126170547945 01-Jan-2014 to 31-Dec-2014 Mean: -0.00449372146119 Cummulative mean -0.0450136929762
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 11,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr+1,1,31); ed=ed.replace(tzinfo=tz.tzutc())
start_date = st.strftime('%d-%b-%Y')
end_date = ed.strftime('%d-%b-%Y')
stn_no = figures.SITES['Neah Bay']['stn_no']
obs = get_NOAA(stn_no, start_date, end_date,'hourly_height')
tides = get_NOAA(stn_no, start_date, end_date, 'predictions')
res_obs_NB = residuals.calculate_residual(obs.wlev, obs.time, tides[' Prediction'], tides.time)
mean = np.mean(res_obs_NB)
means.append(mean)
print '{} to {} Mean: {}'.format(st.strftime('%d-%b-%Y'), ed.strftime('%d-%b-%Y'),mean)
print 'Cummulative mean', np.mean(np.array(means))
res['winter'] = means
01-Nov-2005 to 31-Jan-2006 Mean: -0.00138224637681 01-Nov-2006 to 31-Jan-2007 Mean: -0.0257413949275 01-Nov-2007 to 31-Jan-2008 Mean: -0.0701576086957 01-Nov-2008 to 31-Jan-2009 Mean: -0.113500905797 01-Nov-2009 to 31-Jan-2010 Mean: 0.0591557971014 01-Nov-2010 to 31-Jan-2011 Mean: -0.0050303442029 01-Nov-2011 to 31-Jan-2012 Mean: -0.132290307971 01-Nov-2012 to 31-Jan-2013 Mean: 0.00279528985507 01-Nov-2013 to 31-Jan-2014 Mean: -0.217135869565 01-Nov-2014 to 31-Jan-2015 Mean: 0.00438677536232 Cummulative mean -0.0498900815217
means = []
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 6,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,8,31); ed=ed.replace(tzinfo=tz.tzutc())
start_date = st.strftime('%d-%b-%Y')
end_date = ed.strftime('%d-%b-%Y')
stn_no = figures.SITES['Neah Bay']['stn_no']
obs = get_NOAA(stn_no, start_date, end_date,'hourly_height')
tides = get_NOAA(stn_no, start_date, end_date, 'predictions')
res_obs_NB = residuals.calculate_residual(obs.wlev, obs.time, tides[' Prediction'], tides.time)
mean = np.mean(res_obs_NB)
means.append(mean)
print '{} to {} Mean: {}'.format(st.strftime('%d-%b-%Y'), ed.strftime('%d-%b-%Y'),mean)
print 'Cummulative mean', np.mean(np.array(means))
res['summer'] = means
01-Jun-2005 to 31-Aug-2005 Mean: -0.00722644927536 01-Jun-2006 to 31-Aug-2006 Mean: -0.0194234601449 01-Jun-2007 to 31-Aug-2007 Mean: -0.0209270833333 01-Jun-2008 to 31-Aug-2008 Mean: -0.0134035326087 01-Jun-2009 to 31-Aug-2009 Mean: -0.0190851449275 01-Jun-2010 to 31-Aug-2010 Mean: -0.0519796195652 01-Jun-2011 to 31-Aug-2011 Mean: -0.0291055253623 01-Jun-2012 to 31-Aug-2012 Mean: -0.0150751811594 01-Jun-2013 to 31-Aug-2013 Mean: -0.0337423007246 01-Jun-2014 to 31-Aug-2014 Mean: -0.0187527173913 Cummulative mean -0.0228721014493
fig,axs=plt.subplots(3,1,figsize=(10,10))
yrs = np.arange(2005,2015,1)
key='Neah Bay'
ax=axs[0]
ax.plot(yrs,means_ann[key], c='b',label ='mean wlev')
ax.plot(yrs,res['annual'], c='g',label ='residual')
ax.set_title('Annual Means')
ax=axs[1]
ax.plot(yrs,means_winter[key], c='b',label ='mean wlev')
ax.plot(yrs,res['winter'], c='g',label ='residual')
ax.set_title('Winter Means')
ax=axs[2]
ax.plot(yrs,means_summer[key], c='b',label ='mean wlev')
ax.plot(yrs,res['summer'], c='g',label ='residual')
ax.set_title('Summer Means')
x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
for ax in axs:
ax.xaxis.set_major_formatter(x_formatter)
#ax.set_ylim([1.7,2.4])
ax.legend()
Centre both residuals and wlev about their 10 yr mean.
fig,axs=plt.subplots(3,1,figsize=(10,10))
yrs = np.arange(2005,2015,1)
key='Neah Bay'
ax=axs[0]
ax.plot(yrs,means_ann[key] - np.mean(means_ann[key]), c='b',label ='mean wlev')
ax.plot(yrs,res['annual']-np.mean(res['annual']), c='g',label ='residual')
ax.set_title('Annual Means')
ax=axs[1]
ax.plot(yrs,means_winter[key] - np.mean(means_winter[key]), c='b',label ='mean wlev')
ax.plot(yrs,res['winter']- np.mean(res['winter']), c='g',label ='residual')
ax.set_title('Winter Means')
ax=axs[2]
ax.plot(yrs,means_summer[key]- np.mean(means_summer[key]), c='b',label ='mean wlev')
ax.plot(yrs,res['summer'] - np.mean(res['summer']), c='g',label ='residual')
ax.set_title('Summer Means')
x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
for ax in axs:
ax.xaxis.set_major_formatter(x_formatter)
#ax.set_ylim([1.7,2.4])
ax.legend(loc=0)
ax.grid()
The curves are practically aligned. So I think we are doing the right thing.
The 10 year mean water level at NB is 1.85cm. 2014 is 1.92cm
The 10 year mean residual is -4.5cm. 2014 is -0.04cm.
start = '01-Jan-2005'; end = '31-Dec-2014'
wlev_10yr = figures.load_archived_observations('Point Atkinson',start,end )
tides,msl = stormtools.load_tidal_predictions('Point Atkinson_atide_compare8_01-Jan-2005_31-Dec-2018.csv')
mean_10yr = wlev_10yr.wlev.mean()
means=[]
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 1,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,12,31); ed=ed.replace(tzinfo=tz.tzutc())
mean = wlev_10yr[(wlev_10yr.time <= ed) & (wlev_10yr.time >= st)]['wlev'].mean()
means.append(mean)
print '{} Mean: {}'.format(yr, mean)
print 'Cummulative mean:', np.mean(np.mean(means))
means_ann['Point Atkinson']=np.array(means)
2005 Mean: 3.12569015056 2006 Mean: 3.14218138097 2007 Mean: 3.09581797367 2008 Mean: 3.07026255708 2009 Mean: 3.08191598947 2010 Mean: 3.15423371867 2011 Mean: 3.11629235348 2012 Mean: 3.15143297909 2013 Mean: 3.05776696807 2014 Mean: 3.15729541032 Cummulative mean: 3.11528894814
means=[]
means_res={}
msl=figures.SITES['Point Atkinson']['msl']
for yr in np.arange(2005,2015,1):
st = datetime.datetime(yr, 1,1); st=st.replace(tzinfo=tz.tzutc())
ed = datetime.datetime(yr,12,31); ed=ed.replace(tzinfo=tz.tzutc())
wlev = wlev_10yr[(wlev_10yr.time <= ed) & (wlev_10yr.time >= st)]['wlev']
time = wlev_10yr[(wlev_10yr.time <= ed) & (wlev_10yr.time >= st)]['time']
residual = residuals.calculate_residual(np.array(wlev),np.array(time), np.array(tides.pred_all)+msl, np.array(tides.time))
mean = np.mean(residual)
means.append(mean)
print '{} Mean: {}'.format(yr, mean)
print 'Cummulative mean:', np.mean(np.mean(means))
means_res['Point Atkinson']=np.array(means)
2005 Mean: 0.0348834322492 2006 Mean: 0.0514537538074 2007 Mean: 0.00610295626789 2008 Mean: -0.0200130471461 2009 Mean: -0.0086933961314 2010 Mean: 0.0645384469498 2011 Mean: 0.0270743274954 2012 Mean: 0.061097693635 2013 Mean: -0.0325515863569 2014 Mean: 0.06773889905 Cummulative mean: 0.025163147982
fig,axs=plt.subplots(1,1,figsize=(10,5))
yrs = np.arange(2005,2015,1)
key='Point Atkinson'
ax=axs
ax.plot(yrs,means_ann[key] - np.mean(means_ann[key]), c='b',label ='mean wlev PA')
ax.plot(yrs,means_res[key]-np.mean(means_res[key]), c='g',label ='residual PA')
key = 'Neah Bay'
ax.plot(yrs,means_ann[key] - np.mean(means_ann[key]), '--r',label ='mean wlev NB')
ax.plot(yrs,res['annual']-np.mean(res['annual']), '--k',label ='residual NB')
ax.set_title('Annual Means')
x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
ax.xaxis.set_major_formatter(x_formatter)
#ax.set_ylim([1.7,2.4])
ax.legend(loc=0)
ax.grid()
ax.set_ylabel('[m]')
<matplotlib.text.Text at 0x7f0ef61bea50>