Python Library TUFLOW Results
Introduction
For the 2016 version of TUFLOW a new output format for time-series was made available, this has the following changes from previous versions:
- Combines the 1D results, 2D plot outputs and new reporting location data
- The outputs are stored in a separate Plot folder in the TUFLOW results directory
- .tpc (TUFLOW Plot Control file links to data in csv and gis folders
- Has additional Node and Channel information files contain connectivity information
This is the default approach for the 2016 version but can be modified with the TUFLOW command "Output Approach == Pre 2016" (refer to the manual for more information on this command.
To make this data easier to work with an open source python library has been created and made available. This allows the user to load results and then interact with these. This library does not have any plotting functionality directly, with the returns typically being arrays (e.g. time and flows) however, the examples below give some examples using common plotting libraries such as matplotlib.
Dependencies
The TUFLOW results library calls a number of python libraries, these are:
- csv
- numpy
- os
- sys
Of these the csv, os and sys functionality should be available directly with the python install. Depending on the method used to install python numpy may need to be installed. If installation of numpy is required, please refer to the numpy documentation http://www.numpy.org/.
Compatible Python Versions
The functionality has been developed for Python 2.7, but should be compatible with Python 3.5. Other versions of python are currently untested.
Functionality
Import
This library is imported with the typical python syntax.
import TUFLOW_results2016
Initialise Results (ResData)
An instance of the results can be initialised with the following syntax:
res = TUFLOW_results2016.ResData()
Load Results
Results are loaded in with the syntax below.
error, message = res.Load(r'D:\TUFLOW\QGIS\test\plot\Plot_Example.tpc')
The two return arguments are:
- error (logical) set to True if an error has been encountered.
- message (string), if an error has occurred the message string will be populated with an error message.
Get Timeseries
Timeseries at a 1D, 2D or reporting location can be returned using the following syntax:
found, results, message = res.getTSData(<ID>,<domain>,<results type>,<geometry>)
The inputs to this are:
The return arguments are:
Examples
Other Versions
An older version that is compatible with results from the 2013 version of TUFLOW (this is limited to the 1D results for this version). This is currently undocumented, however, if you would like this please contact support@tuflow.com.