Python Library TUFLOW Results: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 18:
=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.
=Usage=
==Import==
This library is imported with the typical python syntax.<br>
<pre>import TUFLOW_results2016</pre>
==Initialise Results (ResData)==
The results data functionality has a class defined, this is named '''ResData'''. An instance of the results can be initialised with the following syntax:
<pre>res = TUFLOW_results2016.ResData()</pre>
==Defined Methods (Functions)==
==Load Results==▼
The following are the defined '''functions''' in the results data class (ResData).
▲===Load Results===
Results are loaded in with the syntax below.
<pre>error, message = res.Load(r'D:\TUFLOW\QGIS\test\plot\Plot_Example.tpc')</pre>
Line 31 ⟶ 34:
* 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 Time-series===
Time-series at a 1D, 2D or reporting location can be returned using the following syntax:
<pre>
Line 51 ⟶ 54:
Will return flow (Q) data for the 1D channel with ID ds3. The optional 'L' geometry indicates that this is stored on a line object in the GIS plot objects.
'''Note''' As the time data typically does not change (this is not a return argument) but can be accessed by the <tt>res.times</tt>. See the examples below.
===Long Profile Functions===
When dealing with 1D long profile data, if a single 1D channel is specified the data for all channels downstream will returned. If two channels are specified, long profile data will only be returned for the channels between the specified channels.
====Get Long Profile Connectivity (LP_getConnectivity)====
This determines and stores the connectivity of the specified channels. This is used in later routines to determine the channels and nodes to plot for the long profile. The syntax is:
<pre>error, message = res.LP_getConnectivity(<US Channel ID>,<US Channel ID or None>)</pre>
Line 71 ⟶ 74:
</pre>
Determines the channels between '''FC01.40''' and '''ds3''', an error will be returned if these channels are not connected.
====Get Long Profile Static Data (LP_getStaticData)====
Once the connectivity between two channels has been determined, this routine can be used to get data that does not change between time-steps. This includes:
* distance information
Line 81 ⟶ 84:
<li>error (logical) - Returns True if an error has been encountered when detecting the connectivity between the specified channel(s).</li>
<li>message (string) - If an error is returned this message string contains information on the issue.</li>
====Get Long Profile Data (LP_getData)====
This function gets data at a specific time. If looping through timesteps (e.g. for an animation) the channel connectivity and static data will not change between timesteps and therefore only the '''LP_getData''' will need to be repeated. The syntax is:
<pre>
Line 97 ⟶ 100:
</pre>
Returns the water level (head) data at time 1 hours using a search tolerance of 0.01 hours.
==Other Attributes==
Once initialised the ResData class also has a number of '''attributes''' associated with it as well as the '''defined functions''' described above, these are outlined in the table below.
{| align="center" class="wikitable"
! style="background-color:#005581; font-weight:bold; color:white;" width=25% | Attribute Name
! style="background-color:#005581; font-weight:bold; color:white;" width=25% | Type
! style="background-color:#005581; font-weight:bold; color:white;" width=50% | Description
|-
|script_version|| string || Contains a version number of the TUFLOW results library, e.g. '2016-01-AA'
|-
|filename|| string|| The full filepath to the .tpc file.
|-
|fpath|| string|| The path of the folder which contains the .tpc file.
|-
|nTypes|| integer|| The number of data types that are stored in the dataset.
|-
|Types || list || A lists of the data types that are stored in the dataset.
|-
|LP || class (LP) || Contains Long profile information, connectivity, distances etc.
|-
|Data_1D|| class(Data_1D) || The 1D results are all stored in this class.
|-
|Data_2D|| class(Data_2D) || The 2D results are all stored in this class.
|-
|Data_RL|| class(Data_RL) || The reporting location results are all stored in this class.
|-
|GIS|| class(GIS)|| This contains the information read in from the <tt>GIS Plot Layer</tt> csv files.
|-
|formatVersion|| integer || The format version of the results as defined in the .tpc file.
|-
|units || string || The units as defined in the .tpc. E.g. "Metric" or "English"
|-
|displayname || string || The simulation name e.g. "M04_5m_001_2015"
|-
|Index || class(PlotObjects)|| This contains data read from the "GIS Plot Objects"
|-
|nodes|| class(NodeInfo) || Contains information on the 1D nodes, as read from the "1D Node Info" .csv file.
|-
|Channels|| class(ChanInfo)|| Contains information on the 1D nodes, as read from the "1D Channel Info" .csv file.
|-
|times || numpy ndarray|| The active times. This is typically static, however calls to function '''getTS''' may cause this array to be updated (if the 1D or 2D outputs have a different output interval)
|}
<br>
=Examples=
These examples can be downloaded in .py format along with the example results from the TUFLOW website (link required).
<pre>
import os #operating system functions
| |||