{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Basic test of the wflow BMI interface" ] }, { "cell_type": "code", "execution_count": 7, "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": 8, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2015-05-27 15:10:31,680 - wflow_sbm.ini - WARNING - Could not read sample id-map for timeseries: c:\\repos\\wflow\\examples\\wflow_rhine_sbm/staticmaps/area.map\n", "2015-05-27 15:10:31,680 - wflow_sbm.ini - WARNING - Could not read sample id-map for timeseries: c:\\repos\\wflow\\examples\\wflow_rhine_sbm/staticmaps/area.map\n", "WARNING:wflow_sbm.ini:Could not read sample id-map for timeseries: c:\\repos\\wflow\\examples\\wflow_rhine_sbm/staticmaps/area.map\n", "2015-05-27 15:10:31,707 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/RunoffGeneratingGWPerc.tbl) returning default value: 0.1\n", "2015-05-27 15:10:31,707 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/RunoffGeneratingGWPerc.tbl) returning default value: 0.1\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/RunoffGeneratingGWPerc.tbl) returning default value: 0.1\n", "2015-05-27 15:10:31,742 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/rootdistpar.tbl) returning default value: -8000\n", "2015-05-27 15:10:31,742 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/rootdistpar.tbl) returning default value: -8000\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/rootdistpar.tbl) returning default value: -8000\n", "2015-05-27 15:10:31,752 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/CapScale.tbl) returning default value: 100.0\n", "2015-05-27 15:10:31,752 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/CapScale.tbl) returning default value: 100.0\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/CapScale.tbl) returning default value: 100.0\n", "2015-05-27 15:10:31,759 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/K4.tbl) returning default value: 0.02307\n", "2015-05-27 15:10:31,759 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/K4.tbl) returning default value: 0.02307\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/K4.tbl) returning default value: 0.02307\n", "2015-05-27 15:10:31,776 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/MaxPercolation.tbl) returning default value: 0.0\n", "2015-05-27 15:10:31,776 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/MaxPercolation.tbl) returning default value: 0.0\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/MaxPercolation.tbl) returning default value: 0.0\n", "2015-05-27 15:10:31,858 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/MporeFrac.tbl) returning default value: 0.0\n", "2015-05-27 15:10:31,858 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/MporeFrac.tbl) returning default value: 0.0\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/MporeFrac.tbl) returning default value: 0.0\n", "2015-05-27 15:10:31,885 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/WaterFrac.tbl) returning default value: 0.0\n", "2015-05-27 15:10:31,885 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/WaterFrac.tbl) returning default value: 0.0\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/WaterFrac.tbl) returning default value: 0.0\n", "2015-05-27 15:10:31,890 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/et_reftopot.tbl) returning default value: 1.0\n", "2015-05-27 15:10:31,890 - wflow_sbm.ini - WARNING - tbl file not found (c:\\repos\\wflow\\examples\\wflow_rhine_sbm/intbl/et_reftopot.tbl) returning default value: 1.0\n", "WARNING:wflow_sbm.ini:tbl file not found (c:\\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": 9, "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": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "27.0" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "(t_end - t_start)/(86400)\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1995-02-01 00:00:00\n", "1995-02-02 00:00:00\n", "1995-02-03 00:00:00\n", "1995-02-04 00:00:00\n", "1995-02-05 00:00:00\n", "1995-02-06 00:00:00\n", "1995-02-07 00:00:00\n", "1995-02-08 00:00:00\n", "1995-02-09 00:00:00\n", "1995-02-10 00:00:00\n", "1995-02-11 00:00:00\n", "1995-02-12 00:00:00\n", "1995-02-13 00:00:00\n", "1995-02-14 00:00:00\n", "1995-02-15 00:00:00\n", "1995-02-16 00:00:00\n", "1995-02-17 00:00:00\n", "1995-02-18 00:00:00\n", "1995-02-19 00:00:00\n", "1995-02-20 00:00:00\n", "1995-02-21 00:00:00\n", "1995-02-22 00:00:00\n", "1995-02-23 00:00:00\n", "1995-02-24 00:00:00\n", "1995-02-25 00:00:00\n", "1995-02-26 00:00:00\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", "# Loop in time and put output of SBM in seperate routing module - 1way link\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.8" } }, "nbformat": 4, "nbformat_minor": 0 }