forked from Tecplot/handyscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16_print_zone_info.py
More file actions
72 lines (63 loc) · 2.16 KB
/
16_print_zone_info.py
File metadata and controls
72 lines (63 loc) · 2.16 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
70
71
72
#!/usr/bin/env python
from __future__ import print_function
import os
from glob import glob
from textwrap import dedent
import tecplot
from tecplot.constant import ZoneType
# Run this script with "-c" to connect to Tecplot 360 on port 7600
# To enable connections in Tecplot 360, click on:
# "Scripting" -> "PyTecplot Connections..." -> "Accept connections"
import sys
if '-c' in sys.argv:
tecplot.session.connect()
def zone_info(zone):
"""Generate a dict of parameters describing a Zone"""
info = dict()
attrs = '''
name
zone_type
strand
num_elements
num_variables
dimensions
num_points_per_element
num_faces
num_points
rank
'''.split()
for attr in attrs:
info[attr] = getattr(zone, attr, None)
return info
examples_dir = tecplot.session.tecplot_examples_directory()
# print info for first three plt files found under the SimpleData directory
infiles = sorted(glob(os.path.join(examples_dir, 'SimpleData', '*.plt')))[:3]
for infile in infiles:
tecplot.data.load_tecplot(infile)
ds = tecplot.active_frame().dataset
print('File:', os.path.basename(infile))
print('Dataset:', ds.title)
# print first three zones in this dataset
for zone in [ds.zone(i) for i in range(min(ds.num_zones, 3))]:
info = zone_info(zone)
print(dedent('''\
Name: {name}
Type: {zone_type}
Strand: {strand}
Elems: {num_elements}
Points: {num_points}
Variables: {num_variables}'''.format(**info)))
if zone.zone_type == ZoneType.Ordered:
print(dedent('''\
Dimensions: {dimensions}
Points/Elem: {num_points_per_element}'''.format(**info)))
elif zone.zone_type in [ZoneType.FEPolygon,
ZoneType.FEPolyhedron]:
print(dedent('''\
Faces: {num_faces}
Rank: {rank}'''.format(**info)))
else:
print(dedent('''\
Rank: {rank}
Points/Elem: {num_points_per_element}'''.format(**info)))
print('\n')