-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathplot_min_max_over_time.py
More file actions
56 lines (44 loc) · 2.09 KB
/
plot_min_max_over_time.py
File metadata and controls
56 lines (44 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Plots the maximums for one zone through time
Description
-----------
This connected-mode script creates a line graph of the min/max values from a zone
over time.
Usage:
> python plot_min_max_over_time.py
For example data, use the ICE example from the Getting Started Bundle
https://tecplot.azureedge.net/data/360GettingStarted.zip
"""
import tecplot as tp
from tecplot.constant import *
tp.session.connect() #connect to a live running instance of Tecplot 360
zone_name = input("Enter the zone name to investigate (use '*' for all zones, wildcards accepted to match multiple zones):")
var_name = input("Enter the variable name to investigate (e.g 'Pressure'):")
# Suspend the interface to speed up execution time
with tp.session.suspend():
dataset = tp.active_frame().dataset
min_values = []
max_values = []
var = dataset.variable(var_name)
zones_to_check = list(dataset.zones(zone_name))
for z in dataset.zones(zone_name):
print("Getting min/max for zone:",z.name)
min_values.append((z.solution_time, z.values(var).min()))
max_values.append((z.solution_time, z.values(var).max()))
# Create a new frame and stuff the extracted values into it for plotting
new_frame = tp.active_page().add_frame()
time_var_name = 't'
ds = new_frame.create_dataset(f'Min/Max {var.name} over time', [time_var_name,var.name])
zone = ds.add_ordered_zone(f'Min {var.name} over time ({zone_name})', len(min_values))
zone.values(time_var_name)[:] = [v[0] for v in min_values]
zone.values(var.name)[:] = [v[1] for v in min_values]
zone.aux_data['Source_Zone'] = zone_name
zone.aux_data['Source_Var'] = var_name
zone = ds.add_ordered_zone(f'Max {var.name} over time ({zone_name})', len(max_values))
zone.values(time_var_name)[:] = [v[0] for v in max_values]
zone.values(var.name)[:] = [v[1] for v in max_values]
zone.aux_data['Source_Zone'] = zone_name
zone.aux_data['Source_Var'] = var_name
line_plot = new_frame.plot(PlotType.XYLine)
line_plot.activate()
line_plot.linemaps().show = True
line_plot.view.fit()