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/data/query.py ADDED
@@ -0,0 +1,334 @@
1
+ from builtins import str
2
+
3
+ from collections import namedtuple
4
+ from ctypes import byref, c_double, c_int32, c_int64
5
+
6
+ from ..tecutil import _tecutil
7
+ from ..constant import *
8
+ from ..exception import *
9
+ from .. import layout
10
+ from ..tecutil import Index, IndexSet, lock
11
+
12
+
13
+ @lock()
14
+ def probe_at_position(x, y, z=None, nearest=False, starting_cell=None,
15
+ starting_zone=None, zones=None, dataset=None, frame=None):
16
+ """Returns field values at a point in space.
17
+
18
+ .. note::
19
+
20
+ The position is taken according to the axis assignments of the `Frame <layout.Frame>`
21
+ which may be any of the associated variables in the `Dataset <tecplot.data.Dataset>` and not
22
+ necessarily ``(X, Y, Z)``. See: `Cartesian3DFieldAxis.variable`.
23
+
24
+ Parameters:
25
+ x,y,z (`float`, *z* is optional): position to probe for field values.
26
+ nearest (`bool`): Returns the values at the nearest node to the given
27
+ position. Probe position must be inside the volume of the data
28
+ being queried, otherwise this will return `None`.
29
+ starting_cell (3-`tuple` of `integers <int>`, optional):
30
+ The ``(i,j,k)``-index of the cell to start looking for the given
31
+ position. This must be used with ``starting_zone``.
32
+ starting_zone (`Zone <data_access>`, optional): The first zone to start
33
+ searching. This is required only when ``starting_cell`` is
34
+ specified.
35
+ zones (`list` of `Zones <data_access>`, optional): Limits the search to
36
+ the given zones. `None` implies searching all zones. (default:
37
+ `None`)
38
+ dataset (`Dataset <tecplot.data.Dataset>`, optional): The `Dataset <tecplot.data.Dataset>` to probe. (defaults to
39
+ the active `Dataset <tecplot.data.Dataset>`.)
40
+ frame (`Frame <layout.Frame>`, optional): The `Frame <layout.Frame>` which determines the spatial
41
+ variable assignment ``(X,Y,Z)``. (defaults to the active `Frame <layout.Frame>`.)
42
+
43
+ Returns:
44
+ `namedtuple <collections.namedtuple>`: ``(data, cell, zone)``:
45
+
46
+ ``data`` (`list` of `floats <float>`)
47
+ The values of each variable in the dataset at the given
48
+ position.
49
+ ``cell`` (3-`tuple` of `integers <int>`)
50
+ ``(i,j,k)`` of the cell containing the given position.
51
+ ``zone`` (`Zone <data_access>`)
52
+ Zone containing the given position
53
+
54
+ .. note:: Returns `None` if the position can't be probed.
55
+
56
+ This method will return `None` if the position is outside the volume
57
+ of the data being queried. This means one should capture the results
58
+ in a single variable and test it against `None` before proceeding::
59
+
60
+ result = tp.data.query.probe_at_position(1.0, 2.0, 3.0)
61
+ if result is None:
62
+ print('probe failed.')
63
+ else:
64
+ data, cell, zone = result
65
+
66
+ Additionally, with Tecplot 360 versions 2018 R1 and later, this
67
+ function will raise an exception if Tecplot 360 was interrupted via the
68
+ GUI during the probe operation.
69
+ """
70
+ if __debug__:
71
+ if frame and dataset and frame.dataset != dataset:
72
+ msg = ('Dataset must be attached to the input Frame: {} != {}'.
73
+ format(repr(frame.dataset), repr(dataset)))
74
+ raise TecplotValueError(msg)
75
+ if (starting_cell is None) ^ (starting_zone is None):
76
+ msg = 'starting_cell option requires an associated starting_zone'
77
+ raise TecplotLogicError(msg)
78
+
79
+ if dataset is None:
80
+ if frame is None:
81
+ frame = layout.active_frame()
82
+ dataset = frame.dataset
83
+ elif frame is None:
84
+ frame = dataset.frame
85
+
86
+ with frame.activated():
87
+ if starting_cell is None:
88
+ start_with_local_cell = False
89
+ i, j, k = 0, 0, 0
90
+ starting_zone_index = 0
91
+ else:
92
+ start_with_local_cell = True
93
+ i, j, k = (x+1 for x in starting_cell)
94
+ starting_zone_index = starting_zone.index
95
+
96
+ allocd = []
97
+ if zones is not None:
98
+ zones = IndexSet(*zones)
99
+ allocd.append(zones)
100
+
101
+ data = (max(3, dataset.num_variables)*c_double)()
102
+
103
+ try:
104
+ result = _tecutil.ProbeAtPosition(
105
+ x, y, z or 0,
106
+ i, j, k,
107
+ IJKPlanes.Volume.value,
108
+ starting_zone_index+1,
109
+ start_with_local_cell,
110
+ data,
111
+ zones,
112
+ z is not None,
113
+ False,
114
+ nearest)
115
+ success, i, j, k, plane, zone_index = result
116
+ except TecplotSystemError as e:
117
+ if 'Assertion' in str(e):
118
+ raise
119
+ success = False
120
+
121
+ if not success:
122
+ if _tecutil.InterruptCheck():
123
+ raise TecplotInterruptError()
124
+ return None
125
+
126
+ cell = (Index(i-1), Index(j-1), Index(k-1))
127
+ zone_index = Index(zone_index-1)
128
+
129
+ for a in allocd:
130
+ a.dealloc()
131
+
132
+ ProbeResult = namedtuple('ProbeResult', ['data', 'cell', 'zone'])
133
+ return ProbeResult(data[:], cell, dataset.zone(zone_index))
134
+
135
+
136
+ @lock()
137
+ def probe_on_surface(positions=((0,),(0,),(0,)), zones=None, variables=None,
138
+ probe_nearest=ProbeNearest.Position, obey_blanking=True,
139
+ num_nearest_nodes=20, tolerance=1e-5, dataset=None,
140
+ frame=None):
141
+ """Returns field values at points on a surface closest the points given.
142
+
143
+ .. note::
144
+
145
+ The positions are processed according to the axis assignments of the
146
+ `Frame <layout.Frame>` which may be any of the associated variables in the `Dataset <tecplot.data.Dataset>`
147
+ and not necessarily (but usually) ``(X, Y, Z)``. See:
148
+ `Cartesian3DFieldAxis.variable`.
149
+
150
+ Parameters:
151
+ positions (2D `float` array): Array of points to probe dimensioned by
152
+ ``(3, N)`` where the first dimension corresponds to ``(x, y, z)``.
153
+ A 1D `float` array is accepted for single point probes, however
154
+ this should be avoided when probing several positions as the
155
+ internal algorithm is optimized for probing many positions at once.
156
+ zones (`list` of `Zones <data_access>`, optional): Limits the search to
157
+ the given zones. `None` implies searching all active relevant
158
+ surface zones including surfaces of ordered volume zones. To search
159
+ FE or polygonal volume boundaries, include the volume zones in this
160
+ list. (default: `None`)
161
+ variables (`list` of `Variables <Variable>`, optional): The variables
162
+ within the dataset to probe. `None` implies all variables.
163
+ (default: `None`)
164
+ probe_nearest (`ProbeNearest`, optional): Probe at the nodal location
165
+ (`ProbeNearest.Node`) or interpolate to nearest location on the
166
+ surface (`ProbeNearest.Position`, default). The return parameter
167
+ **cells_or_nodes** will be cells if set to `ProbeNearest.Position`
168
+ (default), or nodes if set to `ProbeNearest.Node`.
169
+ obey_blanking (`bool`, optional): Do not search blanked cells according
170
+ the frame's style settings. (default: `True`)
171
+ num_nearest_nodes (`int`, optional): Only consider surface
172
+ cells that contain one of the closest ``N`` nodes to the probed
173
+ position. For highly varying surfaces, the nearest cell may or may
174
+ not contain the nearest nodes to the probe position and so this
175
+ value should be increased accordingly, however doing so increases
176
+ the search-space linearly. (default: 20)
177
+ tolerance (`float`, optional): The percentage of the longest cartesian
178
+ ``(x, y, z)`` dimension subtended by the polygons of the surface.
179
+ This is used in several parts of the algorithm to find the nearest
180
+ position on the surface zones and should be increased when probing
181
+ imprecise nodal position data. (default: 1e-5)
182
+ dataset (`Dataset <tecplot.data.Dataset>`, optional): The `Dataset <tecplot.data.Dataset>` to probe. (defaults to
183
+ the active `Dataset <tecplot.data.Dataset>`.)
184
+ frame (`Frame <layout.Frame>`, optional): The `Frame <layout.Frame>` which determines the spatial
185
+ variable assignment ``(X,Y,Z)``. (defaults to the active `Frame <layout.Frame>`.)
186
+
187
+ Returns:
188
+ `namedtuple <collections.namedtuple>`: ``(data, cells_or_nodes, planes,
189
+ zone)``:
190
+
191
+ ``data`` (`list` of `floats <float>`)
192
+ Flattened `float` array which can be reshaped to ``(V, N)``
193
+ where ``V`` is the number of variables returned (either the
194
+ number of variables in the dataset or the length of
195
+ **variables** input parameter) and ``N`` is the number of
196
+ points probed.
197
+ ``cells_or_nodes`` (`list` of `integers <int>`)
198
+ The index to the cells (or nodes if `ProbeNearest.Node` was
199
+ passed in to **probe_nearest**) containing the returned
200
+ positions.
201
+ ``planes`` (`list` of `IJKPlanes`)
202
+ For ordered zones, these are the plane-orientations of the
203
+ cells for each probed position.
204
+ ``zones`` (`list` of `Zones <data_access>`)
205
+ Zones containing the given positions.
206
+
207
+ .. versionadded:: 2018.1
208
+ Probe on surface requires Tecplot 360 2018 R1 or later.
209
+
210
+ .. note:: The frame's plot type must be set to `PlotType.Cartesian3D`
211
+
212
+ Probe on surface requires the spatial variables to be set according to
213
+ the frame's style. This can be done by setting the plot type to
214
+ `PlotType.Cartesian3D`. Example::
215
+
216
+ tp.active_frame().plot_type = tp.constant.PlotType.Cartesian3D
217
+
218
+ For probing on 2D data, use `probe_at_position()`.
219
+
220
+ .. note:: Linear zones will always return nearest nodal values.
221
+
222
+ If linear zones, which are ignored by default, are included in the
223
+ **zones** parameter, the resulting values on that zone will always be
224
+ nodal and no interpolation on the position will be done.
225
+
226
+ .. note:: Irregular or jaggged surfaces may behave poorly.
227
+
228
+ For performance reasons, this algorithm has the potential to miss the
229
+ closest position on highly varying surfaces. This can be addressed by
230
+ first increasing **num_nearest_nodes** to search more of the zones and
231
+ then by increasing the **tolerance** to allow for imprecise position
232
+ data - skewed polygons for example.
233
+
234
+ All nodes of each cell considered are checked for co-planarity. This
235
+ check can be relaxed slightly by increasing the **tolerance**
236
+ parameter. The nearest position calculation will then be made assuming
237
+ the cells are planar and the resulting positions may be imprecise.
238
+
239
+ Example usage:
240
+
241
+ .. code-block:: python
242
+ :emphasize-lines: 14,28
243
+
244
+ from os import path
245
+ import numpy as np
246
+
247
+ import tecplot as tp
248
+ from tecplot.constant import PlotType
249
+
250
+ examples = tp.session.tecplot_examples_directory()
251
+ datafile = path.join(examples, 'SimpleData', 'F18.plt')
252
+ ds = tp.data.load_tecplot(datafile)
253
+ fr = tp.active_frame()
254
+ fr.plot_type = PlotType.Cartesian3D
255
+
256
+ # probe a single point
257
+ res = tp.data.query.probe_on_surface((13.5, 4.0, 0.6 ))
258
+
259
+ '''
260
+ The following line will print:
261
+ (13.499723788684996, 3.9922783797612795, 0.49241572276992346,
262
+ 0.0018958827755862578, 0.07313805429221854, 0.997276718375976,
263
+ 0.06335166319722907)
264
+ '''
265
+ print(res.data)
266
+
267
+ # probe multiple points
268
+ points = np.array([[13.5, 4.0, 0.6], # just above starboard wing
269
+ [13.5, -4.0, 0.6]]) # just above port wing
270
+
271
+ res = tp.data.query.probe_on_surface(points.transpose())
272
+ values = np.array(res.data).reshape((-1, len(points))).transpose()
273
+
274
+ '''
275
+ The following will print the probed position and the result of the probe
276
+ [ 13.5 4. 0.6] [ 1.34997238e+01 3.99227838e+00 4.92415723e-01
277
+ 1.89588278e-03 7.31380543e-02 9.97276718e-01 6.33516632e-02]
278
+ [ 13.5 -4. 0.6] [ 1.34997238e+01 -3.99227838e+00 4.92415723e-01
279
+ 1.89588278e-03 7.31380543e-02 9.97276718e-01 6.33516632e-02]
280
+ '''
281
+ for pt, v in zip(points, values):
282
+ print(pt, v)
283
+ """
284
+ if __debug__:
285
+ if frame and dataset and frame.dataset != dataset:
286
+ msg = ('Dataset must be attached to the input Frame: {} != {}'.
287
+ format(repr(frame.dataset), repr(dataset)))
288
+ raise TecplotValueError(msg)
289
+
290
+ if dataset is None:
291
+ if frame is None:
292
+ frame = layout.active_frame()
293
+ dataset = frame.dataset
294
+ elif frame is None:
295
+ frame = dataset.frame
296
+
297
+ if not hasattr(positions[0], '__iter__'):
298
+ positions = tuple(tuple([p]) for p in positions)
299
+
300
+ nvariables = dataset.num_variables if variables is None else len(variables)
301
+
302
+ with frame.activated():
303
+ n = max(len(p) for p in positions)
304
+ m = n * nvariables
305
+ x = (c_double * n)(*[float(p) for p in positions[0]])
306
+ y = (c_double * n)(*[float(p) for p in positions[1]])
307
+ z = (c_double * n)(*[float(p) for p in positions[2]])
308
+ v = (c_double * m)()
309
+ cells_or_nodes = (c_int64 * n)()
310
+ planes = (c_int32 * n)()
311
+ zone_indices = (c_int32 * n)()
312
+
313
+ zone_set = None if zones is None else IndexSet(zones)
314
+ var_set = None if variables is None else IndexSet(variables)
315
+ try:
316
+ if not _tecutil.ProbeOnSurface(n, x, y, z, zone_set, var_set,
317
+ ProbeNearest(probe_nearest).value,
318
+ obey_blanking, num_nearest_nodes,
319
+ tolerance, v, cells_or_nodes,
320
+ planes, zone_indices):
321
+ raise TecplotSystemError()
322
+ finally:
323
+ if zone_set is not None:
324
+ zone_set.dealloc()
325
+ if var_set is not None:
326
+ var_set.dealloc()
327
+
328
+ cells_or_nodes = tuple(cells_or_nodes)
329
+ planes = tuple(IJKPlanes(i) for i in planes)
330
+ zones = tuple(dataset.zone(i) for i in zone_indices)
331
+
332
+ SurfaceProbeResult = namedtuple('SurfaceProbeResult',
333
+ ['data', 'cells_or_nodes', 'planes', 'zones'])
334
+ return SurfaceProbeResult(tuple(v), cells_or_nodes, planes, zones)
tecplot/data/save.py ADDED
@@ -0,0 +1,343 @@
1
+ import logging
2
+
3
+ from ..tecutil import _tecutil
4
+ from ..constant import *
5
+ from ..exception import *
6
+ from .. import layout, macro, tecutil
7
+ from ..tecutil import IndexSet, lock, sv
8
+
9
+
10
+ log = logging.getLogger(__name__)
11
+
12
+
13
+ @lock()
14
+ def _save_tecplot(binary, frame, dataset, filename, include_text, include_geom,
15
+ include_data, include_data_share_linkage,
16
+ include_autogen_face_neighbors, use_point_format,
17
+ associate_with_layout, zones, variables, precision, version):
18
+ if dataset is None:
19
+ if frame is None:
20
+ frame = layout.active_frame()
21
+ elif frame is None:
22
+ frame = dataset.frame
23
+ elif frame.dataset != dataset:
24
+ msg = ('Input dataset must be attached to the input Frame: {} != {}'.
25
+ format(repr(frame.dataset), repr(dataset)))
26
+ raise TecplotValueError(msg)
27
+
28
+ with frame.activated():
29
+ with tecutil.ArgList() as arglist:
30
+ alloc_list = []
31
+ arglist[sv.FNAME] = tecutil.normalize_path(filename)
32
+ arglist[sv.BINARY] = binary
33
+
34
+ if zones is not None:
35
+ s = IndexSet(zones)
36
+ alloc_list.append(s)
37
+ arglist[sv.ZONELIST] = s
38
+
39
+ if variables is not None:
40
+ s = IndexSet(variables)
41
+ alloc_list.append(s)
42
+ arglist[sv.VARLIST] = s
43
+
44
+ arglist[sv.INCLUDETEXT] = include_text
45
+ arglist[sv.INCLUDEGEOM] = include_geom
46
+ arglist[sv.INCLUDEDATA] = include_data
47
+ arglist[sv.INCLUDEDATASHARELINKAGE] = include_data_share_linkage
48
+ arglist[sv.INCLUDEAUTOGENFACENEIGHBORS] = \
49
+ include_autogen_face_neighbors
50
+ arglist[sv.ASSOCIATELAYOUTWITHDATAFILE] = associate_with_layout
51
+ if version is not None:
52
+ arglist[sv.TECPLOTVERSIONTOWRITE] = BinaryFileVersion(version)
53
+ arglist[sv.PRECISION] = precision
54
+ arglist[sv.USEPOINTFORMAT] = use_point_format
55
+
56
+ try:
57
+ if not _tecutil.DataSetWriteX(arglist):
58
+ raise TecplotSystemError()
59
+ finally:
60
+ for a in alloc_list:
61
+ a.dealloc()
62
+
63
+ return frame.dataset
64
+
65
+
66
+ def save_tecplot_ascii(filename, frame=None, dataset=None, zones=None,
67
+ variables=None, include_text=None, precision=None,
68
+ include_geom=None, include_data=None,
69
+ include_data_share_linkage=None,
70
+ include_autogen_face_neighbors=None,
71
+ use_point_format=None):
72
+ """Write Tecplot ASCII data file.
73
+
74
+ Parameters:
75
+ filename (`str`): Name of the data file to write. (See note
76
+ below conerning absolute and relative paths.)
77
+ frame (`Frame <layout.Frame>`, optional): The `Frame <layout.Frame>` which holds the `Dataset <tecplot.data.Dataset>` to
78
+ be written. If this option and *dataset* are both `None`, the
79
+ currently active `Frame <layout.Frame>` is used. (default: `None`)
80
+ dataset (`Dataset <tecplot.data.Dataset>`, optional): The `Dataset <tecplot.data.Dataset>` to write out. If this
81
+ and *frame* are both `None`, the `Dataset <tecplot.data.Dataset>` of the currently active
82
+ `Frame <layout.Frame>` is used. (default: `None`)
83
+ include_text (`bool`, optional): Write out all text,
84
+ geometries and custom labels. (default: `True`)
85
+ include_geom (`bool`, optional): Write out all geometries.
86
+ (default: `True`)
87
+ include_data (`bool`, optional): Write out the data. Set
88
+ this to `False` if you only want to write out annotations.
89
+ (default: `True`)
90
+ include_data_share_linkage (`bool`, optional): Conserve space
91
+ and write the variable and connectivity linkage wherever
92
+ possible. If `False`, this will write out all data, losing the
93
+ connectivity sharing linkage for future dataset reads of the
94
+ file. (default: `True`)
95
+ include_autogen_face_neighbors (`bool`, optional): Save the
96
+ face neighbor connectivity. This may produce very large data
97
+ files. (default: `False`)
98
+ use_point_format (`bool`, optional): Write out point format,
99
+ otherwise use block format.
100
+ (default: `False`)
101
+ zones (`list` of `Zones <data_access>`, optional): `Zones
102
+ <data_access>` to write out. Use `None` to write out all `Zones
103
+ <data_access>`. (default: `None`)
104
+ variables (`list` of `Variables <Variable>`, optional):
105
+ `Variables <Variable>` to write out. Use `None` to write out all
106
+ `Variables <Variable>`. (default: `None`)
107
+ precision (`int`, optional): ASCII decimal precision to use.
108
+ (default: 12)
109
+
110
+ Returns:
111
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` read from when saving.
112
+
113
+ Raises:
114
+ `TecplotSystemError`
115
+ `TecplotLogicError`
116
+
117
+ .. note:: **Absolute and relative paths with PyTecplot**
118
+
119
+ Relative paths, when used within the PyTecplot API are always from
120
+ Python's current working directory which can be obtained by calling
121
+ :func:`os.getcwd()`. This is true for batch and `connected
122
+ <tecplot.session.connect()>` modes. One exception to this is paths
123
+ within a macro command or file which will be relative to the |Tecplot
124
+ Engine|'s home directory, which is typically the |Tecplot 360|
125
+ installation directory. Finally, when connected to a remote (non-local)
126
+ instance of Tecplot 360, only absolute paths are allowed.
127
+
128
+ Note that backslashes must be escaped which is especially important for
129
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
130
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
131
+ respectively. Alternatively, one may use Python's raw strings:
132
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
133
+
134
+ Example:
135
+ In this example, we load sample data and save the data in Tecplot ASCII
136
+ format:
137
+
138
+ .. code-block:: python
139
+ :emphasize-lines: 12-14
140
+
141
+ from os import path
142
+ import tecplot
143
+ examples_directory = tecplot.session.tecplot_examples_directory()
144
+ infile = path.join(examples_directory,
145
+ 'OneraM6wing', 'OneraM6_SU2_RANS.plt')
146
+ dataset = tecplot.data.load_tecplot(infile)
147
+ variables_to_save = [dataset.variable(V)
148
+ for V in ('x','y','z','Pressure_Coefficient')]
149
+
150
+ zone_to_save = dataset.zone('WingSurface')
151
+ # write data out to an ascii file
152
+ tecplot.data.save_tecplot_ascii('wing.dat', dataset=dataset,
153
+ variables=variables_to_save,
154
+ zones=[zone_to_save])
155
+ """
156
+ return _save_tecplot(
157
+ binary=False, frame=frame, dataset=dataset,
158
+ filename=filename, include_text=include_text,
159
+ include_geom=include_geom, include_data=include_data,
160
+ include_data_share_linkage=include_data_share_linkage,
161
+ include_autogen_face_neighbors=include_autogen_face_neighbors,
162
+ use_point_format=use_point_format,
163
+ associate_with_layout=None,
164
+ precision=precision,
165
+ zones=zones, variables=variables,
166
+ version=None)
167
+
168
+
169
+ def save_tecplot_plt(filename, frame=None, dataset=None, zones=None,
170
+ variables=None, version=None, include_text=None,
171
+ include_geom=None, include_data=None,
172
+ include_data_share_linkage=None,
173
+ include_autogen_face_neighbors=None,
174
+ associate_with_layout=None):
175
+ """Write Tecplot binary PLT data file.
176
+
177
+ Parameters:
178
+ filename (`str`): Name of the data file to write. (See note
179
+ below conerning absolute and relative paths.)
180
+ frame (`Frame <layout.Frame>`, optional): The `Frame <layout.Frame>` which holds the `Dataset <tecplot.data.Dataset>` to
181
+ be written. If this option and *dataset* are both `None`, the
182
+ currently active `Frame <layout.Frame>` is used. (default: `None`)
183
+ dataset (`Dataset <tecplot.data.Dataset>`, optional): The `Dataset <tecplot.data.Dataset>` to write out. If this
184
+ and *frame* are both `None`, the `Dataset <tecplot.data.Dataset>` of the currently active
185
+ `Frame <layout.Frame>` is used. (default: `None`)
186
+ zones (`list` of `Zones <data_access>`, optional): `Zones
187
+ <data_access>` to write out. If `None`, all `Zones <data_access>`
188
+ will be saved.
189
+ variables (`list` of `Variables <Variable>`, optional):
190
+ `Variables <Variable>` to write out. If `None`, all `Variables
191
+ <Variable>` will be saved.
192
+ include_text (`bool`, optional): Write out all text,
193
+ geometries and custom labels. (default: `True`)
194
+ include_geom (`bool`, optional): Write out all geometries.
195
+ (default: `True`)
196
+ include_data (`bool`, optional): Write out the data. Set
197
+ this to `False` if you only want to write out annotations.
198
+ (default: `True`)
199
+ include_data_share_linkage (`bool`, optional): Conserve space
200
+ and write the variable and connectivity linkage wherever
201
+ possible. If `False`, this will write out all data, losing the
202
+ connectivity sharing linkage for future dataset reads of the
203
+ file. (default: `False`)
204
+ include_autogen_face_neighbors (`bool`, optional): Save the
205
+ face neighbor connectivity. This may produce very large data
206
+ files. (default: `False`)
207
+ associate_with_layout (`bool`, optional): Associate this
208
+ data file with the current layout. Set to `False` to write the
209
+ datafile without modifying Tecplot's current data file to layout
210
+ association. If *version* is set to anything other than
211
+ `BinaryFileVersion.Current`, this association is not possible,
212
+ and this parameter will be ignored. (default: `True`)
213
+ version (`BinaryFileVersion`, optional): Specifies the
214
+ file version to write. Note that some data may be excluded from
215
+ the file if it cannot be supported in the specified version.
216
+ Possible values are: `Tecplot2006`, `Tecplot2008`, `Tecplot2009`
217
+ and `BinaryFileVersion.Current`. (default:
218
+ `BinaryFileVersion.Current`)
219
+
220
+ Returns:
221
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` read from when saving.
222
+
223
+ Raises:
224
+ `TecplotSystemError`
225
+ `TecplotLogicError`
226
+
227
+ .. note:: **Absolute and relative paths with PyTecplot**
228
+
229
+ Relative paths, when used within the PyTecplot API are always from
230
+ Python's current working directory which can be obtained by calling
231
+ :func:`os.getcwd()`. This is true for batch and `connected
232
+ <tecplot.session.connect()>` modes. One exception to this is paths
233
+ within a macro command or file which will be relative to the |Tecplot
234
+ Engine|'s home directory, which is typically the |Tecplot 360|
235
+ installation directory. Finally, when connected to a remote (non-local)
236
+ instance of Tecplot 360, only absolute paths are allowed.
237
+
238
+ Note that backslashes must be escaped which is especially important for
239
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
240
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
241
+ respectively. Alternatively, one may use Python's raw strings:
242
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
243
+
244
+ Example:
245
+ In this example, we load sample data and save the data in Tecplot
246
+ binary PLT format:
247
+
248
+ .. code-block:: python
249
+ :emphasize-lines: 13-15
250
+
251
+ from os import path
252
+ import tecplot
253
+ examples_directory = tecplot.session.tecplot_examples_directory()
254
+ infile = path.join(examples_directory,
255
+ 'OneraM6wing', 'OneraM6_SU2_RANS.plt')
256
+ dataset = tecplot.data.load_tecplot(infile)
257
+ variables_to_save = [dataset.variable(V)
258
+ for V in ('x', 'y', 'z',
259
+ 'Pressure_Coefficient')]
260
+
261
+ zone_to_save = dataset.zone('WingSurface')
262
+ # write data out to a binary file
263
+ tecplot.data.save_tecplot_plt('wing.plt', dataset=dataset,
264
+ variables=variables_to_save,
265
+ zones=[zone_to_save])
266
+ """
267
+ return _save_tecplot(
268
+ binary=True, frame=frame, dataset=dataset,
269
+ filename=filename, include_text=include_text,
270
+ include_geom=include_geom, include_data=include_data,
271
+ include_data_share_linkage=include_data_share_linkage,
272
+ include_autogen_face_neighbors=include_autogen_face_neighbors,
273
+ use_point_format=None,
274
+ associate_with_layout=associate_with_layout,
275
+ precision=None,
276
+ zones=zones, variables=variables,
277
+ version=version)
278
+
279
+
280
+ def save_tecplot_szl(filename, frame=None, dataset=None):
281
+ """Write Tecplot SZL data file.
282
+
283
+ Parameters:
284
+ filename (`str`): Name of the data file to write. (See note
285
+ below conerning absolute and relative paths.)
286
+ frame (`Frame <layout.Frame>`, optional): The `Frame <layout.Frame>` which holds the `Dataset <tecplot.data.Dataset>` to
287
+ be written. If this option and *dataset* are both `None`, the
288
+ currently active `Frame <layout.Frame>` is used. (default: `None`)
289
+ dataset (`Dataset <tecplot.data.Dataset>`, optional): The `Dataset <tecplot.data.Dataset>` to write out. If this
290
+ and *frame* are both `None`, the `Dataset <tecplot.data.Dataset>` of the currently active
291
+ `Frame <layout.Frame>` is used. (default: `None`)
292
+
293
+ Returns:
294
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` read from when saving.
295
+
296
+ .. note:: **Absolute and relative paths with PyTecplot**
297
+
298
+ Relative paths, when used within the PyTecplot API are always from
299
+ Python's current working directory which can be obtained by calling
300
+ :func:`os.getcwd()`. This is true for batch and `connected
301
+ <tecplot.session.connect()>` modes. One exception to this is paths
302
+ within a macro command or file which will be relative to the |Tecplot
303
+ Engine|'s home directory, which is typically the |Tecplot 360|
304
+ installation directory. Finally, when connected to a remote (non-local)
305
+ instance of Tecplot 360, only absolute paths are allowed.
306
+
307
+ Note that backslashes must be escaped which is especially important for
308
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
309
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
310
+ respectively. Alternatively, one may use Python's raw strings:
311
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
312
+
313
+ Example:
314
+ In this example, we load sample data and save it in Tecplot SZL
315
+ format:
316
+
317
+ .. code-block:: python
318
+ :emphasize-lines: 7
319
+
320
+ from os import path
321
+ import tecplot
322
+ examples_directory = tecplot.session.tecplot_examples_directory()
323
+ infile = path.join(examples_directory,
324
+ 'OneraM6wing', 'OneraM6_SU2_RANS.plt')
325
+ dataset = tecplot.data.load_tecplot(infile)
326
+ tecplot.data.save_tecplot_szl('wing.szplt')
327
+ """
328
+ if dataset is None:
329
+ if frame is None:
330
+ frame = layout.active_frame()
331
+ elif frame is None:
332
+ frame = dataset.frame
333
+ elif frame.dataset != dataset:
334
+ msg = ('Input dataset must be attached to the input Frame: {} != {}'.
335
+ format(repr(frame.dataset), repr(dataset)))
336
+ raise TecplotValueError(msg)
337
+
338
+ filepath = tecutil.normalize_path(filename)
339
+ with frame.activated():
340
+ macro.execute_extended_command(
341
+ 'Tecplot Subzone Data Tools',
342
+ 'WRITEDATASET FILENAME="{}"'.format(filepath))
343
+ return frame.dataset