{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Basic test of the wflow BMI interface" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using matplotlib backend: Qt4Agg\n" ] } ], "source": [ "import wflow.wflow_bmi as bmi\n", "import logging\n", "%matplotlib\n", "reload(bmi)\n", "%matplotlib inline \n", "import datetime" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:32:57,658 - wflow_sbm.ini - WARNING - Could not read sample id-map for timeseries: /home/jaap/repos/wflow/examples/wflow_rhine_sbm/staticmaps/area.map\n", "WARNING:wflow_sbm.ini:Could not read sample id-map for timeseries: /home/jaap/repos/wflow/examples/wflow_rhine_sbm/staticmaps/area.map\n", "2015-05-19 18:32:57,670 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/RunoffGeneratingGWPerc.tbl) returning default value: 0.1\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/RunoffGeneratingGWPerc.tbl) returning default value: 0.1\n", "2015-05-19 18:32:57,695 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/rootdistpar.tbl) returning default value: -8000\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/rootdistpar.tbl) returning default value: -8000\n", "2015-05-19 18:32:57,702 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/CapScale.tbl) returning default value: 100.0\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/CapScale.tbl) returning default value: 100.0\n", "2015-05-19 18:32:57,704 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/K4.tbl) returning default value: 0.02307\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/K4.tbl) returning default value: 0.02307\n", "2015-05-19 18:32:57,721 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/MaxPercolation.tbl) returning default value: 0.0\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/MaxPercolation.tbl) returning default value: 0.0\n", "2015-05-19 18:32:57,767 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/MporeFrac.tbl) returning default value: 0.0\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/MporeFrac.tbl) returning default value: 0.0\n", "2015-05-19 18:32:57,790 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/WaterFrac.tbl) returning default value: 0.0\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/WaterFrac.tbl) returning default value: 0.0\n", "2015-05-19 18:32:57,794 - wflow_sbm.ini - WARNING - tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/et_reftopot.tbl) returning default value: 1.0\n", "WARNING:wflow_sbm.ini:tbl file not found (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/intbl/et_reftopot.tbl) returning default value: 1.0\n" ] } ], "source": [ "# This is the LAnd Atmophere (LA) model\n", "LA_model = bmi.wflowbmi_csdms()\n", "LA_model.initialize('../../examples/wflow_rhine_sbm/wflow_sbm.ini',loglevel=logging.WARN)\n", "\n", "# This is the routing (LA) model\n", "RT_model = bmi.wflowbmi_csdms()\n", "RT_model.initialize('../../examples/wflow_rhine_sbm/wflow_routing.ini',loglevel=logging.WARN)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "t_end = RT_model.get_end_time()\n", "t_start = RT_model.get_start_time()\n", "t = RT_model.get_current_time()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "27.0" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "(t_end - t_start)/(86400)\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:06,368 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.001) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.001) for timestep not present, returning 75.0\n", "2015-05-19 18:33:06,594 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "1995-02-01 00:00:00\n", "1995-02-02 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:06,804 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-03 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:07,013 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-04 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:07,222 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-05 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:07,431 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-06 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:07,667 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-07 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:07,879 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-08 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:08,087 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-09 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:08,298 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-10 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:08,526 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-11 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:08,734 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-12 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:08,955 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-13 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:09,159 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-14 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:09,376 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-15 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:09,578 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-16 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:09,801 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-17 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:10,013 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-18 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:10,227 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-19 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:10,426 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-20 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:10,627 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-21 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:10,830 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-22 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:11,027 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-23 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:11,227 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-24 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:11,442 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-25 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:11,654 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-26 00:00:00" ] }, { "name": "stderr", "output_type": "stream", "text": [ "2015-05-19 18:33:11,863 - wflow_sbm.ini - WARNING - Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n", "WARNING:wflow_sbm.ini:Climatology data (/home/jaap/repos/wflow/examples/wflow_rhine_sbm/monthlyclim/ROOT0000.002) for timestep not present, returning 75.0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "1995-02-27 00:00:00\n" ] } ], "source": [ "t_end = RT_model.get_end_time()\n", "t = RT_model.get_start_time()\n", "\n", "\n", "\n", "\n", "while t < t_end:\n", " LA_model.update()\n", " # Now set the output from the LA model (specific Q) as input to the RT model\n", " thevar = LA_model.get_value(\"InwaterMM\")\n", " RT_model.set_value(\"IW\",thevar) # The IW is set in the wflow_routing.ini var as a forcing\n", " RT_model.update()\n", " t = RT_model.get_current_time()\n", " \n", " print datetime.datetime.fromtimestamp(t)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "LA_model.finalize()\n", "RT_model.finalize()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }