-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathTimeStats.py
More file actions
69 lines (52 loc) · 2.09 KB
/
TimeStats.py
File metadata and controls
69 lines (52 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
57
58
59
60
61
62
63
64
65
66
67
68
69
"""Compute a Time Statistics of a Time Strand
usage:
> python TimeStats.py <Strand Number>
Input
-----
Strand Number - Optional- Defines the set of zones to calculate the average over.
If not supplied, all strands will be calculated.
Strand number can be found in Dataset Information dialog.
Description
-----------
This script assumes that a transient dataset is loaded into 360 with PyTecplot
Connections enabled via the Scripting menu. The result of the script will be two
new zones where one is the minimum value for each node through time and the other zone
will have the maximum value for each node through time.
Necessary modules
-----------------
tpmath
Useful Mathematical Utilities for PyTecplot
tputils
Generic PyTecplot Utilities
"""
import tecplot as tp
import tpmath
import tputils
import time
import sys
tp.session.connect()
try:
in_strand = int(sys.argv[1])
except:
in_strand = None
start = time.time()
with tp.session.suspend():
dataset = tp.active_frame().dataset
plot = tp.active_frame().plot()
# Assumes that the grid variables are constant and wont be calculated.
constant_variables = tputils.get_axes_variable_assignment(plot)
variables_to_compute = list(dataset.variables())
tp.macro.execute_command("$!FileConfig LoadOnDemand { UNLOADSTRATEGY = MinimizeMemoryUse }")
zones_by_strand = tputils.get_zones_by_strand(dataset)
if in_strand != None:
print("Computing statistics for strand: ", in_strand)
source_zones = zones_by_strand[in_strand]
tpmath.compute_statistics(source_zones, variables_to_compute, constant_variables)
else:
print("Computing statistics for all strands")
for strand, source_zones in zones_by_strand.items():
strand_start = time.time()
print("Computing statistics for strand: ", strand)
tpmath.compute_statistics(source_zones, variables_to_compute, constant_variables)
print("Time for strand {} = {}".format(strand, time.time()-strand_start))
print("Elapsed time: ", time.time()-start)