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,112 @@
1
+ """|Tecplot Engine| State and |Tecplot License| Management
2
+
3
+ The `session` module contains methods used to manipulate the |Tecplot Engine|
4
+ such as notification of a `state change` that was done such as adding or
5
+ modifying data. It also contains methods for acquiring and releasing the
6
+ |Tecplot License|.
7
+
8
+ .. _state change:
9
+
10
+ State Changes
11
+ -------------
12
+
13
+ State changes are the method for propagating information when an event occurs.
14
+ A state change can be triggered by many events. Examples include: loading a
15
+ data file, changing the color of a mesh plot, creating a new zone, or changing
16
+ the plot type.
17
+
18
+ In general, state changes are already handled internally after each call to the
19
+ PyTecplot API. This can cause a script that performs many operations,
20
+ especially those that alter data, to run slowly since the |Tecplot Engine| must
21
+ update it's internal state every time a state change is received. To speed up
22
+ such scripts, it may be necessary to use the `tecplot.session.suspend()`
23
+ context. This will collect state changes for any operation performed and will
24
+ emit the required state changes only upon exit of the context.
25
+
26
+ Using the `tecplot.session.suspend()` context in combination with Python's
27
+ "-OO" flag which removes many run-time checks in the PyTecplot API is the
28
+ recommended way to run a PyTecplot script which requires faster execution
29
+ time. The user should be aware that, when using the "-OO" flag, errors may
30
+ not be recoverable by the |Tecplot Engine|.
31
+
32
+ """
33
+
34
+ from .aux_data import AuxData
35
+ from .config import configuration
36
+ from .session import (acquire_license, clear_suspend, connect, connected,
37
+ disconnect, license_expiration, release_license,
38
+ start_roaming, stop, stop_roaming, suspend,
39
+ suspend_enter, suspend_exit)
40
+ from .state_changed import connectivity_altered, data_altered, zone_added
41
+ from .style import (Style, SubStyle, get_style, set_style,
42
+ IJK, IJKMaxFract, IJKMinFract, IndependentVariableLimits,
43
+ Limits, IndexIJK, IndexRange, RectPosition, RectSize,
44
+ SplineDerivativeAtEnds, XY, XYZ)
45
+
46
+ import os
47
+ import platform
48
+ from ..tecutil import _tecutil_connector
49
+
50
+
51
+ def tecplot_install_directory():
52
+ """|Tecplot 360| installation directory.
53
+
54
+ Top-level installation directory for |Tecplot 360|. This will
55
+ typically contain configuration files and the examples directory.
56
+
57
+ This directory is platform-dependent and will contain configuration files
58
+ and the examples directory:
59
+
60
+ .. code-block:: python
61
+ :emphasize-lines: 4
62
+
63
+ import os
64
+ import tecplot
65
+
66
+ install_dir = tecplot.session.tecplot_install_directory()
67
+ infile = os.path.join(install_dir, 'examples', 'SimpleData', 'SpaceShip.lpk')
68
+
69
+ tecplot.load_layout(infile)
70
+ tecplot.export.save_png('spaceship.png', 600, supersample=3)
71
+
72
+ .. figure:: /_static/images/spaceship.png
73
+ :width: 300px
74
+ :figwidth: 300px
75
+ """
76
+ if not _tecutil_connector.connected:
77
+ _tecutil_connector.start()
78
+ d = _tecutil_connector.tecsdkhome
79
+ if d:
80
+ if platform.system() in ['Darwin', 'Mac']:
81
+ d = os.path.normpath(os.path.join(d, '..', '..'))
82
+ return d
83
+
84
+
85
+ def tecplot_examples_directory():
86
+ """|Tecplot 360| examples directory.
87
+
88
+ Examples directory that is typically installed with |Tecplot 360|.
89
+ This may be overridden with the TECPLOT_EXAMPLES environment variable.
90
+
91
+ This directory is platform-dependent and by default contains the various
92
+ examples shipped with |Tecplot 360|:
93
+
94
+ .. code-block:: python
95
+ :emphasize-lines: 4
96
+
97
+ import os
98
+ import tecplot
99
+
100
+ examples_dir = tecplot.session.tecplot_examples_directory()
101
+ infile = os.path.join(examples_dir, 'SimpleData', 'F18.lay')
102
+
103
+ tecplot.load_layout(infile)
104
+ tecplot.export.save_png('load_example.png', 600, supersample=3)
105
+
106
+ .. figure:: /_static/images/load_example.png
107
+ :width: 300px
108
+ :figwidth: 300px
109
+ """
110
+ d = tecplot_install_directory()
111
+ if d:
112
+ return os.environ.get('TECPLOT_EXAMPLES', os.path.join(d, 'examples'))
@@ -0,0 +1,276 @@
1
+ import ctypes
2
+ import itertools as it
3
+ from collections import namedtuple
4
+ from contextlib import contextmanager
5
+ from enum import Enum
6
+
7
+ from ..tecutil import _tecutil
8
+ from ..constant import *
9
+ from ..exception import *
10
+ from ..tecutil import lock, lock_attributes
11
+
12
+
13
+ @lock_attributes
14
+ class AuxData(ctypes.c_void_p):
15
+ """Auxiliary data.
16
+
17
+ The |Tecplot Engine| can hold auxiliary data attached to one of the
18
+ following objects:
19
+
20
+ - `Layout <layout.aux_data>`
21
+ - `Page <Page.aux_data>`
22
+ - `Frame <Frame.aux_data>`
23
+ - `Dataset <Dataset.aux_data>`
24
+ - `Variable <Variable.aux_data>`
25
+ - `Zone <OrderedZone.aux_data>`
26
+ - `Linemap <XYLinemap.aux_data>`
27
+
28
+ Auxiliary data is an ordered key-value pair that behaves like an ordered
29
+ dictionary, or `OrderedDict <collections.OrderedDict>`. Keys are strings
30
+ which are ordered alphabetically and values can additionally be access by
31
+ index. The keys must be alphanumeric (special characters "." and "_" are
32
+ allowed), must not contain spaces, and must begin with a non-numeric
33
+ character or underscore. Values, on the other hand, are arbitrary strings
34
+ and can contain anything except the null character. In this example, we
35
+ query the auxiliary data attached to the dataset and add some information
36
+ to it. Notice that the stored order is alphabetical:
37
+
38
+ .. code-block:: python
39
+
40
+ import tecplot as tp
41
+
42
+ aux = tp.active_frame().aux_data
43
+ aux['info'] = 'Here is some information.'
44
+ aux['Xavg'] = 3.14159
45
+ aux['note'] = 'Aux data values are always converted to strings.'
46
+
47
+ '''
48
+ The following code will print:
49
+ info: Here is some information.
50
+ note: Aux data values are always converted to strings.
51
+ Xavg: 3.14159
52
+ '''
53
+ for k, v in aux.items():
54
+ print('{}: {}'.format(k,v))
55
+ """
56
+ def __init__(self, parent, object_type, object_index=None):
57
+ self.parent = parent
58
+ self.object_type = object_type
59
+ self.getref_args = [] if object_index is None else [object_index + 1]
60
+ super().__init__(self._native_reference)
61
+
62
+ @property
63
+ def _native_reference(self):
64
+ _dispatch = {
65
+ AuxDataObjectType.Dataset: _tecutil.AuxDataDataSetGetRef,
66
+ AuxDataObjectType.Frame: _tecutil.AuxDataFrameGetRef,
67
+ AuxDataObjectType.Layout: _tecutil.AuxDataLayoutGetRef,
68
+ AuxDataObjectType.Linemap: _tecutil.AuxDataLineMapGetRef,
69
+ AuxDataObjectType.Page: _tecutil.AuxDataPageGetRef,
70
+ AuxDataObjectType.Variable: _tecutil.AuxDataVarGetRef,
71
+ AuxDataObjectType.Zone: _tecutil.AuxDataZoneGetRef}
72
+ with self._activated_parent():
73
+ return _dispatch[self.object_type](*self.getref_args)
74
+
75
+ @contextmanager
76
+ def _activated_parent(self):
77
+ if self.parent:
78
+ with self.parent.activated():
79
+ yield
80
+ else:
81
+ yield
82
+
83
+ @contextmanager
84
+ def assignment(self):
85
+ _tecutil.AuxDataBeginAssign()
86
+ try:
87
+ yield
88
+ finally:
89
+ _tecutil.AuxDataEndAssign()
90
+
91
+ def index(self, key):
92
+ """Returns the zero-based index of the element based on key.
93
+
94
+ Example usage::
95
+
96
+ >>> frame = tp.active_frame()
97
+ >>> frame.aux_data['result'] = '3.1415'
98
+ >>> frame.aux_data['other_info'] = '128'
99
+ >>> print(frame.aux_data.index('other_info'))
100
+ 0
101
+ >>> print(frame.aux_data.index('result'))
102
+ 1
103
+ """
104
+ try:
105
+ success, index = _tecutil.AuxDataGetItemIndex(self, key)
106
+ index -= 1
107
+ if not success:
108
+ raise TecplotKeyError
109
+ except TecplotSystemError:
110
+ raise TecplotKeyError
111
+ return index
112
+
113
+ _Item = namedtuple('Item', ['key', 'value', 'dtype', 'retain'])
114
+
115
+ def _item(self, index):
116
+ res =_tecutil.AuxDataGetItemByIndex(self, index + 1)
117
+ key, value, dtype, retain = res
118
+ if dtype is AuxDataType.String:
119
+ value = ctypes.cast(value, ctypes.c_char_p).value.decode('utf-8')
120
+ else:
121
+ # if we ever add another type to AuxDataType, this would
122
+ # need to be expanded as well as setitem which currently
123
+ # just converts every input to a string.
124
+ raise TecplotNotImplementedError
125
+ return AuxData._Item(key, value, dtype, retain)
126
+
127
+ def key(self, index):
128
+ """Returns the key at a specific zero-based index.
129
+
130
+ Example usage::
131
+
132
+ >>> frame = tp.active_frame()
133
+ >>> frame.aux_data['result'] = '3.1415'
134
+ >>> frame.aux_data['other_info'] = '128'
135
+ >>> print(frame.aux_data.key(0))
136
+ other_info
137
+ >>> print(frame.aux_data.key(1))
138
+ result
139
+ """
140
+ return self._item(index).key
141
+
142
+ def __getitem__(self, key):
143
+ if isinstance(key, str):
144
+ key = self.index(key)
145
+ return self._item(key).value
146
+
147
+ @lock()
148
+ def __setitem__(self, key, value):
149
+ if isinstance(key, int):
150
+ try:
151
+ key = self.key(key)
152
+ except:
153
+ raise TecplotIndexError
154
+ if not _tecutil.AuxDataSetItem(self, key, str(value),
155
+ AuxDataType.String.value, True):
156
+ raise TecplotSystemError()
157
+
158
+ @lock()
159
+ def __delitem__(self, key):
160
+ if isinstance(key, str):
161
+ key = self.index(key)
162
+ _tecutil.AuxDataDeleteItemByIndex(self, key + 1)
163
+
164
+ def __len__(self):
165
+ return _tecutil.AuxDataGetNumItems(self)
166
+
167
+ def __iter__(self):
168
+ self._current_index = -1
169
+ self._current_length = len(self)
170
+ return self
171
+
172
+ def __next__(self):
173
+ self._current_index += 1
174
+ if self._current_index < self._current_length:
175
+ return self.key(self._current_index)
176
+ else:
177
+ raise StopIteration
178
+
179
+ def next(self):
180
+ return self.__next__()
181
+
182
+ def items(self):
183
+ """Yields all key/value pairs of the Aux Data attached to the parent.
184
+
185
+ Elements are always ordered alphabetically by the keys. Example usage::
186
+
187
+ >>> frame = tp.active_frame()
188
+ >>> frame.aux_data['result'] = '3.1415'
189
+ >>> frame.aux_data['other_info'] = '128'
190
+ >>> for key, value in frame.aux_data.items():
191
+ ... print(key, value)
192
+ other_info 128
193
+ result 3.1415
194
+ """
195
+ for i in range(len(self)):
196
+ item = self._item(i)
197
+ yield item.key, item.value
198
+
199
+ def keys(self):
200
+ """Yields all keys of the Aux Data attached to the parent.
201
+
202
+ Elements are always ordered alphabetically by the keys. Example usage::
203
+
204
+ >>> frame = tp.active_frame()
205
+ >>> frame.aux_data['result'] = '3.1415'
206
+ >>> frame.aux_data['other_info'] = '128'
207
+ >>> for value in frame.aux_data.keys():
208
+ ... print(value)
209
+ other_info
210
+ result
211
+ """
212
+ for key in self:
213
+ yield key
214
+
215
+ def values(self):
216
+ """Yields all values of the Aux Data attached to the parent.
217
+
218
+ Elements are always ordered alphabetically by the keys. Example usage::
219
+
220
+ >>> frame = tp.active_frame()
221
+ >>> frame.aux_data['result'] = '3.1415'
222
+ >>> frame.aux_data['other_info'] = '128'
223
+ >>> for value in frame.aux_data.values():
224
+ ... print(value)
225
+ 128
226
+ 3.1415
227
+ """
228
+ for _, value in self.items():
229
+ yield value
230
+
231
+ def as_dict(self):
232
+ """Returns a Python dict of the Aux Data attached to the parent.
233
+
234
+ Note that this will remove the alphabetical ordering guarantee that Aux
235
+ Data has since Python dict objects are unordered. Example usage::
236
+
237
+ >>> frame = tp.active_frame()
238
+ >>> frame.aux_data['result'] = '3.1415'
239
+ >>> frame.aux_data['other_info'] = '128'
240
+ >>> aux = frame.aux_data.as_dict()
241
+ >>> print(aux)
242
+ {'result': '3.1415', 'other_info': '128'}
243
+ """
244
+ return {k: v for k, v in self.items()}
245
+
246
+ def __str__(self):
247
+ return str(self.as_dict())
248
+
249
+ def update(self, *other, **kwargs):
250
+ """Update Aux Data with key/value pairs from another Aux Data or dict.
251
+
252
+ Example usage::
253
+
254
+ >>> frame = tp.active_frame()
255
+ >>> frame.aux_data.update({'result': '3.1415', 'other_info': '128'})
256
+ >>> print(frame.aux_data)
257
+ {'result': '3.1415', 'other_info': '128'}
258
+ """
259
+ with self.assignment():
260
+ for d in it.chain(other, [kwargs]):
261
+ for k, v in d.items():
262
+ self[k] = v
263
+
264
+ def clear(self):
265
+ """Deletes all Aux Data from the associated object.
266
+
267
+ Example usage::
268
+
269
+ >>> print(frame.aux_data)
270
+ {'bb': 'test bb', 'cc': 'test cc', 'aa': 'test aa'}
271
+ >>> frame.aux_data.clear()
272
+ >>> print(frame.aux_data)
273
+ {}
274
+ """
275
+ for key in list(self.keys()):
276
+ del self[key]
@@ -0,0 +1,92 @@
1
+ r"""
2
+ .. function:: tecplot.session.configuration()
3
+
4
+ Run-time configuration parameters can be accessed and changed through the
5
+ configuration instance returned by ``tecplot.session.configuration()``::
6
+
7
+ >>> conf = tecplot.session.configuration()
8
+ >>> print(conf.latex.command)
9
+ pdflatex -interaction=batchmode -output-directory=@OUTDIR @INFILE
10
+ >>> conf.latex.preamble = '\usepackage{amsmath}'
11
+
12
+ The default settings have been tested with MiKTeX and TeXLive engines and
13
+ should work without the need for any changes to the session configuration.
14
+ However, you may wish to change the LaTeX packages which are loaded by default
15
+ or use a different LaTeX engine. See the Tecplot user manual for guidance in
16
+ changing your LaTeX configuration file so changes persist across sessions.
17
+
18
+ Available configuration parameters:
19
+
20
+ .. contents::
21
+ :local:
22
+ :depth: 1
23
+
24
+ ``latex.command``
25
+ ^^^^^^^^^^^^^^^^^
26
+
27
+ The system command used to compile LaTeX text objects. Parameters ``@OUTDIR``
28
+ and ``@INFILE`` are replaced with appropriate strings to coordinate the
29
+ creation of the final rendered text.
30
+
31
+ Type:
32
+ `str`
33
+ Default:
34
+ "latex -interaction=batchmode -output-directory=\@OUTDIR @INFILE"
35
+
36
+ ``latex.dvipng_command``
37
+ ^^^^^^^^^^^^^^^^^^^^^^^^
38
+
39
+ The system command used to convert the output from the LaTeX command from DVI
40
+ to PNG. The parameters ``@DPI``, ``@PAGERANGE``, ``@OUTFILE`` and ``@INFILE``
41
+ are replaced with appropriate strings to coordinate the creation fo the final
42
+ rendered text.
43
+
44
+ Type:
45
+ `str`
46
+ Default:
47
+ "dvipng -bg Transparent -D @DPI -pp @PAGERANGE -T tight -o @OUTFILE @INFILE"
48
+
49
+ ``latex.preamble``
50
+ ^^^^^^^^^^^^^^^^^^
51
+
52
+ Code that will be placed before the ``\begin{document}`` section of the LaTeX
53
+ source to be compiled. This primarily used for loading LaTeX packages.
54
+
55
+ Type:
56
+ `str`
57
+ Default:
58
+ "\\usepackage{amsfonts}\\usepackage{amsmath}\\usepackage{amssymb}\\usepackage{amsthm}"
59
+
60
+ """
61
+ from builtins import str
62
+
63
+ from ..tecutil import sv
64
+ from .style import StyleConfig, style_property
65
+
66
+
67
+ class ConfigLaTeX(StyleConfig):
68
+ command = style_property(str, sv.LATEXCMD)
69
+ preamble = style_property(str, sv.PREAMBLE)
70
+ dvipng_command = style_property(str, sv.DVIPNGCMD)
71
+
72
+
73
+ class ConfigLimits(StyleConfig):
74
+ load_on_demand_threshold_min = style_property(
75
+ float, sv.LODTHRESHOLDMINFRACT)
76
+ load_on_demand_threshold_max = style_property(
77
+ float, sv.LODTHRESHOLDMAXFRACT)
78
+
79
+
80
+ class ConfigOpenGL(StyleConfig):
81
+ run_display_lists_after_building = style_property(
82
+ bool, sv.RUNDISPLAYLISTSAFTERBUILDING)
83
+
84
+
85
+ class ConfigInterface(StyleConfig):
86
+ opengl = ConfigOpenGL('interface.opengl', sv.INTERFACE, sv.OPENGLCONFIG)
87
+
88
+
89
+ class configuration(StyleConfig):
90
+ latex = ConfigLaTeX('latex', sv.LATEX)
91
+ limits = ConfigLimits('limits', sv.LIMITS)
92
+ interface = ConfigInterface('interface', sv.INTERFACE)