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/plot/slice.py ADDED
@@ -0,0 +1,1544 @@
1
+ from builtins import int, super
2
+
3
+ import itertools as it
4
+
5
+ from collections.abc import Iterable
6
+
7
+ from ..tecutil import _tecutil, sv
8
+ from ..constant import *
9
+ from ..exception import *
10
+ from .. import session, tecutil, version
11
+
12
+
13
+ class SliceMesh(session.SubStyle):
14
+ """Mesh attributes of the slice group.
15
+
16
+ .. code-block:: python
17
+ :emphasize-lines: 12
18
+
19
+ from os import path
20
+ import tecplot as tp
21
+ from tecplot.constant import SliceSurface, ContourType
22
+
23
+ examples_dir = tp.session.tecplot_examples_directory()
24
+ datafile = path.join(examples_dir, 'SimpleData', 'DuctFlow.plt')
25
+ dataset = tp.data.load_tecplot(datafile)
26
+ plot = tp.active_frame().plot()
27
+ plot.show_slices = True
28
+ plot.contour(0).variable = dataset.variable('U(M/S)')
29
+
30
+ plot.slice(0).mesh.show = True
31
+
32
+ # ensure consistent output between interactive (connected) and batch
33
+ plot.contour(0).levels.reset_to_nice()
34
+
35
+ tp.export.save_png('slice_mesh.png', 600, supersample=3)
36
+
37
+ .. figure:: /_static/images/slice_mesh.png
38
+ :width: 300px
39
+ :figwidth: 300px
40
+ """
41
+ def __init__(self, slice_group):
42
+ super().__init__(slice_group, sv.MESH)
43
+
44
+ @property
45
+ def show(self):
46
+ """`bool`: Show mesh lines.
47
+
48
+ Example usage::
49
+
50
+ >>> plot.slice(0).mesh.show = True
51
+ """
52
+ return self._get_style(bool, sv.SHOW)
53
+
54
+ @show.setter
55
+ def show(self, value):
56
+ self._set_style(bool(value), sv.SHOW)
57
+
58
+ @property
59
+ def color(self):
60
+ """`Color` or `ContourGroup`: Slice mesh line Color.
61
+
62
+ Slice mesh lines can be a solid color or be colored by a
63
+ `ContourGroup` as obtained through the ``plot.contour`` property.
64
+
65
+ Example usage::
66
+
67
+ >>> plot.slice(0).mesh.show = True
68
+ >>> plot.slice(0).mesh.color = Color.Green
69
+ """
70
+ return tecutil.color_spec(self._get_style(Color, sv.COLOR),
71
+ self.parent.plot)
72
+
73
+ @color.setter
74
+ def color(self, value):
75
+ self._set_style(tecutil.color_spec(value), sv.COLOR)
76
+
77
+ @property
78
+ def line_thickness(self):
79
+ """`float`: Mesh line thickness.
80
+
81
+ The mesh line thickness is specified as a percentage of the frame width.
82
+
83
+ Example usage::
84
+
85
+ >>> plot.slice(0).mesh.show = True
86
+ >>> plot.slice(0).mesh.line_thickness = 0.8
87
+ """
88
+ return self._get_style(float, sv.LINETHICKNESS)
89
+
90
+ @line_thickness.setter
91
+ def line_thickness(self, value):
92
+ self._set_style(float(value), sv.LINETHICKNESS)
93
+
94
+
95
+ class SliceShade(session.SubStyle):
96
+ """Shade attributes of the slice group.
97
+
98
+ Show shading on the slice when `SliceContour.show` has not been
99
+ selected or is set to `ContourType.Lines`:
100
+
101
+ .. code-block:: python
102
+ :emphasize-lines: 11-14
103
+
104
+ from os import path
105
+ import tecplot as tp
106
+ from tecplot.constant import Color
107
+
108
+ examples_dir = tp.session.tecplot_examples_directory()
109
+ datafile = path.join(examples_dir, 'SimpleData', 'Pyramid.plt')
110
+ dataset = tp.data.load_tecplot(datafile)
111
+
112
+ plot = tp.active_frame().plot()
113
+ plot.show_slices = True
114
+ plot.slice(0).contour.show = False
115
+ shade = plot.slice(0).shade
116
+ shade.show = True
117
+ shade.color = Color.Red # Slice will be colored solid red.
118
+ tp.export.save_png('slice_shade.png', 600, supersample=3)
119
+
120
+ .. figure:: /_static/images/slice_shade.png
121
+ :width: 300px
122
+ :figwidth: 300px
123
+ """
124
+
125
+ def __init__(self, slice_group):
126
+ super().__init__(slice_group, sv.SHADE)
127
+
128
+ @property
129
+ def show(self):
130
+ """`bool`: Show shade attributes.
131
+
132
+ Example usage::
133
+
134
+ >>> plot.slice(0).shade.show = True
135
+ """
136
+ return self._get_style(bool, sv.SHOW)
137
+
138
+ @show.setter
139
+ def show(self, value):
140
+ self._set_style(bool(value), sv.SHOW)
141
+
142
+ @property
143
+ def color(self):
144
+ """`Color`: Shade color.
145
+
146
+ `Color.MultiColor` and `Color.RGBColor` coloring are not available.
147
+ Use flooded contours for multi-color or RGB flooding
148
+
149
+ Example usage::
150
+
151
+ >>> plot.slice(0).shade.show = True
152
+ >>> plot.slice(0).shade.color = Color.Blue
153
+ """
154
+ return self._get_style(Color, sv.COLOR)
155
+
156
+ @color.setter
157
+ def color(self, value):
158
+ self._set_style(Color(value), sv.COLOR)
159
+
160
+ @property
161
+ def use_lighting_effect(self):
162
+ """`bool`: Use lighting effect.
163
+
164
+ When set to `True`, the lighting effect may be selected with the
165
+ `SliceEffects.lighting_effect` attribute.
166
+
167
+ .. note::
168
+ Setting `SliceShade.use_lighting_effect` will also set
169
+ the same value for `SliceContour.use_lighting_effect`,
170
+ and vice-versa.
171
+
172
+ Example usage::
173
+
174
+ >>> plot.slice(0).shade.use_lighting_effect = True
175
+ >>> plot.slice(0).effects.lighting_effect = LightingEffect.Paneled
176
+ """
177
+ return self._get_style(bool, sv.USELIGHTINGEFFECT)
178
+
179
+ @use_lighting_effect.setter
180
+ def use_lighting_effect(self, value):
181
+ self._set_style(bool(value), sv.USELIGHTINGEFFECT)
182
+
183
+
184
+ class SliceEffects(session.SubStyle):
185
+ """Slice effects for this slice.
186
+
187
+ .. code-block:: python
188
+ :emphasize-lines: 16-17
189
+
190
+ from os import path
191
+ import tecplot as tp
192
+
193
+ examples_dir = tp.session.tecplot_examples_directory()
194
+ datafile = path.join(examples_dir, 'SimpleData', 'DuctFlow.plt')
195
+ dataset = tp.data.load_tecplot(datafile)
196
+
197
+ plot = tp.active_frame().plot()
198
+
199
+ plot.show_slices = True
200
+ slice_0 = plot.slice(0)
201
+
202
+ plot.contour(0).variable = dataset.variable('U(M/S)')
203
+ slice_0.contour.show = True
204
+
205
+ slice_0.effects.use_translucency = True
206
+ slice_0.effects.surface_translucency = 70
207
+
208
+ # ensure consistent output between interactive (connected) and batch
209
+ plot.contour(0).levels.reset_to_nice()
210
+
211
+ tp.export.save_png('slice_effects.png', 600, supersample=3)
212
+
213
+ .. figure:: /_static/images/slice_effects.png
214
+ :width: 300px
215
+ :figwidth: 300px
216
+ """
217
+ def __init__(self, slice_group):
218
+ super().__init__(slice_group, sv.EFFECTS)
219
+
220
+ @property
221
+ def lighting_effect(self):
222
+ """`LightingEffect`: Surface lighting effect.
223
+
224
+ Slice lighting effects must be enabled by setting
225
+ `SliceContour.use_lighting_effect` or
226
+ `SliceShade.use_lighting_effect` to `True` when setting this value.
227
+
228
+ There are two types of lighting effects: Paneled and Gouraud:
229
+
230
+ * `Paneled`: Within each cell, the color assigned to each area by
231
+ shading or contour flooding is tinted by a shade constant
232
+ across the cell. This shade is based on the orientation
233
+ of the cell relative to your 3D light source.
234
+ * `Gouraud`: This offers smoother, more continuous shading than
235
+ Paneled shading, but it also results in slower plotting and
236
+ larger print files. `Gouraud` shading is not continuous across
237
+ zone boundaries unless face neighbors are specified in the
238
+ data. `Gouraud` shading is not available for finite element
239
+ volume `Zones <data_access>` when blanking is active. The
240
+ zone's lighting effect reverts to `Paneled` shading in this
241
+ case.
242
+
243
+ Example usage::
244
+
245
+ >>> plot.slice(0).contour.use_lighting_effect = True
246
+ >>> plot.slice(0).effects.lighting_effect = LightingEffect.Paneled
247
+ """
248
+ return self._get_style(LightingEffect, sv.LIGHTINGEFFECT)
249
+
250
+ @lighting_effect.setter
251
+ def lighting_effect(self, value):
252
+ self._set_style(LightingEffect(value), sv.LIGHTINGEFFECT)
253
+
254
+ @property
255
+ def surface_translucency(self):
256
+ """`int`: Surface translucency of the slice group.
257
+
258
+ Slice surface translucency must be enabled by setting
259
+ `SliceEffects.use_translucency` = `True` when setting this value.
260
+
261
+
262
+ Valid slice translucency values range
263
+ from one (opaque) to 99 (translucent).
264
+
265
+ Example usage::
266
+
267
+ >>> plot.slice(0).effects.use_translucency = True
268
+ >>> plot.slice(0).effects.surface_translucency = 20
269
+ """
270
+ return self._get_style(int, sv.SURFACETRANSLUCENCY)
271
+
272
+ @surface_translucency.setter
273
+ def surface_translucency(self, value):
274
+ self._set_style(int(value), sv.SURFACETRANSLUCENCY)
275
+
276
+ @property
277
+ def use_translucency(self):
278
+ """`bool`: Enable surface translucency for this slice group.
279
+
280
+ The surface translucency value can be changed by setting
281
+ `SliceEffects.surface_translucency`.
282
+
283
+ Example usage::
284
+
285
+ >>> plot.slice(0).effects.use_translucency = True
286
+ >>> plot.slice(0).effects.surface_translucency = 20
287
+ """
288
+ return self._get_style(bool, sv.USETRANSLUCENCY)
289
+
290
+ @use_translucency.setter
291
+ def use_translucency(self, value):
292
+ self._set_style(bool(value), sv.USETRANSLUCENCY)
293
+
294
+
295
+ class SliceEdge(session.SubStyle):
296
+ """Edge attributes of the slice group.
297
+
298
+ When enabled, selected edge lines of all slices in this group will
299
+ be shown:
300
+
301
+ .. code-block:: python
302
+ :emphasize-lines: 13-14
303
+
304
+ from os import path
305
+ import tecplot as tp
306
+
307
+ examples_dir = tp.session.tecplot_examples_directory()
308
+ datafile = path.join(examples_dir, 'SimpleData', 'DuctFlow.plt')
309
+ dataset = tp.data.load_tecplot(datafile)
310
+
311
+ plot = tp.active_frame().plot()
312
+ plot.show_slices = True
313
+ plot.contour(0).variable = dataset.variable('U(M/S)')
314
+
315
+ slice_0 = plot.slice(0)
316
+ slice_0.edge.show = True
317
+ slice_0.edge.line_thickness = 0.8
318
+
319
+ # ensure consistent output between interactive (connected) and batch
320
+ plot.contour(0).levels.reset_to_nice()
321
+
322
+ tp.export.save_png('slice_edge.png', 600, supersample=3)
323
+
324
+ .. figure:: /_static/images/slice_edge.png
325
+ :width: 300px
326
+ :figwidth: 300px
327
+ """
328
+
329
+ def __init__(self, slice_group):
330
+ super().__init__(slice_group, sv.EDGELAYER)
331
+
332
+ @property
333
+ def edge_type(self):
334
+ """`EdgeType`: Edge type.
335
+
336
+ There are two types of edges in |Tecplot 360|: creases and borders.
337
+
338
+ An edge border is the boundary of a `Zone <data_access>`. An edge
339
+ crease appears when the inside angle between two cells is less than a
340
+ user-defined limit. The inside angle can range from 0-180 degrees
341
+ (where 180 degrees indicates coplanar surfaces). The default inside
342
+ angle for determining an edge crease is 135 degrees.
343
+
344
+ Example usage::
345
+
346
+ >>> plot.slice(0).edge.show = True
347
+ >>> plot.slice(0).edge.edge_type = EdgeType.BordersAndCreases
348
+ """
349
+ return self._get_style(EdgeType, sv.EDGETYPE)
350
+
351
+ @edge_type.setter
352
+ def edge_type(self, value):
353
+ self._set_style(EdgeType(value), sv.EDGETYPE)
354
+
355
+ @property
356
+ def show(self):
357
+ """`bool`: Show edges.
358
+
359
+ This property must be set to `True` to show any of the other edge
360
+ properties.
361
+
362
+ Example usage::
363
+
364
+ >>> plot.slice(0).edge.show = True
365
+ >>> plot.slice(0).edge.edge_type = EdgeType.BordersAndCreases
366
+ """
367
+ return self._get_style(bool, sv.SHOW)
368
+
369
+ @show.setter
370
+ def show(self, value):
371
+ self._set_style(bool(value), sv.SHOW)
372
+
373
+ @property
374
+ def color(self):
375
+ """`Color`: Edge color.
376
+
377
+ Example usage::
378
+
379
+ >>> plot.slice(0).edge.show = True
380
+ >>> plot.slice(0).edge.color = Color.Blue
381
+ """
382
+ return self._get_style(Color, sv.COLOR)
383
+
384
+ @color.setter
385
+ def color(self, value):
386
+ self._set_style(Color(value), sv.COLOR)
387
+
388
+ @property
389
+ def line_thickness(self):
390
+ """`float`: Edge line thickness as a percentage of frame width.
391
+
392
+ Example usage::
393
+
394
+ >>> plot.slice(0).edge.show = True
395
+ >>> plot.slice(0).edge.line_thickness = .8
396
+ """
397
+ return self._get_style(float, sv.LINETHICKNESS)
398
+
399
+ @line_thickness.setter
400
+ def line_thickness(self, value):
401
+ self._set_style(float(value), sv.LINETHICKNESS)
402
+
403
+
404
+ class SliceVector(session.SubStyle):
405
+ """Vector attributes of the slice group.
406
+
407
+ .. code-block:: python
408
+ :emphasize-lines: 22-25
409
+
410
+ from os import path
411
+ import tecplot as tp
412
+ from tecplot.constant import *
413
+
414
+ examples_dir = tp.session.tecplot_examples_directory()
415
+ datafile = path.join(examples_dir, 'SimpleData', 'DuctFlow.plt')
416
+ dataset = tp.data.load_tecplot(datafile)
417
+
418
+ plot = tp.active_frame().plot()
419
+
420
+ plot.show_slices = True
421
+ slice_0 = plot.slice(0)
422
+
423
+ plot.contour(0).variable = dataset.variable('T(K)')
424
+
425
+ # Vector variables must be assigned before displaying
426
+ vectors = plot.vector
427
+ vectors.u_variable = dataset.variable('U(M/S)')
428
+ vectors.v_variable = dataset.variable('V(M/S)')
429
+ vectors.w_variable = dataset.variable('W(M/S)')
430
+
431
+ slice_vector = plot.slice(0).vector
432
+ slice_vector.show = True
433
+ slice_vector.vector_type = VectorType.MidAtPoint
434
+ slice_vector.color = Color.BluePurple
435
+
436
+ slice_0.effects.use_translucency = True
437
+ slice_0.effects.surface_translucency = 30
438
+
439
+ # ensure consistent output between interactive (connected) and batch
440
+ plot.contour(0).levels.reset_to_nice()
441
+
442
+ tp.export.save_png('slice_vector.png', 600, supersample=3)
443
+
444
+ .. figure:: /_static/images/slice_vector.png
445
+ :width: 300px
446
+ :figwidth: 300px
447
+ """
448
+
449
+ def __init__(self, slice_group):
450
+ super().__init__(slice_group, sv.VECTOR)
451
+
452
+ @property
453
+ def show(self):
454
+ """`bool`: Show vectors on slices.
455
+
456
+ Example usage::
457
+
458
+ >>> plot.slice(0).vector.show = True
459
+ """
460
+ return self._get_style(bool, sv.SHOW)
461
+
462
+ @show.setter
463
+ def show(self, value):
464
+ self._set_style(bool(value), sv.SHOW)
465
+
466
+ @property
467
+ def color(self):
468
+ """`Color`: Set slice vector color.
469
+
470
+ Example usage::
471
+
472
+ >>> plot.slice(0).vector.show = True
473
+ >>> plot.slice(0).vector.color = Color.Red
474
+ """
475
+ return self._get_style(Color, sv.COLOR)
476
+
477
+ @color.setter
478
+ def color(self, value):
479
+ self._set_style(Color(value), sv.COLOR)
480
+
481
+ @property
482
+ def is_tangent(self):
483
+ """`bool`: Use tangent vectors for slices.
484
+
485
+ Example usage::
486
+
487
+ >>> plot.slice(0).vector.show = True
488
+ >>> plot.slice(0).vector.is_tangent = True
489
+ """
490
+ return self._get_style(bool, sv.ISTANGENT)
491
+
492
+ @is_tangent.setter
493
+ def is_tangent(self, value):
494
+ self._set_style(bool(value), sv.ISTANGENT)
495
+
496
+ @property
497
+ def line_thickness(self):
498
+ """`float`: Vector line thickness as a percentage of the frame height.
499
+
500
+ Typical values are .02, .1, .4, .8, 1.5
501
+
502
+ Example usage::
503
+
504
+ >>> plot.slice(0).vector.show = True
505
+ >>> plot.slice(0).vector.line_thickness = .1
506
+ """
507
+ return self._get_style(float, sv.LINETHICKNESS)
508
+
509
+ @line_thickness.setter
510
+ def line_thickness(self, value):
511
+ self._set_style(float(value), sv.LINETHICKNESS)
512
+
513
+ @property
514
+ def vector_type(self):
515
+ """`VectorType`: Type of vector for slices in this slice group.
516
+
517
+ Example usage::
518
+
519
+ >>> plot.slice(0).vector.show = True
520
+ >>> plot.slice(0).vector.vector_type = VectorType.MidAtPoint
521
+ """
522
+ return self._get_style(VectorType, sv.VECTORTYPE)
523
+
524
+ @vector_type.setter
525
+ def vector_type(self, value):
526
+ self._set_style(VectorType(value), sv.VECTORTYPE)
527
+
528
+ @property
529
+ def arrowhead_style(self):
530
+ """`ArrowheadStyle`: Arrowhead style of slice vectors.
531
+
532
+ Example usage::
533
+
534
+ >>> plot.slice(0).vector.show = True
535
+ >>> plot.slice(0).vector.arrowhead_style = ArrowheadStyle.Hollow
536
+ """
537
+ return self._get_style(ArrowheadStyle, sv.ARROWHEADSTYLE)
538
+
539
+ @arrowhead_style.setter
540
+ def arrowhead_style(self, value):
541
+ self._set_style(ArrowheadStyle(value), sv.ARROWHEADSTYLE)
542
+
543
+
544
+ class SliceContour(session.SubStyle):
545
+ """Contour attributes of the slice group.
546
+
547
+ .. code-block:: python
548
+ :emphasize-lines: 18-21
549
+
550
+ from os import path
551
+ import tecplot as tp
552
+ from tecplot.constant import SliceSurface, ContourType
553
+
554
+ examples_dir = tp.session.tecplot_examples_directory()
555
+ datafile = path.join(examples_dir, 'SimpleData', 'DuctFlow.plt')
556
+ dataset = tp.data.load_tecplot(datafile)
557
+
558
+ plot = tp.active_frame().plot()
559
+
560
+ plot.show_slices = True
561
+ slice_0 = plot.slice(0)
562
+
563
+ # Use contour(0) for Flooding and contour(2) for Lines
564
+ plot.contour(0).variable = dataset.variable('P(N/m2)')
565
+ plot.contour(2).variable = dataset.variable('T(K)')
566
+ plot.contour(2).legend.show = False
567
+ slice_0.contour.show = True
568
+ slice_0.contour.flood_contour_group = plot.contour(0)
569
+ slice_0.contour.line_contour_group = plot.contour(2)
570
+ slice_0.contour.contour_type = ContourType.Overlay # AKA "Both lines and flood"
571
+
572
+ slice_0.show_primary_slice = False
573
+ slice_0.show_start_and_end_slices = True
574
+ slice_0.show_intermediate_slices = True
575
+ slice_0.start_position = (-.21, .05, .025)
576
+ slice_0.end_position = (1.342, .95, .475)
577
+ slice_0.num_intermediate_slices = 3
578
+
579
+ # ensure consistent output between interactive (connected) and batch
580
+ slice_0.contour.flood_contour_group.levels.reset_to_nice()
581
+ slice_0.contour.line_contour_group.levels.reset_to_nice()
582
+
583
+ tp.export.save_png('slice_contour.png', 600, supersample=3)
584
+
585
+ .. figure:: /_static/images/slice_contour.png
586
+ :width: 300px
587
+ :figwidth: 300px
588
+ """
589
+ def __init__(self, slice_group):
590
+ super().__init__(slice_group, sv.CONTOUR)
591
+ self.plot = slice_group.plot
592
+
593
+ @property
594
+ def show(self):
595
+ """`bool`: Show contours on the slice.
596
+
597
+ Example usage::
598
+
599
+ >>> plot.show_slices = True
600
+ >>> plot.slice(1).contour.show = True
601
+ """
602
+ return self._get_style(bool, sv.SHOW)
603
+
604
+ @show.setter
605
+ def show(self, value):
606
+ self._set_style(bool(value), sv.SHOW)
607
+
608
+ @property
609
+ def contour_type(self):
610
+ """`ContourType`: Contour type for the slice contours.
611
+
612
+ Example usage::
613
+
614
+ >>> plot.show_slices = True
615
+ >>> plot.slice(0).contour.contour_type = ContourType.AverageCell
616
+ """
617
+ return self._get_style(ContourType, sv.CONTOURTYPE)
618
+
619
+ @contour_type.setter
620
+ def contour_type(self, value):
621
+ self._set_style(ContourType(value), sv.CONTOURTYPE)
622
+
623
+ @property
624
+ def line_color(self):
625
+ """`Color`: `Color` of contour lines.
626
+
627
+ Selecting `Color.MultiColor` will color the slice contour lines
628
+ based on the `contour group <tecplot.plot.ContourGroup>` variable.
629
+
630
+ Example usage::
631
+
632
+ >>> plot.show_slices = True
633
+ >>> plot.slice(0).contour.line_color = Color.Blue
634
+ """
635
+ return self._get_style(Color, sv.COLOR)
636
+
637
+ @line_color.setter
638
+ def line_color(self, value):
639
+ self._set_style(Color(value), sv.COLOR)
640
+
641
+ @property
642
+ def line_thickness(self):
643
+ """`float`: Contour line thickness as a percentage of frame width.
644
+
645
+ Suggested values are one of: **.02, .1, .4, .8, 1.5**
646
+
647
+ Example usage::
648
+
649
+ >>> plot.show_slices = True
650
+ >>> plot.slice(0).contour.line_thickness = .4
651
+ """
652
+ return self._get_style(float, sv.LINETHICKNESS)
653
+
654
+ @line_thickness.setter
655
+ def line_thickness(self, value):
656
+ self._set_style(float(value), sv.LINETHICKNESS)
657
+
658
+ @property
659
+ def flood_contour_group_index(self):
660
+ """`Index`: Zero-based `Index` of the flodding `ContourGroup`.
661
+
662
+ This property sets and gets, by `Index`, the `ContourGroup` used for
663
+ flooding. Changing style on this `ContourGroup` will affect all
664
+ fieldmaps on the same `Frame <layout.Frame>` that use it.
665
+
666
+ Example usage::
667
+
668
+ >>> plot.show_slices = True
669
+ >>> contour = plot.slice(0).contour
670
+ >>> contour.flood_contour_group_index = 1
671
+ """
672
+ return self._get_style(tecutil.Index, sv.FLOODCOLORING)
673
+
674
+ @flood_contour_group_index.setter
675
+ def flood_contour_group_index(self, index):
676
+ self._set_style(tecutil.Index(index), sv.FLOODCOLORING)
677
+
678
+ @property
679
+ def flood_contour_group(self):
680
+ """`ContourGroup`: Contour group to use for flooding.
681
+
682
+ Changing style on this `ContourGroup` will affect all
683
+ fieldmaps on the same `Frame <layout.Frame>` that use it.
684
+
685
+ Example usage::
686
+
687
+ >>> group = plot.contour(1)
688
+ >>> contour = plot.slice(1).contour
689
+ >>> contour.flood_contour_group = group
690
+ """
691
+ indices = self.flood_contour_group_index
692
+ if isinstance(indices, Iterable):
693
+ return tuple([self.plot.contour(i) for i in indices])
694
+ else:
695
+ return self.plot.contour(indices)
696
+
697
+ @flood_contour_group.setter
698
+ def flood_contour_group(self, flood_contour_group):
699
+ self.flood_contour_group_index = flood_contour_group.index
700
+
701
+ @property
702
+ def line_contour_group_index(self):
703
+ """`int`: Zero-based `Index` of the `ContourGroup` for contour lines.
704
+
705
+ This property sets and gets, by `Index`, the `ContourGroup` used for
706
+ line placement. Although all properties of the `ContourGroup` can be
707
+ manipulated through this object, many of them (i.e., color) will not
708
+ affect the lines unless the `FieldmapContour.line_color` is set to the
709
+ same `ContourGroup`. Note that changing style on this `ContourGroup`
710
+ will affect all other fieldmaps on the same `Frame <layout.Frame>` that use it.
711
+
712
+ Example usage::
713
+
714
+ >>> plot.show_slices = True
715
+ >>> contour = plot.slice(0).contour
716
+ >>> contour.line_contour_group_index = 2
717
+ """
718
+ return self._get_style(tecutil.Index, sv.LINECONTOURGROUP)
719
+
720
+ @line_contour_group_index.setter
721
+ def line_contour_group_index(self, index):
722
+ self._set_style(tecutil.Index(index), sv.LINECONTOURGROUP)
723
+
724
+ @property
725
+ def line_contour_group(self):
726
+ """`ContourGroup`: Contour group to use for contour lines.
727
+
728
+ Changing style on this `ContourGroup` will affect all
729
+ fieldmaps on the same `Frame <layout.Frame>` that use it.
730
+
731
+ Example usage::
732
+
733
+ >>> group = plot.contour(1)
734
+ >>> contour = plot.slice(1).contour
735
+ >>> contour.line_contour_group = group
736
+ """
737
+ indices = self.line_contour_group_index
738
+ if isinstance(indices, Iterable):
739
+ return tuple([self.plot.contour(i) for i in indices])
740
+ else:
741
+ return self.plot.contour(indices)
742
+
743
+ @line_contour_group.setter
744
+ def line_contour_group(self, line_contour_group):
745
+ self.line_contour_group_index = line_contour_group.index
746
+
747
+ @property
748
+ def use_lighting_effect(self):
749
+ """`bool`; Enable lighting effect.
750
+
751
+ .. note::
752
+ Setting `SliceContour.use_lighting_effect` will also set
753
+ the same value for `SliceShade.use_lighting_effect`,
754
+ and vice-versa.
755
+
756
+ The lighting effect is set with `SliceEffects.lighting_effect`, and may
757
+ be one of `LightingEffect.Gouraud` or `LightingEffect.Paneled`.
758
+
759
+ Example usage::
760
+
761
+ >>> plot.show_slices = True
762
+ >>> contour = plot.slice(0).contour
763
+ >>> contour.use_lighting_effect = True
764
+ >>> plot.slice(0).effects.lighting_effect = LightingEffect.Paneled
765
+ """
766
+ return self._get_style(bool, sv.USELIGHTINGEFFECT)
767
+
768
+ @use_lighting_effect.setter
769
+ def use_lighting_effect(self, value):
770
+ self._set_style(bool(value), sv.USELIGHTINGEFFECT)
771
+
772
+
773
+ class SliceGroupCollection(session.Style):
774
+ """Change attributes associated with multiple slices.
775
+
776
+ Slices can include lighting effects, contours, meshes, and more. To
777
+ customize these and other attributes of slices, use this object. It
778
+ controls the style for specific slice groups within a `Frame <layout.Frame>`. Slice
779
+ `contour <SliceGroup.contour>`, vector, edge, effects, mesh, visibility and
780
+ position information are accessed through this class:
781
+
782
+ .. code-block:: python
783
+ :emphasize-lines: 12-29
784
+
785
+ from os import path
786
+ import tecplot as tp
787
+ from tecplot.constant import *
788
+
789
+ examples_dir = tp.session.tecplot_examples_directory()
790
+ datafile = path.join(examples_dir, 'SimpleData', 'DuctFlow.plt')
791
+ dataset = tp.data.load_tecplot(datafile)
792
+
793
+ plot = tp.active_frame().plot()
794
+ plot.contour(0).variable = dataset.variable('U(M/S)')
795
+
796
+ plot.show_slices = True
797
+ slices = plot.slices(0, 1, 2)
798
+ slices.show = True
799
+
800
+ slices.contour.show = True
801
+ slices.contour.contour_type = ContourType.Overlay
802
+ slices.effects.use_translucency = True
803
+ slices.effects.surface_translucency = 70
804
+
805
+ # Show arbitrary slices
806
+ slices.orientation = SliceSurface.Arbitrary
807
+ slices.origin = (0.1, 0.2, 0)
808
+ slices[0].arbitrary_normal = (1, 0.5, 0)
809
+ slices[1].arbitrary_normal = (0.2, 1, 0)
810
+ slices[2].arbitrary_normal = (0, 0, 1)
811
+
812
+ slices.edge.show = True
813
+ slices.edge.line_thickness = 0.4
814
+
815
+ plot.contour(0).levels.reset_to_nice()
816
+ plot.contour(0).legend.show = False
817
+
818
+ tp.export.save_png('slice_collection.png')
819
+
820
+ .. figure:: /_static/images/slice_collection.png
821
+ :width: 300px
822
+ :figwidth: 300px
823
+
824
+ Up to eight different slice groups can be set and each slice group can use
825
+ different slice planes or different ranges for the same slice plane.
826
+
827
+ This class behaves like `SliceGroup` except that setting any underlying
828
+ style will do so for all of the represented slice groups. The style
829
+ properties are then always returned as a `tuple` of properties, one for
830
+ each group, ordered by index number. This means there is an asymmetry
831
+ between setting and getting any property under this object, illustrated by
832
+ the following example::
833
+
834
+ >>> slices = plot.slices(0, 1, 2)
835
+ >>> slices.show = True
836
+ >>> print(slices.show)
837
+ (True, True, True)
838
+
839
+ All examples that set style on a single slice like the following::
840
+
841
+ >>> plot.slice(0).contour.show = True
842
+
843
+ may be converted to setting the same style on all slice groups like so::
844
+
845
+ >>> plot.slices().contour.show = True
846
+
847
+ .. seealso:: `SliceGroup`
848
+
849
+ .. versionadded:: 1.2
850
+ Slice collection objects.
851
+ """
852
+ def __init__(self, plot, *indices):
853
+ if __debug__:
854
+ assert all(0 <= i < 8 for i in indices), \
855
+ 'Slice index out of range (must be in the range: [0,7])'
856
+ if indices:
857
+ self._indices = set([tecutil.Index(i) for i in indices])
858
+ else:
859
+ self._indices = set(range(8))
860
+ self.plot = plot
861
+ super().__init__(sv.SLICEATTRIBUTES, uniqueid=self.plot.frame.uid)
862
+
863
+ @property
864
+ def indices(self):
865
+ return sorted(self._indices)
866
+
867
+ def __getitem__(self, index):
868
+ return SliceGroup(self.plot, self.indices[index])
869
+
870
+ def __iter__(self):
871
+ self._current_index = -1
872
+ self._max_index = len(self._indices)
873
+ return self
874
+
875
+ def __next__(self):
876
+ self._current_index += 1
877
+ if self._current_index < self._max_index:
878
+ return self[self._current_index]
879
+ raise StopIteration
880
+
881
+ def next(self): # if sys.version_info < (3,)
882
+ return self.__next__()
883
+
884
+ def __eq__(self, other):
885
+ return (self.indices == other.indices) and (self.plot == other.plot)
886
+
887
+ def __ne__(self, other):
888
+ return not self.__eq__(other)
889
+
890
+ def _get_style(self, rettype, *svargs, **kwargs):
891
+ res = []
892
+ for index in self.indices:
893
+ kwargs.update(**{sv.OFFSET1: index})
894
+ res.append(super()._get_style(rettype, *svargs, **kwargs))
895
+ return tuple(res)
896
+
897
+ def _set_style(self, value, *svargs, **kwargs):
898
+ for index in self.indices:
899
+ kwargs.update(**{sv.OFFSET1: index})
900
+ super()._set_style(value, *svargs, **kwargs)
901
+
902
+ @tecutil.lock()
903
+ def extract(self, mode=ExtractMode.SingleZone, assign_strand_ids=True,
904
+ resulting_1d_zone_type=Resulting1DZoneType.IOrderedIfPossible,
905
+ transient_mode=TransientOperationMode.SingleSolutionTime):
906
+ """Create new zones from this slice collection.
907
+
908
+ Extracts the current slices represented by this group to the
909
+ `Dataset <data.Dataset>` as one or more zones.
910
+
911
+ Parameters:
912
+ mode (`ExtractMode`, optional): Determines how many zones are
913
+ created upon extraction. Possible values are:
914
+ `ExtractMode.SingleZone` (default) and
915
+ `ExtractMode.OneZonePerConnectedRegion`.
916
+ assign_strand_ids (`bool`, optional): Automatically assign strand
917
+ ID's to the created zones. (default: `True`)
918
+ resulting_1d_zone_type (`Resulting1DZoneType`, optional): The type
919
+ of zone to create when the result is one-dimensional. Possible
920
+ values are: `Resulting1DZoneType.IOrderedIfPossible` (default)
921
+ and `Resulting1DZoneType.FELineSegment`.
922
+ transient_mode (`TransientOperationMode`): Determines which
923
+ solution times are used to extract slices when transient data
924
+ is available in the dataset. Possible values are
925
+ `TransientOperationMode.SingleSolutionTime` (default) or
926
+ `TransientOperationMode.AllSolutionTimes`.
927
+
928
+ Returns:
929
+
930
+ generator_ of the extracted zones.
931
+
932
+ .. seealso:: `tecplot.data.extract.extract_slice()`
933
+
934
+ Example usage showing how to convert the resulting generator into a
935
+ reusable list object of zones::
936
+
937
+ >>> slice_zones = list(plot.slices(0, 1).extract())
938
+
939
+ .. _generator: https://docs.python.org/3/reference/expressions.html#generator-expressions
940
+ """
941
+ transient_mode = TransientOperationMode(transient_mode)
942
+ dataset = self.plot.frame.dataset
943
+ mode = ExtractMode(mode)
944
+ nzones = dataset.num_zones
945
+ with self.plot.frame.activated(), \
946
+ tecutil.ArgList() as arglist:
947
+
948
+ arglist[sv.EXTRACTMODE] = mode
949
+ arglist[sv.AUTOSTRANDTRANSIENTDATA] = bool(assign_strand_ids)
950
+ zone_type = Resulting1DZoneType(resulting_1d_zone_type)
951
+ arglist[sv.RESULTING1DZONETYPE] = zone_type
952
+ if transient_mode != TransientOperationMode.SingleSolutionTime:
953
+ arglist[sv.TRANSIENTOPERATIONMODE] = transient_mode
954
+
955
+ with tecutil.IndexSet(*self._indices) as groups:
956
+ arglist[sv.GROUPS] = groups
957
+ if not _tecutil.ExtractSlicesX(arglist):
958
+ raise TecplotSystemError()
959
+
960
+ return (dataset.zone(i) for i in range(nzones, dataset.num_zones))
961
+
962
+ @property
963
+ def vector(self):
964
+ """`SliceVector`: Vector attributes for this slice group.
965
+
966
+ Example usage::
967
+
968
+ >>> plot.slice(0).vector.show = True
969
+ """
970
+ return SliceVector(self)
971
+
972
+ @property
973
+ def edge(self):
974
+ """`SliceEdge`: Edge attributes for this slice group.
975
+
976
+ Example usage::
977
+
978
+ >>> plot.slice(0).edge.show = True
979
+ """
980
+ return SliceEdge(self)
981
+
982
+ @property
983
+ def effects(self):
984
+ """`SliceEffects`: Effects attributes for this slice group.
985
+
986
+ Example usage::
987
+
988
+ >>> plot.slice(0).effects.use_translucency = True
989
+ """
990
+ return SliceEffects(self)
991
+
992
+ @property
993
+ def shade(self):
994
+ """`SliceShade`: Shade attributes for this slice group.
995
+
996
+ Example usage::
997
+
998
+ >>> plot.slice(0).shade.show = True
999
+ """
1000
+ return SliceShade(self)
1001
+
1002
+ @property
1003
+ def mesh(self):
1004
+ """`SliceMesh`: Mesh attributes for this slice group.
1005
+
1006
+ Example usage::
1007
+
1008
+ >>> plot.slice(0).mesh.show = True
1009
+ """
1010
+ return SliceMesh(self)
1011
+
1012
+ @property
1013
+ def show(self):
1014
+ """`bool`: Show slices for this slice group.
1015
+
1016
+ Example usage::
1017
+
1018
+ >>> plot.slice(0).show = True
1019
+ """
1020
+ return self._get_style(bool, sv.SHOWGROUP)
1021
+
1022
+ @show.setter
1023
+ def show(self, value):
1024
+ self._set_style(bool(value), sv.SHOWGROUP)
1025
+
1026
+ @property
1027
+ def show_primary_slice(self):
1028
+ """`bool`; Include the primary slice (first slice placed) in the `Plot`.
1029
+
1030
+ Example usage::
1031
+
1032
+ >>> plot.slice(0).show = True
1033
+ >>> plot.slice(0).show_primary_slice = True
1034
+
1035
+ """
1036
+ return self._get_style(bool, sv.SHOWPRIMARYSLICE)
1037
+
1038
+ @show_primary_slice.setter
1039
+ def show_primary_slice(self, value):
1040
+ self._set_style(bool(value), sv.SHOWPRIMARYSLICE)
1041
+
1042
+ @property
1043
+ def contour(self):
1044
+ """`SliceContour`: Contour attributes for the slice group.
1045
+
1046
+ Example usage::
1047
+
1048
+ >>> plot.slice(0).contour.show = True
1049
+ """
1050
+ return SliceContour(self)
1051
+
1052
+ @property
1053
+ def orientation(self):
1054
+ """`SliceSurface`: Select on which plane the slice is drawn.
1055
+
1056
+ You may also choose `SliceSurface.Arbitrary` to place the
1057
+ slice on an arbitrary plane.
1058
+
1059
+ To orient slices in an arbitrary direction,
1060
+ choose `SliceSurface.Arbitrary`.
1061
+ As with other slices, you may specify origin points for a primary
1062
+ slice and/or for start and end slices. Slices pass through the
1063
+ indicated origin point(s), so you can easily align the edge of a
1064
+ slice or group of slices along some other feature of the plot,
1065
+ such as an axis. If intermediate slices are activated,
1066
+ they are drawn equally spaced between the slices
1067
+ defined by the start and end origins.
1068
+
1069
+ Example usage::
1070
+
1071
+ >>> plot.slice(0).orientation = SliceSurface.XPlanes
1072
+ """
1073
+ return self._get_style(SliceSurface, sv.SLICESURFACE)
1074
+
1075
+ @orientation.setter
1076
+ def orientation(self, value):
1077
+ self._set_style(SliceSurface(value), sv.SLICESURFACE)
1078
+
1079
+ @property
1080
+ def arbitrary_normal(self):
1081
+ """`tuple`: Normal for arbitrary slices.
1082
+
1083
+ Example usage::
1084
+
1085
+ >>> plot.slice(0).orientation = SliceSurface.Arbitrary
1086
+ >>> plot.slice(0).arbitrary_normal = (0.1, 0.2, 0.3)
1087
+ >>> plot.slice(0).arbitrary_normal.x
1088
+ 0.1
1089
+ >>> plot.slice(0).arbitrary_normal.y
1090
+ 0.2
1091
+ >>> plot.slice(0).arbitrary_normal.z
1092
+ 0.3
1093
+ """
1094
+ return session.XYZ(self, sv.NORMAL)
1095
+
1096
+ @arbitrary_normal.setter
1097
+ def arbitrary_normal(self, values):
1098
+ session.XYZ(self, sv.NORMAL)[:] = values
1099
+
1100
+ def _position(self, svarg):
1101
+ index_orientations = (SliceSurface.IPlanes,
1102
+ SliceSurface.JPlanes,
1103
+ SliceSurface.KPlanes)
1104
+ spatial = [o not in index_orientations for o in self.orientation]
1105
+ if all(spatial):
1106
+ return session.XYZ(self, svarg)
1107
+ elif any(spatial):
1108
+ msg = 'all slices must have the same type of orientation'
1109
+ raise TecplotLogicError(msg)
1110
+ else:
1111
+ return session.IndexIJK(self, svarg)
1112
+
1113
+ @property
1114
+ def origin(self):
1115
+ """`tuple` or `int`: Origin of the slice.
1116
+
1117
+ This will be a 3-`tuple` of `float` if `orientation` is ``X,Y,Z`` or
1118
+ zero-based `int` if `orientation` is ``I,J,K``. For arbitrary slice
1119
+ orientation, the origin can be any location. For axis orientations
1120
+ (`XPlanes`, `YPlanes`, etc.) two of the three components are not used.
1121
+
1122
+ Example usage::
1123
+
1124
+ >>> slice_0 = plot.slice(0)
1125
+ >>> slice_0.orientation = SliceSurface.IPlanes
1126
+ >>> slice_0.origin = (1, 0, 0)
1127
+ >>> dx = (1, 1, 1)
1128
+ >>> slice_0.origin += dx
1129
+ >>> slice_0.origin.i
1130
+ 2
1131
+ >>> slice_0.origin.j
1132
+ 1
1133
+ >>> slice_0.origin.k
1134
+ 1
1135
+
1136
+ >>> slice_0.orientation = SliceSurface.Arbitrary
1137
+ >>> slice_0.origin = (.5, .1, .1)
1138
+ >>> slice_0.origin += dx
1139
+ >>> slice_0.origin.x
1140
+ 1.5
1141
+ >>> slice_0.origin.y
1142
+ .1
1143
+ >>> slice_0.origin.z
1144
+ .1
1145
+ """
1146
+ return self._position(sv.PRIMARYPOSITION)
1147
+
1148
+ @origin.setter
1149
+ def origin(self, values):
1150
+ self._position(sv.PRIMARYPOSITION)[:] = values
1151
+
1152
+ @property
1153
+ def end_position(self):
1154
+ """`tuple` or `int`: Position of the end slice.
1155
+
1156
+ `SliceGroup.show_start_and_end_slices` must be `True` to show the end
1157
+ slice. This will be a 3-`tuple` of `float` if `orientation` is
1158
+ ``X,Y,Z`` or zero-based `int` if `orientation` is ``I,J,K``.
1159
+
1160
+ Example usage::
1161
+
1162
+ >>> plot.slice(0).show_start_and_end_slices = True
1163
+ >>> plot.slice(0).end_position = (1, 1, 1)
1164
+ >>> plot.slice(0).end_position.i
1165
+ 1
1166
+ """
1167
+ return self._position(sv.ENDPOSITION)
1168
+
1169
+ @end_position.setter
1170
+ def end_position(self, values):
1171
+ self._position(sv.ENDPOSITION)[:] = values
1172
+
1173
+ @property
1174
+ def start_position(self):
1175
+ """`tuple` or `int`: Position of the start slice.
1176
+
1177
+ `SliceGroup.show_start_and_end_slices` must be `True` to show the start
1178
+ slice. This will be a 3-`tuple` of `float` if `orientation` is
1179
+ ``X,Y,Z`` or zero-based `int` if `orientation` is ``I,J,K``.
1180
+
1181
+ Example usage::
1182
+
1183
+ >>> plot.slice(0).show_start_and_end_slices = True
1184
+ >>> plot.slice(0).start_position = (1, 1, 1)
1185
+ >>> plot.slice(0).start_position.i
1186
+ 1
1187
+ """
1188
+ return self._position(sv.STARTPOSITION)
1189
+
1190
+ @start_position.setter
1191
+ def start_position(self, values):
1192
+ self._position(sv.STARTPOSITION)[:] = values
1193
+
1194
+ @property
1195
+ def num_intermediate_slices(self):
1196
+ """`int`: Number of intermediate slicing planes.
1197
+
1198
+ You may specify between 1 and 5,000 intermediate slices.
1199
+
1200
+ Example usage::
1201
+
1202
+ >>> # Show 2 intermediate slices
1203
+ >>> plot.slice(0).num_intermediate_slices = 2
1204
+ """
1205
+ return self._get_style(int, sv.NUMINTERMEDIATESLICES)
1206
+
1207
+ @num_intermediate_slices.setter
1208
+ def num_intermediate_slices(self, value):
1209
+ self._set_style(int(value), sv.NUMINTERMEDIATESLICES)
1210
+
1211
+ @property
1212
+ def show_intermediate_slices(self):
1213
+ """Show intermediate slices.
1214
+
1215
+ Intermediate slices are evenly distributed between the start and end
1216
+ slices.
1217
+
1218
+ Example usage::
1219
+
1220
+ >>> plot.slice(0).show_intermediate_slices = True
1221
+ """
1222
+ return self._get_style(bool, sv.SHOWINTERMEDIATESLICES)
1223
+
1224
+ @show_intermediate_slices.setter
1225
+ def show_intermediate_slices(self, value):
1226
+ self._set_style(bool(value), sv.SHOWINTERMEDIATESLICES)
1227
+
1228
+ @property
1229
+ def obey_source_zone_blanking(self):
1230
+ """`bool`: Obey source zone blanking.
1231
+
1232
+ When set to `True`, slices are subject to any blanking used for
1233
+ the data. When set to `False`, slices are generated for blanked
1234
+ and unblanked regions.
1235
+
1236
+ Example usage::
1237
+
1238
+ >>> plot.slice(0).obey_source_zone_blanking = True
1239
+ """
1240
+ return self._get_style(bool, sv.OBEYSOURCEZONEBLANKING)
1241
+
1242
+ @obey_source_zone_blanking.setter
1243
+ def obey_source_zone_blanking(self, value):
1244
+ self._set_style(bool(value), sv.OBEYSOURCEZONEBLANKING)
1245
+
1246
+ @property
1247
+ def slice_source(self):
1248
+ """`SliceSource`: `Zones <data_access>` to slice through.
1249
+
1250
+ Choose to slice through volume `Zones <data_access>`, surface `Zones
1251
+ <data_access>`, or the surfaces of volume `Zones <data_access>`.
1252
+
1253
+ Example usage::
1254
+
1255
+ >>> plot.slice(0).slice_source = SliceSource.SurfaceZones
1256
+ """
1257
+ return self._get_style(SliceSource, sv.SLICESOURCE)
1258
+
1259
+ @slice_source.setter
1260
+ def slice_source(self, value):
1261
+ self._set_style(SliceSource(value), sv.SLICESOURCE)
1262
+
1263
+ @property
1264
+ def show_start_and_end_slices(self):
1265
+ """`bool`: Include start and end slices.
1266
+
1267
+ Example usage::
1268
+
1269
+ >>> plot.slice(0).show_start_and_end_slices = True
1270
+ """
1271
+ return self._get_style(bool, sv.SHOWSTARTENDSLICE)
1272
+
1273
+ @show_start_and_end_slices.setter
1274
+ def show_start_and_end_slices(self, value):
1275
+ self._set_style(bool(value), sv.SHOWSTARTENDSLICE)
1276
+
1277
+ @property
1278
+ def surface_generation_method(self):
1279
+ """`SurfaceGenerationMethod`: Determines how the surface is generated.
1280
+
1281
+ May be one of:
1282
+
1283
+ * `SurfaceGenerationMethod.Auto`:
1284
+ Selects one of the surface generation algorithms best suited for
1285
+ the zones participating in the slice generation. "All polygons" is
1286
+ used if one or more of the participating zones is polytope,
1287
+ otherwise "allow quads" is used.
1288
+ * `SurfaceGenerationMethod.AllPolygons`:
1289
+ Similar to the "All triangles" method except that all interior
1290
+ faces generated as a result of triangulation that are not part of
1291
+ the original mesh are eliminated. This preserves the original mesh
1292
+ of the source zones on the resulting slice.
1293
+ * `SurfaceGenerationMethod.AllTriangles`:
1294
+ An advanced algorithm that can handle complex saddle issues and
1295
+ guarantees that there will be no holes in the final surface. As the
1296
+ surface is composed entirely of triangles, it can be delivered more
1297
+ efficiently to the graphics hardware.
1298
+ * `SurfaceGenerationMethod.AllowQuads`:
1299
+ Produces quads or triangles, and the resulting surface more closely
1300
+ resembles the shape of the volume cells from the source zone. Since
1301
+ the quads are not arbitrarily divided into triangles, no biases are
1302
+ introduced, and the resulting surface may appear smoother. This
1303
+ method is preferred when the source zone is FE-Brick or IJK-Ordered
1304
+ and the surface is aligned with the source cells.
1305
+
1306
+ Example usage::
1307
+
1308
+ >>> from tecplot.constant import SurfaceGenerationMethod
1309
+ >>> plot.slice(0).surface_generation_method = \\
1310
+ ... SurfaceGenerationMethod.AllowQuads
1311
+ """
1312
+ return self._get_style(SurfaceGenerationMethod,
1313
+ sv.SURFACEGENERATIONMETHOD)
1314
+
1315
+ @surface_generation_method.setter
1316
+ def surface_generation_method(self, value):
1317
+ self._set_style(SurfaceGenerationMethod(value),
1318
+ sv.SURFACEGENERATIONMETHOD)
1319
+
1320
+ @property
1321
+ def clip(self):
1322
+ """`ClipPlane`: Orientation of data clipping for this slice group.
1323
+
1324
+ Clipping the field data, isosurfaces, streamtraces or other plot
1325
+ objects using slices requires setting the ``clip`` property of the
1326
+ slice as well as adding the slice group to the ``clip_planes`` property
1327
+ on the fieldmap effects. Only slice groups 0 to 5 are available for
1328
+ clipping in this framework::
1329
+
1330
+ >>> from tecplot.constant import *
1331
+ >>> # setup slice and clipping orientation
1332
+ >>> slice = plot.slice(0)
1333
+ >>> slice.origin = (7, 0, 0)
1334
+ >>> slice.clip = ClipPlane.AbovePrimarySlice
1335
+ >>> # add slice group to the fieldmap clip planes
1336
+ >>> plot.fieldmap(0).effects.clip_planes = [slice]
1337
+ >>> # turn on and set value of isosurface
1338
+ >>> # and enforce slice clipping
1339
+ >>> isosurf = plot.isosurface(0)
1340
+ >>> isosurf.isosurface_values = 3
1341
+ >>> isosurf.use_slice_clipping = True
1342
+ >>> # turn on isosurfaces and slices
1343
+ >>> pt.show_isosurfaces = True
1344
+ >>> pt.show_slices = True
1345
+
1346
+ .. warning:: **Slice clipping is only supported for X, Y and Z-planes.**
1347
+
1348
+ Slice clipping has no effect for slices that have an orientation of
1349
+ `SliceSurface.Arbitrary`, `SliceSurface.IPlanes`,
1350
+ `SliceSurface.JPlanes` or , `SliceSurface.KPlanes`. That is, the
1351
+ orientation must be one of: `SliceSurface.XPlanes`,
1352
+ `SliceSurface.YPlanes` or `SliceSurface.ZPlanes`.
1353
+ """
1354
+ return self._get_style(ClipPlane, sv.CLIPPLANE)
1355
+
1356
+ @clip.setter
1357
+ def clip(self, value):
1358
+ self._set_style(ClipPlane(value), sv.CLIPPLANE)
1359
+
1360
+ @property
1361
+ def use_slice_clipping(self):
1362
+ """`bool`: Clip this slice by any intersecting slices.
1363
+
1364
+ Example usage::
1365
+
1366
+ >>> from tecplot.constant import ClipPlane
1367
+ >>> slice = plot.slice(0)
1368
+ >>> slice.clip = ClipPlane.AbovePrimarySlice
1369
+ >>> plot.fieldmap(0).effects.clip_planes = slice
1370
+ >>> plot.slice(1).use_slice_clipping = True
1371
+
1372
+ .. seealso:: `SliceGroup.clip`
1373
+ """
1374
+ return self._get_style(bool, sv.OBEYCLIPPLANES)
1375
+
1376
+ @use_slice_clipping.setter
1377
+ def use_slice_clipping(self, value):
1378
+ self._set_style(bool(value), sv.OBEYCLIPPLANES)
1379
+
1380
+
1381
+ class SliceGroup(SliceGroupCollection):
1382
+ """Change attributes associated with a specific slice group.
1383
+
1384
+ Slices can include lighting effects, contours, meshes, and more.
1385
+ To customize these and other attributes of slices, use this object.
1386
+
1387
+ This object controls the style for a specific slice group within a `Frame <layout.Frame>`.
1388
+ Slice `contour <SliceGroup.contour>`, vector, edge, effects, mesh,
1389
+ visibility and position information are accessed through this class:
1390
+
1391
+ .. code-block:: python
1392
+ :emphasize-lines: 19-40
1393
+
1394
+ from os import path
1395
+ import tecplot as tp
1396
+ from tecplot.constant import *
1397
+
1398
+ examples_dir = tp.session.tecplot_examples_directory()
1399
+ datafile = path.join(examples_dir, 'SimpleData', 'DuctFlow.plt')
1400
+ dataset = tp.data.load_tecplot(datafile)
1401
+
1402
+ plot = tp.active_frame().plot()
1403
+ plot.contour(0).variable = dataset.variable('U(M/S)')
1404
+ plot.show_edge = True
1405
+ plot.fieldmap(0).edge.edge_type = EdgeType.Creases
1406
+
1407
+ vectors = plot.vector
1408
+ vectors.u_variable = dataset.variable('U(M/S)')
1409
+ vectors.v_variable = dataset.variable('V(M/S)')
1410
+ vectors.w_variable = dataset.variable('W(M/S)')
1411
+
1412
+ plot.show_slices = True
1413
+ slice_0 = plot.slice(0)
1414
+
1415
+ slice_0.contour.show = True
1416
+ slice_0.contour.contour_type = ContourType.Overlay # AKA "Both lines and flood"
1417
+
1418
+ slice_0.effects.use_translucency = True
1419
+ slice_0.effects.surface_translucency = 30
1420
+
1421
+ # Show an arbitrary slice
1422
+ slice_0.orientation = SliceSurface.Arbitrary
1423
+ slice_0.arbitrary_normal = (1, .5, 0)
1424
+
1425
+ slice_0.show_primary_slice = False
1426
+ slice_0.show_start_and_end_slices = True
1427
+ slice_0.start_position = (-.21, .05, .025)
1428
+ slice_0.end_position = (1.342, .95, .475)
1429
+ slice_0.show_intermediate_slices = True
1430
+ slice_0.num_intermediate_slices = 3
1431
+
1432
+ slice_0.edge.show = True
1433
+ slice_0.edge.line_thickness = 0.4
1434
+
1435
+ # ensure consistent output between interactive (connected) and batch
1436
+ plot.contour(0).levels.reset_to_nice()
1437
+
1438
+ tp.export.save_png('slice_group.png', 600, supersample=3)
1439
+
1440
+ .. figure:: /_static/images/slice_group.png
1441
+ :width: 300px
1442
+ :figwidth: 300px
1443
+
1444
+ Up to eight different slice groups can be set. Each slice group can use
1445
+ different slice planes or different ranges for the same slice plane.
1446
+
1447
+ >>> slice_3 = plot.slice(3)
1448
+ >>> slice_3.contour.show = True
1449
+
1450
+ .. seealso:: `SliceGroupCollection`
1451
+ """
1452
+ def __init__(self, plot, index):
1453
+ self.index = index
1454
+ super().__init__(plot, index)
1455
+
1456
+ def _get_style(self, rettype, *svargs, **kwargs):
1457
+ return super()._get_style(rettype, *svargs, **kwargs)[0]
1458
+
1459
+ def _position(self, svarg):
1460
+ if self.orientation in (SliceSurface.IPlanes,
1461
+ SliceSurface.JPlanes,
1462
+ SliceSurface.KPlanes):
1463
+ return session.IndexIJK(self, svarg)
1464
+ else:
1465
+ return session.XYZ(self, svarg)
1466
+
1467
+ @tecutil.lock()
1468
+ def set_arbitrary_from_points(self, p1, p2, p3):
1469
+ """Set an arbitrary slice from 3 points.
1470
+
1471
+ Set the normal and origin of an arbitrary slice using three points.
1472
+ The origin will be set to the 3rd point.
1473
+
1474
+ The three points must not be coincident or collinear.
1475
+ The slice's origin is set to the third point and its normal
1476
+ is recalculated such that the cutting plane passes through all three
1477
+ points.
1478
+
1479
+ Parameters:
1480
+ p1: 3-`tuple` of floats ``(x, y, z)``
1481
+ p2: 3-`tuple` of floats ``(x, y, z)``
1482
+ p3: 3-`tuple` of floats ``(x, y, z)``
1483
+
1484
+ Example usage::
1485
+
1486
+ >>> slice0 = plot.slice(0)
1487
+ >>> slice0.set_arbitrary_from_points((0.0, 0.0, 0.0),
1488
+ ... (0.1, 0.2, 0.3),
1489
+ ... (0.1, 0.1, 0.1))
1490
+ """
1491
+ uid = self._style_attrs[sv.UNIQUEID]
1492
+ points = list(it.chain(p1, p2, p3))
1493
+ if not _tecutil.SliceSetArbitraryUsingThreePoints(
1494
+ uid, self.index + 1, *points):
1495
+ msg = 'Error creating arbitrary slice from three points'
1496
+ raise TecplotSystemError(msg)
1497
+
1498
+ def extract(self, mode=ExtractMode.SingleZone, assign_strand_ids=True,
1499
+ resulting_1d_zone_type=Resulting1DZoneType.IOrderedIfPossible,
1500
+ transient_mode=TransientOperationMode.SingleSolutionTime):
1501
+ """Create new zones from this slice.
1502
+
1503
+ Extracts the current slices represented by this group to the
1504
+ `Dataset <data.Dataset>` as one or more zones.
1505
+
1506
+ Parameters:
1507
+ mode (`ExtractMode`, optional): Determines how many zones are
1508
+ created upon extraction. Possible values are:
1509
+ `ExtractMode.SingleZone` (default) and
1510
+ `ExtractMode.OneZonePerConnectedRegion`.
1511
+ assign_strand_ids (`bool`, optional): Automatically assign strand
1512
+ ID's to the created zones. (default: `True`)
1513
+ resulting_1d_zone_type (`Resulting1DZoneType`, optional): The type
1514
+ of zone to create when the result is one-dimensional. Possible
1515
+ values are: `Resulting1DZoneType.IOrderedIfPossible` (default)
1516
+ and `Resulting1DZoneType.FELineSegment`.
1517
+ transient_mode (`TransientOperationMode`): Determines which
1518
+ solution times are used to extract slices when transient data
1519
+ is available in the dataset. Possible values are
1520
+ `TransientOperationMode.SingleSolutionTime` (default) or
1521
+ `TransientOperationMode.AllSolutionTimes`.
1522
+
1523
+ Returns:
1524
+
1525
+ The extracted zone is returned if **mode** is
1526
+ `ExtractMode.SingleZone` and **transient_mode** is
1527
+ `TransientOperationMode.SingleSolutionTime`, otherwise a generator_
1528
+ of the extracted zones.
1529
+
1530
+ .. seealso:: `tecplot.data.extract.extract_slice()`
1531
+
1532
+ Example usage::
1533
+
1534
+ >>> slice_zone = plot.slice(0).extract()
1535
+ """
1536
+ result = super().extract(mode, assign_strand_ids,
1537
+ resulting_1d_zone_type, transient_mode)
1538
+ if (
1539
+ mode == ExtractMode.SingleZone and
1540
+ transient_mode == TransientOperationMode.SingleSolutionTime
1541
+ ):
1542
+ return list(result)[0]
1543
+ else:
1544
+ return result