pytecplot 1.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. pytecplot-1.5.2.dist-info/LICENSE.html +77 -0
  2. pytecplot-1.5.2.dist-info/METADATA +508 -0
  3. pytecplot-1.5.2.dist-info/RECORD +97 -0
  4. pytecplot-1.5.2.dist-info/WHEEL +5 -0
  5. pytecplot-1.5.2.dist-info/top_level.txt +1 -0
  6. tecplot/__init__.py +94 -0
  7. tecplot/annotation/__init__.py +7 -0
  8. tecplot/annotation/annotation.py +223 -0
  9. tecplot/annotation/geometry.py +369 -0
  10. tecplot/annotation/georeference.py +33 -0
  11. tecplot/annotation/image.py +185 -0
  12. tecplot/annotation/iter.py +105 -0
  13. tecplot/annotation/polyline.py +381 -0
  14. tecplot/annotation/text.py +744 -0
  15. tecplot/constant.py +401 -0
  16. tecplot/data/__init__.py +34 -0
  17. tecplot/data/array.py +645 -0
  18. tecplot/data/create.py +1 -0
  19. tecplot/data/dataset.py +1809 -0
  20. tecplot/data/extract.py +544 -0
  21. tecplot/data/face_neighbors.py +494 -0
  22. tecplot/data/facemap.py +814 -0
  23. tecplot/data/load.py +2075 -0
  24. tecplot/data/nodemap.py +577 -0
  25. tecplot/data/operate.py +928 -0
  26. tecplot/data/query.py +334 -0
  27. tecplot/data/save.py +343 -0
  28. tecplot/data/variable.py +280 -0
  29. tecplot/data/zone.py +841 -0
  30. tecplot/exception.py +201 -0
  31. tecplot/export/__init__.py +13 -0
  32. tecplot/export/animation.py +521 -0
  33. tecplot/export/export_setup.py +318 -0
  34. tecplot/export/image.py +577 -0
  35. tecplot/export/print_setup.py +218 -0
  36. tecplot/export/time_animation.py +607 -0
  37. tecplot/extension/__init__.py +14 -0
  38. tecplot/extension/ipython.py +68 -0
  39. tecplot/layout/__init__.py +20 -0
  40. tecplot/layout/frame.py +1285 -0
  41. tecplot/layout/layout.py +488 -0
  42. tecplot/layout/page.py +541 -0
  43. tecplot/legend/__init__.py +4 -0
  44. tecplot/legend/contour_legend.py +516 -0
  45. tecplot/legend/legend.py +141 -0
  46. tecplot/legend/line_legend.py +66 -0
  47. tecplot/legend/rgb_coloring_legend.py +291 -0
  48. tecplot/legend/scatter_legend.py +136 -0
  49. tecplot/macro.py +339 -0
  50. tecplot/plot/__init__.py +62 -0
  51. tecplot/plot/axes.py +881 -0
  52. tecplot/plot/axis.py +1350 -0
  53. tecplot/plot/blanking.py +584 -0
  54. tecplot/plot/contour.py +1302 -0
  55. tecplot/plot/effects.py +162 -0
  56. tecplot/plot/fieldmap.py +2159 -0
  57. tecplot/plot/grid.py +758 -0
  58. tecplot/plot/isosurface.py +1167 -0
  59. tecplot/plot/labels.py +338 -0
  60. tecplot/plot/linemap.py +1905 -0
  61. tecplot/plot/linking.py +489 -0
  62. tecplot/plot/plot.py +1791 -0
  63. tecplot/plot/rgb_coloring.py +281 -0
  64. tecplot/plot/scatter.py +396 -0
  65. tecplot/plot/slice.py +1544 -0
  66. tecplot/plot/streamtrace.py +1949 -0
  67. tecplot/plot/symbol.py +567 -0
  68. tecplot/plot/ticks.py +666 -0
  69. tecplot/plot/title.py +380 -0
  70. tecplot/plot/vector.py +679 -0
  71. tecplot/plot/view.py +868 -0
  72. tecplot/session/__init__.py +112 -0
  73. tecplot/session/aux_data.py +276 -0
  74. tecplot/session/config.py +92 -0
  75. tecplot/session/session.py +425 -0
  76. tecplot/session/state_changed.py +225 -0
  77. tecplot/session/style.py +504 -0
  78. tecplot/tecutil/__init__.py +16 -0
  79. tecplot/tecutil/arglist.py +230 -0
  80. tecplot/tecutil/captured_output.py +177 -0
  81. tecplot/tecutil/constant.py +1312 -0
  82. tecplot/tecutil/index_set.py +118 -0
  83. tecplot/tecutil/lock.py +36 -0
  84. tecplot/tecutil/message_pb2.py +39 -0
  85. tecplot/tecutil/preamble.py +54 -0
  86. tecplot/tecutil/stringlist.py +114 -0
  87. tecplot/tecutil/sv.py +1662 -0
  88. tecplot/tecutil/tecutil.py +12402 -0
  89. tecplot/tecutil/tecutil_client.py +627 -0
  90. tecplot/tecutil/tecutil_connector.py +937 -0
  91. tecplot/tecutil/tecutil_rpc.py +6845 -0
  92. tecplot/tecutil/util.py +332 -0
  93. tecplot/text/__init__.py +3 -0
  94. tecplot/text/font.py +224 -0
  95. tecplot/text/label_format.py +374 -0
  96. tecplot/text/textbox.py +106 -0
  97. tecplot/version.py +41 -0
@@ -0,0 +1,230 @@
1
+ from collections.abc import Iterable
2
+ from collections import OrderedDict, namedtuple
3
+ from enum import Enum
4
+ from ctypes import (c_char, c_char_p, c_double, c_int, c_int64, c_size_t,
5
+ c_void_p, byref, cast, pointer, POINTER)
6
+
7
+ from .tecutil_connector import _tecutil, _tecutil_connector
8
+ from ..exception import *
9
+ from .. import version
10
+ from ..constant import ArgListArgType
11
+ from .stringlist import StringList
12
+ from .index_set import IndexSet
13
+ from .util import Index
14
+
15
+
16
+ class RemoteArgList(c_void_p):
17
+ """Dict-like object holding string,object pairs."""
18
+ def __init__(self, *args, **kwargs):
19
+ super().__init__(_tecutil.ArgListAlloc())
20
+ self._handles = {}
21
+ self._nargs = 0
22
+ for a in args:
23
+ self.update(**a)
24
+ self.update(**kwargs)
25
+
26
+ # data access
27
+ def _index(self, key):
28
+ try:
29
+ success, index = _tecutil.ArgListGetIndexByArgName(self, key)
30
+ if success:
31
+ return index - 1
32
+ except TecplotSystemError:
33
+ return None
34
+
35
+ def _key(self, index):
36
+ return _tecutil.ArgListGetArgNameByIndex(self, index + 1)
37
+
38
+ def _type(self, index):
39
+ return ArgListArgType(_tecutil.ArgListGetArgTypeByIndex(self, index+1))
40
+
41
+ def _item(self, index):
42
+ get_by_index = {
43
+ ArgListArgType.ArbParam: _tecutil.ArgListGetArbParamByIndex,
44
+ ArgListArgType.ArbParamPtr: _tecutil.ArgListGetArbParamPtrByIndex,
45
+ ArgListArgType.Array: _tecutil.ArgListGetArrayByIndex,
46
+ ArgListArgType.Double: _tecutil.ArgListGetDoubleByIndex,
47
+ ArgListArgType.DoublePtr: _tecutil.ArgListGetDoublePtrByIndex,
48
+ ArgListArgType.Int: _tecutil.ArgListGetIntByIndex,
49
+ ArgListArgType.Set: _tecutil.ArgListGetSetByIndex,
50
+ ArgListArgType.String: _tecutil.ArgListGetStringByIndex,
51
+ ArgListArgType.StringList: _tecutil.ArgListGetStringListByIndex,
52
+ ArgListArgType.StringPtr: _tecutil.ArgListGetStringPtrByIndex, }
53
+ item_type = self._type(index)
54
+ if index in self._handles and item_type is ArgListArgType.Int:
55
+ return self._handles[index]
56
+ else:
57
+ return get_by_index[item_type](self, index + 1)
58
+
59
+ def __getitem__(self, key):
60
+ index = self._index(key)
61
+ return self._item(index)
62
+
63
+ def __setitem__(self, key, val):
64
+ if __debug__:
65
+ if key in self.keys():
66
+ raise TecplotLogicError('Duplicate ArgList key: '+key)
67
+ # ignore all values set to None.
68
+ if val is None:
69
+ return
70
+ if isinstance(val, StringList):
71
+ self._handles[self._nargs] = val
72
+ _tecutil.ArgListAppendStringList(self, key, val)
73
+ elif isinstance(val, IndexSet):
74
+ self._handles[self._nargs] = val
75
+ _tecutil.ArgListAppendSet(self, key, val)
76
+ elif isinstance(val, str):
77
+ _tecutil.ArgListAppendString(self, key, val)
78
+ elif isinstance(val, (float, c_double)):
79
+ _tecutil.ArgListAppendDouble(self, key, val)
80
+ elif isinstance(val, POINTER(c_double)):
81
+ self._handles[self._nargs] = val
82
+ _tecutil.ArgListAppendDoublePtr(self, key, val)
83
+ elif isinstance(val, Index):
84
+ self._handles[self._nargs] = val
85
+ _tecutil.ArgListAppendInt(self, key, val + 1)
86
+ elif isinstance(val, (int, bool)):
87
+ _tecutil.ArgListAppendInt(self, key, val)
88
+ elif isinstance(val, Enum):
89
+ _tecutil.ArgListAppendInt(self, key, val.value)
90
+ elif isinstance(val, c_size_t):
91
+ _tecutil.ArgListAppendArbParam(self, key,
92
+ cast(byref(val), POINTER(c_int64)).contents)
93
+ elif isinstance(val, POINTER(c_size_t)):
94
+ val = cast(val, POINTER(c_int64))
95
+ self._handles[self._nargs] = val
96
+ _tecutil.ArgListAppendArbParamPtr(self, key, val)
97
+ elif isinstance(val, POINTER(POINTER(c_char))):
98
+ self._handles[self._nargs] = val
99
+ _tecutil.ArgListAppendArbParamPtr(self, key, val)
100
+ elif isinstance(val, POINTER(c_char_p)):
101
+ self._handles[self._nargs] = val
102
+ _tecutil.ArgListAppendStringPtr(self, key, val)
103
+ else:
104
+ if isinstance(val, Iterable):
105
+ val = list(val)
106
+ if isinstance(val, list):
107
+ if isinstance(val[0], Enum):
108
+ v = (c_int * len(val))(*[e.value for e in val])
109
+ self._handles[self._nargs] = v
110
+ _tecutil.ArgListAppendArray(self, key, v)
111
+ elif isinstance(val[0], float):
112
+ v = (c_double * len(val))(*val)
113
+ self._handles[self._nargs] = v
114
+ _tecutil.ArgListAppendArray(self, key, v)
115
+ elif len(val) == 0 or isinstance(val[0], int):
116
+ v = (c_int64 * len(val))(*val)
117
+ self._handles[self._nargs] = v
118
+ _tecutil.ArgListAppendArray(self, key, v)
119
+ else:
120
+ msg = 'invalid type: {} ({} = {})'
121
+ msg = msg.format(type(val), key, val)
122
+ raise TecplotTypeError(msg)
123
+ else:
124
+ msg = 'invalid type: {} ({} = {})'
125
+ msg = msg.format(type(val), key, val)
126
+ raise TecplotTypeError(msg)
127
+ self._nargs += 1
128
+
129
+ def __len__(self):
130
+ return _tecutil.ArgListGetArgCount(self)
131
+
132
+ def keys(self):
133
+ for index in range(len(self)):
134
+ yield self._key(index)
135
+
136
+ def items(self):
137
+ for index, key in enumerate(self.keys()):
138
+ yield key, self._item(index)
139
+
140
+ # string representations
141
+ def __repr__(self):
142
+ kwargs = []
143
+ for key, val in self.items():
144
+ kwargs.append("{key}='{val}'".format(key=key, val=val))
145
+ return 'ArgList({kwargs})'.format(kwargs=', '.join(kwargs))
146
+
147
+ def __str__(self):
148
+ return str(dict(self))
149
+
150
+ # iterating
151
+ def __iter__(self):
152
+ self.current_index = -1
153
+ self.current_length = len(self)
154
+ return self
155
+
156
+ def __next__(self):
157
+ self.current_index += 1
158
+ if self.current_index < self.current_length:
159
+ return self._key(self.current_index)
160
+ else:
161
+ del self.current_index
162
+ del self.current_length
163
+ raise StopIteration()
164
+
165
+ # context management
166
+ def __enter__(self):
167
+ return self
168
+
169
+ def __exit__(self, *args):
170
+ self.dealloc()
171
+
172
+ # public methods
173
+ def update(self, *args, **kwargs):
174
+ if len(args) > 1:
175
+ msg = 'update expected at most 1 arguments, got ' + len(args)
176
+ raise TypeError(msg)
177
+ if len(args):
178
+ try:
179
+ for k, v in args[0]:
180
+ if v is not None:
181
+ self[k] = v
182
+ except TypeError:
183
+ msg = 'arglist update elements require 2 arguments (key, value)'
184
+ raise ValueError(msg)
185
+ for k, v in kwargs.items():
186
+ if v is not None:
187
+ self[k] = v
188
+
189
+ def clear(self):
190
+ _tecutil.ArgListClear(self)
191
+ self._handles = {}
192
+ self._nargs = 0
193
+
194
+ def dealloc(self):
195
+ _tecutil.ArgListDealloc(pointer(self))
196
+ self._handles = {}
197
+ self._nargs = 0
198
+
199
+
200
+ class LocalArgList(OrderedDict):
201
+ def __setitem__(self, key, val):
202
+ # setting to None deletes existing key
203
+ if val is None:
204
+ if key in self.keys():
205
+ del self[key]
206
+ return
207
+
208
+ accepted_types = tuple([str, StringList, IndexSet, float, c_double,
209
+ POINTER(c_double), int, bool, Enum, c_size_t, POINTER(c_size_t),
210
+ POINTER(c_int64), POINTER(POINTER(c_char)), POINTER(c_char_p),
211
+ Iterable, Index])
212
+ if not isinstance(val, accepted_types):
213
+ raise TecplotTypeError(type(val))
214
+
215
+ return OrderedDict.__setitem__(self, key, val)
216
+
217
+ def __repr__(self):
218
+ kwargs = []
219
+ for key, val in self.items():
220
+ kwargs.append("{key}='{val}'".format(key=key, val=val))
221
+ return 'ArgList({kwargs})'.format(kwargs=', '.join(kwargs))
222
+
223
+ def __enter__(self):
224
+ return self
225
+
226
+ def __exit__(self, *args):
227
+ self.clear()
228
+
229
+ def dealloc(self):
230
+ self.clear()
@@ -0,0 +1,177 @@
1
+ import os
2
+ import sys
3
+
4
+ from contextlib import contextmanager
5
+ from io import TextIOWrapper, UnsupportedOperation
6
+ from tempfile import TemporaryFile
7
+
8
+ try:
9
+ import ctypes
10
+ import platform
11
+ from ctypes.util import find_library
12
+ if platform.system() == 'Windows':
13
+ from ctypes.util import find_msvcrt
14
+ msvcrt = find_msvcrt()
15
+ if msvcrt is not None:
16
+ libc = ctypes.cdll[msvcrt]
17
+ else:
18
+ libc = ctypes.cdll.msvcrt
19
+ elif platform.system() in ['Mac', 'Darwin']:
20
+ libc = ctypes.CDLL(find_library('c'))
21
+ else: # if platform.system() in ['Linux']:
22
+ libc = ctypes.CDLL(None)
23
+ except ImportError: # pragma: no cover
24
+ libc = None
25
+
26
+
27
+ @contextmanager
28
+ def captured_output(out=os.devnull, err=None, mode='wb', errmode=None):
29
+
30
+ if platform.system() == 'Windows':
31
+ yield
32
+ return
33
+
34
+ err = out if err is None else err
35
+ errmode = mode if errmode is None else errmode
36
+
37
+ def open_stream(target):
38
+ try:
39
+ stream = open(target, mode)
40
+ fd = stream.fileno()
41
+ istemp = True
42
+ isbuff = False
43
+ except TypeError:
44
+ try:
45
+ fd = target.fileno()
46
+ stream = target
47
+ istemp = False
48
+ isbuff = False
49
+ except (AttributeError, UnsupportedOperation):
50
+ stream = TemporaryFile(mode='w+b')
51
+ fd = stream.fileno()
52
+ istemp = True
53
+ isbuff = True
54
+ return stream, fd, istemp, isbuff
55
+
56
+ try:
57
+ # flush all output streams
58
+ if libc is not None:
59
+ libc.fflush(None)
60
+
61
+ if (sys.stdout is not None) and (out is not None):
62
+ ### stdout
63
+ redirected_stdout = sys.stdout is not sys.__stdout__
64
+ # save previous output stream
65
+ _sys_stdout = sys.__stdout__
66
+ _sys_stdout_fd = _sys_stdout.fileno()
67
+ _sys_stdout_fd_dup = os.dup(_sys_stdout_fd)
68
+ # flush pending output
69
+ _sys_stdout.flush()
70
+ if redirected_stdout:
71
+ sys.stdout.flush()
72
+ out_stream, out_fd, out_istemp, out_isbuff = open_stream(out)
73
+ # overwrite file objects and low-level file descriptors
74
+ os.dup2(out_fd, _sys_stdout_fd)
75
+ if redirected_stdout:
76
+ _saved_stdout = sys.stdout
77
+ sys.stdout = os.fdopen(os.dup(out_fd),'wb')
78
+ sys.stdout = TextIOWrapper(sys.stdout)
79
+
80
+ if (sys.stderr is not None) and (err is not None):
81
+ ### stderr
82
+ redirected_stderr = sys.stderr is not sys.__stderr__
83
+ # save previous output stream
84
+ _sys_stderr = sys.__stderr__
85
+ _sys_stderr_fd = _sys_stderr.fileno()
86
+ _sys_stderr_fd_dup = os.dup(_sys_stderr_fd)
87
+ # flush pending output
88
+ _sys_stderr.flush()
89
+ if redirected_stderr:
90
+ sys.stderr.flush()
91
+ if err is out:
92
+ err_stream,err_fd,err_istemp,err_isbuff = out_stream,out_fd,False,False
93
+ else:
94
+ err_stream,err_fd,err_istemp,err_isbuff = open_stream(err)
95
+ # overwrite file objects and low-level file descriptors
96
+ os.dup2(err_fd, _sys_stderr_fd)
97
+ if redirected_stderr:
98
+ _saved_stderr = sys.stderr
99
+ sys.stderr = os.fdopen(os.dup(err_fd),'wb')
100
+ sys.stderr = TextIOWrapper(sys.stderr)
101
+
102
+ finally:
103
+ try:
104
+ yield
105
+
106
+ finally:
107
+
108
+ # flush all output streams
109
+ if libc is not None:
110
+ libc.fflush(None)
111
+
112
+ if (sys.stdout is not None) and (out is not None):
113
+ ### restore stdout
114
+ _sys_stdout.flush()
115
+ if redirected_stdout:
116
+ sys.stdout.flush()
117
+ # restore original streams and file descriptors
118
+ os.dup2(_sys_stdout_fd_dup, _sys_stdout_fd)
119
+ if redirected_stdout:
120
+ sys.stdout.close()
121
+ sys.stdout = _saved_stdout
122
+ else:
123
+ sys.stdout = _sys_stdout
124
+ os.close(_sys_stdout_fd_dup)
125
+
126
+
127
+ if (sys.stderr is not None) and (err is not None):
128
+ ### restore stderr
129
+ _sys_stderr.flush()
130
+ if redirected_stderr:
131
+ sys.stderr.flush()
132
+ # restore original streams and file descriptors
133
+ os.dup2(_sys_stderr_fd_dup, _sys_stderr_fd)
134
+ if redirected_stderr:
135
+ sys.stderr.close()
136
+ sys.stderr = _saved_stderr
137
+ else:
138
+ sys.stderr = _sys_stderr
139
+ os.close(_sys_stderr_fd_dup)
140
+
141
+
142
+ if (sys.stdout is not None) and (out is not None):
143
+ if out_isbuff:
144
+ out_stream.seek(0)
145
+ out_bytes = out_stream.read()
146
+ if len(out_bytes):
147
+ try:
148
+ out.write(out_bytes)
149
+ except:
150
+ out_str = out_bytes.decode().strip()
151
+ try:
152
+ out.write(out_str)
153
+ except:
154
+ out_msg = 'captured output:\n{0}'.format(' '+out_str.replace('\n','\n '))
155
+ out(out_msg)
156
+
157
+ if out_istemp:
158
+ out_stream.close()
159
+
160
+ if (sys.stderr is not None) and (err is not None):
161
+ if err is not out:
162
+ if err_isbuff:
163
+ err_stream.seek(0)
164
+ err_bytes = err_stream.read()
165
+ if len(err_bytes):
166
+ try:
167
+ err.write(err_bytes)
168
+ except:
169
+ err_str = err_bytes.decode().strip()
170
+ try:
171
+ err.write(err_str)
172
+ except:
173
+ err_msg = 'captured output:\n{0}'.format(' '+err_str.replace('\n','\n '))
174
+ err(err_msg)
175
+
176
+ if err_istemp:
177
+ err_stream.close()