Difference between revisions of "PyTuflow"

From Tuflow
Jump to navigation Jump to search
Line 200: Line 200:
 
: '''Count:''' ''int''
 
: '''Count:''' ''int''
 
:: Number of connected channels
 
:: Number of connected channels
'''Examples'''
+
'''Example'''
 
<pre>
 
<pre>
 
import pytuflow as tu
 
import pytuflow as tu
Line 217: Line 217:
 
     # print to console     
 
     # print to console     
 
     print('{0} channels connected to {1}'.format(conn_count, node))
 
     print('{0} channels connected to {1}'.format(conn_count, node))
 +
else:
 +
    # did not load correctly, print error message to console
 +
    print(message)
 +
</pre>
 +
==channelConnections==
 +
 +
<b>channelConnections (</b> Node ID <b>)</b><br>
 +
Returns a list of the channels connected to a given node<br>
 +
;Parameters:
 +
: '''Node ID:''' ''str''
 +
:: Name or ID of node e.g. 'Chan_A.1'
 +
;Returns:
 +
: '''Out:''' ''list''
 +
:: List of connected channels e.g. ['Chan_A', 'Chan_B']
 +
'''Example'''
 +
<pre>
 +
import pytuflow as tu
 +
 +
# Initialise result class
 +
res = tu.ResData()
 +
 +
# load .tpc result file
 +
path = r'C:\TUFLOW\results\M04_5m_001.tpc'
 +
err, message = res.load(path)
 +
 +
# check results were loaded successfully before calling function
 +
if not err:
 +
    node = 'Chan_A.1'
 +
    conn_chans = res.channelConnections(node)
 +
    # print to console   
 +
    print('Channels connected to {0}:'.format(node))
 +
    for chan in conn_chans:
 +
        print(chan)
 
else:
 
else:
 
     # did not load correctly, print error message to console
 
     # did not load correctly, print error message to console
 
     print(message)
 
     print(message)
 
</pre>
 
</pre>

Revision as of 10:53, 11 February 2019

Class: ResData

Class for TUFLOW time series results.

Initialised as an empty object, or with results with a *.tpc in TUFLOW 2016 release and later or *.info in TUFLOW 2013 release.

import pytuflow as tu


res = tu.ResData()  # initialising as an empty object

# or

res = tu.ResData('M01_5m_001.tpc')  # initialising with results

Methods

Method Description Returns
channelConnectionCount ( str Node ID ) Returns the number of channels connected to a given node int Count
channelConnections ( str Node ID ) Returns a list of the channels connected to a given node list Channel IDs
channelCount ( str Node ID ) Returns the total number of channels in results int Count
channelResultTypes () Returns a list of all the available result types for channels list of Result Types
channels () Returns a list of all the channels IDs in the results list Channel IDs
channelsDownstream ( str Node ID ) Returns a list of all the channels downstream of a given node list Channel IDs
channelsUpstream ( str Node ID ) Returns a list of all the channels upstream of a given node list Channel IDs
format () Returns the result format i.e. '2013' or '2016' str Format
getAdverseGradients () Returns locations of any adverse water level or energy level (if result type available) gradients in long profile. Note getLongProfileData method must be called prior to calling this method tuple Adverse Water Level Gradient Locations ( list x data, list y data )
tuple Adverse Energy Level Gradient Locations ( list x data, list y data )
getLongProfileData ( float Timestep, str Result Type, str Channel ID, [optional] str 2nd Channel ID ) Returns long profile data from a given channel to another channel. If no second channel is specified will continue until no further channels downstream bool Error
str Message
tuple Profile Data ( list x values, list y values )
getLongProfileTimeOfMax () Returns the time of maximum water level along the current profile. Note getLongProfileData method must be called prior to calling this method list x values
list y values
getPipes () Returns any pipe or culvert data in the current profile. Note getLongProfileData method must be called prior to calling this method list pipes [ list pipe vertexes [ tuple vertex ( x point, y point ) ] ]
getTimeSeriesData ( str Element, str Result Type, [optional] str domain ) Returns time series data for the given element (1D node, 1D channel, 2D PO, RL) for a the given result type. If there are duplicate names between 1D, PO, or RL elements it will give priority return to 1D elements first, PO elements second, and lastly RL elements unless 'domain' variable is explicitly specified (domain options: '1D', '2D', 'RL') bool Error
str Message
tuple time series data ( list x data, list y data )
load ( str filepath ) Loads result file. File formats are *.tpc for TUFLOW release 2016 and later, or *.info for TUFLOW release 2013 bool Error
str Message
longProfileResultTypes () Returns list of available long profile result types list Result Types
maximum ( str Element, str Result Type, [optional] str Domain ) Returns the maximum result value for the given element (1D node, 1D channel, 2D PO, RL) for the given result type. If there are duplicate names between 1D, PO, or RL elements it will give priority return to 1D elements first, PO elements second, and lastly RL elements unless 'domain' variable is explicitly specified (domain options: '1D', '2D', 'RL') bool Error
str Message
float Maximum Value
maximumTimestepChange ( str Element, str Result Type, [optional] str Domain ) Returns the maximum change in result value in one timestep for the given element (RL elements supported only) for the given result type. If there are duplicate names between 1D, PO, or RL elements it will give priority return to 1D elements first, PO elements second, and lastly RL elements unless 'domain' variable is explicitly specified (domain options: '1D', '2D', 'RL') bool Error
str Message
float Maximum Value
name () Returns the name of the result str Name
nodeCount () Returns the total number of nodes in the results int Count
nodeDownstream ( str Channel ID ) Returns the name of the downstream node of a given channel str Node ID
nodeResultTypes ( str Channel ID ) Returns a list of all the available result types for nodes list Result Types
nodes () Returns a list of all the node IDs in the results list Node IDs
nodeUpstream ( str Channel ID ) Returns the name of the upstream node of a given channel str Node ID
poNames () Returns a list of all the available Plot Output names list PO ID
poResultTypes () Returns a list of all the available Plot Output result types list Result Types
rlCount () Returns the total number of Reporting Locations (of all geometry type) in the results int Count
rlLineCount () Returns the total number of line Reporting Locations in the results int Count
rlNames () Returns a list of all the Reporting Location names list RL ID
rlPointCount () Returns the total number of point Reporting Locations in the results int Count
rlRegionCount () Returns the total number of region Reporting Locations in the results int Count
rlResultTypes () Returns a list of all the available Reporting Location result types list Result Types
source () Returns the full file path to the source result file (*.tpc or *.info) str Path
timeOfMaximum ( str Element, str Result Type, [optional] str Domain ) Returns the time of maximum for the given element (1D node, 1D channel, 2D PO, RL) for the given result type. If there are duplicate names between 1D, PO, or RL elements it will give priority return to 1D elements first, PO elements second, and lastly RL elements unless 'domain' variable is explicitly specified (domain options: '1D', '2D', 'RL') bool Error
str Message
float Time (hrs)
timeOfMaximumTimestepChange ( str Element, str Result Type, [optional] str Domain ) Returns the time of maximum for change in result value in one timestep for the given element (RL elements supported only) for the given result type. If there are duplicate names between 1D, PO, or RL elements it will give priority return to 1D elements first, PO elements second, and lastly RL elements unless 'domain' variable is explicitly specified (domain options: '1D', '2D', 'RL') bool Error
str Message
float Time (hrs)

channelConnectionCount

channelConnectionCount ( Node ID )
Returns the number of channels connected to a given node

Parameters
Node ID: str
Name or ID of node e.g. 'Chan_A.1'
Returns
Count: int
Number of connected channels

Example

import pytuflow as tu

# Initialise result class
res = tu.ResData()

# load .tpc result file
path = r'C:\TUFLOW\results\M04_5m_001.tpc'
err, message = res.load(path)

# check results were loaded successfully before calling function
if not err:
    node = 'Chan_A.1'
    conn_count = res.channelConnectionCount(node)
    # print to console    
    print('{0} channels connected to {1}'.format(conn_count, node))
else:
    # did not load correctly, print error message to console
    print(message)

channelConnections

channelConnections ( Node ID )
Returns a list of the channels connected to a given node

Parameters
Node ID: str
Name or ID of node e.g. 'Chan_A.1'
Returns
Out: list
List of connected channels e.g. ['Chan_A', 'Chan_B']

Example

import pytuflow as tu

# Initialise result class
res = tu.ResData()

# load .tpc result file
path = r'C:\TUFLOW\results\M04_5m_001.tpc'
err, message = res.load(path)

# check results were loaded successfully before calling function
if not err:
    node = 'Chan_A.1'
    conn_chans = res.channelConnections(node)
    # print to console    
    print('Channels connected to {0}:'.format(node))
    for chan in conn_chans:
        print(chan)
else:
    # did not load correctly, print error message to console
    print(message)