Namakan Lake Water Levels

The purpose of this notebook is to create a data series for the water level on Namakan Lake. The data series is written to a file NL.pkl that can be read into other notebooks using NL = pd.read_pickle('../data/NL.pkl').

The data series is constructed using data from stations 05PA003 from the Water Survey of Canada.

Read Data from Water Survey of Canada

The Water Survey of Canada currently maintains a station on Namakan Lake recording lake level. Station 05PA003, located just upstream of Kettle Falls, has been in place since 1911.

The data set is imported into the workspace by running the Water Survey of Canada notebook.

In [1]:
# Display graphics inline with the notebook
%matplotlib inline

# Standard Python modules
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
import datetime
import requests

import seaborn as sns
sns.set_context('talk')

# Modules to display images and data tables
from IPython.display import Image
from IPython.core.display import display

WSC_STATIONS = pd.read_pickle('../data/WSC_STATIONS')
WSC_LEVELS = pd.read_pickle('../data/WSC_LEVELS')

def mapWSC(stationList):
    # returns a .png map image
    S = WSC_STATIONS.ix[stationList,['STATION_NAME','LATITUDE','LONGITUDE']]
    locs = ["{0},{1}".format(S.ix[s,'LATITUDE'], S.ix[s,'LONGITUDE']) \
             for s in S.index]
    google_maps_url = \
        "https://maps.googleapis.com/maps/api/staticmap?" + \
        "size=640x320" + \
        "&maptype=terrain" + \
        "&markers=color:red%7Csize:mid%7C" + "|".join(locs)
    display(S)
    return Image(requests.get(google_maps_url).content)
In [2]:
kf = '05PA003'
sq = '05PA013'
mapWSC([kf,sq])
STATION_NAME LATITUDE LONGITUDE
STATION_NUMBER
05PA003 NAMAKAN LAKE ABOVE KETTLE FALLS DAM 48.50000 -92.63886
05PA013 NAMAKAN LAKE AT SQUIRREL ISLAND 48.49686 -92.65856
Out[2]:
In [3]:
plt.figure(figsize=(10,5))

WSC_LEVELS[kf].plot(lw=1)
WSC_LEVELS[sq].plot(lw=1)
plt.legend([WSC_STATIONS.ix[kf,'STATION_NAME'] + ' (' + kf + ')',
            WSC_STATIONS.ix[sq,'STATION_NAME'] + ' (' + sq + ')'])
plt.xlabel('Year')
plt.ylabel('Level [meters]')
Out[3]:
<matplotlib.text.Text at 0x115819b00>

Overlap Period

In [4]:
st = datetime.datetime(2007,1,1)
en = datetime.datetime(2008,12,31)

plt.figure(figsize=(10,5))
WSC_LEVELS[st:en][kf].plot()
WSC_LEVELS[st:en][sq].plot()

plt.legend([WSC_STATIONS.ix[kf,'STATION_NAME'] + ' (' + kf + ')',
            WSC_STATIONS.ix[sq,'STATION_NAME'] + ' (' + sq + ')'])
plt.xlabel('Year')
plt.ylabel('Level [meters]')
Out[4]:
<matplotlib.text.Text at 0x11937bf98>

Data Reconciliation

In [5]:
NL = WSC_LEVELS[[kf,sq]].mean(axis=1)
NL.name = 'NAMAKAN LAKE (RECONCILED)'

fig,ax = plt.subplots(1,1,figsize=(10,5))
NL.plot(lw=1)
plt.ylabel('level [meters]')
plt.title(NL.name \
          + ' from ' + NL.index.min().strftime('%m-%d-%Y') \
          + ' to ' + NL.index.max().strftime('%m-%d-%Y'))
Out[5]:
<matplotlib.text.Text at 0x112199400>

Writing the Namakan Lake Level Data Series to a File

In [6]:
NL.to_pickle('../data/NL.pkl')