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
tecplot/macro.py ADDED
@@ -0,0 +1,339 @@
1
+ import contextlib
2
+ import io
3
+ import logging
4
+ import os
5
+ import re
6
+ import textwrap
7
+ import sys
8
+
9
+ from .tecutil import _tecutil, _tecutil_connector
10
+ from .exception import TecplotLogicError, TecplotSystemError, TecplotMacroError
11
+ from . import tecutil
12
+
13
+ log = logging.getLogger(__name__)
14
+
15
+
16
+ if not hasattr(contextlib, 'nullcontext'):
17
+ @contextlib.contextmanager
18
+ def nullcontext(result=None):
19
+ yield result
20
+ contextlib.nullcontext = nullcontext
21
+
22
+
23
+ @tecutil.lock()
24
+ def execute_function(name, parameters=None):
25
+ """Runs a macro function.
26
+
27
+ Parameters:
28
+ name: (`str`): Name of the macro function to run. This name
29
+ is not case sensitive. Must be a non-zero length `str`.
30
+
31
+ parameters: (`str`): Any parameters which the quick macro
32
+ requires. Pass `None` (default) for macro functions which require no
33
+ parameters. The parameters are passed as a string which includes
34
+ the parenthesis. For example, if the macro function takes a
35
+ string parameter and int parameter, pass
36
+ **'("string_parameter_name", 2)'** Default: `None`
37
+
38
+ Macro functions must be defined before they are used. Typically they
39
+ are defined in the 'tecplot.mcr' configuration file which is read
40
+ when |Tecplot Engine| is initialized. Macro functions
41
+ may also be available in the Quick Macro Panel when the Tecplot 360 GUI
42
+ is running.
43
+
44
+ .. note::
45
+ See the |Tecplot Macro Scripting Guide| for more information about
46
+ macro functions.
47
+
48
+ Run the "Tile Frames" macro functions. This macro function is defined in
49
+ the file "tecplot.mcr", which is located in the Tecplot 360
50
+ installation directory::
51
+
52
+ >>> tecplot.macro.execute_function('Tile Frames')
53
+
54
+ Run a macro function named "Calculate" which takes no parameters and
55
+ another macro function called "Display" which takes the name of a
56
+ layout file and an integer as parameters::
57
+
58
+ >>> tp.macro.execute_function('Calculate')
59
+ >>> tp.macro.execute_function('Display', '("contour.lay", 2)')
60
+ """
61
+ try:
62
+ if not _tecutil.MacroRunFunction(
63
+ name.strip(),
64
+ parameters.strip() if parameters else None):
65
+ raise TecplotMacroError(name)
66
+ except (TecplotLogicError, TecplotSystemError) as e:
67
+ raise TecplotMacroError(str(e))
68
+
69
+
70
+ @tecutil.lock()
71
+ def execute_command(command):
72
+ """Runs a series of tecplot macro commands.
73
+
74
+ Parameters:
75
+ command (`str`): The macro commands to be run.
76
+
77
+ .. warning:: Zero-based Indexing
78
+
79
+ It is important to know that all indexing in |PyTecplot| scripts are
80
+ zero-based. This is a departure from the macro language which is
81
+ one-based. This is to keep with the expectations when working in the
82
+ python language. However, |PyTecplot| does not modify strings that are
83
+ passed to the |Tecplot Engine|. This means that one-based indexing
84
+ should be used when running macro commands from python or when using
85
+ `execute_equation() <tecplot.data.operate.execute_equation>`.
86
+
87
+ This command splits the input into individual commands and runs them one
88
+ at a time. See the |Tecplot Macro Scripting Guide| for details about
89
+ |Tecplot 360|'s macro language.
90
+
91
+ .. warning::
92
+ The $!VARSET command is not supported. Tecplot Macro variables should be
93
+ converted to Python variables.
94
+
95
+ .. warning::
96
+ Intrinsic variables (that is, variables with pipes such as
97
+ ``|DATASETFNAME|``) are not supported. If you need to use an intrinsic
98
+ variable in the macro command, add the macro command to a text file and
99
+ call `execute_file`.
100
+
101
+ See the |Tecplot Macro Scripting Guide| for more information about raw data
102
+ and intrinsic variables.
103
+
104
+ The following command will perform the same operations as the
105
+ `Hello, World! example <hello_world>`::
106
+
107
+ >>> tecplot.macro.execute_command(r'''
108
+ ... $!ATTACHTEXT
109
+ ... ANCHORPOS { X = 35 Y = 50 }
110
+ ... TEXTSHAPE { HEIGHT = 35 }
111
+ ... TEXT = 'Hello, World!'
112
+ ... $!EXPORTSETUP EXPORTFNAME = 'hello_world.png'
113
+ ... $!EXPORT
114
+ ... EXPORTREGION = CURRENTFRAME
115
+ ... ''')
116
+ """
117
+ varset = re.compile(r'\$!VARSET.*', re.IGNORECASE)
118
+ for c in tecutil.split_macro(command):
119
+ if __debug__:
120
+ if varset.match(c):
121
+ msg = ('The $!VARSET command is not supported in\n'
122
+ 'execute_macro(). Python variables should be used\n'
123
+ 'instead of macro variables. Alternatively, you can\n'
124
+ 'execute a macro in a file with '
125
+ 'macro.execute_file().\n'
126
+ '$!VARSET is supported in execute_file()')
127
+ raise TecplotMacroError(c + '\n' + msg)
128
+ log.debug('executing command:\n' + c)
129
+ try:
130
+ if not _tecutil.MacroExecuteCommand(c):
131
+ raise TecplotMacroError(c)
132
+ except (TecplotLogicError, TecplotSystemError) as e:
133
+ raise TecplotMacroError(str(e))
134
+
135
+
136
+ @tecutil.lock()
137
+ def execute_extended_command(command_processor_id, command, raw_data=None):
138
+ """Runs a tecplot macro command defined in an addon.
139
+
140
+ Parameters:
141
+ command_processor_id (`str`): A unique string used to
142
+ determine the API to call when an extended macro command is
143
+ processed. API's are provided by add-ons or applications
144
+ that extend the Tecplot macro language.
145
+
146
+ Typically this will be the name of an add-on or application,
147
+ followed by a version number. For example: 'CFDAnalyzer4'.
148
+
149
+ Each application or add-on may provide one or more unique
150
+ command processor ID strings corresponding to different API's,
151
+ or different versions of an API.
152
+
153
+ For example, a file converter add-on responsible
154
+ for converting DXF files for Tecplot might provide two versions
155
+ of an API:
156
+ "DXFCONVERTTOOL-1.2", and "DXFCONVERTTOOL-2.0".
157
+ In that case either of these strings would be passed in the
158
+ *command_processor_id* parameter to indicate the version of the
159
+ API to use.
160
+
161
+ command (`str`): The command to run.
162
+ raw_data (`str`): Raw data required for the command, if any
163
+ (default: `None`).
164
+
165
+ .. warning:: Zero-based Indexing
166
+
167
+ It is important to know that all indexing in |PyTecplot| scripts are
168
+ zero-based. This is a departure from the macro language which is
169
+ one-based. This is to keep with the expectations when working in the
170
+ python language. However, |PyTecplot| does not modify strings that are
171
+ passed to the |Tecplot Engine|. This means that one-based indexing
172
+ should be used when running macro commands from python or when using
173
+ `execute_equation() <tecplot.data.operate.execute_equation>`.
174
+
175
+ In general, the command string is formatted prior to being fed into the
176
+ |Tecplot Engine| so liberal use of whitespace, including new-lines, are
177
+ acceptable.
178
+
179
+ Example::
180
+
181
+ >>> tecplot.macro.execute_extended_command(
182
+ ... 'Multi Frame Manager',
183
+ ... 'TILEFRAMESSQUARE')
184
+ """
185
+ try:
186
+ if not _tecutil.MacroExecuteExtendedCommand(
187
+ command_processor_id, command.replace('\n', ' '), raw_data):
188
+ raise TecplotMacroError(command)
189
+ except AttributeError:
190
+ command = textwrap.dedent('''
191
+ $!EXTENDEDCOMMAND
192
+ COMMANDPROCESSORID = '{procid}'
193
+ COMMAND = '{cmd}'
194
+ '''.format(procid=command_processor_id,
195
+ cmd=' '.join(command. split()).replace(r"'", r"\'")))
196
+ execute_command(command)
197
+ except TecplotLogicError:
198
+ raise TecplotMacroError()
199
+
200
+
201
+ @tecutil.lock()
202
+ def execute_file(filename):
203
+ """Run a macro file.
204
+
205
+ Parameters:
206
+ filename (`str`): The file to be run. (See note
207
+ below concerning absolute and relative paths.)
208
+
209
+ .. warning:: Zero-based Indexing
210
+
211
+ It is important to know that all indexing in |PyTecplot| scripts are
212
+ zero-based. This is a departure from the macro language which is
213
+ one-based. This is to keep with the expectations when working in the
214
+ python language. However, |PyTecplot| does not modify strings that are
215
+ passed to the |Tecplot Engine|. This means that one-based indexing
216
+ should be used when running macro commands from python or when using
217
+ `execute_equation() <tecplot.data.operate.execute_equation>`.
218
+
219
+ .. note:: **Absolute and relative paths with PyTecplot**
220
+
221
+ Relative paths, when used within the PyTecplot API are always from
222
+ Python's current working directory which can be obtained by calling
223
+ :func:`os.getcwd()`. This is true for batch and `connected
224
+ <tecplot.session.connect()>` modes. One exception to this is paths
225
+ within a macro command or file which will be relative to the |Tecplot
226
+ Engine|'s home directory, which is typically the |Tecplot 360|
227
+ installation directory. Finally, when connected to a remote (non-local)
228
+ instance of Tecplot 360, only absolute paths are allowed.
229
+
230
+ Note that backslashes must be escaped which is especially important for
231
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
232
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
233
+ respectively. Alternatively, one may use Python's raw strings:
234
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
235
+
236
+ Example::
237
+
238
+ >>> tecplot.macro.execute_file('/path/to/macro_file.mcr')
239
+ """
240
+ try:
241
+ filepath = tecutil.normalize_path(filename)
242
+ if not _tecutil.MacroRunFile(filepath):
243
+ raise TecplotMacroError(filepath)
244
+ except (TecplotLogicError, TecplotSystemError) as e:
245
+ raise TecplotMacroError(str(e))
246
+
247
+
248
+ @contextlib.contextmanager
249
+ def record(out=None, header=None):
250
+ """Record a block of python code as a macro.
251
+
252
+ Parameters:
253
+ out (`str` filename, output stream object or `None`): Output file
254
+ name of the resulting macro or a text buffer object that
255
+ implements write() and flush() methods. If `None`, then a
256
+ `io.StringIO()` object is yielded and can be used to get the
257
+ string after exiting the context.
258
+ header (`str`, optional): String to prepend to the output. This will
259
+ default to "#!MC 1410\n" for a macro file, but be empty when output
260
+ to a buffer. Set this to an empty string to elide the header when
261
+ writing to a file.
262
+
263
+ Example output to a file::
264
+
265
+ import tecplot as tp
266
+ with tp.macro.record('recording.mcr'):
267
+ tp.active_frame().plot().show_contour = True
268
+
269
+ The resulting contents of the recording.mcr::
270
+
271
+ $!FieldLayers ShowContour = Yes
272
+
273
+ Example output to a string buffer::
274
+
275
+ import io
276
+ import tecplot as tp
277
+ with io.StringIO() as buf:
278
+ with tp.macro.record(buf):
279
+ tp.active_frame().plot().show_contour = True
280
+ mcr = buf.getvalue()
281
+ print(mcr)
282
+
283
+ Example output to a new string buffer (setting out to `None`). This
284
+ will produce the same string as the string buffer example above::
285
+
286
+ import tecplot as tp
287
+ with tp.macro.record() as buf:
288
+ tp.active_frame().plot().show_contour = True
289
+ mcr = buf.getvalue()
290
+ print(mcr)
291
+ """
292
+ suffix = '.mcr'
293
+ if isinstance(out, str):
294
+ if out.endswith('.py'):
295
+ suffix = '.py'
296
+ ctx = contextlib.closing(open(out, 'w'))
297
+ header = '#!MC 1410\n' if header is None else header
298
+ elif out is None:
299
+ ctx = contextlib.nullcontext(io.StringIO())
300
+ else:
301
+ ctx = contextlib.nullcontext(out)
302
+
303
+ with ctx as ostream:
304
+ with tecutil.temporary_closed_file(suffix=suffix) as ftmp:
305
+ _tecutil_connector.macro_record_start(ftmp)
306
+ try:
307
+ with tecutil.force_recording():
308
+ yield ostream
309
+ finally:
310
+ _tecutil_connector.macro_record_end()
311
+
312
+ with open(ftmp, 'r') as fin:
313
+ src = fin.read().strip()
314
+ if header is not None:
315
+ ostream.write(header)
316
+ if suffix == '.mcr':
317
+ src = src[src.find('$!'):]
318
+ ostream.write(src)
319
+ ostream.flush()
320
+
321
+
322
+ def translate(source):
323
+ """Translate macro source code into Python.
324
+
325
+ Parameters:
326
+ source (`str`): A multiline string containing the macro commands to be
327
+ translated.
328
+
329
+ If no translation is available or the translation fails, the
330
+ `tp.macro.execute_command()` method will be used as a fall-back. No import
331
+ statements are included, and the following header is assumed::
332
+
333
+ import tecplot as tp
334
+ from tecplot.constant import *
335
+ """
336
+ result = []
337
+ for command in tecutil.split_macro(source):
338
+ result.append(_tecutil_connector.translate_macro_to_python(command))
339
+ return '\n'.join(result)
@@ -0,0 +1,62 @@
1
+ from .axes import (Cartesian2DFieldAxes, Cartesian3DFieldAxes, OrientationAxis,
2
+ PolarLineAxes, SketchAxes, XYLineAxes)
3
+ from .axis import (AxisLine2D, AxisLine3D, Cartesian2DFieldAxis,
4
+ Cartesian2DAxisLine, Cartesian3DFieldAxis,
5
+ PolarAngleLineAxis, RadialAxisLine2D, RadialLineAxis,
6
+ SketchAxis, XYLineAxis)
7
+ from .blanking import (ValueBlanking, ValueBlankingCartesian2D,
8
+ ValueBlankingCartesian3D, ValueBlankingConstraint,
9
+ ValueBlankingConstraintCartesian2D)
10
+ from .blanking import IJKBlanking
11
+ from .contour import (ContourGroup, ContourColorCutoff, ContourColormapFilter,
12
+ ContourColormapOverride, ContourColormapZebraShade,
13
+ ContourLabels, ContourLevels, ContourLines)
14
+ from .effects import LightSource
15
+ from .fieldmap import (FieldmapContour, FieldmapEdge, FieldmapEffects,
16
+ FieldmapEffects3D, Fieldmap, Cartesian2DFieldmap,
17
+ Cartesian2DFieldmapCollection, Cartesian3DFieldmap,
18
+ Cartesian3DFieldmapCollection, FieldmapMesh,
19
+ FieldmapPoints, FieldmapScatter, FieldmapShade,
20
+ FieldmapShade3D, FieldmapSurfaces, FieldmapVector)
21
+ from .grid import (Cartesian2DGridArea, Cartesian3DGridArea, GridArea,
22
+ PreciseGrid, GridLines, GridLines2D, MarkerGridLine,
23
+ MarkerGridLine2D, MinorGridLines, MinorGridLines2D,
24
+ PolarAngleGridLines, PolarAngleMarkerGridLine,
25
+ PolarAngleMinorGridLines)
26
+ from .isosurface import (IsosurfaceContour, IsosurfaceEffects, IsosurfaceGroup,
27
+ IsosurfaceMesh, IsosurfaceShade, IsosurfaceVector)
28
+ from .labels import FieldPlotDataLabels, LinePlotDataLabels
29
+ from .linemap import (PolarLinemap, PolarLinemapCollection, XYLinemap,
30
+ XYLinemapCollection, LinemapBars, LinemapCurve,
31
+ LinemapErrorBars, LinemapIndices, LinemapLine,
32
+ LinemapSymbols)
33
+ from .linking import (Cartesian2DPlotLinkingBetweenFrames,
34
+ Cartesian3DPlotLinkingBetweenFrames,
35
+ DataPlotLinkingBetweenFrames, DataPlotLinkingWithinFrame,
36
+ FieldPlotLinkingBetweenFrames,
37
+ FieldPlotLinkingWithinFrame, LinkingWithinFrame,
38
+ PolarPlotLinkingBetweenFrames,
39
+ SketchPlotLinkingBetweenFrames,
40
+ XYLinePlotLinkingBetweenFrames)
41
+ from .plot import (Cartesian2DFieldPlot, Cartesian3DFieldPlot, PolarLinePlot,
42
+ SketchPlot, XYLinePlot)
43
+ from .rgb_coloring import RGBColoring
44
+ from .scatter import PieCharts, PieChartsWedge, Scatter
45
+ from .slice import (SliceGroup, SliceGroupCollection, SliceContour, SliceVector,
46
+ SliceEdge, SliceEffects, SliceShade, SliceMesh)
47
+ from .streamtrace import (StreamtraceRodRibbon, StreamtraceRodRibbonContour,
48
+ StreamtraceRodRibbonEffects,
49
+ StreamtraceRodRibbonMesh, StreamtraceRodRibbonShade,
50
+ Streamtraces, StreamtraceTerminationLine,
51
+ StreamtraceTiming)
52
+ from .symbol import (GeometryScatterSymbol, GeometrySymbol,
53
+ ScatterReferenceSymbol, Symbol, TextScatterSymbol,
54
+ TextSymbol)
55
+ from .ticks import (RadialTicks, RadialTickLabels, Ticks2D, Ticks3D,
56
+ TickLabels2D, TickLabels3D)
57
+ from .title import (Axis2DTitle, DataAxis2DTitle, DataAxis3DTitle,
58
+ RadialAxisTitle)
59
+ from .vector import ReferenceVector, ReferenceVectorLabel, Vector2D, Vector3D
60
+ from .view import (Cartesian2DFieldView, Cartesian2DViewport, Cartesian3DView,
61
+ PolarView, PolarViewport, ReadOnlyViewport, Viewport,
62
+ XYLineView)