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.
To run the model from Delft-FEWS the following actions need to be performed:
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.
Command line arguments:
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>
<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>rhine/inmaps/runinfo.xml</argument>
<argument>-w</argument>
<argument>./</argument>
<argument>-C</argument>
<argument>rhine</argument>
<argument>-I</argument>
<argument>wflow_sbm.ini</argument>
<argument>-T</argument>
<argument>86400</argument>
</arguments>
<timeOut>1200000</timeOut>
<overrulingDiagnosticFile>wflow_diag.xml</overrulingDiagnosticFile>
</executeActivity>
</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.
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.
Usage pre adapter:
wflow_adapt -M Pre -t InputTimeseriesXml -I inifile -T timestepInSeconds
Usage postadapter:
Issues:
Todo
rewrite and simplify convert log to XML
$Author$ $Id$ $Rev$
Gets the endtime of the run from the FEWS runinfo file
Gets the list of mapstacks fews expect from the runinfo file and create those
Gets the starttime from the FEWS runinfo file
Gets the number of timesteps from the FEWS runinfo file.
Converts a wflow log file to a Delft-Fews XML diag file
Main entry for using the module as a command line program (e.g. from the Delft-FEWS GA)
writes a mapstack xml file
Reads the pi-state xml file inxml and updates the data/time of the state using datetime. Writes updated file to outxml
Warning
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.
Converts and PI xml timeseries file to a number of tss files.
The tss files are created using the following rules:
- tss filename determined by the content of the parameter element with a ”.tss” postfix
- files are created in “outputdir”
- multiple locations will be multiple columns in the tss file written in order of appearance in the XML file
Gets Date/time info from XML file and creates .tss files with:
- Day of year
- Hour of day
- Others may follow
Set-up the logging system and return a logger object. Exit if this fails
Converts a .tss file to a PI-xml file