{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains material from [Controlling Natural Watersheds](https://jckantor.github.io/Controlling-Natural-Watersheds);\n", "content is available [on Github](https://github.com/jckantor/Controlling-Natural-Watersheds.git).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Changes to Rainy River Flows 1970-2010](http://nbviewer.jupyter.org/github/jckantor/Controlling-Natural-Watersheds/blob/master/notebooks/02.03-Changes_in_Rainy_River_Flows_1970-2010.ipynb) | [Contents](toc.ipynb) | [State of Nature Flows](http://nbviewer.jupyter.org/github/jckantor/Controlling-Natural-Watersheds/blob/master/notebooks/02.05-State-of-Nature-Flows.ipynb) >
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Flow Constrictions on Upper Rainy River"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Display graphics inline with the notebook\n",
"%matplotlib notebook\n",
"\n",
"# Standard Python modules\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import os\n",
"import datetime\n",
"\n",
"# Modules to display images and data tables\n",
"from IPython.display import Image\n",
"from IPython.core.display import display\n",
"\n",
"dir = '../data/'\n",
"img = '../figures/'\n",
"\n",
"hydat = pd.HDFStore('../data/hydat.h5')\n",
"DLY_LEVELS = hydat['DLY_LEVELS']\n",
"DLY_FLOWS = hydat['DLY_FLOWS']\n",
"STATIONS = hydat['STATIONS']\n",
"\n",
"def getFlowsWSC(s):\n",
" data = DLY_FLOWS[DLY_FLOWS['STATION_NUMBER'] == s]\n",
" ts = {}\n",
" for k in data.index:\n",
" mo = str(data.ix[k,'MONTH'])\n",
" yr = str(data.ix[k,'YEAR'])\n",
" for n in range(1,data.ix[k,'NO_DAYS']+1):\n",
" ts[pd.to_datetime(mo+'/'+str(n)+'/'+yr)] = data.ix[k,'FLOW'+str(n)] \n",
" ts = pd.Series(ts)\n",
" ts.name = STATIONS.ix[s,'STATION_NAME'] + ' (' + s + ')'\n",
" # drop initial and terminal null entries\n",
" j = 0\n",
" while pd.isnull(ts.ix[j]):\n",
" j += 1\n",
" k = len(ts.index) - 1\n",
" while pd.isnull(ts.ix[k]):\n",
" k += -1 \n",
" return ts[j:k]\n",
"\n",
"def getLevelsWSC(s):\n",
" global DLY_LEVELS\n",
" data = DLY_LEVELS[DLY_LEVELS['STATION_NUMBER'] == s]\n",
" ts = {}\n",
" for k in data.index:\n",
" mo = str(data.ix[k,'MONTH'])\n",
" yr = str(data.ix[k,'YEAR'])\n",
" for n in range(1,data.ix[k,'NO_DAYS']+1):\n",
" ts[pd.to_datetime(mo+'/'+str(n)+'/'+yr)] = data.ix[k,'LEVEL'+str(n)] \n",
" ts = pd.Series(ts)\n",
" ts.name = STATIONS.ix[s,'STATION_NAME'] + ' (' + s + ')'\n",
" # drop initial and terminal null entries\n",
" j = 0\n",
" while pd.isnull(ts.ix[j]):\n",
" j += 1\n",
" k = len(ts.index) - 1\n",
" while pd.isnull(ts.ix[k]):\n",
" k += -1\n",
" return ts[j:k]\n",
"\n",
"def mapWSC(stationList):\n",
" S = STATIONS.ix[stationList,['STATION_NAME','LATITUDE','LONGITUDE']]\n",
" locs = [\"{0},{1}\".format(S.ix[s,'LATITUDE'], S.ix[s,'LONGITUDE']) \\\n",
" for s in S.index]\n",
" google_maps_url = \\\n",
" \"https://maps.googleapis.com/maps/api/staticmap?\" + \\\n",
" \"size=640x320\" + \\\n",
" \"&maptype=terrain\" + \\\n",
" \"&markers=color:red%7Csize:mid%7C\" + \"|\".join(locs)\n",
" img = Image(url = google_maps_url) \n",
" display(img)\n",
" return S"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"