Calibration of the wflow_sbm model for the Rhine catchment using EOBS data

Calibration of the wflow\_sbm model for the Rhine catchment using EOBS data

gets the current time in seconds after the start of the run
Assumed daily timesteps if not defined in the user model

Returns a numpy array (matrix) for the specified map and the current
timestep. If the maps is not dynamic the current staus of the map is
returns which may be undefined for maps that are filled with data 
at the end of a run
Missing value is -999

wf_DynamicFramework(userModel, lastTimeStep=0, firstTimestep=1, datetimestart=datetime.datetime(1990, 1, 1, 0, 0))

set single value in a map on row, col (0 based). All other values in the 
map remain the same. Numbering starts at the upper left corner.

Input: 
- mapname - string with name of map
- row - row to set the value in
- col - column to set the value in
- values - single scalar

set single value in a map on xcor, ycor (0 based). All other values in the 
map remain the same.

Input: 
- xcor - xcor to set the value in
- ycor - ycor to set the value in
- value - single scalar

Resumes the state variable of the previous timestep in memory
it uses the wf_supplyVariableNamesAndRoles() function to find them.
The variables are inserted into the model object

multiply a parameter map with a single scalar 
value. Current settings for dimensions are assumed.

Input: 

Saves the maps defined in the summary section to disk
[summary] # Single values or end values
[summary_sum] # accumulative maps over the model run
[summary_avg] # average of maps over the model run
[summary_max] # max of maps over the model run
[summary_min] # min of maps over the model run

set single value in an ldd on xcor, ycor (0 based). All other values in the 
map remain the same. Calls lddrepair to ensure the ldd is sound

Input: 
- mapname of tipy ldd - string with name of map
- values - single scalar (see pcraster ldddescription for legal values)
            e.g. use 5 for setting a pit

values - single scalar (see pcraster ldddescription for legal values)
          e.g. use 5 for setting a pit

e.g. use 5 for setting a pit

set a map with values from a python list or a single scalar 
value. In case a single value is specified the value will be distributed
uniformly over the map. Current settings for
dimensions are assumed.

Input: 
- values - single list of value of length rows * cols or a single
   scalar
   
values - single list of value of length rows * cols or a single
 scalar
 
scalar

Input:
- caseName - dir with case
- runId - run dir within case
- configfile - name of the configfile (.ini type)

Save maps to be used in memory at startup and do not call the ini file each time

set a map with values from a numpy array. Current settings for

Input: 
- values - numpy array

wf_DynamicFramework.createRunId(intbl='intbl', logfname='wflow.log', NoOverWrite=True, model='model', modelVersion='no version', level=10)

Create runId dir and copy table files to it
Also changes the working dir to the case/runid directory

returns a single value for row and col from the
map given (zero based).

Returns a list of variables
List of list with the following structure::

List of list with the following structure:

[[ name, role, unit]
[ name, role, unit]
...   
]
role: 0 = input (to the model)
      1 = is output (from the model)
      2 = input/output (state information)
      3 = model parameter
unit: 0 = mm/timestep
      1 = m^3/sec
      2 = m
      3 = degree Celcius
      4 = mm
      5 = -

The first time this function is called the exchangeitems object is filled
with data from the ini file.

Returns a pcrmap for the specified map and the current

wf_DynamicFramework.wf_multParameterValuesArea(mapname, value, areacode, areamapname)

multiply a parameter map with a single scalar
value for area with id area only. Current settings for dimensions are assumed.

Input:
- areacode - id of the area in the areamap
- areamapname - name of the areamap

Returns a python list for the specified map and the current
timestep. If the maps is not dynamic the current status of the map is
returned which may be undefined for maps that are filled with data 

wf_DynamicFramework.readtblDefault(pathtotbl, landuse, subcatch, soil, default, cloneMap=None)

returns a single value for the x and y coordinates from the
map given uses getValAtPoint(in_map,xcor,ycor) from terrain_lib.py

Resumes the state variables from disk as .map files (or arrays of maps files using
a _? postfix)

Returns a python list for the specified parameter map and the current
returned.

set a parameter map with values from a python list or a single scalar 
uniformly over the map. Current settings for dimensions are assumed.

Input: 
   scalar

 scalar

wf_DynamicFramework.wf_readmap(name, default, verbose=True, filetype='PCRaster')

Adjusted version of readmapNew. the style variable is used to indicated
how the data is read::

how the data is read:

1 - default: reads pcrmaps
2 - memory: assumes the map is made available (in memory) using
the in-memory interface

note:

the style variable is set using the variable list from the API
section in the ini file

Suspend the state variables to disk as .map files
Also saves the summary maps

set a map with values from a pcrmap. Current settings for

Input: 
- pcrmap - pcraster map

Save the state variable of the current timestep in memory
This function is normally called as part of the run. Normally there is
no need to call it directly.

wf_DynamicFramework.loggingSetUp(caseName, runId, logfname, model, modelversion, level=20)

Sets up the logging system assuming we are in the runId directory

This is a replacement for the standard pcraster/python DynamicFramwork class.It provides extra functionality to simplify linking the models build in the framwork
with other models. The provided functionality allows external programs to control
and interrogate the model.

Compared to the original pcraster class the usermodel needs to be extended with
the stateVariables() method which lists the state variables. Other items to be
exchanged most be listed in the API section of the .ini file

In addition, the following methods must also be called at  startup:

$Author: schelle $
$Id: wf_DynamicFramework.py 915 2014-02-10 07:33:56Z schelle $
$Rev: 915 $

readtblDefault() (wf_DynamicFramework.wf_DynamicFramework method)

wf_QuickResume() (wf_DynamicFramework.wf_DynamicFramework method)

wf_QuickSuspend() (wf_DynamicFramework.wf_DynamicFramework method)

wf_multParameterValues() (wf_DynamicFramework.wf_DynamicFramework method)

wf_multParameterValuesArea() (wf_DynamicFramework.wf_DynamicFramework method)

wf_saveTimeSeries() (wf_DynamicFramework.wf_DynamicFramework method)

wf_savedynMaps() (wf_DynamicFramework.wf_DynamicFramework method)

wf_savesummarymaps() (wf_DynamicFramework.wf_DynamicFramework method)

wf_setParameterValues() (wf_DynamicFramework.wf_DynamicFramework method)

wf_setValueLdd() (wf_DynamicFramework.wf_DynamicFramework method)

wf_setValueRowCol() (wf_DynamicFramework.wf_DynamicFramework method)

wf_setValuesAsNumpy() (wf_DynamicFramework.wf_DynamicFramework method)

wf_setValuesAsPcrMap() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyCurrentTime() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyGridDim() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyMapAsList() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyMapAsNumpy() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyMapAsPcrMap() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyParameterAsList() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyRowCol() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyScalar() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyScalarRowCol() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyVariableCount() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyVariableNames() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyVariableRoles() (wf_DynamicFramework.wf_DynamicFramework method)

wf_supplyVariableUnits() (wf_DynamicFramework.wf_DynamicFramework method)

First check if a prepared  maps of the same name is present
in the staticmaps directory. next try to
read a tbl file to match a landuse, catchment and soil map. Returns 
the default value if the tbl file is not found.

Input:
-  pathtotbl: full path to table file
-  landuse: landuse map
-  subcatch: subcatchment map
-  soil: soil map
-  default: default value
-  optional clonemap to check maps against

Output: 
- map constructed from tbl file or map with default value

D:\repos\wflow\wflow-py\wflow\wflow_adapt.py:docstring of wflow_adapt

    This function does not fully parse the xml file and will only work properly
if the xml files date the dateTime element written on one line.

Reads the pi-state xml file inxml and updates the data/time of
the state using datetime. Writes updated file to outxml

Can be use in scripts to set the date.time of the 
output state.xml that Delft-FEWS writes.

This function does not fully parse the xml file and will only work properly

mapstackxml(mapstackxml, mapstackname, locationname, parametername, Sdate, Edate, timestepsecs)

wflow_adapt is an adapter that links wflow to Delft-FEWS
(http://publicwiki.deltares.nl/display/FEWSDOC/Home). it is typically run from the
Delft-FEWS general adapter.

tss filename determined by the content of the parameter element with a ".tss" postfix

multiple locations will be multiple columns in the tss file written in order
of appearance in the XML file

D:\repos\wflow\wflow-py\wflow\wflow_adapt.py:docstring of wflow_adapt.main

Main entry for using the module as a command line program (e.g. from the Delft-FEWS GA)

D:\repos\wflow\wflow-py\wflow\wflow_adapt.py:docstring of wflow_adapt.setlogger

Set-up the logging system and return a logger object. Exit if this fails

Gets the list of mapstacks fews expect from the runinfo file and create those

D:\repos\wflow\wflow-py\wflow\wflow_adapt.py:docstring of wflow_adapt.log2xml

To run the model from Delft-FEWS the following actions need to be
performed:

wflow_[sbm|hbv].py needs to be run with the -F option where the argument refers
to a Delft-FEWS runinfo.xml file

you need to specify fewsrun=1 in the model section of the .ini file

The postadapter (wflow\_adapt.py) needs to be run after the wflow run

The postadapter (wflow_adapt.py) needs to be run after the wflow run

Because DELFT-FEWS exports the mapstacks beginning at 0 and pcraster
expects them to start at 1 you will need to add a delay of one
timesstep to mapstack timeseries exported to wflow. This will mean
the first timestep (.000) is empty but that one will be ignored by
wflow anyway.

The adapter also tries to convert the log messages of the model into Delft-FEWS diagnostics
XML format.

Also the adapter log files is converted to wflow_adapt_diag.xml

An example of executing wflow from the Delft-FEWS general adapter
is shown below:

<executeActivities>
<executeActivity>
<description>Run wflow</description>
<command><executable>bin-wflow\wflow_sbm.exe</executable></command>
    <arguments>
    <argument>-C</argument>
    <argument>rhine</argument>
    <argument>-F</argument>
    <argument>rhine/inmaps/runinfo.xml</argument>
    <argument>-f</argument>
</arguments>
<timeOut>7200000</timeOut>
</executeActivity>
<description>Run wflow post</description>
<command> <executable>bin-wflow\wflow_adapt.exe</executable> </command> <arguments>
    <argument>-M</argument>
    <argument>Post</argument>
    <argument>-s</argument>
    <argument>rhine/instate/state.xml</argument>
    <argument>-o</argument>
    <argument>rhine/instate/outstate.xml</argument>
    <argument>-r</argument>
    <argument>-w</argument>
    <argument>./</argument>
    <argument>-I</argument>
    <argument>wflow_sbm.ini</argument>
    <argument>-T</argument>
    <argument>86400</argument>
<timeOut>1200000</timeOut>
<overrulingDiagnosticFile>wflow_diag.xml</overrulingDiagnosticFile>
</executeActivities>

The wflow_adapt module can also be used by other programs to convert .tss files to
pi-xml vv. Below the API documentation of the module is given.

tss_topixml(tssfile, xmlfile, locationname, parametername, Sdate, timestep)

wflow_adapt.py: Simple wflow Delft-FEWS adapter in python. This file can be run
as a script from the command-line or be used as a module that provides (limited)
functionality for converting PI-XML files to .tss and back.

**wflow_adapt** -M Pre -t InputTimeseriesXml -I inifile -T timestepInSeconds

**wflow_adapt**-M Post -t InputTimeseriesXml -s inputStateFile -I inifile 
-o outputStateFile -r runinfofile -w workdir -C case -T timestepInSeconds [-R runId]

Delft-Fews exports data from 0 to timestep. PCraster starts to count at 1.
Renaming the files is not desireable. The solution is the add a delay of 1 
timestep in the GA run that exports the mapstacks to wflow.

There is a considerable amount of duplication (e.g. info in the runinfo.xml and
the .ini file that you need to specify again :-())

$Id: wflow_adapt.py 915 2014-02-10 07:33:56Z schelle $
$Rev: 915 $

D:\repos\wflow\wflow-py\wflow\wflow_delwaq.py:docstring of wflow_delwaq

add support for a coarser delwaq network based on supplied map.      

Unexpected possible title overline or transition.
Treating it as ordinary text because it's so short.

For each segment two sources (inflows) are constructed, fast and slow
each representing different runoff compartments from the wflow model.
Fast represents SOF [#]_, HOF [#]_ and SSSF [#]_ while Slow represent
groundwater flow.

To estimate load of different nutrients to Johor strait two wflow\_sbm models
have been setup. Next these models where linked to delwaq as follows:

To estimate load of different nutrients to Johor strait two wflow_sbm models

HOF: Hortonian Overland Flow (or infiltration excess Overland Flow)

SSSF: SubSurface Storm Flow. Rapid lateral flow through the
top part of the soil profile.

The above results in a system in which the different flow types (including
the LU type where they have been generated) can be traced throughout the
system. Each each gauge location the discharge and the flow components
that make up the discharge are reported.

.. figure:: _images/sing_24.png
        :width: 800px

        Figure: Discharge and flow types for a small Singapore catchment. The
        Singapore catchment are dominated by fast flow types but during the end
        of the dry periods the slow flow types start to rise in importance.

Figure: Discharge and flow types for a small Singapore catchment. The
Singapore catchment are dominated by fast flow types but during the end
of the dry periods the slow flow types start to rise in importance.

.. figure:: _images/malay_7.png

        Figure: Discharge, flow types and resulting total P for a catchment in
        Malaysia.

Figure: Discharge, flow types and resulting total P for a catchment in
Malaysia.

By assuming each flow type is an end-member in a mixing model we can add
fixed concentration of real parameters to the flow fractions and multiply
those with the concentrations of the end-membesrt modelled concentration
at the gauge locations can be obtained for each timestep.

.. figure:: _images/sbm_flowtypes.png

    Figure: Flow types in the topog\_sbm models used in the
    Singapore/Malaysia case. HOF = Hortonian or Infiltration excess
    overland flow. SOF = Saturation overland flow, GW = exfiltrating
    groundwater. Note that the subcell representation of saturated
    areas means that both SOF and GW can occur before a cell is
    completely saturated.

Figure: Flow types in the topog\_sbm models used in the
Singapore/Malaysia case. HOF = Hortonian or Infiltration excess
overland flow. SOF = Saturation overland flow, GW = exfiltrating
groundwater. Note that the subcell representation of saturated
areas means that both SOF and GW can occur before a cell is
completely saturated.

Figure: Flow types in the topog_sbm models used in the

The figure above shows the flow types in the models used in Singapore and
Malaysia. Groundwater flow (both from completely saturated cell and
subcell groundwater flow) makes up the Slow flow that is fed into the delwaq
model while SOF and HOF make up the Fast flow to the delwaq model. In addition
the water is also labelled according to the landuse type of the cell that
it flows out off.

The whole procedure was setup in a Delft-FEWS configuration that can run
the following steps operationally:

digraph Flows {
node[shape=record,width=.1,height=.1];
"Pre-Process P, T and PET data to match the model grid" -> "Run the hydrological Model"
"Run the hydrological Model" -> " Save all flows per cell"
" Save all flows per cell" -> "Feed flows per LU type and flow type to delwaq"
"Feed flows per LU type and flow type to delwaq" -> "Obtain flow fraction per LU and flow type at gauge locations"
"Obtain flow fraction per LU and flow type at gauge locations" -> "Multiply constituent concentration per LU and flow type with fraction"
"Multiply constituent concentration per LU and flow type with fraction" -> "Sum all fraction concentrations to obtain total concentration at gauge locations"
}

The volumes in the delwaq segment are taken from the wflow\_sbm
kinematic wave volumes

The volumes in the delwaq segment are taken from the wflow_sbm

Next the flow types are combined with the available land-use classes.
As such a Luclass times flowtypes matrix of constituents is made.
Each constituent (e.g. Slow flow of LU class 1) is traced troughout
the system. All constituents are conservative and have a
concentration of 1 as they flow in each segement.

To check for consistency an Initial water type and a Check water
type are introduced. The Initial water will leave the system gradually
after a cold start, the Check water type is added to each flow
component and should be 1 at each location in the system (Mass Balance
Check).

Check).

Fast represents SOF 

Writes the number of exchnages to file (number of rows in the pointer file)

The following very simple example demonstrated how the pointer file is
created.  First the pcraster ldd:

As can be seen both 9 and 10 are bottom points. The
generated pointer file is shown below::

generated pointer file is shown below:

 ;Written by dw_WritePointer
 ;nr of pointers is:  20
  1          3          0          0
  2          4          0          0
  3          5          0          0
  4          6          0          0
  5          7          0          0
  6          8          0          0
  7          9          0          0
  8         10          0          0
  9         -1          0          0
 10         -2          0          0
 -3          1          0          0
 -4          2          0          0
 -5          3          0          0
 -6          4          0          0
 -7          5          0          0
 -8          6          0          0
 -9          7          0          0
-10          8          0          0
-11          9          0          0
-12         10          0          0

D:\repos\wflow\wflow-py\wflow\wflow_delwaq.py:docstring of wflow_delwaq.readTS

Read a pcraster map for a timestep without using the dynamic framework

Converts a pcrmap to a numpy array.that is flattend and from which
missing values are removed. Used for generating delwaq data

dw_WriteSegmentOrExchangeData(ttime, fname, datablock, boundids, WriteAscii=True)

Writes a timestep to a segment/exchange data file (appends to an existing
file or creates a new one).

Input:
- time - time for this timestep  
- fname - File path of the segment/exchange data file</param>
- datablock - array with data
- boundids to write more than 1 block
- WriteAscii - set to 1 to alse make an ascii dump

The pointer file for delwaq is made using the following information:

The wflow\_ldd.map files is used to create the internal flow network,
it defines the segments and how water flows between the segments

The wflow_ldd.map files is used to create the internal flow network,

The number of inflows into each segment determines is taken
from the sources mapstacks (-S option). Together these sources
should include all the water that enters the kinematic wave
reservoir. These are the red and green arrows in the figure below

The delwaq network is generated for the area define in the
wflow_catchment map. The included area is define by all cells were the
catchment id in a cel is larger than 1.

.. figure:: _images/delwaq-exchanges.png
        :width: 640px

        Figure: How exchanges and inflows are connected

Within the includes_flow directory the following files are made:

surface.dat - surface area of the water per segment (N+1), noseq

length.dat - One timestep only (constant). Content is two times noq

Here nrseg is the number of segments (taken from the non-missing grid
cell in the wflow_ldd.map file) and noq is the number of exchanges which
is calculated as the number of segments plus number the of inflows
(in each segment) times the number of segments

Delwaq expects volumes to be instantanious values at the start of a
timestes while flows are integrated between tow timesteps. For volumes
N+1 timesteps are needed, for flows N timesteps.  The figure below
demonstrates this principle for N=4.

node0 [label="{Time|Volume|Flow integrated}"];
node1 [label="{T=0|Volume=0|Flow=0 to 1}"];
node2 [label="{T=1|Volume=1|Flow=1 to 2}"];
node3 [label="{T=2|Volume=2|Flow=2 to 3}"];
node4 [label="{T=3|Volume=3|Flow=3 to 4}"];
node5 [label="{T=4|Volume=4|May be zero}"];
node1 -> node2
node2 -> node3
node3 -> node4
node4 -> node5
}

The volume.dat file is filled with N+1 steps of volumes of the wflow
kinematic wave reservoir. To obtain the needed lag between the flows and
the volumes the volumes are taken from the kinematic wave reservoir one
timestep back (OldKinWaveVolume).

The flow.dat files is filled as follows. For each timestep internal
flows (within the kinematic wave reservoir, i.e. flows from segment to
segment) are written first (blue in the layout above). Next the flow
into each segment are written. Depending on how many inflow types are
given to the script (sources). For one type, one set of flows is
written, if there are two types two sets etc (green and red in the
layout above).

Writes B1_T0.inc, B2_outputtimers.inc, B2_sysclock.inc and /B2_simtimers.inc
Assumes daily timesteps for now!

An ldd is used to determine the from-to relations for delwaq using
the PCraster up/downstreams commands.
*amap* is used to link boundaries to the segments for delwaq (negative 
numbers). These are area based boundaries. Diffboun is a 
python dictionary with inflows for each
cell.

 is used to link boundaries to the segments for delwaq (negative 
cell.

Input:
- ldd
- map to determine the active points)
- difboun : number of inflow boundaries per cell
- layers [nr of soil layers (only vertical flow)]. 

Output:
- pointer, fromto, outflows, boundaries, segment
- matrix with 4 colums: from to, zero, zero.
- catchid

use savetxt("pointer.inc",pointer,fmt='%10.0f') to save this
for use with delwaq

The pointers list first contains the "internal" fluxes in
the kinematic wave reservoir, next the fluxes (1-n) into the 
kinematic wave reservoir.

Test option to seperate construction of network from filling of the input
arrays

Ad support to not only follow the kinematic wave reservoir but also
the flow trough the soil reservoirs. Basically make three layers:
    
    #. kinematic wave reservoir (surface water)
    #. unsaturated store (only vertical flow)
    #. saturated store (horizontal and vertical flow)

- add labeling of different inflows ( the information is already present)

Writes the boundary list file
B5\_boundlist.inc
Numbering is abs(exchnage id)

B5_boundlist.inc

add labeling of different inflows ( the information is already present)

it writes substances for the areas and an initial and mass balance 
check substance

The wflow\_delwaq module provides a set of functions to construct a
delwaq pointer file from a PCRaster local drainage network.
A command-line interface is provide that allows you to
create a delwaq model that can be linked to a wflow model.

The wflow_delwaq module provides a set of functions to construct a

The script sets-up a one-layer model (representing the kinematic wave
reservoir). Water is labeled according to the area and flux where it
enters the kinematic wave reservoir.

For the script to work a run of the wflow model must be available and a
template directory in which the delwaq model is created should also be
available. These are indicated by the -C -R and -D command line
options. The -R and -C options indicate the wflow case and wflow run
directories while the -D option indicates the delwaq template
directory.

debug/
fixed/
fixed/B2_numsettings.inc
fixed/B4_dispersion.inc
fixed/B4_dispx.inc
fixed/B9_Hisvar.inc
fixed/B9_Mapvar.inc
includes_deltashell/
includes_flow/
run.bat
dlwqlib.dll
libcta.dll
libiomp5md.dll
waq_plugin_wasteload.dll
delwaq1.exe
delwaq2.exe
deltashell.inp

The debug, includes_flow, and includes_deltashell directories are
filled by the script. After that delwaq1.exe and delwaq2.exe programs
may be run (the run.bat file shows how this is done)::

may be run (the run.bat file shows how this is done):

the script sets up delwaq such that the result for the wflow gauges locations
are stored in the deltashell.his file.

Simple export library for pcraster/python delwaq link. The module can be
used to export an ldd to a delwaq pointer file and fill the input arrays.
The library includes a command-line interface that allows you to setup
a delwaq model and feed it with forcing data.

This is an experimental version. A complete redesign is needed as this 
version is unstable and very poorly structured!

the wflow run should have saved at least the folowing mapstacks::

the wflow run should have saved at least the folowing mapstacks:

- self.OldKinWaveVolume=vol
- self.WaterLevel=lev
- self.SurfaceRunoff=run
- self.Inwater=inw  (or the different components that make up this flux)

The script always sets-up at least two Substances, Initial and Check. Initial
is present everywhere at startup and the concentration is zero
in all inputs. Check is not present at startup and set to 1 in all inputs.

The script takes an areamap that can be used to tag water as it enters the
model. This can be a landuse map, a subcatchment map etc. Furthermore water
can also be tagged based on the flux into the model.

The naming of the sustances is as follows: "Area" areamap_class inflow_number

-C: caseDir - set the wflow case directory to use
-R: runId - set the wflow runId to use
-T: Set last timestep
-O: set starttime ('%Y-%m-%d% H:%M:%S')
-a: Also write dynamic area data if this option is set
-j: if this option is set the static data is not generated (default is on) 
-A: sets the areamap used to specify the fraction sources. This can be
    a subcatcment map, a soil type map, a land use maps etc. Default is:
    staticmaps/wflow_subcatch.map (relative to the caseDir directory)
-D: delwaqdir - set the basedir to create the delwaq schematisation in 
-S: sourcemap - name of the wflow output map to use as source. 
    it should be a variable that flows into the kinematic wave routine
    inw is normally used as it contain all water per cell that flows into
    the kinematic wave function.
    Use multiple -S options to include multiple maps
-s: Set the model timesteps in seconds (default 86400)
-F: if set the model is expected to be run by FEWS. It will determine
    the timesteps from the runinfo.xml file and save the output initial
    conditions to an alternate location. The runinfo.xml file should be located
    in the inmaps directory of the case. 
-c: Name of the wflow configuration file

$Id: wflow_delwaq.py 813 2013-10-07 09:18:36Z schelle $
$Rev: 813 $

D:\repos\wflow\wflow-py\wflow\wflow_gr4.py:docstring of wflow_gr4.main

Perform command line execution of the model. This example uses the getopt
module to parse the command line options.

The user can set the caseName, the runDir, the timestep and the configfile.

The model  needs a number of settings in the ini file. The default name for the ini file
is wflow\_gr4.ini.

is wflow_gr4.ini.

[model]

Tslice=1
# Maximum upstream distance to update the flow in metres

[gr4]
dt = 1
B = 0.9
D = 1.25
X4 = 32.83
# X1,X2 and X3 are given as .tbl files or maps

[layout]
# if set to zero the cell-size is given in lat/long (the default)
sizeinmetres = 1

[outputmaps]
# Add maps here

# List all timeseries in tss format to save in this section. Timeseries are
# produced as averages per subcatchment. The discharge (run) timeseries
# is always saved (as samples at the gauge location)s.
[outputtss]
self.S_X1=S_X1
self.R_X3=R_X3
self.Pr=Pr
self.Q=Q

Supplies the current time in seconds after the start of the run
This function is optional. If it is not set the framework assumes
the model runs with daily timesteps.

An *experimental* implementation of the gr4 model. It is based on the hourly (gr4h) version

 implementation of the gr4 model. It is based on the hourly (gr4h) version

D:\repos\wflow\wflow-py\wflow\wflow_gr4.py:docstring of wflow_gr4.initUH2

D:\repos\wflow\wflow-py\wflow\wflow_gr4.py:docstring of wflow_gr4.mk_qres

Returns an array (or ayyar of maps) to store the 
delayed flow in

evaporation quantity substracted from the production reservoir [mm]

Initial part of the gr4 model, executed only once. Reads all static model
information (parameters) and sets-up the variables used in modelling.

capacity of the production store, accounts for soil moisture (number) [mm]

Suspends the model to disk. All variables needed to restart the model
are saved to disk as pcraster maps. Use resume() to re-read them

D:\repos\wflow\wflow-py\wflow\wflow_gr4.py:docstring of wflow_gr4

Usage:
wflow_gr4  [-l loglevel][-c configfile][-f][-h] -C case -R Runid -

-F: if set wflow is expected to be run by FEWS. It will determine
the timesteps from the runinfo.xml file and save the output initial
conditions to an alternate location. The runinfo.xml file should be located
in the inmaps directory of the case. Also set fewsrun=1 in the .ini file!    

in the inmaps directory of the case. Also set fewsrun=1 in the .ini file!

$Id: wflow_gr4.py 923 2014-03-13 13:48:37Z schelle $
$Rev: 923 $

This function is required. Read initial state maps (they are output of a 
previous call to suspend()). The implementation showns her is the most basic 
setup needed.

D:\repos\wflow\wflow-py\wflow\wflow_gr4.py:docstring of wflow_gr4.pcr_tanh

D:\repos\wflow\wflow-py\wflow\wflow_gr4.py:docstring of wflow_gr4.initUH1

The max length of the arrays is determined  by the X4 parameter (int(X4))

The X4 parameter is always uniform over that catchment. Howvere, the state
of the UH is determined per grid cell.

D:\repos\wflow\wflow-py\wflow\wflow_gr4.py:docstring of wflow_gr4.WflowModel

returns a list of state variables that are essential to the model. 
This list is essential for the resume and suspend functions to work.

This function is specific for each model and **must** be present.

production reservoir content at the beginning of the time step (divided by X1) [mm]

routing reservoir content at the beginning of the time step (divided by X3) [mm]

Changed in version 0.91: - Calculation of GWScale moved to resume() to allow fitting.

New in version 0.91: - added S-curve for freezing soil infiltration reduction calculations