PyTuflow: Difference between revisions

Content deleted Content added
No edit summary
Line 730:
::: '''data point:''' ''float''
:::: e.g. ([0, 1, 2, 3, 4, 5], [10, 20, 30, 20, 10, 0]
'''ExampleExamples'''<br>
Plotting results for multiple elements
<pre>
import matplotlib.pyplot as plt # plotting library
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 continuing
if not err:
# initialise plot
fig, ax = plt.subplots()
 
# get time series data and add to plot
elements = ['Chan_A', 'Chan_B', 'Chan_C']
result_type = 'H'
for element in elements:
err_ts, mess_ts, data = res.getTimeSeriesData(element, result_type)
# check for error before plotting
if not err_ts:
x, y = data
ax.plot(x, y, label=element)
else:
# error occurred getting long profile data, print error message to console
print(mess_ts)
# add legend to plot
lines, labs = ax.get_legend_handles_labels()
ax.legend(lines, labs)
# show plot
fig.show()
else:
# did not load correctly, print error message to console
print(message)
</pre>
 
==load==