-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathchange_solution_time_units.py
More file actions
49 lines (37 loc) · 1.54 KB
/
change_solution_time_units.py
File metadata and controls
49 lines (37 loc) · 1.54 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
"""Updating Solution Time in a running instance of Tecplot
Description
-----------
This connected-mode script (turn-on PyTecplot connections in the GUI) changes the solution time values
and stores the result as the new solution time and as zone aux data.
Use this script as a template for changing solution time units.
Usage:
General:
> python change_solution_time_units.py
Necessary modules
-----------------
datetime
A module with generic date and time abilities.
"""
import datetime
import tecplot as tp
tp.session.connect()
with tp.session.suspend():
for z in tp.active_frame().dataset.zones():
if z.strand > 0:
solution_time = z.solution_time
#
# Modify the units here
# example: seconds to hours
#
solution_time /= 3600
# Two methods can be used:
# Add Zone Auxiliary Data with the new values. This doesn't modify the original data and
# has more flexibility since you can use string values. For example you want to format
# the string to represent hh:mm:ss format.
z.aux_data["SolutionTime"] = str(datetime.timedelta(hours=solution_time))
# Or you can modify the value in place. This is limited to numeric values.
z.solution_time = solution_time
#
# If you added Zone Auxiliary Data, this will display the text (assuming FieldMap #1 has transient data).
#
tp.active_frame().add_text("&(AUXZONE[ACTIVEOFFSET=1]:SolutionTime)", position=(50,50))