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/load.py ADDED
@@ -0,0 +1,2075 @@
1
+ import getpass
2
+ import logging
3
+ import os
4
+ import platform
5
+ import textwrap
6
+ import warnings
7
+
8
+ from ..tecutil import _tecutil, _tecutil_connector
9
+ from ..constant import *
10
+ from ..exception import *
11
+ from .. import layout, macro, tecutil, version
12
+ from ..tecutil import IndexSet, StringList, lock, sv
13
+
14
+
15
+ log = logging.getLogger(__name__)
16
+
17
+
18
+ @lock()
19
+ def _tecplot_loader_load_data(arglist,
20
+ frame,
21
+ read_data_option=None,
22
+ reset_style=None,
23
+ initial_plot_first_zone_only=None,
24
+ initial_plot_type=None,
25
+ assign_strand_ids=None,
26
+ add_zones_to_existing_strands=None):
27
+ frame = frame or layout.active_frame()
28
+
29
+ # If read_data_option is append and there is no data, we
30
+ # need to silently change it to "Replace in Active Frame"
31
+ if read_data_option == ReadDataOption.Append and (
32
+ not frame.has_dataset or frame.dataset.num_zones == 0):
33
+ read_data_option = ReadDataOption.ReplaceInActiveFrame
34
+ if read_data_option == ReadDataOption.ReplaceInActiveFrame:
35
+ read_data_option = None # Replace in active frame is the default
36
+
37
+ with frame.activated():
38
+ arglist.update(**{
39
+ sv.READDATAOPTION: read_data_option,
40
+ sv.RESETSTYLE: reset_style,
41
+ sv.INITIALPLOTFIRSTZONEONLY: initial_plot_first_zone_only,
42
+ sv.INITIALPLOTTYPE: initial_plot_type,
43
+ sv.ASSIGNSTRANDIDS: assign_strand_ids,
44
+ sv.ADDZONESTOEXISTINGSTRANDS: add_zones_to_existing_strands})
45
+
46
+ if __debug__:
47
+ msg = 'loading data:'
48
+ for k, v in arglist.items():
49
+ if k == sv.FILENAMESORINSTRUCTIONS:
50
+ msg += '\n {}:'.format(k)
51
+ for i in v:
52
+ msg += '\n {}'.format(i)
53
+ else:
54
+ msg += '\n {}: {}'.format(k, v)
55
+ log.debug(msg)
56
+
57
+ if not _tecutil.DataSetReadX(arglist):
58
+ raise TecplotSystemError()
59
+
60
+ return frame.dataset
61
+
62
+
63
+ @lock()
64
+ def load_converge_hdf5(filenames,
65
+ frame=None,
66
+ read_data_option=ReadDataOption.Append,
67
+ reset_style=None,
68
+ initial_plot_type=None):
69
+ """Read CONVERGE HDF5 data files.
70
+
71
+ Parameters:
72
+ filenames (`str` or `list` of `strings <str>`): CONVERGE HDF5 data
73
+ files to be read. (See note below concerning absolute and relative
74
+ paths.)
75
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
76
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
77
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
78
+ and the zones are appended by default.
79
+ read_data_option (`ReadDataOption`, optional): Specify how the data
80
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
81
+
82
+ Possible values are:
83
+ * `ReadDataOption.ReplaceInActiveFrame`
84
+ Remove the dataset from the active frame prior to reading in the
85
+ new dataset. If other frames use the same `Dataset
86
+ <tecplot.data.Dataset>` in the active frame, they will continue to
87
+ use the old one.
88
+ * `ReadDataOption.Append`
89
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
90
+ * `ReadDataOption.Replace`
91
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
92
+ frame and to all other frames that use the same `Dataset
93
+ <tecplot.data.Dataset>`.
94
+ reset_style (`bool`, optional): Reset the style for
95
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
96
+ <layout.Frame>`'s current style is preserved. (default: `True`)
97
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
98
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
99
+ To have |Tecplot 360| determine the most appropriate plot type
100
+ for the data, use `PlotType.Automatic`. Possible values are:
101
+ `PlotType.Automatic` (default), `Cartesian3D`, `Cartesian2D`,
102
+ `XYLine`, `PlotType.Sketch`, `PolarLine`.
103
+
104
+ Returns:
105
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
106
+ the loaded data.
107
+
108
+ .. note:: **Absolute and relative paths with PyTecplot**
109
+
110
+ Relative paths, when used within the PyTecplot API are always from
111
+ Python's current working directory which can be obtained by calling
112
+ :func:`os.getcwd()`. This is true for batch and `connected
113
+ <tecplot.session.connect()>` modes. One exception to this is paths
114
+ within a macro command or file which will be relative to the |Tecplot
115
+ Engine|'s home directory, which is typically the |Tecplot 360|
116
+ installation directory. Finally, when connected to a remote (non-local)
117
+ instance of Tecplot 360, only absolute paths are allowed.
118
+
119
+ Note that backslashes must be escaped which is especially important for
120
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
121
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
122
+ respectively. Alternatively, one may use Python's raw strings:
123
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
124
+
125
+ .. versionadded:: 2019.1
126
+ Loading CONVERGE HDF5 data requires Tecplot 360 2019 R1 or later.
127
+
128
+ .. versionadded:: 1.2
129
+ """
130
+ if isinstance(filenames, str):
131
+ filenames = filenames.split(',')
132
+
133
+ filenames = [tecutil.normalize_path(f) for f in filenames]
134
+
135
+ if not _tecutil_connector.connected \
136
+ or _tecutil_connector.client.host in ['localhost', '127.0.0.1']:
137
+ for f in filenames:
138
+ if not os.path.exists(f):
139
+ raise TecplotOSError('File not found: ' + f)
140
+
141
+ with tecutil.StringList('STANDARDSYNTAX', '1.0') as instr:
142
+ with tecutil.ArgList() as arglist:
143
+ arglist[sv.DATASETREADER] = 'CONVERGE HDF5 File Loader'
144
+ instr += ['FILELIST_DATAFILES', str(len(filenames))] + filenames
145
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
146
+ return _tecplot_loader_load_data(
147
+ arglist, frame=frame, read_data_option=read_data_option,
148
+ reset_style=reset_style,
149
+ initial_plot_type=initial_plot_type,
150
+ assign_strand_ids=True)
151
+
152
+
153
+ @lock()
154
+ def load_converge_output(filenames,
155
+ frame=None,
156
+
157
+ read_data_option=ReadDataOption.Append,
158
+ reset_style=None):
159
+ """Read CONVERGE Output data files.
160
+
161
+ Parameters:
162
+ filenames (`str` or `list` of `strings <str>`): CONVERGE Output data
163
+ files to be read. (See note below concerning absolute and relative
164
+ paths.)
165
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
166
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
167
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
168
+ and the zones are appended by default.
169
+ read_data_option (`ReadDataOption`, optional): Specify how the data
170
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
171
+
172
+ Possible values are:
173
+ * `ReadDataOption.ReplaceInActiveFrame`
174
+ Remove the dataset from the active frame prior to reading in the
175
+ new dataset. If other frames use the same `Dataset
176
+ <tecplot.data.Dataset>` in the active frame, they will continue to
177
+ use the old one.
178
+ * `ReadDataOption.Append`
179
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
180
+ * `ReadDataOption.Replace`
181
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
182
+ frame and to all other frames that use the same `Dataset
183
+ <tecplot.data.Dataset>`.
184
+ reset_style (`bool`, optional): Reset the style for
185
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
186
+ <layout.Frame>`'s current style is preserved. (default: `True`)
187
+
188
+ Returns:
189
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
190
+ the loaded data.
191
+
192
+ .. note:: **Absolute and relative paths with PyTecplot**
193
+
194
+ Relative paths, when used within the PyTecplot API are always from
195
+ Python's current working directory which can be obtained by calling
196
+ :func:`os.getcwd()`. This is true for batch and `connected
197
+ <tecplot.session.connect()>` modes. One exception to this is paths
198
+ within a macro command or file which will be relative to the |Tecplot
199
+ Engine|'s home directory, which is typically the |Tecplot 360|
200
+ installation directory. Finally, when connected to a remote (non-local)
201
+ instance of Tecplot 360, only absolute paths are allowed.
202
+
203
+ Note that backslashes must be escaped which is especially important for
204
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
205
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
206
+ respectively. Alternatively, one may use Python's raw strings:
207
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
208
+ """
209
+ if isinstance(filenames, str):
210
+ filenames = filenames.split(',')
211
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
212
+ with tecutil.ArgList() as arglist:
213
+ arglist[sv.DATASETREADER] = 'CONVERGE Output File Loader'
214
+ instr += ['FILELIST', str(len(filenames))]
215
+ instr += [tecutil.normalize_path(f) for f in filenames]
216
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
217
+ return _tecplot_loader_load_data(
218
+ arglist, frame=frame, read_data_option=read_data_option,
219
+ reset_style=reset_style)
220
+
221
+
222
+ @lock()
223
+ def load_fvcom(filenames,
224
+
225
+ frame=None,
226
+
227
+ read_data_option=ReadDataOption.Append,
228
+ reset_style=None,
229
+ initial_plot_type=None):
230
+ """Read FVCOM netCDF data files.
231
+
232
+ Parameters:
233
+ filenames (`str` or `list` of `strings <str>`): FVCOM data
234
+ files to be read. (See note below concerning absolute and relative
235
+ paths.)
236
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
237
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
238
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
239
+ and the zones are appended by default.
240
+ read_data_option (`ReadDataOption`, optional): Specify how the data
241
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
242
+
243
+ Possible values are:
244
+ * `ReadDataOption.ReplaceInActiveFrame`
245
+ Remove the dataset from the active frame prior to reading in the
246
+ new dataset. If other frames use the same `Dataset
247
+ <tecplot.data.Dataset>` in the active frame, they will continue to
248
+ use the old one.
249
+ * `ReadDataOption.Append`
250
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
251
+ * `ReadDataOption.Replace`
252
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
253
+ frame and to all other frames that use the same `Dataset
254
+ <tecplot.data.Dataset>`.
255
+ reset_style (`bool`, optional): Reset the style for
256
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
257
+ <layout.Frame>`'s current style is preserved. (default: `True`)
258
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
259
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
260
+ To have |Tecplot 360| determine the most appropriate plot type
261
+ for the data, use `PlotType.Automatic`. Possible values are:
262
+ `PlotType.Automatic` (default), `Cartesian3D`, `Cartesian2D`,
263
+ `XYLine`, `PlotType.Sketch`, `PolarLine`.
264
+
265
+ Returns:
266
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
267
+ the loaded data.
268
+
269
+ .. note:: **Absolute and relative paths with PyTecplot**
270
+
271
+ Relative paths, when used within the PyTecplot API are always from
272
+ Python's current working directory which can be obtained by calling
273
+ :func:`os.getcwd()`. This is true for batch and `connected
274
+ <tecplot.session.connect()>` modes. One exception to this is paths
275
+ within a macro command or file which will be relative to the |Tecplot
276
+ Engine|'s home directory, which is typically the |Tecplot 360|
277
+ installation directory. Finally, when connected to a remote (non-local)
278
+ instance of Tecplot 360, only absolute paths are allowed.
279
+
280
+ Note that backslashes must be escaped which is especially important for
281
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
282
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
283
+ respectively. Alternatively, one may use Python's raw strings:
284
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
285
+
286
+ .. versionadded:: 2018.2
287
+ Loading FVCOM data requires Tecplot 360 2018 R2 or later.
288
+ """
289
+ if isinstance(filenames, str):
290
+ filenames = filenames.split(',')
291
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
292
+ with tecutil.ArgList() as arglist:
293
+ arglist[sv.DATASETREADER] = 'FVCOM netCDF Loader'
294
+ instr += ['FILELIST_DATAFILES', str(len(filenames))]
295
+ instr += [tecutil.normalize_path(f) for f in filenames]
296
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
297
+ return _tecplot_loader_load_data(
298
+ arglist, frame=frame, read_data_option=read_data_option,
299
+ reset_style=reset_style,
300
+ initial_plot_type=initial_plot_type,
301
+ assign_strand_ids=True)
302
+
303
+
304
+ @lock()
305
+ def load_cgns(filenames,
306
+
307
+ frame=None,
308
+
309
+ read_data_option=ReadDataOption.Append,
310
+ reset_style=None,
311
+ initial_plot_first_zone_only=None,
312
+ initial_plot_type=None,
313
+
314
+ zones=None,
315
+ variables=None,
316
+
317
+ load_convergence_history=None,
318
+ combine_fe_sections=None,
319
+ average_to_nodes='Arithmetic',
320
+ uniform_grid=None,
321
+ assign_strand_ids=None,
322
+ add_zones_to_existing_strands=None,
323
+
324
+ include_boundary_conditions=True):
325
+ """Read CGNS data files.
326
+
327
+ Parameters:
328
+ filenames (`str` or `list` of `strings <str>`): CGNS data
329
+ files to be read. (See note below concerning absolute and relative
330
+ paths.)
331
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
332
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
333
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
334
+ and the zones are appended by default.
335
+ read_data_option (`ReadDataOption`, optional): Specify how the data
336
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
337
+
338
+ Possible values are:
339
+ * `ReadDataOption.ReplaceInActiveFrame`
340
+ Remove the dataset from the active frame prior to reading in the
341
+ new dataset. If other frames use the same `Dataset
342
+ <tecplot.data.Dataset>` in the active frame, they will continue to
343
+ use the old one.
344
+ * `ReadDataOption.Append`
345
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
346
+ * `ReadDataOption.Replace`
347
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
348
+ frame and to all other frames that use the same `Dataset
349
+ <tecplot.data.Dataset>`.
350
+ reset_style (`bool`, optional): Reset the style for
351
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
352
+ <layout.Frame>`'s current style is preserved. (default: `True`)
353
+ initial_plot_first_zone_only (`bool`, optional): Informs
354
+ the |Tecplot Engine| that after the data is loaded it only needs to
355
+ activate the first enabled `Zone <data_access>` for the initial
356
+ plot. This option is particularly useful if you have many `Zones
357
+ <data_access>` and want to get the data into the |Tecplot Engine|
358
+ and the first `Zone <data_access>` drawn as fast as possible. The
359
+ inactive `Zones <data_access>` can always be activated when needed.
360
+ (default: `False`)
361
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
362
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
363
+ To have |Tecplot 360| determine the most appropriate plot type
364
+ for the data, use `PlotType.Automatic`. Possible values are:
365
+ `PlotType.Automatic` (default), `Cartesian3D`, `Cartesian2D`,
366
+ `XYLine`, `PlotType.Sketch`, `PolarLine`.
367
+
368
+ zones (`list` of `integers <int>`, optional): List of zone indexes to
369
+ load starting from zero. `None` implies loading all zones.
370
+ (default: `None`)
371
+ variables (`list` of `integers <int>`, optional): List of variable
372
+ indexes, beyond the first coordinate variables, to load starting
373
+ from zero. `None` implies loading all variables. The grid will
374
+ always be loaded and an index of zero indicates the first
375
+ non-coordinate variable. (default: `None`)
376
+
377
+ load_convergence_history (`bool`, optional): Load the
378
+ global convergence history rather than any grid or solution data.
379
+ (default: `False`)
380
+ combine_fe_sections (`bool`, optional): Combine all
381
+ finite-element sections with the zone cell-dimension into one
382
+ zone. (default: `False`)
383
+ average_to_nodes (`str`, optional): Average
384
+ cell-centered data to grid nodes using the specified method.
385
+ (Options: `None`, "Arithmetic", "Laplacian", default: "Arithmetic")
386
+ uniform_grid (`bool`, optional): Indicates the grid
387
+ structure is the same for all time steps. (default: `True`)
388
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
389
+ zones that have a strand ID of -1. (default: `True`)
390
+ add_zones_to_existing_strands (`bool`, optional): Add the
391
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
392
+ new data specifies strands, new ones will be created beginning after the
393
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `False`)
394
+
395
+ include_boundary_conditions (`bool`, optional): Load the
396
+ boundary conditions along with the data. Upon loading, the
397
+ associated fieldmaps will remain inactive. For unstructured data,
398
+ boundary conditions are always loaded and this option is ignored.
399
+ (default: `True`)
400
+
401
+ Returns:
402
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
403
+ the loaded data.
404
+
405
+ Raises:
406
+ `TecplotSystemError`: Internal error when loading data.
407
+ `TecplotTypeError`: Invalid input.
408
+
409
+ .. note:: **Absolute and relative paths with PyTecplot**
410
+
411
+ Relative paths, when used within the PyTecplot API are always from
412
+ Python's current working directory which can be obtained by calling
413
+ :func:`os.getcwd()`. This is true for batch and `connected
414
+ <tecplot.session.connect()>` modes. One exception to this is paths
415
+ within a macro command or file which will be relative to the |Tecplot
416
+ Engine|'s home directory, which is typically the |Tecplot 360|
417
+ installation directory. Finally, when connected to a remote (non-local)
418
+ instance of Tecplot 360, only absolute paths are allowed.
419
+
420
+ Note that backslashes must be escaped which is especially important for
421
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
422
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
423
+ respectively. Alternatively, one may use Python's raw strings:
424
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
425
+ """
426
+ if __debug__:
427
+ avg_to_nodes_opts = [None, 'Arithmetic', 'Laplacian']
428
+ if average_to_nodes not in avg_to_nodes_opts:
429
+ msg = 'average_to_nodes must be one of: '
430
+ msg += ', '.join(str(x) for x in avg_to_nodes_opts)
431
+ raise TecplotTypeError(msg)
432
+
433
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
434
+ with tecutil.ArgList() as arglist:
435
+ arglist[sv.DATASETREADER] = 'CGNS LOADER'
436
+ instr += ['LoaderVersion', 'V3']
437
+
438
+ # We need to add the cgns library version to the arglist,
439
+ # although this setting is not exposed in the API.
440
+ instr += ['CgnsLibraryVersion', '3.1.4']
441
+
442
+ if isinstance(filenames, str):
443
+ filenames = filenames.split(',')
444
+ instr += ['FILELIST_CGNSFILES', str(len(filenames))]
445
+ instr += [tecutil.normalize_path(f) for f in filenames]
446
+
447
+ if zones is not None:
448
+ indexes = [str(int(z)) for z in zones]
449
+ instr += ['ZoneList', ','.join(indexes)]
450
+ if variables is not None:
451
+ indexes = [str(int(v)) for v in variables]
452
+ instr += ['VarList', ','.join(indexes)]
453
+
454
+ if average_to_nodes is None:
455
+ instr += ['AverageToNodes', 'No']
456
+ elif average_to_nodes != 'Arithmetic':
457
+ # Default for 'AverageToNoes' is 'Yes'
458
+ # Default for AveragingMethods is 'Arithmetic'
459
+ instr += ['AveragingMethod', average_to_nodes]
460
+
461
+ if uniform_grid is not None:
462
+ instr += ['UniformGridStructure',
463
+ 'Yes' if uniform_grid else 'No']
464
+
465
+ if combine_fe_sections is not None:
466
+ instr += [
467
+ 'SectionLoad', 'SeparateZones'
468
+ if combine_fe_sections else 'Combine']
469
+ if include_boundary_conditions is not None:
470
+ instr += ['LoadBCs',
471
+ 'Yes' if include_boundary_conditions else 'No']
472
+ if load_convergence_history is not None:
473
+ instr += ['LoadConvergenceHistory',
474
+ 'Yes' if load_convergence_history else 'No']
475
+ if assign_strand_ids is not None:
476
+ instr += ['AssignStrandIDs',
477
+ 'Yes' if assign_strand_ids else 'No']
478
+
479
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
480
+
481
+ return _tecplot_loader_load_data(
482
+ arglist, frame=frame, read_data_option=read_data_option,
483
+ reset_style=reset_style,
484
+ initial_plot_first_zone_only=initial_plot_first_zone_only,
485
+ initial_plot_type=initial_plot_type,
486
+ assign_strand_ids=assign_strand_ids,
487
+ add_zones_to_existing_strands=add_zones_to_existing_strands)
488
+
489
+
490
+ @lock()
491
+ def load_fluent(case_filenames=None,
492
+ data_filenames=None,
493
+
494
+ frame=None,
495
+
496
+ append=True,
497
+ zones=None,
498
+ variables=None,
499
+
500
+ all_poly_zones=None,
501
+ average_to_nodes='Arithmetic',
502
+ time_interval=None,
503
+ assign_strand_ids=True,
504
+ add_zones_to_existing_strands=None,
505
+
506
+ include_particle_data=None,
507
+ include_additional_quantities=True,
508
+ save_uncompressed_files=None):
509
+ """Read Fluent data files.
510
+
511
+ Parameters:
512
+ case_filenames (`str` or `list` of `strings <str>`, optional):
513
+ Case (*.cas*, *.cas.gz*) files to be read. Compressed files with
514
+ extension *.gz* are supported. (See note below concerning absolute
515
+ and relative paths.)
516
+ data_filenames (`str` or `list` of `strings <str>`, optional):
517
+ Data (*.dat*, *.xml*, *.dat.gz*, *.fdat*, *.fdat.gz*, etc.) files
518
+ to be read. Compressed files with extension *.gz* are supported.
519
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
520
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
521
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
522
+ and the zones are appended by default.
523
+ append (`bool`, optional): Append the data to the existing
524
+ `Dataset <tecplot.data.Dataset>`. If `False`, the existing data attached to
525
+ the `Frame <layout.Frame>` is deleted and replaced. (default: `True`)
526
+
527
+ zones (`str` or `list` of `integers <int>`, optional): List of
528
+ zone indexes (zero-based) to load or string specifying the type of
529
+ zones to load. Possible values are: "CellsAndBoundaries",
530
+ "CellsOnly" and "BoundariesOnly". Specifying one of these options
531
+ is mutually exclusive with the ``variables`` option. (default:
532
+ "CellsAndBoundaries")
533
+ variables (`list` of `strings <str>`, optional): List of variable
534
+ names to load. `None` implies loading all variables. (default:
535
+ `None`)
536
+
537
+ all_poly_zones (`bool`, optional): Converts all zones to
538
+ Tecplot polytope (polyhedral or polygonal) zones. (default:
539
+ `False`)
540
+ average_to_nodes (`str`, optional): Average
541
+ cell-centered data to grid nodes using the specified method.
542
+ (Options: `None`, "Arithmetic", "Laplacian", default: "Arithmetic")
543
+ time_interval (`float`, optional): Use a constant time interval between
544
+ each data (*.dat*) file. If `None`, the flow-data parameter of each
545
+ solution data (*.dat*) file is used. (default: `None`)
546
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
547
+ zones that have a strand ID of -1. (default: `True`)
548
+
549
+ .. note::
550
+ assign_strand_ids only applies if you have also provided a
551
+ time_interval, otherwise it will be ignored.
552
+ add_zones_to_existing_strands (`bool`, optional): Add the
553
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
554
+ new data specifies strands, new ones will be created beginning after the
555
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `False`)
556
+
557
+ include_particle_data (`bool`, optional): Load particle
558
+ data from the data (*.dat*) files. If loading particle data from an XML
559
+ file, the XML file should be included in the ``data_filenames``
560
+ list. (default: `False`)
561
+ include_additional_quantities (`bool`, optional): Load
562
+ quantities that were derived from the FLUENT's standard quantities.
563
+ (default: `True`) *New in Tecplot 360 2017 R2*.
564
+ save_uncompressed_files (`bool`, optional): Save the
565
+ uncompressed files to the compressed files' location.
566
+
567
+ Returns:
568
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
569
+ the loaded data.
570
+
571
+ Raises:
572
+ `TecplotSystemError`: Internal error when loading data.
573
+ `TecplotTypeError`: In-valid input.
574
+
575
+ .. note:: **Absolute and relative paths with PyTecplot**
576
+
577
+ Relative paths, when used within the PyTecplot API are always from
578
+ Python's current working directory which can be obtained by calling
579
+ :func:`os.getcwd()`. This is true for batch and `connected
580
+ <tecplot.session.connect()>` modes. One exception to this is paths
581
+ within a macro command or file which will be relative to the |Tecplot
582
+ Engine|'s home directory, which is typically the |Tecplot 360|
583
+ installation directory. Finally, when connected to a remote (non-local)
584
+ instance of Tecplot 360, only absolute paths are allowed.
585
+
586
+ Note that backslashes must be escaped which is especially important for
587
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
588
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
589
+ respectively. Alternatively, one may use Python's raw strings:
590
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
591
+
592
+ Notes:
593
+ The ``zones`` option takes either a `list` of zone indexes to be
594
+ imported or one of "CellsAndBoundaries", "CellsOnly" or
595
+ "BoundariesOnly" to indicate the type of zones the user wants to load,
596
+ however these options are mutually exclusive with the ``variables``
597
+ option::
598
+
599
+ >>> dataset = tecplot.data.load_fluent(['one.cas', 'two.cas'],
600
+ ... data_filenames=['one.dat', 'two.dat'],
601
+ ... variables = ['Pressure','Velocity'],
602
+ ... zones = [0,1,3])
603
+ """
604
+ if isinstance(case_filenames, str):
605
+ case_filenames = [case_filenames]
606
+ if isinstance(data_filenames, str):
607
+ data_filenames = [data_filenames]
608
+
609
+ if __debug__:
610
+ zone_types_opts = ['CellsAndBoundaries', 'CellsOnly', 'BoundariesOnly']
611
+ avg_to_nodes_opts = [None, 'Arithmetic', 'Laplacian']
612
+ if isinstance(zones, str):
613
+ if zones not in zone_types_opts:
614
+ msg = 'Zones must be list of indexes or one of: '
615
+ msg += ', '.join(zone_types_opts)
616
+ raise TecplotTypeError(msg)
617
+ if variables is not None:
618
+ msg = 'Loading a subset of variables is allowed only if'
619
+ msg += ' zones is None or a list of zones.'
620
+ raise TecplotTypeError(msg)
621
+ if (case_filenames or data_filenames) is None:
622
+ raise TecplotTypeError('You must specify a case or data file.')
623
+ if (case_filenames is None) and (len(data_filenames) != 1):
624
+ msg = 'Case file is required when loading multiple data files'
625
+ raise TecplotTypeError(msg)
626
+ if average_to_nodes not in avg_to_nodes_opts:
627
+ msg = 'average_to_nodes must be one of: '
628
+ msg += ', '.join(str(x) for x in avg_to_nodes_opts)
629
+ raise TecplotTypeError(msg)
630
+
631
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
632
+ with tecutil.ArgList() as arglist:
633
+ arglist[sv.DATASETREADER] = 'Fluent Data Loader'
634
+
635
+ if append:
636
+ instr += ['Append', 'Yes']
637
+
638
+ if case_filenames is not None:
639
+ if data_filenames is not None:
640
+ nfiles = len(case_filenames) + len(data_filenames)
641
+ instr += ['LoadOption', 'MultipleCaseAndData',
642
+ 'FILELIST_Files', str(nfiles)]
643
+ instr += [tecutil.normalize_path(f)
644
+ for f in list(case_filenames) +
645
+ list(data_filenames)]
646
+ else:
647
+ instr += ['LoadOption', 'MultipleCaseAndData',
648
+ 'FILELIST_Files', str(len(case_filenames))]
649
+ instr += [tecutil.normalize_path(f)
650
+ for f in list(case_filenames)]
651
+ else:
652
+ instr += ['LoadOption', 'ResidualsOnly',
653
+ 'FILENAME_DataFile',
654
+ tecutil.normalize_path(data_filenames[0])]
655
+
656
+ if time_interval is not None:
657
+ instr += ["UnsteadyOption", 'ApplyConstantTimeInterval']
658
+ instr += ['TimeInterval', str(float(time_interval))]
659
+
660
+ if isinstance(zones, str):
661
+ instr += ['GridZones', zones]
662
+ elif (zones or variables) is not None:
663
+ instr += ["GridZones", 'SelectedZones']
664
+ if zones is not None:
665
+ zone_indexes = ','.join(str(int(z) + 1) for z in zones)
666
+ instr += ['ZoneList', zone_indexes]
667
+ if variables is not None:
668
+ var_names = '\n'.join(variables)
669
+ instr += ['VarNameList', var_names]
670
+
671
+ if include_particle_data: # "No" is the default
672
+ instr += ['IncludeParticleData',
673
+ 'Yes']
674
+ if all_poly_zones: # "No" is the default
675
+ instr += ['AllPolyZones',
676
+ 'Yes']
677
+ if average_to_nodes is None:
678
+ instr += ['AverageToNodes', 'No']
679
+ elif average_to_nodes != 'Arithmetic':
680
+ # Default for 'AverageToNoes' is 'Yes'
681
+ # Default for AveragingMethods is 'Arithmetic'
682
+ instr += ['AveragingMethod', average_to_nodes]
683
+
684
+ if assign_strand_ids is not None:
685
+ instr += ['AssignStrandIDs',
686
+ 'Yes' if assign_strand_ids else 'No']
687
+ if add_zones_to_existing_strands is not None:
688
+ instr += ['AddZonesToExistingStrands',
689
+ 'Yes' if add_zones_to_existing_strands else 'No']
690
+
691
+ # Always explicitly provide SaveUncompressedFiles
692
+ instr += ['SaveUncompressedFiles',
693
+ 'Yes' if save_uncompressed_files else 'No']
694
+
695
+ instr += ['LoadAdditionalQuantities',
696
+ 'Yes' if include_additional_quantities else 'No']
697
+
698
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
699
+
700
+ return _tecplot_loader_load_data(arglist, frame=frame)
701
+
702
+
703
+ @lock()
704
+ def load_fluent_cff(filenames,
705
+ frame=None,
706
+ read_data_option=ReadDataOption.Append,
707
+ reset_style=None,
708
+ initial_plot_type=None,
709
+ solution_time_source=None,
710
+ include_interior_face_zones=None,
711
+ include_particle_zones=None):
712
+ """Read Fluent Common Fluids Format files.
713
+
714
+ Parameters:
715
+ filenames (`str` or `list` of `strings <str>`): One or more Fluent CFF
716
+ case (*.cas.h5*) files followed by zero or more Fluent CFF data
717
+ (*.dat.h5*) files (See note below concerning absolute and relative
718
+ paths.)
719
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
720
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
721
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
722
+ and the zones are appended by default.
723
+ read_data_option (`ReadDataOption`, optional): Specify how the data
724
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
725
+
726
+ Possible values are:
727
+ * `ReadDataOption.ReplaceInActiveFrame`
728
+ Remove the dataset from the active frame prior to reading in the
729
+ new dataset. If other frames use the same `Dataset
730
+ <tecplot.data.Dataset>` in the active frame, they will continue to
731
+ use the old one.
732
+ * `ReadDataOption.Append`
733
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
734
+ * `ReadDataOption.Replace`
735
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
736
+ frame and to all other frames that use the same `Dataset
737
+ <tecplot.data.Dataset>`.
738
+ reset_style (`bool`, optional): Reset the style for
739
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
740
+ <layout.Frame>`'s current style is preserved. (default: `True`)
741
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
742
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
743
+ To have |Tecplot 360| determine the most appropriate plot type for
744
+ the data, use `PlotType.Automatic`. Possible values are:
745
+ `PlotType.Automatic`, `Cartesian3D`, `Cartesian2D`, `XYLine`,
746
+ `PlotType.Sketch`, `PolarLine`. (default: `PlotType.Automatic`)
747
+ solution_time_source (`FluentCFFLoader.SolutionTimeSource`, optional):
748
+ Assign the solution times of the zones based on the specified
749
+ criteria. (default: `FluentCFFLoader.SolutionTimeSource.Auto`)
750
+
751
+ Possible values are:
752
+ * `FluentCFFLoader.SolutionTimeSource.Auto`
753
+ First looks for and uses solution time specified in the
754
+ simulation settings of the Fluent CFF data files. If that
755
+ information isn't present in all supplied files, next looks
756
+ for solution time embedded in ``filenames``. If solution
757
+ time cannot be determined, the loader assigns a constant
758
+ time interval, starting at zero and incrementing by one, if
759
+ there is a single file, or if there are case and data file
760
+ combinations, otherwise assigns static solution times of
761
+ zero.
762
+ * `FluentCFFLoader.SolutionTimeSource.SteadyState`
763
+ Assigns a static solution time of zero to all zones.
764
+ * `FluentCFFLoader.SolutionTimeSource.ConstantTimeInterval`
765
+ Assigns a constant time interval, starting at zero and
766
+ incrementing by one
767
+ include_interior_face_zones (`bool`, optional): Interior face zones,
768
+ which are used to build cell zones, are loaded as independent
769
+ face zones. (default: `False`)
770
+ include_particle_zones (`bool`, optional): Loads particle data as
771
+ I-ordered zones and nodal variables if it exists in the data
772
+ (*dat.h5*) file(s). (default: `True`)
773
+
774
+ Returns:
775
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
776
+ the loaded data.
777
+
778
+ .. note:: **Absolute and relative paths with PyTecplot**
779
+
780
+ Relative paths, when used within the PyTecplot API are always from
781
+ Python's current working directory which can be obtained by calling
782
+ :func:`os.getcwd()`. This is true for batch and `connected
783
+ <tecplot.session.connect()>` modes. One exception to this is paths
784
+ within a macro command or file which will be relative to the |Tecplot
785
+ Engine|'s home directory, which is typically the |Tecplot 360|
786
+ installation directory. Finally, when connected to a remote (non-local)
787
+ instance of Tecplot 360, only absolute paths are allowed.
788
+
789
+ Note that backslashes must be escaped which is especially important for
790
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
791
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
792
+ respectively. Alternatively, one may use Python's raw strings:
793
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
794
+
795
+ .. note::
796
+ The Fluent CFF loader is not available on macOS.
797
+
798
+ The Fluent CFF loader takes one or more case files, followed by zero or
799
+ more data files in a single list::
800
+
801
+ >>> dataset = tecplot.data.load_fluent_cff(
802
+ ... ['one.cas.h5', 'one.dat.h5', 'two.dat.h5', 'three.cas.h5'],
803
+ ... read_data_option = ReadDataOption.Replace,
804
+ ... include_interior_face_zones = True)
805
+
806
+ .. versionadded:: 2021.1
807
+ Loading Fluent CFF files requires Tecplot 360 2021 R1 or later.
808
+
809
+ .. versionadded:: 1.4
810
+ """
811
+ if isinstance(filenames, str):
812
+ filenames = filenames.split(',')
813
+
814
+ filenames = [tecutil.normalize_path(f) for f in filenames]
815
+
816
+ TimeSource = FluentCFFLoader.SolutionTimeSource
817
+ with tecutil.StringList('STANDARDSYNTAX', '1.0') as instr:
818
+ with tecutil.ArgList() as arglist:
819
+ arglist[sv.DATASETREADER] = 'Fluent Common Fluid Files Loader'
820
+ instr += ['FILELIST_DATAFILES', str(len(filenames))] + filenames
821
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
822
+ if solution_time_source is not None:
823
+ instr += ['SolutionTimeSource',
824
+ TimeSource(solution_time_source).value]
825
+ if include_interior_face_zones: # 'No' is the default
826
+ instr += ['IncludeInteriorFaceZones', 'Yes']
827
+ if include_particle_zones is False:
828
+ instr += ['IncludeParticleZones', 'No']
829
+ return _tecplot_loader_load_data(
830
+ arglist, frame=frame, read_data_option=read_data_option,
831
+ reset_style=reset_style,
832
+ initial_plot_type=initial_plot_type,
833
+ assign_strand_ids=True)
834
+
835
+
836
+ @lock()
837
+ def load_telemac(filenames=None,
838
+ boundary_filename=None,
839
+ frame=None,
840
+ read_data_option=ReadDataOption.Append,
841
+ reset_style=None,
842
+ initial_plot_type=None):
843
+ """Read Telemac data files and/or boundary file.
844
+
845
+ Parameters:
846
+ filenames (`str` or `list` of `strings <str>`, optional): Telemac data
847
+ file(s) to be read. (See note below concerning absolute and
848
+ relative paths.) Not required if a boundary file is being appended
849
+ to an existing data set.
850
+ boundary_filename (`str`, optional): Boundary file. If loaded with
851
+ multiple Telemac files, will be applied to the first Telemac file.
852
+ If loaded with no Telemac files, must be appended to an existing
853
+ data set (read_data_option must be `ReadDataOption.Append`, the
854
+ default).
855
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
856
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
857
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
858
+ and the zones are appended by default.
859
+ read_data_option (`ReadDataOption`, optional): Specify how the data
860
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
861
+
862
+ Possible values are:
863
+ * `ReadDataOption.ReplaceInActiveFrame`
864
+ Remove the dataset from the active frame prior to reading in the
865
+ new dataset. If other frames use the same `Dataset
866
+ <tecplot.data.Dataset>` in the active frame, they will continue to
867
+ use the old one.
868
+ * `ReadDataOption.Append`
869
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
870
+ * `ReadDataOption.Replace`
871
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
872
+ frame and to all other frames that use the same `Dataset
873
+ <tecplot.data.Dataset>`.
874
+ reset_style (`bool`, optional): Reset the style for
875
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
876
+ <layout.Frame>`'s current style is preserved. (default: `True`)
877
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
878
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
879
+ To have |Tecplot 360| determine the most appropriate plot type for
880
+ the data, use `PlotType.Automatic`. Possible values are:
881
+ `PlotType.Automatic`, `Cartesian3D`, `Cartesian2D`, `XYLine`,
882
+ `PlotType.Sketch`, `PolarLine`. (default: `PlotType.Automatic`)
883
+
884
+ Returns:
885
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
886
+ the loaded data.
887
+
888
+ .. note:: **Absolute and relative paths with PyTecplot**
889
+
890
+ Relative paths, when used within the PyTecplot API are always from
891
+ Python's current working directory which can be obtained by calling
892
+ :func:`os.getcwd()`. This is true for batch and `connected
893
+ <tecplot.session.connect()>` modes. One exception to this is paths
894
+ within a macro command or file which will be relative to the |Tecplot
895
+ Engine|'s home directory, which is typically the |Tecplot 360|
896
+ installation directory. Finally, when connected to a remote (non-local)
897
+ instance of Tecplot 360, only absolute paths are allowed.
898
+
899
+ Note that backslashes must be escaped which is especially important for
900
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
901
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
902
+ respectively. Alternatively, one may use Python's raw strings:
903
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
904
+
905
+ .. versionadded:: 2019.1
906
+ Loading Telemac data requires Tecplot 360 2019 R1 or later.
907
+ """
908
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
909
+ with tecutil.ArgList() as arglist:
910
+ arglist[sv.DATASETREADER] = 'Telemac Data Loader'
911
+
912
+ if filenames is not None:
913
+ if isinstance(filenames, str):
914
+ filenames = filenames.split(',')
915
+ instr += ['FILELIST_TELEMAC', str(len(filenames))]
916
+ instr += [tecutil.normalize_path(f) for f in filenames]
917
+
918
+ if boundary_filename is not None:
919
+ instr += ['FILENAME_BOUNDARY',
920
+ tecutil.normalize_path(boundary_filename)]
921
+
922
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
923
+
924
+ return _tecplot_loader_load_data(
925
+ arglist, frame=frame, read_data_option=read_data_option,
926
+ reset_style=reset_style,
927
+ initial_plot_type=initial_plot_type,
928
+ assign_strand_ids=True)
929
+
930
+
931
+ @lock()
932
+ def load_plot3d(grid_filenames=None,
933
+ solution_filenames=None,
934
+ function_filenames=None,
935
+ name_filename=None,
936
+
937
+ frame=None,
938
+
939
+ append=True,
940
+ # setting any of these three implies auto_detect=False
941
+ data_structure=None, # (1D|2D|3DP|3DW|UNSTRUCTURED)
942
+ is_multi_grid=None, # (True|False)
943
+ style=None, # (PLOT2DCLASSIC|PLOT3DFUNCTION|OVERFLOW)
944
+
945
+ ascii_is_double=None, # (True|False)
946
+ ascii_has_blanking=None, # (True|False)
947
+ uniform_grid=None, # (True|False)
948
+
949
+ assign_strand_ids=True,
950
+ add_zones_to_existing_strands=True,
951
+ append_function_variables=None, # (True|False)
952
+ include_boundaries=True):
953
+ """Read Plot3D data files.
954
+
955
+ Parameters:
956
+ grid_filenames (`list` of `strings <str>`, optional): One or more grid
957
+ file names to be read. (See note below concerning absolute and
958
+ relative paths.)
959
+ solution_filenames (`list` of `strings <str>`, optional): One or more
960
+ solution data file names to be read.
961
+ function_filenames (`list` of `strings <str>`, optional): One or more
962
+ function file names.
963
+ name_filename (`str`, optional): Path to the name file.
964
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
965
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
966
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
967
+ and the zones are appended by default.
968
+ append (`bool`, optional): Append the data to the existing
969
+ `Dataset <tecplot.data.Dataset>`. If `False`, the existing data attached to
970
+ the `Frame <layout.Frame>` is deleted and replaced. (default: `True`)
971
+ data_structure (`str`, optional): Specifies the data
972
+ structure and overrides the automatic detection. Options are:
973
+ ``1D``, ``2D``, ``3DP``, ``3DW``, ``UNSTRUCTURED``. Setting this
974
+ requires ``is_multi_grid`` and ``style`` to be set as well.
975
+ is_multi_grid (`bool`, optional): Sets data as multi-grid
976
+ and overrides the automatic data structure detection. Setting
977
+ this requires ``data_structure`` and ``style`` to be set as well.
978
+ style (`bool`, optional): Specifies the data style and
979
+ overrides the automatic data structure detection. Options are:
980
+ ``PLOT3DCLASSIC``, ``PLOT3DFUNCTION``, ``OVERFLOW``. Setting this
981
+ requires ``data_structure`` and ``is_multi_grid`` to be set as
982
+ well.
983
+
984
+ ascii_is_double (`bool`, optional): Indicates that
985
+ floating-point numbers found in the text data files should be
986
+ store with 64-bit precision. (default: `False`)
987
+ ascii_has_blanking (`bool`, optional): Indicates that the
988
+ text data files contain blanking. (default: `False`)
989
+ uniform_grid (`bool`, optional): Indicates the grid
990
+ structure is the same for all time steps. (default: `True`)
991
+
992
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
993
+ zones that have a strand ID of -1. (default: `True`)
994
+ add_zones_to_existing_strands (`bool`, optional): Add the
995
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
996
+ new data specifies strands, new ones will be created beginning after the
997
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `True`)
998
+ append_function_variables (`bool`, optional): Append
999
+ variables in function files to those found in solution files.
1000
+ (default: `False`)
1001
+ include_boundaries (`bool`, optional): Loads boundary zones
1002
+ found in the ".g.fvbnd" file located in the same directory as the
1003
+ grid file, if available. (default: `True`)
1004
+
1005
+ Returns:
1006
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1007
+ the loaded data.
1008
+
1009
+ Raises:
1010
+ `TecplotSystemError`: Internal error when loading data.
1011
+ `TecplotValueError`: In-valid input.
1012
+
1013
+ .. note:: **Absolute and relative paths with PyTecplot**
1014
+
1015
+ Relative paths, when used within the PyTecplot API are always from
1016
+ Python's current working directory which can be obtained by calling
1017
+ :func:`os.getcwd()`. This is true for batch and `connected
1018
+ <tecplot.session.connect()>` modes. One exception to this is paths
1019
+ within a macro command or file which will be relative to the |Tecplot
1020
+ Engine|'s home directory, which is typically the |Tecplot 360|
1021
+ installation directory. Finally, when connected to a remote (non-local)
1022
+ instance of Tecplot 360, only absolute paths are allowed.
1023
+
1024
+ Note that backslashes must be escaped which is especially important for
1025
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1026
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1027
+ respectively. Alternatively, one may use Python's raw strings:
1028
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1029
+
1030
+ .. note:: Data structure is automatically detected by default.
1031
+
1032
+ The options ``data_structure``, ``is_multi_grid`` and ``style``
1033
+ must be supplied together or not at all. When all of these are
1034
+ `None`, the data structure is automatically detected.
1035
+
1036
+ The variables from the function files can be appended to the dataset
1037
+ upon loading::
1038
+
1039
+ >>> dataset = tecplot.data.load_plot3d(
1040
+ ... grid_filenames = 'data.g',
1041
+ ... solution_filenames = ['t0.q', 't1.q'],
1042
+ ... function_filenames = ['t0.f', 't1.f'],
1043
+ ... append_function_variables = True)
1044
+ """
1045
+ if isinstance(grid_filenames, str):
1046
+ grid_filenames = [grid_filenames]
1047
+ if isinstance(solution_filenames, str):
1048
+ solution_filenames = [solution_filenames]
1049
+ if isinstance(function_filenames, str):
1050
+ function_filenames = [function_filenames]
1051
+
1052
+ if __debug__:
1053
+ data_structure_opts = [None, '1D', '2D', '3DP', '3DW', 'UNSTRUCTURED']
1054
+ style_opts = [None, 'PLOT3DCLASSIC', 'PLOT3DFUNCTION', 'OVERFLOW']
1055
+ if data_structure not in data_structure_opts:
1056
+ msg = 'data_structure must be one of: '
1057
+ msg += ', '.join(str(x) for x in data_structure_opts)
1058
+ raise TecplotValueError(msg)
1059
+ if style not in style_opts:
1060
+ msg = 'style must be one of: '
1061
+ msg += ', '.join(str(x) for x in style_opts)
1062
+ raise TecplotValueError(msg)
1063
+ if grid_filenames and solution_filenames:
1064
+ if len(grid_filenames) != 1 and \
1065
+ len(grid_filenames) != len(solution_filenames):
1066
+ raise TecplotValueError(textwrap.dedent('''\
1067
+ You must specify a single grid file or
1068
+ the same number of grid and solution files.'''))
1069
+ autodetect_opts = [data_structure, is_multi_grid, style]
1070
+ if sum([x is None for x in autodetect_opts]) not in [0, 3]:
1071
+ raise TecplotValueError(textwrap.dedent('''\
1072
+ The options: data_structure, is_multi_grid and style
1073
+ must be supplied all together or not at all.'''))
1074
+
1075
+ frame = frame or layout.active_frame()
1076
+
1077
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
1078
+ with tecutil.ArgList() as arglist:
1079
+ arglist[sv.DATASETREADER] = 'PLOT3D Loader'
1080
+
1081
+ preexisting_dataset = frame.has_dataset and frame.dataset.num_zones
1082
+ if append is not None:
1083
+ if append:
1084
+ if preexisting_dataset:
1085
+ instr += ['Append', 'Yes']
1086
+ else:
1087
+ instr += ['Append', 'No']
1088
+
1089
+ if grid_filenames is not None:
1090
+ instr += ['FILELIST_GRIDFILES', str(len(grid_filenames))]
1091
+ instr += [tecutil.normalize_path(f) for f in grid_filenames]
1092
+ if solution_filenames is not None:
1093
+ instr += ['FILELIST_SOLUTIONFILES',
1094
+ str(len(solution_filenames))]
1095
+ instr += [tecutil.normalize_path(f) for f in solution_filenames]
1096
+ if function_filenames is not None:
1097
+ instr += ['FILELIST_FUNCTIONFILES',
1098
+ str(len(function_filenames))]
1099
+ instr += [tecutil.normalize_path(f) for f in function_filenames]
1100
+ if name_filename is not None:
1101
+ instr += ['FILENAME_NAMEFILE',
1102
+ tecutil.normalize_path(name_filename)]
1103
+
1104
+ if (data_structure or is_multi_grid or style) is None:
1105
+ instr += ['AUTODETECT', 'Yes']
1106
+ else:
1107
+ instr += ['AUTODETECT', 'No']
1108
+ instr += ['DATASTRUCTURE', data_structure]
1109
+ instr += ['ISMULTIGRID', 'Yes' if is_multi_grid else 'No']
1110
+ instr += ['STYLE', style]
1111
+
1112
+ if ascii_is_double is not None:
1113
+ instr += ['ASCIIISDOUBLE', 'Yes' if ascii_is_double else 'No']
1114
+ if ascii_has_blanking is not None:
1115
+ instr += ['ASCIIHASBLANK',
1116
+ 'Yes' if ascii_has_blanking else 'No']
1117
+
1118
+ if uniform_grid is not None:
1119
+ instr += ['UNIFORMGRIDSTRUCTURE',
1120
+ 'Yes' if uniform_grid else 'No']
1121
+ if assign_strand_ids is not None:
1122
+ instr += ['ASSIGNSTRANDIDS',
1123
+ 'Yes' if assign_strand_ids else 'No']
1124
+ if add_zones_to_existing_strands is not None:
1125
+ if preexisting_dataset:
1126
+ instr += ['ADDTOEXISTINGSTRANDS',
1127
+ 'Yes' if add_zones_to_existing_strands else 'No']
1128
+
1129
+ if append_function_variables is not None:
1130
+ if solution_filenames or preexisting_dataset:
1131
+ instr += ['APPENDFUNCTIONVARIABLES',
1132
+ 'Yes' if append_function_variables else 'No']
1133
+ if include_boundaries is not None:
1134
+ instr += ['LOADBOUNDARY', 'Yes' if include_boundaries else 'No']
1135
+
1136
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
1137
+
1138
+ try:
1139
+ return _tecplot_loader_load_data(arglist, frame=frame)
1140
+ except TecplotLogicError as e:
1141
+ if str(e).startswith('The boundary file does not'):
1142
+ log.warning(e)
1143
+ return layout.active_frame().dataset
1144
+ raise
1145
+
1146
+
1147
+ @lock()
1148
+ def load_cfx(filename,
1149
+ frame=None,
1150
+ append=True,
1151
+ assign_strand_ids=True,
1152
+ add_zones_to_existing_strands=True,
1153
+ initial_plot_type=PlotType.Automatic):
1154
+ """Read an ANSYS CFX data file.
1155
+
1156
+ Parameters:
1157
+ filename (`str`): The data file to be read. (See note below concerning
1158
+ absolute and relative paths.)
1159
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1160
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1161
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1162
+ and the zones are appended by default.
1163
+ append (`bool`, optional): Append the data to the existing
1164
+ `Dataset <tecplot.data.Dataset>`. If `False`, the existing data attached to
1165
+ the `Frame <layout.Frame>` is deleted and replaced. (default: `True`)
1166
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
1167
+ zones that have a strand ID of -1. (default: `True`)
1168
+ add_zones_to_existing_strands (`bool`, optional): Add the
1169
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
1170
+ new data specifies strands, new ones will be created beginning after the
1171
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `True`)
1172
+ initial_plot_type (`PlotType`, optional): Set the initial plot type
1173
+ upon loading of the data. Must be one of `PlotType.Automatic`
1174
+ (default), `PlotType.Cartesian3D` or `PlotType.Cartesian2D`.
1175
+
1176
+ Returns:
1177
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1178
+ the loaded data.
1179
+
1180
+ .. note:: **Absolute and relative paths with PyTecplot**
1181
+
1182
+ Relative paths, when used within the PyTecplot API are always from
1183
+ Python's current working directory which can be obtained by calling
1184
+ :func:`os.getcwd()`. This is true for batch and `connected
1185
+ <tecplot.session.connect()>` modes. One exception to this is paths
1186
+ within a macro command or file which will be relative to the |Tecplot
1187
+ Engine|'s home directory, which is typically the |Tecplot 360|
1188
+ installation directory. Finally, when connected to a remote (non-local)
1189
+ instance of Tecplot 360, only absolute paths are allowed.
1190
+
1191
+ Note that backslashes must be escaped which is especially important for
1192
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1193
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1194
+ respectively. Alternatively, one may use Python's raw strings:
1195
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1196
+
1197
+ .. note::
1198
+ The CFX loader is not available on macOS.
1199
+ """
1200
+ if platform.system() == 'Darwin':
1201
+ msg = 'CFX data loader is not available on macOS'
1202
+ raise TecplotNotImplementedError(msg)
1203
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
1204
+ with tecutil.ArgList() as arglist:
1205
+ arglist[sv.DATASETREADER] = 'ANSYS CFX (FEA)'
1206
+ instr += ['FEALoaderVersion', FEALoader.Version.Current.value]
1207
+ instr += ['FILENAME_File', tecutil.normalize_path(filename)]
1208
+
1209
+ frame = frame or layout.active_frame()
1210
+ preexisting_dataset = frame.has_dataset and frame.dataset.num_zones
1211
+ if preexisting_dataset:
1212
+ instr += ['Append', 'Yes' if append else 'No']
1213
+ instr += ['AddToExistingStrands',
1214
+ 'Yes' if add_zones_to_existing_strands else 'No']
1215
+
1216
+ instr += ['AutoAssignStrandIDs',
1217
+ 'Yes' if assign_strand_ids else 'No']
1218
+ initplottype = PlotType(initial_plot_type)
1219
+ if initplottype != PlotType.Automatic:
1220
+ instr += ['InitialPlotType', initplottype.name]
1221
+
1222
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
1223
+ return _tecplot_loader_load_data(arglist, frame=frame)
1224
+
1225
+
1226
+ @lock()
1227
+ def load_ensight(filename,
1228
+ frame=None,
1229
+ read_data_option=ReadDataOption.Append,
1230
+ reset_style=None,
1231
+ initial_plot_first_zone_only=None,
1232
+ initial_plot_type=None,
1233
+ assign_strand_ids=True,
1234
+ add_zones_to_existing_strands=None):
1235
+ """Read Ensight data files and/or boundary file.
1236
+
1237
+ Parameters:
1238
+ filename (`str`): The case file to be read. (See note below concerning
1239
+ absolute and relative paths.)
1240
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1241
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1242
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1243
+ and the zones are appended by default.
1244
+ read_data_option (`ReadDataOption`, optional): Specify how the data
1245
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
1246
+
1247
+ Possible values are:
1248
+ * `ReadDataOption.ReplaceInActiveFrame`
1249
+ Remove the dataset from the active frame prior to reading in the
1250
+ new dataset. If other frames use the same `Dataset
1251
+ <tecplot.data.Dataset>` in the active frame, they will continue to
1252
+ use the old one.
1253
+ * `ReadDataOption.Append`
1254
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
1255
+ * `ReadDataOption.Replace`
1256
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
1257
+ frame and to all other frames that use the same `Dataset
1258
+ <tecplot.data.Dataset>`.
1259
+ reset_style (`bool`, optional): Reset the style for
1260
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
1261
+ <layout.Frame>`'s current style is preserved. (default: `True`)
1262
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
1263
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
1264
+ To have |Tecplot 360| determine the most appropriate plot type for
1265
+ the data, use `PlotType.Automatic`. Possible values are:
1266
+ `PlotType.Automatic`, `Cartesian3D`, `Cartesian2D`, `XYLine`,
1267
+ `PlotType.Sketch`, `PolarLine`. (default: `PlotType.Automatic`)
1268
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
1269
+ zones that have a strand ID of -1. (default: `True`)
1270
+ add_zones_to_existing_strands (`bool`, optional): Add the
1271
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
1272
+ new data specifies strands, new ones will be created beginning after the
1273
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `True`)
1274
+
1275
+ Returns:
1276
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1277
+ the loaded data.
1278
+
1279
+ .. note:: **Absolute and relative paths with PyTecplot**
1280
+
1281
+ Relative paths, when used within the PyTecplot API are always from
1282
+ Python's current working directory which can be obtained by calling
1283
+ :func:`os.getcwd()`. This is true for batch and `connected
1284
+ <tecplot.session.connect()>` modes. One exception to this is paths
1285
+ within a macro command or file which will be relative to the |Tecplot
1286
+ Engine|'s home directory, which is typically the |Tecplot 360|
1287
+ installation directory. Finally, when connected to a remote (non-local)
1288
+ instance of Tecplot 360, only absolute paths are allowed.
1289
+
1290
+ Note that backslashes must be escaped which is especially important for
1291
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1292
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1293
+ respectively. Alternatively, one may use Python's raw strings:
1294
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1295
+ """
1296
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
1297
+ with tecutil.ArgList() as arglist:
1298
+ arglist[sv.DATASETREADER] = 'EnSight Loader'
1299
+ instr += ['FILENAME_CASEFILE', tecutil.normalize_path(filename)]
1300
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
1301
+ return _tecplot_loader_load_data(
1302
+ arglist, frame=frame, read_data_option=read_data_option,
1303
+ reset_style=reset_style,
1304
+ initial_plot_first_zone_only=initial_plot_first_zone_only,
1305
+ initial_plot_type=initial_plot_type,
1306
+ assign_strand_ids=assign_strand_ids,
1307
+ add_zones_to_existing_strands=add_zones_to_existing_strands)
1308
+
1309
+
1310
+ '''
1311
+ @lock()
1312
+ def load_kiva(filenames,
1313
+ frame=None,
1314
+ is_double=True,
1315
+ load_particle_data=True,
1316
+ velocity_vector='u_vel',
1317
+ dataset_title=None):
1318
+ """Read Kiva/GMV data files.
1319
+
1320
+ Parameters:
1321
+ filenames (`str` or `list` of `strings <str>`): The data file(s) to be
1322
+ read. (See note below concerning absolute and relative paths.)
1323
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1324
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1325
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1326
+ and the zones are appended by default.
1327
+ is_double (`bool`, optional): Allows greater precision for your data
1328
+ values. (default: `True`)
1329
+ load_particle_data (`bool`, optional): Adds a zone for any files
1330
+ containing particle data. (default: `True`)
1331
+ velocity_vector (`str`, optional): Identify the naming convention for
1332
+ your velocity vectors. This is the name of the first component (u)
1333
+ and is typically one of: "u_vel" (default), "u-vel" or "u".
1334
+ dataset_title (`str`, optional): The name of the resulting `Dataset
1335
+ <tecplot.data.Dataset>` in Tecplot. (default: `None`)
1336
+
1337
+ Returns:
1338
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1339
+ the loaded data.
1340
+
1341
+ .. note:: **Absolute and relative paths with PyTecplot**
1342
+
1343
+ Relative paths, when used within the PyTecplot API are always from
1344
+ Python's current working directory which can be obtained by calling
1345
+ :func:`os.getcwd()`. This is true for batch and `connected
1346
+ <tecplot.session.connect()>` modes. One exception to this is paths
1347
+ within a macro command or file which will be relative to the |Tecplot
1348
+ Engine|'s home directory, which is typically the |Tecplot 360|
1349
+ installation directory. Finally, when connected to a remote (non-local)
1350
+ instance of Tecplot 360, only absolute paths are allowed.
1351
+
1352
+ Note that backslashes must be escaped which is especially important for
1353
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1354
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1355
+ respectively. Alternatively, one may use Python's raw strings:
1356
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1357
+ """
1358
+ if isinstance(filenames, str):
1359
+ filenames = [filenames]
1360
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
1361
+ with tecutil.ArgList() as arglist:
1362
+ arglist[sv.DATASETREADER] = 'Kiva Loader'
1363
+ instr += ['FILELIST_DataFiles', str(len(filenames))]
1364
+ instr += [tecutil.normalize_path(f) for f in filenames]
1365
+ instr += ['ISDOUBLE', 'YES' if is_double else 'No']
1366
+ instr += ['LOADPARTICLEDATA', 'YES' if load_particle_data else 'No']
1367
+ instr += ['VELVECTOR', str(velocity_vector)]
1368
+ if dataset_title:
1369
+ instr += ['DATASETTITLE', str(dataset_title)]
1370
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
1371
+ return _tecplot_loader_load_data(arglist, frame)
1372
+ '''
1373
+
1374
+
1375
+ @lock()
1376
+ def load_openfoam(
1377
+ filename,
1378
+ frame=None,
1379
+ append=True,
1380
+ boundary_zone_construction=None,
1381
+ assign_strand_ids=True,
1382
+ add_zones_to_existing_strands=True,
1383
+ initial_plot_type=PlotType.Automatic,
1384
+ initial_plot_first_zone_only=False
1385
+ ):
1386
+ """Read an OpenFOAM data file.
1387
+
1388
+ Parameters:
1389
+ filename (`str`): The data file to be read. (See note below concerning
1390
+ absolute and relative paths.)
1391
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1392
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1393
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1394
+ and the zones are appended by default.
1395
+ append (`bool`, optional): Append the data to the existing
1396
+ `Dataset <tecplot.data.Dataset>`. If `False`, the existing data attached to
1397
+ the `Frame <layout.Frame>` is deleted and replaced. (default: `True`)
1398
+ boundary_zone_construction (`OpenFOAMLoader.BoundaryZoneConstruction`, optional):
1399
+ Set how the boundary zones are constructed. This may be either
1400
+ `OpenFOAMLoader.BoundaryZoneConstruction.Reconstructed` (default)
1401
+ or `OpenFOAMLoader.BoundaryZoneConstruction.Decomposed`. This
1402
+ option requires Tecplot 360 2019 R1 or later.
1403
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
1404
+ zones that have a strand ID of -1. (default: `True`)
1405
+ add_zones_to_existing_strands (`bool`, optional): Add the
1406
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
1407
+ new data specifies strands, new ones will be created beginning after the
1408
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `True`)
1409
+ initial_plot_type (`PlotType`, optional): Set the initial plot type
1410
+ upon loading of the data. Must be one of `PlotType.Automatic`
1411
+ (default), `PlotType.Cartesian3D` or `PlotType.Cartesian2D`.
1412
+ initial_plot_first_zone_only (`bool`, optional): Informs
1413
+ the |Tecplot Engine| that after the data is loaded it only needs to
1414
+ activate the first enabled `Zone <data_access>` for the initial
1415
+ plot. This option is particularly useful if you have many `Zones
1416
+ <data_access>` and want to get the data into the |Tecplot Engine|
1417
+ and the first `Zone <data_access>` drawn as fast as possible. The
1418
+ inactive `Zones <data_access>` can always be activated when needed.
1419
+ (default: `False`)
1420
+
1421
+ Returns:
1422
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1423
+ the loaded data.
1424
+
1425
+ .. note:: **Absolute and relative paths with PyTecplot**
1426
+
1427
+ Relative paths, when used within the PyTecplot API are always from
1428
+ Python's current working directory which can be obtained by calling
1429
+ :func:`os.getcwd()`. This is true for batch and `connected
1430
+ <tecplot.session.connect()>` modes. One exception to this is paths
1431
+ within a macro command or file which will be relative to the |Tecplot
1432
+ Engine|'s home directory, which is typically the |Tecplot 360|
1433
+ installation directory. Finally, when connected to a remote (non-local)
1434
+ instance of Tecplot 360, only absolute paths are allowed.
1435
+
1436
+ Note that backslashes must be escaped which is especially important for
1437
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1438
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1439
+ respectively. Alternatively, one may use Python's raw strings:
1440
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1441
+
1442
+ .. warning:: **Zone and variable ordering may change between releases**
1443
+
1444
+ Due to possible changes in data loaders or data formats over time, the
1445
+ ordering of zones and variables may be different between versions of
1446
+ Tecplot 360. Therefore it is recommended to always reference zones and
1447
+ variables **by name** instead of by index.
1448
+ """
1449
+ if isinstance(boundary_zone_construction, BoundaryZoneConstruction):
1450
+ enum_value = boundary_zone_construction.value
1451
+ boundary_zone_construction = \
1452
+ OpenFOAMLoader.BoundaryZoneConstruction(enum_value)
1453
+ if __debug__:
1454
+ tecutil.api_moved('BoundaryZoneConstruction',
1455
+ 'OpenFOAMLoader.BoundaryZoneConstruction',
1456
+ '1.4', '2021 R1', warning=True)
1457
+
1458
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
1459
+ with tecutil.ArgList() as arglist:
1460
+ arglist[sv.DATASETREADER] = 'OpenFOAM (FEA)'
1461
+
1462
+ instr += ['FEALoaderVersion', FEALoader.Version.Current.value]
1463
+ instr += ['FILENAME_File', tecutil.normalize_path(filename)]
1464
+
1465
+ frame = frame or layout.active_frame()
1466
+ preexisting_dataset = frame.has_dataset and frame.dataset.num_zones
1467
+ if preexisting_dataset:
1468
+ instr += ['Append', 'Yes' if append else 'No']
1469
+ instr += ['AddToExistingStrands',
1470
+ 'Yes' if add_zones_to_existing_strands else 'No']
1471
+
1472
+ instr += ['AutoAssignStrandIDs',
1473
+ 'Yes' if assign_strand_ids else 'No']
1474
+ initplottype = PlotType(initial_plot_type)
1475
+ if initplottype != PlotType.Automatic:
1476
+ instr += ['InitialPlotType', initplottype.name]
1477
+ instr += ['ShowFirstZoneOnly',
1478
+ 'Yes' if initial_plot_first_zone_only else 'No']
1479
+
1480
+ BZCon = OpenFOAMLoader.BoundaryZoneConstruction
1481
+ if boundary_zone_construction is None:
1482
+ bzcon = BZCon.Reconstructed
1483
+ else:
1484
+ bzcon = BZCon(boundary_zone_construction)
1485
+ instr += ['BoundaryZoneConstruction', bzcon.value]
1486
+
1487
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
1488
+ return _tecplot_loader_load_data(arglist, frame=frame)
1489
+
1490
+
1491
+ @lock()
1492
+ def load_stl(filename,
1493
+ frame=None,
1494
+ append=True,
1495
+ subdivide_zones=STLLoader.SubdivideZones.DoNotSubdivide,
1496
+ assign_strand_ids=True,
1497
+ add_zones_to_existing_strands=True,
1498
+ initial_plot_type=PlotType.Automatic,
1499
+ initial_plot_first_zone_only=False):
1500
+ """Read a 3D Systems STL data file.
1501
+
1502
+ Parameters:
1503
+ filename (`str`): The data file to be read. (See note below concerning
1504
+ absolute and relative paths.)
1505
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1506
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1507
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1508
+ and the zones are appended by default.
1509
+ append (`bool`, optional): Append the data to the existing
1510
+ `Dataset <tecplot.data.Dataset>`. If `False`, the existing data attached to
1511
+ the `Frame <layout.Frame>` is deleted and replaced. (default: `True`)
1512
+ subdivide_zones (`STLLoader.SubdivideZones`, optional): Specify method
1513
+ of zone division. Possible values are:
1514
+ `STLLoader.SubdivideZones.DoNotSubdivide` (default),
1515
+ `STLLoader.SubdivideZones.ByComponent` and
1516
+ `STLLoader.SubdivideZones.ByElementType`.
1517
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
1518
+ zones that have a strand ID of -1. (default: `True`)
1519
+ add_zones_to_existing_strands (`bool`, optional): Add the
1520
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
1521
+ new data specifies strands, new ones will be created beginning after the
1522
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `True`)
1523
+ initial_plot_type (`PlotType`, optional): Set the initial plot type
1524
+ upon loading of the data. Must be one of `PlotType.Automatic`
1525
+ (default), `PlotType.Cartesian3D` or `PlotType.Cartesian2D`.
1526
+ initial_plot_first_zone_only (`bool`, optional): Informs
1527
+ the |Tecplot Engine| that after the data is loaded it only needs to
1528
+ activate the first enabled `Zone <data_access>` for the initial
1529
+ plot. This option is particularly useful if you have many `Zones
1530
+ <data_access>` and want to get the data into the |Tecplot Engine|
1531
+ and the first `Zone <data_access>` drawn as fast as possible. The
1532
+ inactive `Zones <data_access>` can always be activated when needed.
1533
+ (default: `False`)
1534
+
1535
+ Returns:
1536
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1537
+ the loaded data.
1538
+
1539
+ .. note:: **Absolute and relative paths with PyTecplot**
1540
+
1541
+ Relative paths, when used within the PyTecplot API are always from
1542
+ Python's current working directory which can be obtained by calling
1543
+ :func:`os.getcwd()`. This is true for batch and `connected
1544
+ <tecplot.session.connect()>` modes. One exception to this is paths
1545
+ within a macro command or file which will be relative to the |Tecplot
1546
+ Engine|'s home directory, which is typically the |Tecplot 360|
1547
+ installation directory. Finally, when connected to a remote (non-local)
1548
+ instance of Tecplot 360, only absolute paths are allowed.
1549
+
1550
+ Note that backslashes must be escaped which is especially important for
1551
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1552
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1553
+ respectively. Alternatively, one may use Python's raw strings:
1554
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1555
+ """
1556
+ if isinstance(subdivide_zones, SubdivideZones):
1557
+ subdivide_zones = STLLoader.SubdivideZones(subdivide_zones.value)
1558
+ if __debug__:
1559
+ tecutil.api_moved('SubdivideZones', 'STLLoader.SubdivideZones',
1560
+ '1.4', '2021 R1', warning=True)
1561
+
1562
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
1563
+ with tecutil.ArgList() as arglist:
1564
+ arglist[sv.DATASETREADER] = '3D Systems STL (FEA)'
1565
+ instr += ['FEALoaderVersion', FEALoader.Version.Current.value]
1566
+ instr += ['FILENAME_File', tecutil.normalize_path(filename)]
1567
+
1568
+ frame = frame or layout.active_frame()
1569
+ preexisting_dataset = frame.has_dataset and frame.dataset.num_zones
1570
+ if preexisting_dataset:
1571
+ instr += ['Append', 'Yes' if append else 'No']
1572
+ instr += ['AddToExistingStrands',
1573
+ 'Yes' if add_zones_to_existing_strands else 'No']
1574
+
1575
+ subdiv = STLLoader.SubdivideZones(subdivide_zones)
1576
+ if subdiv != STLLoader.SubdivideZones.DoNotSubdivide:
1577
+ instr += ['SubdivideZonesBy', subdiv.value]
1578
+ instr += ['AutoAssignStrandIDs',
1579
+ 'Yes' if assign_strand_ids else 'No']
1580
+ initplottype = PlotType(initial_plot_type)
1581
+ if initplottype != PlotType.Automatic:
1582
+ instr += ['InitialPlotType', initplottype.name]
1583
+ instr += ['ShowFirstZoneOnly',
1584
+ 'Yes' if initial_plot_first_zone_only else 'No']
1585
+
1586
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
1587
+ return _tecplot_loader_load_data(arglist, frame=frame)
1588
+
1589
+
1590
+ @lock()
1591
+ def load_vtk(filenames,
1592
+ frame=None,
1593
+ read_data_option=ReadDataOption.Append,
1594
+ reset_style=True,
1595
+ initial_plot_type=PlotType.Automatic,
1596
+ assign_strand_ids=True,
1597
+ add_zones_to_existing_strands=False,
1598
+ solution_time_source=VTKLoader.SolutionTimeSource.Auto):
1599
+ """Read VTK data files.
1600
+
1601
+ Parameters:
1602
+ filenames (`str` or `list` of `strings <str>`): The data file(s) to be
1603
+ read. (See note below concerning absolute and relative paths.)
1604
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1605
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1606
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1607
+ and the zones are appended by default.
1608
+ read_data_option (`ReadDataOption`, optional): Specify how the data
1609
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
1610
+
1611
+ Possible values are:
1612
+ * `ReadDataOption.ReplaceInActiveFrame`
1613
+ The `Dataset <tecplot.data.Dataset>` in the active frame is
1614
+ replaced by the new `Dataset <tecplot.data.Dataset>`. If other
1615
+ frames were using the same `Dataset <tecplot.data.Dataset>`
1616
+ originally in the active frame, they will continue to use it.
1617
+ * `ReadDataOption.Append`
1618
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
1619
+ * `ReadDataOption.Replace`
1620
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
1621
+ frame, and to all other frames that use the same `Dataset
1622
+ <tecplot.data.Dataset>`.
1623
+
1624
+ Default: `ReadDataOption.Append`
1625
+ reset_style (`bool`, optional): Reset the style for
1626
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
1627
+ <layout.Frame>`'s current style is preserved. (default: `True`)
1628
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
1629
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
1630
+ To have |Tecplot 360| determine the most appropriate plot type
1631
+ for the data, use `PlotType.Automatic`. Possible values are:
1632
+ `PlotType.Automatic` (default), `Cartesian3D`, `Cartesian2D`,
1633
+ `XYLine`, `PlotType.Sketch`, `PolarLine`.
1634
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
1635
+ zones that have a strand ID of -1. (default: `True`)
1636
+ add_zones_to_existing_strands (`bool`, optional): Add the
1637
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
1638
+ new data specifies strands, new ones will be created beginning after the
1639
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `False`)
1640
+
1641
+ solution_time_source (`VTKLoader.SolutionTimeSource`, optional): Assign
1642
+ the solution times of the zones based on the specified criteria.
1643
+ Possible values are: `VTKLoader.SolutionTimeSource.Auto` (default)
1644
+ which favors the "time" scalar over the numbers embedded in the
1645
+ file names, `VTKLoader.SolutionTimeSource.None_` which does not
1646
+ assign solutions times or strands,
1647
+ `VTKLoader.SolutionTimeSource.FromFieldData` which uses the "time"
1648
+ scalar and `VTKLoader.SolutionTimeSource.FromFilename` which uses
1649
+ the solution time embedded in the file names.
1650
+
1651
+ Returns:
1652
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1653
+ the loaded data.
1654
+
1655
+ .. note:: **Absolute and relative paths with PyTecplot**
1656
+
1657
+ Relative paths, when used within the PyTecplot API are always from
1658
+ Python's current working directory which can be obtained by calling
1659
+ :func:`os.getcwd()`. This is true for batch and `connected
1660
+ <tecplot.session.connect()>` modes. One exception to this is paths
1661
+ within a macro command or file which will be relative to the |Tecplot
1662
+ Engine|'s home directory, which is typically the |Tecplot 360|
1663
+ installation directory. Finally, when connected to a remote (non-local)
1664
+ instance of Tecplot 360, only absolute paths are allowed.
1665
+
1666
+ Note that backslashes must be escaped which is especially important for
1667
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1668
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1669
+ respectively. Alternatively, one may use Python's raw strings:
1670
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1671
+ """
1672
+ if isinstance(solution_time_source, SolutionTimeSource):
1673
+ enum_value = solution_time_source.value
1674
+ solution_time_source = VTKLoader.SolutionTimeSource(enum_value)
1675
+ if __debug__:
1676
+ tecutil.api_moved('SolutionTimeSource',
1677
+ 'VTKLoader.SolutionTimeSource',
1678
+ '1.4', '2021 R1', warning=True)
1679
+
1680
+ if isinstance(filenames, str):
1681
+ filenames = [filenames]
1682
+ with StringList('STANDARDSYNTAX', '1.0') as instr:
1683
+ with tecutil.ArgList() as arglist:
1684
+ arglist[sv.DATASETREADER] = 'VTK Data Loader'
1685
+ instr += ['FILELIST_DATAFILES', str(len(filenames))]
1686
+ instr += [tecutil.normalize_path(f) for f in filenames]
1687
+ instr += ['SOLUTIONTIMESOURCE',
1688
+ VTKLoader.SolutionTimeSource(solution_time_source).value]
1689
+ arglist[sv.FILENAMESORINSTRUCTIONS] = instr
1690
+ return _tecplot_loader_load_data(
1691
+ arglist, frame=frame, read_data_option=read_data_option,
1692
+ reset_style=reset_style, initial_plot_type=initial_plot_type,
1693
+ assign_strand_ids=assign_strand_ids,
1694
+ add_zones_to_existing_strands=add_zones_to_existing_strands)
1695
+
1696
+
1697
+ @lock()
1698
+ def load_tecplot(filenames,
1699
+
1700
+ frame=None,
1701
+
1702
+ read_data_option=ReadDataOption.Append,
1703
+ reset_style=None,
1704
+ initial_plot_first_zone_only=None,
1705
+ initial_plot_type=None,
1706
+
1707
+ zones=None,
1708
+ variables=None,
1709
+
1710
+ collapse=None,
1711
+ skip=None,
1712
+ assign_strand_ids=True,
1713
+ add_zones_to_existing_strands=None,
1714
+
1715
+ include_text=None,
1716
+ include_geom=None,
1717
+ include_custom_labels=None,
1718
+ include_data=None):
1719
+ """Read a tecplot data file.
1720
+
1721
+ Parameters:
1722
+ filenames (`str` or `list` of `strings <str>`): Files to be
1723
+ read. (See note below concerning absolute and relative paths.)
1724
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1725
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1726
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1727
+ and the zones are appended by default.
1728
+ read_data_option (`ReadDataOption`, optional): Specify how the data
1729
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
1730
+
1731
+ Possible values are:
1732
+ * `ReadDataOption.ReplaceInActiveFrame`
1733
+ The `Dataset <tecplot.data.Dataset>` in the active frame is
1734
+ replaced by the new `Dataset <tecplot.data.Dataset>`. If other
1735
+ frames were using the same `Dataset <tecplot.data.Dataset>`
1736
+ originally in the active frame, they will continue to use it.
1737
+ * `ReadDataOption.Append`
1738
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
1739
+ * `ReadDataOption.Replace`
1740
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
1741
+ frame, and to all other frames that use the same `Dataset
1742
+ <tecplot.data.Dataset>`.
1743
+
1744
+ Default: `ReadDataOption.Append`
1745
+ reset_style (`bool`, optional): Reset the style for
1746
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
1747
+ <layout.Frame>`'s current style is preserved. (default: `True`)
1748
+ initial_plot_first_zone_only (`bool`, optional): Informs
1749
+ the |Tecplot Engine| that after the data is loaded it only needs to
1750
+ activate the first enabled `Zone <data_access>` for the initial
1751
+ plot. This option is particularly useful if you have many `Zones
1752
+ <data_access>` and want to get the data into the |Tecplot Engine|
1753
+ and the first `Zone <data_access>` drawn as fast as possible. The
1754
+ inactive `Zones <data_access>` can always be activated when needed.
1755
+ (default: `False`)
1756
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
1757
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
1758
+ To have |Tecplot 360| determine the most appropriate plot type
1759
+ for the data, use `PlotType.Automatic`. Possible values are:
1760
+ `PlotType.Automatic` (default), `Cartesian3D`, `Cartesian2D`,
1761
+ `XYLine`, `PlotType.Sketch`, `PolarLine`.
1762
+
1763
+ zones (`set` of `integers <int>`, optional): Set of `Zones
1764
+ <data_access>` to load. Use `None` to load all zones. (default:
1765
+ `None`)
1766
+ variables (`set` of `strings <str>` or `integers <int>`, optional):
1767
+ Set of `Variables <Variable>` to load. Use `None` to load all
1768
+ variables. (default: `None`)
1769
+
1770
+ collapse (`bool`, optional): Reindex `Zones <data_access>` and
1771
+ `Variables <Variable>` if any are disabled. (default: `False`)
1772
+ skip: (3-`tuple` of `integers <int>`, optional) The *ijk*-skip. A value
1773
+ of (1,1,1) loads every data point in the *(i,j,k)* directions. A
1774
+ value of (2,2,2) loads every other data point and so forth. This
1775
+ only applies to ordered data. (default: (1,1,1))
1776
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
1777
+ zones that have a strand ID of -1. (default: `True`)
1778
+ add_zones_to_existing_strands (`bool`, optional): Add the
1779
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
1780
+ new data specifies strands, new ones will be created beginning after the
1781
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `False`)
1782
+
1783
+ include_text (`bool`, optional): Load any text, geometries, or
1784
+ custom labels (default: `True`)
1785
+ include_geom (`bool`, optional): Load geometries. (default:
1786
+ `True`)
1787
+ include_custom_labels (`bool`, optional): (default: `True`)
1788
+ include_data (`bool`, optional): Load data. Set this to
1789
+ `False` if you only want annotations such as text or geometries.
1790
+ (default: `True`)
1791
+
1792
+ Returns:
1793
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1794
+ the loaded data.
1795
+
1796
+ Raises:
1797
+ `TecplotSystemError`: Internal error when loading data.
1798
+ `TecplotTypeError`: In-valid input.
1799
+
1800
+ .. note:: **Absolute and relative paths with PyTecplot**
1801
+
1802
+ Relative paths, when used within the PyTecplot API are always from
1803
+ Python's current working directory which can be obtained by calling
1804
+ :func:`os.getcwd()`. This is true for batch and `connected
1805
+ <tecplot.session.connect()>` modes. One exception to this is paths
1806
+ within a macro command or file which will be relative to the |Tecplot
1807
+ Engine|'s home directory, which is typically the |Tecplot 360|
1808
+ installation directory. Finally, when connected to a remote (non-local)
1809
+ instance of Tecplot 360, only absolute paths are allowed.
1810
+
1811
+ Note that backslashes must be escaped which is especially important for
1812
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1813
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1814
+ respectively. Alternatively, one may use Python's raw strings:
1815
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1816
+ """
1817
+ if isinstance(filenames, str):
1818
+ filenames = [filenames]
1819
+ with StringList(tecutil.normalize_path(f) for f in filenames) as fnames:
1820
+ with tecutil.ArgList() as arglist:
1821
+ allocd = []
1822
+
1823
+ arglist.update(**{
1824
+ sv.DATASETREADER: 'TECPLOT',
1825
+ sv.FILENAMESORINSTRUCTIONS: fnames,
1826
+ sv.INCLUDETEXT: include_text,
1827
+ sv.INCLUDEGEOM: include_geom,
1828
+ sv.INCLUDECUSTOMLABELS: include_custom_labels,
1829
+ sv.INCLUDEDATA: include_data,
1830
+ sv.COLLAPSEZONESANDVARS: collapse})
1831
+
1832
+ if zones is not None:
1833
+ zoneset = IndexSet(zones)
1834
+ allocd.append(zoneset)
1835
+ arglist[sv.ZONELIST] = zoneset
1836
+
1837
+ if variables is None:
1838
+ arglist[sv.VARLOADMODE] = VarLoadMode.ByName
1839
+
1840
+ else:
1841
+ if isinstance(variables[0], int):
1842
+ arglist[sv.VARLOADMODE] = VarLoadMode.ByPosition
1843
+ varset = IndexSet(*variables)
1844
+ allocd.append(varset)
1845
+ arglist[sv.VARPOSITIONLIST] = varset
1846
+ elif isinstance(variables[0], str):
1847
+ arglist[sv.VARLOADMODE] = VarLoadMode.ByName
1848
+ var_string_list = StringList(*variables)
1849
+ allocd.append(var_string_list)
1850
+ arglist[sv.VARNAMELIST] = var_string_list
1851
+ else:
1852
+ err = 'unknown type for variables: {}'
1853
+ raise TecplotTypeError(err.format(type(variables)))
1854
+ if skip is not None:
1855
+ i, j, k = skip
1856
+ arglist[sv.ISKIP] = i
1857
+ arglist[sv.JSKIP] = j
1858
+ arglist[sv.KSKIP] = k
1859
+
1860
+ try:
1861
+ return _tecplot_loader_load_data(
1862
+ arglist, frame=frame, read_data_option=read_data_option,
1863
+ reset_style=reset_style,
1864
+ initial_plot_first_zone_only=initial_plot_first_zone_only,
1865
+ initial_plot_type=initial_plot_type,
1866
+ assign_strand_ids=assign_strand_ids,
1867
+ add_zones_to_existing_strands=add_zones_to_existing_strands)
1868
+ finally:
1869
+ for a in allocd:
1870
+ a.dealloc()
1871
+
1872
+
1873
+ @lock()
1874
+ def load_tecplot_szl(filenames,
1875
+
1876
+ frame=None,
1877
+
1878
+ read_data_option=ReadDataOption.Append,
1879
+ reset_style=None,
1880
+ initial_plot_first_zone_only=None,
1881
+ initial_plot_type=None,
1882
+ assign_strand_ids=True,
1883
+ add_zones_to_existing_strands=None,
1884
+
1885
+ server=None,
1886
+ connection_method=None,
1887
+ user=None,
1888
+ authentication_method=None,
1889
+ ssh_private_keyfile=None,
1890
+ szlserver_path=None):
1891
+ """Read tecplot SZL data file.
1892
+
1893
+ Parameters:
1894
+ filenames (`str` or `list` of `strings <str>`): Files to be
1895
+ read. (See note below concerning absolute and relative paths.)
1896
+ frame (`Frame <tecplot.layout.Frame>`, optional): The `Frame
1897
+ <tecplot.layout.Frame>` to attach the resulting `Dataset`. If
1898
+ `None`, the currently active `Frame <tecplot.layout.Frame>` is used
1899
+ and the zones are appended by default.
1900
+ read_data_option (`ReadDataOption`, optional): Specify how the data
1901
+ is loaded into Tecplot. (default: `ReadDataOption.Append`)
1902
+
1903
+ Possible values are:
1904
+ * `ReadDataOption.ReplaceInActiveFrame`
1905
+ Remove the dataset from the active frame prior to reading in the
1906
+ new dataset. If other frames use the same `Dataset
1907
+ <tecplot.data.Dataset>` in the active frame, they will continue to
1908
+ use the old one.
1909
+ * `ReadDataOption.Append`
1910
+ Append to the existing `Dataset <tecplot.data.Dataset>`.
1911
+ * `ReadDataOption.Replace`
1912
+ Replace the `Dataset <tecplot.data.Dataset>` attached to the active
1913
+ frame and to all other frames that use the same `Dataset
1914
+ <tecplot.data.Dataset>`.
1915
+ reset_style (`bool`, optional): Reset the style for
1916
+ destination `Frame <layout.Frame>`. If `False`, the `Frame
1917
+ <layout.Frame>`'s current style is preserved. (default: `True`)
1918
+ initial_plot_first_zone_only (`bool`, optional): Informs
1919
+ the |Tecplot Engine| that after the data is loaded it only needs to
1920
+ activate the first enabled `Zone <data_access>` for the initial
1921
+ plot. This option is particularly useful if you have many `Zones
1922
+ <data_access>` and want to get the data into the |Tecplot Engine|
1923
+ and the first `Zone <data_access>` drawn as fast as possible. The
1924
+ inactive `Zones <data_access>` can always be activated when needed.
1925
+ (default: `False`)
1926
+ initial_plot_type (`PlotType`, optional): Forces a specific type of
1927
+ plot upon loading of the data. Only used if *resetstyle* is `True`.
1928
+ To have |Tecplot 360| determine the most appropriate plot type
1929
+ for the data, use `PlotType.Automatic`. Possible values are:
1930
+ `PlotType.Automatic` (default), `Cartesian3D`, `Cartesian2D`,
1931
+ `XYLine`, `PlotType.Sketch`, `PolarLine`.
1932
+
1933
+ assign_strand_ids (`bool`, optional): Assign strand ID's to
1934
+ zones that have a strand ID of -1. (default: `True`)
1935
+ add_zones_to_existing_strands (`bool`, optional): Add the
1936
+ `Zones <data_access>` to matching strands, if they exist. Otherwise, if the
1937
+ new data specifies strands, new ones will be created beginning after the
1938
+ last strand in the `Dataset <tecplot.data.Dataset>`. (default: `False`)
1939
+
1940
+ server (`str`, optional): Load the data remotely from this
1941
+ server address. When provided, file paths will be relative to the
1942
+ SZL server's working directory. (default: `None`)
1943
+ connection_method (`SZLLoader.RemoteConnectionMethod`, optional): When
1944
+ *server* is given, this specifies the type of connection to be
1945
+ made. Possible values are:
1946
+ `SZLLoader.RemoteConnectionMethod.Tunneled` (default),
1947
+ `SZLLoader.RemoteConnectionMethod.Direct`,
1948
+ `SZLLoader.RemoteConnectionMethod.Manual`.
1949
+ user (`str`, optional): When *server* is given and *connection_method*
1950
+ is `SZLLoader.RemoteConnectionMethod.Tunneled` or
1951
+ `SZLLoader.RemoteConnectionMethod.Direct`, this specifies the
1952
+ username to use when logging into the server. This will default to
1953
+ the client host's user name.
1954
+ authentication_method (`SZLLoader.RemoteAuthenticationMethod`, optional):
1955
+ The authentication method to use when connecting to the remote
1956
+ server when *connection_method* is
1957
+ `SZLLoader.RemoteConnectionMethod.Tunneled` or
1958
+ `SZLLoader.RemoteConnectionMethod.Direct`. Possible values are
1959
+ `SZLLoader.RemoteAuthenticationMethod.SSHAgent`,
1960
+ `SZLLoader.RemoteAuthenticationMethod.SSHPrivateKey` (default)
1961
+ which uses the file specified by *ssh_private_keyfile* or
1962
+ `SZLLoader.RemoteAuthenticationMethod.Password` which will prompt
1963
+ the user for the remote login password in the console.
1964
+ ssh_private_keyfile (`str`, optional): When *server* is specified and
1965
+ *connection_method* is set to
1966
+ `SZLLoader.RemoteConnectionMethod.Tunneled` or
1967
+ `SZLLoader.RemoteConnectionMethod.Direct` and when
1968
+ *authentication_method* is set to
1969
+ `SZLLoader.RemoteAuthenticationMethod.SSHPrivateKey`, this
1970
+ specifies the full path to the private SSH keyfile. This parameter
1971
+ defaults to ``~/.ssh/id_rsa`` where ``~`` expands out to the local
1972
+ user's home directory.
1973
+
1974
+ Returns:
1975
+ `Dataset <tecplot.data.Dataset>`: The `Dataset <tecplot.data.Dataset>` holding
1976
+ the loaded data.
1977
+
1978
+ .. note:: **Absolute and relative paths with PyTecplot**
1979
+
1980
+ Relative paths, when used within the PyTecplot API are always from
1981
+ Python's current working directory which can be obtained by calling
1982
+ :func:`os.getcwd()`. This is true for batch and `connected
1983
+ <tecplot.session.connect()>` modes. One exception to this is paths
1984
+ within a macro command or file which will be relative to the |Tecplot
1985
+ Engine|'s home directory, which is typically the |Tecplot 360|
1986
+ installation directory. Finally, when connected to a remote (non-local)
1987
+ instance of Tecplot 360, only absolute paths are allowed.
1988
+
1989
+ Note that backslashes must be escaped which is especially important for
1990
+ windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
1991
+ which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
1992
+ respectively. Alternatively, one may use Python's raw strings:
1993
+ ``r"C:\\Users"`` and ``r"\\\\server\\path"``
1994
+
1995
+ """
1996
+ if isinstance(connection_method, RemoteConnectionMethod):
1997
+ enum_value = connection_method.value
1998
+ connection_method = SZLLoader.RemoteConnectionMethod(enum_value)
1999
+ if __debug__:
2000
+ tecutil.api_moved('RemoteConnectionMethod',
2001
+ 'SZLLoader.RemoteConnectionMethod',
2002
+ '1.4', '2021 R1', warning=True)
2003
+ if isinstance(authentication_method, RemoteAuthenticationMethod):
2004
+ enum_value = authentication_method.value
2005
+ authentication_method = SZLLoader.RemoteAuthenticationMethod(enum_value)
2006
+ if __debug__:
2007
+ tecutil.api_moved('RemoteAuthenticationMethod',
2008
+ 'SZLLoader.RemoteAuthenticationMethod',
2009
+ '1.4', '2021 R1', warning=True)
2010
+
2011
+ ConnectionMethod = SZLLoader.RemoteConnectionMethod
2012
+ AuthenticationMethod = SZLLoader.RemoteAuthenticationMethod
2013
+ if isinstance(filenames, str):
2014
+ filenames = [filenames]
2015
+ if server is not None:
2016
+ if connection_method is None:
2017
+ connection_method = ConnectionMethod.Tunneled
2018
+ else:
2019
+ connection_method = ConnectionMethod(connection_method)
2020
+
2021
+ if (
2022
+ not _tecutil_connector.connected and
2023
+ connection_method == ConnectionMethod.Manual
2024
+ ):
2025
+ msg = 'Manual connection to SZL server not supported in batch mode'
2026
+ raise TecplotLogicError(msg)
2027
+
2028
+ with tecutil.ArgList() as arglist:
2029
+ if server is None:
2030
+ instr = ['STANDARDSYNTAX', '1.0']
2031
+ instr += ['FILELIST_DATAFILES', str(len(filenames))]
2032
+ instr += [tecutil.normalize_path(f) for f in filenames]
2033
+
2034
+ arglist['DATASETREADER'] = 'Tecplot Subzone Data Loader'
2035
+ else:
2036
+ if user is None:
2037
+ user = getpass.getuser()
2038
+
2039
+ instr = ['Connection Method', connection_method.value,
2040
+ 'MACHINE', server]
2041
+
2042
+ if connection_method in [ConnectionMethod.Tunneled,
2043
+ ConnectionMethod.Direct]:
2044
+ if authentication_method is None:
2045
+ auth = AuthenticationMethod.SSHPrivateKey
2046
+ else:
2047
+ auth = AuthenticationMethod(authentication_method)
2048
+
2049
+ instr += ['USER', user, 'SSH Authentication Option', auth.value]
2050
+
2051
+ if auth == AuthenticationMethod.SSHPrivateKey:
2052
+ if ssh_private_keyfile is None:
2053
+ homedir = os.path.expanduser('~')
2054
+ keyfile = os.path.join(homedir, '.ssh', 'id_rsa')
2055
+ else:
2056
+ keyfile = os.path.expanduser(ssh_private_keyfile)
2057
+ instr += ['Key Path', str(keyfile)]
2058
+
2059
+ if szlserver_path is not None:
2060
+ instr += ['Server Executable Path', str(szlserver_path)]
2061
+
2062
+ instr += ['FILELIST_DATAFILES', str(len(filenames))]
2063
+ instr += filenames
2064
+
2065
+ arglist[sv.DATASETREADER] = 'SZL Remote Loader'
2066
+
2067
+ with tecutil.StringList(*instr) as instr:
2068
+ arglist['FILENAMESORINSTRUCTIONS'] = instr
2069
+ return _tecplot_loader_load_data(
2070
+ arglist, frame=frame, read_data_option=read_data_option,
2071
+ reset_style=reset_style,
2072
+ initial_plot_first_zone_only=initial_plot_first_zone_only,
2073
+ initial_plot_type=initial_plot_type,
2074
+ assign_strand_ids=assign_strand_ids,
2075
+ add_zones_to_existing_strands=add_zones_to_existing_strands)