pytecplot 1.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. pytecplot-1.5.2.dist-info/LICENSE.html +77 -0
  2. pytecplot-1.5.2.dist-info/METADATA +508 -0
  3. pytecplot-1.5.2.dist-info/RECORD +97 -0
  4. pytecplot-1.5.2.dist-info/WHEEL +5 -0
  5. pytecplot-1.5.2.dist-info/top_level.txt +1 -0
  6. tecplot/__init__.py +94 -0
  7. tecplot/annotation/__init__.py +7 -0
  8. tecplot/annotation/annotation.py +223 -0
  9. tecplot/annotation/geometry.py +369 -0
  10. tecplot/annotation/georeference.py +33 -0
  11. tecplot/annotation/image.py +185 -0
  12. tecplot/annotation/iter.py +105 -0
  13. tecplot/annotation/polyline.py +381 -0
  14. tecplot/annotation/text.py +744 -0
  15. tecplot/constant.py +401 -0
  16. tecplot/data/__init__.py +34 -0
  17. tecplot/data/array.py +645 -0
  18. tecplot/data/create.py +1 -0
  19. tecplot/data/dataset.py +1809 -0
  20. tecplot/data/extract.py +544 -0
  21. tecplot/data/face_neighbors.py +494 -0
  22. tecplot/data/facemap.py +814 -0
  23. tecplot/data/load.py +2075 -0
  24. tecplot/data/nodemap.py +577 -0
  25. tecplot/data/operate.py +928 -0
  26. tecplot/data/query.py +334 -0
  27. tecplot/data/save.py +343 -0
  28. tecplot/data/variable.py +280 -0
  29. tecplot/data/zone.py +841 -0
  30. tecplot/exception.py +201 -0
  31. tecplot/export/__init__.py +13 -0
  32. tecplot/export/animation.py +521 -0
  33. tecplot/export/export_setup.py +318 -0
  34. tecplot/export/image.py +577 -0
  35. tecplot/export/print_setup.py +218 -0
  36. tecplot/export/time_animation.py +607 -0
  37. tecplot/extension/__init__.py +14 -0
  38. tecplot/extension/ipython.py +68 -0
  39. tecplot/layout/__init__.py +20 -0
  40. tecplot/layout/frame.py +1285 -0
  41. tecplot/layout/layout.py +488 -0
  42. tecplot/layout/page.py +541 -0
  43. tecplot/legend/__init__.py +4 -0
  44. tecplot/legend/contour_legend.py +516 -0
  45. tecplot/legend/legend.py +141 -0
  46. tecplot/legend/line_legend.py +66 -0
  47. tecplot/legend/rgb_coloring_legend.py +291 -0
  48. tecplot/legend/scatter_legend.py +136 -0
  49. tecplot/macro.py +339 -0
  50. tecplot/plot/__init__.py +62 -0
  51. tecplot/plot/axes.py +881 -0
  52. tecplot/plot/axis.py +1350 -0
  53. tecplot/plot/blanking.py +584 -0
  54. tecplot/plot/contour.py +1302 -0
  55. tecplot/plot/effects.py +162 -0
  56. tecplot/plot/fieldmap.py +2159 -0
  57. tecplot/plot/grid.py +758 -0
  58. tecplot/plot/isosurface.py +1167 -0
  59. tecplot/plot/labels.py +338 -0
  60. tecplot/plot/linemap.py +1905 -0
  61. tecplot/plot/linking.py +489 -0
  62. tecplot/plot/plot.py +1791 -0
  63. tecplot/plot/rgb_coloring.py +281 -0
  64. tecplot/plot/scatter.py +396 -0
  65. tecplot/plot/slice.py +1544 -0
  66. tecplot/plot/streamtrace.py +1949 -0
  67. tecplot/plot/symbol.py +567 -0
  68. tecplot/plot/ticks.py +666 -0
  69. tecplot/plot/title.py +380 -0
  70. tecplot/plot/vector.py +679 -0
  71. tecplot/plot/view.py +868 -0
  72. tecplot/session/__init__.py +112 -0
  73. tecplot/session/aux_data.py +276 -0
  74. tecplot/session/config.py +92 -0
  75. tecplot/session/session.py +425 -0
  76. tecplot/session/state_changed.py +225 -0
  77. tecplot/session/style.py +504 -0
  78. tecplot/tecutil/__init__.py +16 -0
  79. tecplot/tecutil/arglist.py +230 -0
  80. tecplot/tecutil/captured_output.py +177 -0
  81. tecplot/tecutil/constant.py +1312 -0
  82. tecplot/tecutil/index_set.py +118 -0
  83. tecplot/tecutil/lock.py +36 -0
  84. tecplot/tecutil/message_pb2.py +39 -0
  85. tecplot/tecutil/preamble.py +54 -0
  86. tecplot/tecutil/stringlist.py +114 -0
  87. tecplot/tecutil/sv.py +1662 -0
  88. tecplot/tecutil/tecutil.py +12402 -0
  89. tecplot/tecutil/tecutil_client.py +627 -0
  90. tecplot/tecutil/tecutil_connector.py +937 -0
  91. tecplot/tecutil/tecutil_rpc.py +6845 -0
  92. tecplot/tecutil/util.py +332 -0
  93. tecplot/text/__init__.py +3 -0
  94. tecplot/text/font.py +224 -0
  95. tecplot/text/label_format.py +374 -0
  96. tecplot/text/textbox.py +106 -0
  97. tecplot/version.py +41 -0
@@ -0,0 +1,2159 @@
1
+ from builtins import int, str, super
2
+
3
+ import warnings
4
+
5
+ from collections.abc import Iterable
6
+ from collections import namedtuple
7
+ from ctypes import cast
8
+ from enum import Enum
9
+ from textwrap import dedent
10
+
11
+ from ..tecutil import _tecutil
12
+ from ..constant import *
13
+ from ..exception import *
14
+ from ..tecutil import Index, IndexSet, color_spec, flatten_args, sv
15
+ from .. import session, tecutil
16
+ from . import symbol
17
+
18
+
19
+ class FieldmapContour(session.SubStyle):
20
+ """Style control for flooding and contour lines.
21
+
22
+ This object controls which contour groups are associated with flooding,
23
+ line placement and line coloring. Three different contour groups may be
24
+ used though there are eight total groups that can be configured in a single
25
+ plot. In this example, we flood by the first contour group (index: 0):
26
+
27
+ .. code-block:: python
28
+
29
+ import numpy as np
30
+
31
+ import tecplot as tp
32
+ from tecplot.constant import *
33
+ from tecplot.data.operate import execute_equation
34
+
35
+ # Get the active frame, setup a grid (30x30x30)
36
+ # where each dimension ranges from 0 to 30.
37
+ # Add variables P,Q,R to the dataset and give
38
+ # values to the data.
39
+ frame = tp.active_frame()
40
+ dataset = frame.dataset
41
+ for v in ['X','Y','Z','P','Q','R']:
42
+ dataset.add_variable(v)
43
+ zone = dataset.add_ordered_zone('Zone', (30,30,30))
44
+ xx = np.linspace(0,30,30)
45
+ for v,arr in zip(['X','Y','Z'],np.meshgrid(xx,xx,xx)):
46
+ zone.values(v)[:] = arr.ravel()
47
+ execute_equation('{P} = -10 * {X} + {Y}**2 + {Z}**2')
48
+ execute_equation('{Q} = {X} - 10 * {Y} - {Z}**2')
49
+ execute_equation('{R} = {X}**2 + {Y}**2 - {Z} ')
50
+
51
+ # Enable 3D field plot and turn on contouring
52
+ # with boundary faces
53
+ frame.plot_type = PlotType.Cartesian3D
54
+ plot = frame.plot()
55
+ srf = plot.fieldmap(0).surfaces
56
+ srf.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
57
+ plot.show_contour = True
58
+
59
+ # get the contour group associated with the
60
+ # newly created zone
61
+ contour = plot.fieldmap(dataset.zone('Zone')).contour
62
+
63
+ # assign flooding to the first contour group
64
+ contour.flood_contour_group = plot.contour(0)
65
+ contour.flood_contour_group.variable = dataset.variable('P')
66
+ contour.flood_contour_group.colormap_name = 'Sequential - Yellow/Green/Blue'
67
+ contour.flood_contour_group.legend.show = False
68
+
69
+ # save image to PNG file
70
+ tp.export.save_png('fieldmap_contour.png', 600, supersample=3)
71
+
72
+ .. figure:: /_static/images/fieldmap_contour.png
73
+ :width: 300px
74
+ :figwidth: 300px
75
+ """
76
+ def __init__(self, fieldmap):
77
+ super().__init__(fieldmap, sv.CONTOUR)
78
+
79
+ @property
80
+ def show(self):
81
+ """`bool`: Enable drawing the contours.
82
+
83
+ Example usage::
84
+
85
+ >>> contour = plot.fieldmap(0).contour
86
+ >>> contour.show = True
87
+ """
88
+ return self._get_style(bool, sv.SHOW)
89
+
90
+ @show.setter
91
+ def show(self, value):
92
+ self._set_style(bool(value), sv.SHOW)
93
+
94
+ @property
95
+ def contour_type(self):
96
+ """`ContourType`: `ContourType` to plot.
97
+
98
+ Possible values are:
99
+
100
+ `ContourType.Flood` (default)
101
+ Filled color between the contour levels.
102
+ `ContourType.Lines`
103
+ Lines only.
104
+ `ContourType.Overlay`
105
+ Lines overlayed on flood.
106
+ `ContourType.AverageCell`
107
+ Filled color by the average value within cells.
108
+ `ContourType.PrimaryValue`
109
+ Filled color by the value at the primary corner of the cells.
110
+
111
+ In this example, we enable both flooding and contour lines::
112
+
113
+ >>> from tecplot.constant import ContourType
114
+ >>> contour = plot.fieldmap(0).contour
115
+ >>> contour.contour_type = ContourType.Overlay
116
+ """
117
+ return self._get_style(ContourType, sv.CONTOURTYPE)
118
+
119
+ @contour_type.setter
120
+ def contour_type(self, value):
121
+ self._set_style(ContourType(value), sv.CONTOURTYPE)
122
+
123
+ @property
124
+ def flood_contour_group_index(self):
125
+ """`int`: Zero-based `Index` of the `ContourGroup` to use for flooding.
126
+
127
+ This property sets and gets, by `Index`, the `ContourGroup` used for
128
+ flooding. Changing style on this `ContourGroup` will affect all other
129
+ fieldmaps on the same `Frame <layout.Frame>` that use it. Example usage::
130
+
131
+ >>> contour = plot.fieldmap(0).contour
132
+ >>> contour.flood_contour_group_index = 1
133
+ >>> contour.flood_contour_group.variable = dataset.variable('P')
134
+
135
+ .. note::
136
+ To set the flood contour to RGB (multivariate) coloring, you must
137
+ set the `FieldmapContour.flood_contour_group` property to
138
+ ``plot.rgb_coloring``. See
139
+ `FieldmapContour.flood_contour_group` for more details.
140
+ """
141
+ return self._get_style(Index, sv.FLOODCOLORING)
142
+
143
+ @flood_contour_group_index.setter
144
+ def flood_contour_group_index(self, index):
145
+ self._set_style(Index(index), sv.FLOODCOLORING)
146
+
147
+ @property
148
+ def flood_contour_group(self):
149
+ """`ContourGroup` or `RGBColoring`: The `ContourGroup` to use
150
+ for flooding.
151
+
152
+ This property sets and gets the `ContourGroup` used for flooding.
153
+ Changing style on this `ContourGroup` will affect all other fieldmaps
154
+ on the same `Frame <layout.Frame>` that use it. Example usage::
155
+
156
+ >>> cmap_name = 'Sequential - Yellow/Green/Blue'
157
+ >>> contour = plot.fieldmap(0).contour
158
+ >>> contour.flood_contour_group = plot.contour(1)
159
+ >>> contour.flood_contour_group.variable = dataset.variable('P')
160
+ >>> contour.flood_contour_group.colormap_name = cmap_name
161
+
162
+ Setting this to the `RGBColoring` instance floods this fieldmap contour
163
+ by the plot's RGB coloring settings. This requires that variables are
164
+ assigned to the red, green and blue color channels::
165
+
166
+ >>> plot.rgb_coloring.red_variable = dataset.variable('x')
167
+ >>> plot.rgb_coloring.green_variable = dataset.variable('y')
168
+ >>> plot.rgb_coloring.blue_variable = dataset.variable('z')
169
+ >>> contour = plot.fieldmap(0).contour
170
+ >>> contour.flood_contour_group = plot.rgb_coloring
171
+
172
+ See `RGBColoring` for more details.
173
+ """
174
+ def contour(plot, i):
175
+ if i == ContourColoring.RGB.value - 1:
176
+ return plot.rgb_coloring
177
+ else:
178
+ return plot.contour(i)
179
+
180
+ index = self.flood_contour_group_index
181
+ if isinstance(index, Iterable):
182
+ return tuple([contour(self.parent.plot, i) for i in index])
183
+ else:
184
+ return contour(self.parent.plot, index)
185
+
186
+ @flood_contour_group.setter
187
+ def flood_contour_group(self, contour_group):
188
+ if isinstance(contour_group,
189
+ type(self.parent.plot.rgb_coloring)):
190
+ self.flood_contour_group_index = ContourColoring.RGB.value - 1
191
+ else:
192
+ self.flood_contour_group_index = contour_group.index
193
+
194
+ @property
195
+ def line_group_index(self):
196
+ """`int`: Zero-based `Index` of the `ContourGroup` for contour lines.
197
+
198
+ This property sets and gets, by `Index`, the `ContourGroup` used for
199
+ line placement and though all properties of the `ContourGroup` can be
200
+ manipulated through this object, many of them such as color will not
201
+ affect the lines unless the `FieldmapContour.line_color` is set to the
202
+ same `ContourGroup`. Note that changing style on this `ContourGroup`
203
+ will affect all other fieldmaps on the same `Frame <layout.Frame>` that use it.
204
+ Example usage::
205
+
206
+ >>> contour = plot.fieldmap(0).contour
207
+ >>> contour.line_group_index = 2
208
+ >>> contour.line_group.variable = dataset.variable('Z')
209
+ """
210
+ return self._get_style(Index, sv.LINECONTOURGROUP)
211
+
212
+ @line_group_index.setter
213
+ def line_group_index(self, index):
214
+ self._set_style(Index(index), sv.LINECONTOURGROUP)
215
+
216
+ @property
217
+ def line_group(self):
218
+ """`ContourGroup`: `ContourGroup` to use for line placement and style.
219
+
220
+ This property sets and gets the `ContourGroup` used for line placement
221
+ and though all properties of the `ContourGroup` can be manipulated
222
+ through this object, many of them such as color will not effect the
223
+ lines unless the `FieldmapContour.line_color` is set to the same
224
+ `ContourGroup`. Note that changing style on this `ContourGroup` will
225
+ affect all other fieldmaps on the same `Frame <layout.Frame>` that use it. Example
226
+ usage::
227
+
228
+ >>> contour = plot.fieldmap(0).contour
229
+ >>> contour.line_group = plot.contour(2)
230
+ >>> contour.line_group.variable = dataset.variable('Z')
231
+ """
232
+ index = self.line_group_index
233
+ if isinstance(index, Iterable):
234
+ return tuple([self.parent.plot.contour(i) for i in index])
235
+ else:
236
+ return self.parent.plot.contour(index)
237
+
238
+ @line_group.setter
239
+ def line_group(self, contour_group):
240
+ self.line_group_index = contour_group.index
241
+
242
+ @property
243
+ def line_color(self):
244
+ """`Color` or `ContourGroup`: The `Color` or `ContourGroup` for lines.
245
+
246
+ FieldmapContour lines can be a solid color or be colored by a
247
+ `ContourGroup` as obtained through the ``plot.contour`` property. Note
248
+ that changing style on this `ContourGroup` will affect all other
249
+ fieldmaps on the same `Frame <layout.Frame>` that use it. Example usage::
250
+
251
+ >>> from tecplot.constant import Color
252
+ >>> contour = plot.fieldmap(1).contour
253
+ >>> contour.line_color = Color.Blue
254
+
255
+ Example of setting the color from a `ContourGroup`::
256
+
257
+ >>> contour = plot.fieldmap(0).contour
258
+ >>> contour.line_color = plot.contour(1)
259
+ >>> contour.line_color.variable = dataset.variable('P')
260
+
261
+ Setting this to the `RGBColoring` instance colors the lines by
262
+ the plot's multivariate contour settings. This requires that variables
263
+ are assigned to the red, green and blue color channels::
264
+
265
+ >>> plot.rgb_coloring.red_variable = dataset.variable('x')
266
+ >>> plot.rgb_coloring.green_variable = dataset.variable('y')
267
+ >>> plot.rgb_coloring.blue_variable = dataset.variable('z')
268
+ >>> plot.fieldmap(0).contour.line_color = plot.rgb_coloring
269
+
270
+ See `RGBColoring` for more details.
271
+ """
272
+ return color_spec(self._get_style(Color, sv.COLOR), self.parent.plot)
273
+
274
+ @line_color.setter
275
+ def line_color(self, value):
276
+ self._set_style(color_spec(value), sv.COLOR)
277
+
278
+ @property
279
+ def line_pattern(self):
280
+ """`LinePattern`: `LinePattern` type to use for contour lines.
281
+
282
+ Possible values: `Solid <LinePattern.Solid>`, `Dashed`, `DashDot`,
283
+ `Dotted`, `LongDash`, `DashDotDot`.
284
+
285
+ Example usage::
286
+
287
+ >>> from tecplot.constant import LinePattern
288
+ >>> contour = plot.fieldmap(0).contour
289
+ >>> contour.line_pattern = LinePattern.DashDotDot
290
+ """
291
+ return self._get_style(LinePattern, sv.LINEPATTERN)
292
+
293
+ @line_pattern.setter
294
+ def line_pattern(self, value):
295
+ self._set_style(LinePattern(value), sv.LINEPATTERN)
296
+
297
+ @property
298
+ def line_thickness(self):
299
+ """`float`: Thickness (`float`) of the drawn lines.
300
+
301
+ This is the line thickness in percentage of the `Frame <layout.Frame>`'s height.
302
+ Example usage::
303
+
304
+ >>> contour = plot.fieldmap(0).contour
305
+ >>> contour.line_thickness = 0.7
306
+ """
307
+ return self._get_style(float, sv.LINETHICKNESS)
308
+
309
+ @line_thickness.setter
310
+ def line_thickness(self, value):
311
+ self._set_style(float(value), sv.LINETHICKNESS)
312
+
313
+ @property
314
+ def pattern_length(self):
315
+ """`float`: Length (`float`) of the pattern segment for non-solid lines.
316
+
317
+ This is the pattern length in percentage of the `Frame <layout.Frame>`'s height.
318
+ Example usage::
319
+
320
+ >>> contour = plot.fieldmap(0).contour
321
+ >>> contour.pattern_length = 3.5
322
+ """
323
+ return self._get_style(float, sv.PATTERNLENGTH)
324
+
325
+ @pattern_length.setter
326
+ def pattern_length(self, value):
327
+ self._set_style(float(value), sv.PATTERNLENGTH)
328
+
329
+ @property
330
+ def use_lighting_effect(self):
331
+ """`bool`: Enable lighting effect on this contour.
332
+
333
+ Example usage::
334
+
335
+ >>> contour = plot.fieldmap(0).contour
336
+ >>> contour.use_lighting_effect = False
337
+ """
338
+ return self._get_style(bool, sv.USELIGHTINGEFFECT)
339
+
340
+ @use_lighting_effect.setter
341
+ def use_lighting_effect(self, value):
342
+ self._set_style(bool(value), sv.USELIGHTINGEFFECT)
343
+
344
+
345
+ class FieldmapEdge(session.SubStyle):
346
+ """Volume boundary lines.
347
+
348
+ An edge plot layer displays the connections of the outer lines
349
+ (``IJ``-ordered zones), finite element surface zones, or planes
350
+ (``IJK``-ordered zones). The FieldmapEdge layer allows you to display the
351
+ edges (creases and borders) of your data. Zone edges exist only for ordered
352
+ zones or 2D finite element zones. Three-dimensional finite element zones do
353
+ not have boundaries:
354
+
355
+ .. code-block:: python
356
+ :emphasize-lines: 15,26-29
357
+
358
+ import os
359
+
360
+ import tecplot as tp
361
+ from tecplot.constant import Color, EdgeType, PlotType, SurfacesToPlot
362
+
363
+ examples_dir = tp.session.tecplot_examples_directory()
364
+ datafile = os.path.join(examples_dir, 'SimpleData', 'F18.plt')
365
+ dataset = tp.data.load_tecplot(datafile)
366
+ frame = dataset.frame
367
+
368
+ # Enable 3D field plot, turn on contouring and translucency
369
+ frame.plot_type = PlotType.Cartesian3D
370
+ plot = frame.plot()
371
+ plot.show_contour = True
372
+ plot.show_edge = True
373
+
374
+ contour = plot.contour(0)
375
+ contour.colormap_name = 'Sequential - Blue'
376
+ contour.variable = dataset.variable('S')
377
+
378
+ # adjust effects for every fieldmap in this dataset
379
+ fmaps = plot.fieldmaps()
380
+ fmaps.contour.flood_contour_group = contour
381
+ fmaps.surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
382
+
383
+ edge = fmaps.edge
384
+ edge.edge_type = EdgeType.Creases
385
+ edge.color = Color.RedOrange
386
+ edge.line_thickness = 0.7
387
+
388
+ # ensure consistent output between interactive (connected) and batch
389
+ plot.contour(0).levels.reset_to_nice()
390
+
391
+ # save image to file
392
+ tp.export.save_png('fieldmap_edge.png', 600, supersample=3)
393
+
394
+ .. figure:: /_static/images/fieldmap_edge.png
395
+ :width: 300px
396
+ :figwidth: 300px
397
+ """
398
+ def __init__(self, fieldmap):
399
+ super().__init__(fieldmap, sv.EDGELAYER)
400
+
401
+ @property
402
+ def show(self):
403
+ """`bool`: Draw the mesh for this fieldmap.
404
+
405
+ Example usage::
406
+
407
+ >>> plot.show_edge = True
408
+ >>> plot.fieldmap(0).edge.show = True
409
+ """
410
+ return self._get_style(bool, sv.SHOW)
411
+
412
+ @show.setter
413
+ def show(self, value):
414
+ self._set_style(bool(value), sv.SHOW)
415
+
416
+ @property
417
+ def edge_type(self):
418
+ """`EdgeType`: Where to draw edge lines.
419
+
420
+ Possible values: `Borders`, `Creases`, `BordersAndCreases`.
421
+
422
+ Example usage::
423
+
424
+ >>> from tecplot.constant import EdgeType
425
+ >>> plot.show_edge = True
426
+ >>> plot.fieldmap(0).edge.edge_type = EdgeType.Creases
427
+ """
428
+ return self._get_style(EdgeType, sv.EDGETYPE)
429
+
430
+ @edge_type.setter
431
+ def edge_type(self, value):
432
+ self._set_style(EdgeType(value), sv.EDGETYPE)
433
+
434
+ @property
435
+ def color(self):
436
+ """`Color`: Line `Color`.
437
+ """
438
+ return self._get_style(Color, sv.COLOR)
439
+
440
+ @color.setter
441
+ def color(self, value):
442
+ self._set_style(Color(value), sv.COLOR)
443
+
444
+ @property
445
+ def line_thickness(self):
446
+ """`float`: Thickness of the edge lines drawn.
447
+
448
+ This is the line thickness in percentage of `Frame <layout.Frame>` height. Example
449
+ usage::
450
+
451
+ >>> plot.fieldmap(0).edge.line_thickness = 0.4
452
+ """
453
+ return self._get_style(float, sv.LINETHICKNESS)
454
+
455
+ @line_thickness.setter
456
+ def line_thickness(self, value):
457
+ self._set_style(float(value), sv.LINETHICKNESS)
458
+
459
+ @property
460
+ def i_border(self):
461
+ """`BorderLocation`: Which border lines to draw in the ``I``-dimension.
462
+
463
+ Possible values: `None`, `Min <BorderLocation.Min>`, `Max
464
+ <BorderLocation.Max>`, `Both <BorderLocation.Both>`.
465
+
466
+ Example usage::
467
+
468
+ >>> from tecplot.constant import BorderLocation
469
+ >>> plot.show_edge = True
470
+ >>> plot.fieldmap(0).edge.i_border = BorderLocation.Min
471
+ """
472
+ value = self._get_style(BorderLocation, sv.IBORDER)
473
+ return None if value is BorderLocation.None_ else value
474
+
475
+ @i_border.setter
476
+ def i_border(self, value):
477
+ if value is None:
478
+ value = BorderLocation.None_
479
+ self._set_style(BorderLocation(value), sv.IBORDER)
480
+
481
+ @property
482
+ def j_border(self):
483
+ """`BorderLocation`: Which border lines to draw in the ``J``-dimension.
484
+
485
+ Possible values: `None`, `Min <BorderLocation.Min>`, `Max
486
+ <BorderLocation.Max>`, `Both <BorderLocation.Both>`.
487
+
488
+ Example usage::
489
+
490
+ >>> from tecplot.constant import BorderLocation
491
+ >>> plot.show_edge = True
492
+ >>> plot.fieldmap(0).edge.j_border = BorderLocation.Both
493
+ """
494
+ value = self._get_style(BorderLocation, sv.JBORDER)
495
+ return None if value is BorderLocation.None_ else value
496
+
497
+ @j_border.setter
498
+ def j_border(self, value):
499
+ if value is None:
500
+ value = BorderLocation.None_
501
+ self._set_style(BorderLocation(value), sv.JBORDER)
502
+
503
+ @property
504
+ def k_border(self):
505
+ """`BorderLocation`: Which border lines to draw in the ``K``-dimension.
506
+
507
+ Possible values: `None`, `Min <BorderLocation.Min>`, `Max
508
+ <BorderLocation.Max>`, `Both <BorderLocation.Both>`.
509
+
510
+ Example usage::
511
+
512
+ >>> from tecplot.constant import BorderLocation
513
+ >>> plot.show_edge = True
514
+ >>> plot.fieldmap(0).edge.k_border = None
515
+ """
516
+ value = self._get_style(BorderLocation, sv.KBORDER)
517
+ return None if value is BorderLocation.None_ else value
518
+
519
+ @k_border.setter
520
+ def k_border(self, value):
521
+ if value is None:
522
+ value = BorderLocation.None_
523
+ self._set_style(BorderLocation(value), sv.KBORDER)
524
+
525
+
526
+ class FieldmapMesh(session.SubStyle):
527
+ """Lines connecting neighboring data points.
528
+
529
+ The mesh plot layer displays the lines connecting neighboring data points
530
+ within a `Zone <data_access>`. For ``I``-ordered data, the mesh is a single
531
+ line connecting all of the points in order of increasing ``I``-index. For
532
+ ``IJ``-ordered data, the mesh consists of two families of lines connecting
533
+ adjacent data points of increasing ``I``-index and increasing ``J``-index.
534
+ For ``IJK``-ordered data, the mesh consists of three families of lines, one
535
+ connecting points of increasing ``I``-index, one connecting points of
536
+ increasing ``J``-index, and one connecting points of increasing
537
+ ``K``-index. For finite element zones, the mesh is a plot of every edge of
538
+ all of the elements that are defined by the connectivity list for the node
539
+ points:
540
+
541
+ .. code-block:: python
542
+ :emphasize-lines: 22-24
543
+
544
+ from os import path
545
+ import numpy as np
546
+ import tecplot as tp
547
+ from tecplot.constant import PlotType, MeshType
548
+
549
+ examples_dir = tp.session.tecplot_examples_directory()
550
+ infile = path.join(examples_dir, 'SimpleData', 'F18.plt')
551
+ dataset = tp.data.load_tecplot(infile)
552
+
553
+ # Enable 3D field plot and turn on contouring
554
+ frame = tp.active_frame()
555
+ frame.plot_type = PlotType.Cartesian3D
556
+ plot = frame.plot()
557
+ plot.show_mesh = True
558
+
559
+ contour = plot.contour(0)
560
+ contour.variable = dataset.variable('S')
561
+ contour.colormap_name = 'Doppler'
562
+ contour.levels.reset_levels(np.linspace(0.02,0.12,11))
563
+
564
+ # set the mesh type and color for all zones
565
+ mesh = plot.fieldmaps().mesh
566
+ mesh.mesh_type = MeshType.HiddenLine
567
+ mesh.color = contour
568
+
569
+ # save image to file
570
+ tp.export.save_png('fieldmap_mesh.png', 600, supersample=3)
571
+
572
+ .. figure:: /_static/images/fieldmap_mesh.png
573
+ :width: 300px
574
+ :figwidth: 300px
575
+ """
576
+ def __init__(self, fieldmap):
577
+ super().__init__(fieldmap, sv.MESH)
578
+
579
+ @property
580
+ def show(self):
581
+ """`bool`: Draw the mesh for this fieldmap.
582
+
583
+ Example usage::
584
+
585
+ >>> from tecplot.constant import SurfacesToPlot
586
+ >>> plot.show_mesh = True
587
+ >>> surfaces = plot.fieldmap(0).surfaces
588
+ >>> surfaces.surfaces_to_plot = SurfacesToPlot.IPlanes
589
+ >>> plot.fieldmap(0).mesh.show = True
590
+ """
591
+ return self._get_style(bool, sv.SHOW)
592
+
593
+ @show.setter
594
+ def show(self, value):
595
+ self._set_style(bool(value), sv.SHOW)
596
+
597
+ @property
598
+ def mesh_type(self):
599
+ """`MeshType`: `MeshType` to show.
600
+
601
+ Possible values:
602
+
603
+ `Wireframe <MeshType.Wireframe>`
604
+ Wire frame meshes are drawn below any other zone layers on the same
605
+ zone. In 3D Cartesian plots, no hidden lines are removed. For 3D
606
+ volume zones (finite element volume or IJK-ordered), the full 3D
607
+ mesh (consisting of all the connecting lines between data points)
608
+ is not generally drawn because the sheer number of lines would make
609
+ it confusing. The mesh drawn will depend on `FieldmapSurfaces`
610
+ which can be obtained through the parent fieldmap with
611
+ ``mesh.fieldmap.surfaces``::
612
+
613
+ from tecplot.constant import MeshType, SurfacesToPlot
614
+ mesh = plot.fieldmap(0).mesh
615
+ mesh.mesh_type = MeshType.Wireframe
616
+ surfaces = mesh.fieldmap.surfaces
617
+ surfaces.surfaces_to_plot = SurfacesToPlot.IPlanes
618
+
619
+ By default, only the mesh on exposed cell faces is shown.
620
+
621
+ `Overlay <MeshType.Overlay>`
622
+ Similar to Wire Frame, mesh lines are drawn over all other zone
623
+ layers except for vectors and scatter symbols. In 3D Cartesian
624
+ plots, the area behind the cells of the plot is still visible
625
+ (unless another plot type such as contour flooding prevents this).
626
+ As with Wire Frame, the mesh drawn will depend on
627
+ `FieldmapSurfaces` which can be obtained through the parent
628
+ fieldmap with ``mesh.fieldmap.surfaces``.
629
+
630
+ `HiddenLine <MeshType.HiddenLine>`
631
+ Similar to Overlay, except hidden lines are removed from behind the
632
+ mesh. In effect, the cells (elements) of the mesh are opaque.
633
+ FieldmapSurfaces and lines that are hidden behind another surface
634
+ are removed from the plot. For 3D volume zones, using this plot
635
+ type obscures everything inside the zone. If you choose this option
636
+ for 3D volume zones, then choosing to plot every surface with::
637
+
638
+ from tecplot.constant import HiddenLine, SurfacesToPlot
639
+ mesh = plot.fieldmap(0).mesh
640
+ mesh.mesh_type = MeshType.HiddenLine
641
+ surfaces = mesh.fieldmap.surfaces
642
+ surfaces.surfaces_to_plot = SurfacesToPlot.All
643
+
644
+ has the same effect as plotting only exposed cell faces with::
645
+
646
+ surfaces.surfaces_to_plot = SurfacesToPlot.ExposedCellFaces
647
+
648
+ but is much slower.
649
+ """
650
+ return self._get_style(MeshType, sv.MESHTYPE)
651
+
652
+ @mesh_type.setter
653
+ def mesh_type(self, value):
654
+ self._set_style(MeshType(value), sv.MESHTYPE)
655
+
656
+ @property
657
+ def color(self):
658
+ """`Color` or `ContourGroup`: The `Color` or `ContourGroup` for lines.
659
+
660
+ FieldmapContour lines can be a solid color or be colored by a
661
+ `ContourGroup` as obtained through the ``plot.contour`` property. Note
662
+ that changing style on this `ContourGroup` will affect all other
663
+ fieldmaps on the same `Frame <layout.Frame>` that use it. Example usage::
664
+
665
+ >>> from tecplot.constant import Color
666
+ >>> plot.fieldmap(1).mesh.color = Color.Blue
667
+
668
+ Example of setting the color from a `ContourGroup`::
669
+
670
+ >>> plot.fieldmap(1).mesh.color = plot.contour(1)
671
+ """
672
+ return color_spec(self._get_style(Color, sv.COLOR), self.parent.plot)
673
+
674
+ @color.setter
675
+ def color(self, value):
676
+ self._set_style(color_spec(value), sv.COLOR)
677
+
678
+ @property
679
+ def line_pattern(self):
680
+ """`LinePattern`: `LinePattern` type to use for mesh lines.
681
+
682
+ Possible values: `Solid <LinePattern.Solid>`, `Dashed`, `DashDot`,
683
+ `Dotted`, `LongDash`, `DashDotDot`.
684
+
685
+ Example usage::
686
+
687
+ >>> from tecplot.constant import LinePattern
688
+ >>> mesh = plot.fieldmap(0).mesh
689
+ >>> mesh.line_pattern = LinePattern.Dashed
690
+ """
691
+ return self._get_style(LinePattern, sv.LINEPATTERN)
692
+
693
+ @line_pattern.setter
694
+ def line_pattern(self, value):
695
+ self._set_style(LinePattern(value), sv.LINEPATTERN)
696
+
697
+ @property
698
+ def line_thickness(self):
699
+ """`float`: Thickness (`float`) of the drawn lines.
700
+
701
+ This is the line thickness in percentage of the `Frame <layout.Frame>`'s height.
702
+ Example usage::
703
+
704
+ >>> plot.fieldmap(0).mesh.line_thickness = 0.7
705
+ """
706
+ return self._get_style(float, sv.LINETHICKNESS)
707
+
708
+ @line_thickness.setter
709
+ def line_thickness(self, value):
710
+ self._set_style(float(value), sv.LINETHICKNESS)
711
+
712
+ @property
713
+ def pattern_length(self):
714
+ """`float`: Length (`float`) of the pattern segment for non-solid lines.
715
+
716
+ This is the pattern length in percentage of the `Frame <layout.Frame>`'s height.
717
+ Example usage::
718
+
719
+ >>> plot.fieldmap(0).mesh.pattern_length = 3.5
720
+ """
721
+ return self._get_style(float, sv.PATTERNLENGTH)
722
+
723
+ @pattern_length.setter
724
+ def pattern_length(self, value):
725
+ self._set_style(float(value), sv.PATTERNLENGTH)
726
+
727
+
728
+ class FieldmapPoints(session.SubStyle):
729
+ """Type and density of the points used for vector and scatter plots.
730
+
731
+ This object controls the location of the points for `FieldmapVector` and
732
+ `FieldmapScatter` plots relative to the cells:
733
+
734
+ .. code-block:: python
735
+ :emphasize-lines: 17-19
736
+
737
+ from os import path
738
+ import tecplot as tp
739
+ from tecplot.constant import PlotType, PointsToPlot
740
+
741
+ examples_dir = tp.session.tecplot_examples_directory()
742
+ infile = path.join(examples_dir, 'SimpleData', 'HeatExchanger.plt')
743
+ dataset = tp.data.load_tecplot(infile)
744
+
745
+ # Enable 3D field plot and turn on contouring
746
+ frame = tp.active_frame()
747
+ frame.plot_type = PlotType.Cartesian2D
748
+ plot = frame.plot()
749
+ plot.vector.u_variable = dataset.variable('U(M/S)')
750
+ plot.vector.v_variable = dataset.variable('V(M/S)')
751
+ plot.show_vector = True
752
+
753
+ points = plot.fieldmaps().points
754
+ points.points_to_plot = PointsToPlot.SurfaceCellCenters
755
+ points.step = (2,2)
756
+
757
+ # save image to file
758
+ tp.export.save_png('fieldmap_points.png', 600, supersample=3)
759
+
760
+ .. figure:: /_static/images/fieldmap_points.png
761
+ :width: 300px
762
+ :figwidth: 300px
763
+ """
764
+ def __init__(self, fieldmap):
765
+ super().__init__(fieldmap, sv.POINTS)
766
+
767
+ @property
768
+ def points_to_plot(self):
769
+ """`PointsToPlot`: Location of the points to show.
770
+
771
+ Possible values:
772
+
773
+ `SurfaceNodes`
774
+ Draws only the nodes that are on the surface of the `Zone
775
+ <data_access>`.
776
+
777
+ `AllNodes`
778
+ Draws all nodes in the `Zone <data_access>`.
779
+
780
+ `SurfaceCellCenters`
781
+ Draws points at the cell centers which are on or near the surface
782
+ of the `Zone <data_access>`.
783
+
784
+ `AllCellCenters`
785
+ Draws points at all cell centers in the `Zone <data_access>`.
786
+
787
+ `AllConnected`
788
+ Draws all the nodes that are connected by the node map. Nodes
789
+ without any connectivity are not drawn.
790
+
791
+ Example usage::
792
+
793
+ >>> from tecplot.constant import PointsToPlot
794
+ >>> pts = plot.fieldmap(0).points
795
+ >>> sts.points_to_plot = PointsToPlot.SurfaceCellCenters
796
+ """
797
+ return self._get_style(PointsToPlot, sv.POINTSTOPLOT)
798
+
799
+ @points_to_plot.setter
800
+ def points_to_plot(self, points):
801
+ self._set_style(PointsToPlot(points), sv.POINTSTOPLOT)
802
+
803
+ @property
804
+ def step(self):
805
+ """`tuple`: Step along the dimensions ``(I, J, K)``.
806
+
807
+ This property specifies the ``I``, ``J``, and ``K``-step intervals. For
808
+ irregular and finite element data, only the first parameter or
809
+ ``I``-Step has an effect. This steps through the nodes in the order
810
+ they are listed in the data file. In this case, a single number can be
811
+ given, but note that the return type is always a 3-`tuple` for both
812
+ ordered and irregular data.
813
+
814
+ Example for ``IJK`` ordered data::
815
+
816
+ >>> plot.fieldmap(0).points.step = (10,10,None)
817
+ >>> print(plot.fieldmap(0).points.step)
818
+ (10, 10, 1)
819
+
820
+ Example for irregular data::
821
+
822
+ >>> plot.fieldmap(0).points.step = 10
823
+ >>> print(plot.fieldmap(0).points.step)
824
+ (10, 1, 1)
825
+ """
826
+ return session.IJK(self, sv.IJKSKIP)
827
+
828
+ @step.setter
829
+ def step(self, *values):
830
+ values = tecutil.flatten_args(*values)
831
+ session.IJK(self, sv.IJKSKIP)[:] = [int(v or 1) for v in values]
832
+
833
+
834
+ class FieldmapScatter(session.SubStyle):
835
+ """Plot of nodes using symbols.
836
+
837
+ `FieldmapScatter` plots display symbols at the data points in a field. The
838
+ symbols may be sized according to the values of a specified variable,
839
+ colored by the values of the contour variable, or may be uniformly sized or
840
+ colored. Unlike contour plots, scatter plots do not require any mesh
841
+ structure connecting the points, allowing scatter plots of irregular data:
842
+
843
+ .. code-block:: python
844
+ :emphasize-lines: 14-18
845
+
846
+ from os import path
847
+ import tecplot as tp
848
+ from tecplot.constant import PlotType, SymbolType, FillMode
849
+
850
+ examples_dir = tp.session.tecplot_examples_directory()
851
+ infile = path.join(examples_dir, 'SimpleData', 'HeatExchanger.plt')
852
+ dataset = tp.data.load_tecplot(infile)
853
+
854
+ frame = tp.active_frame()
855
+ frame.plot_type = PlotType.Cartesian2D
856
+ plot = frame.plot()
857
+ plot.show_scatter = True
858
+
859
+ scatter = plot.fieldmaps().scatter
860
+ scatter.symbol_type = SymbolType.Geometry
861
+ scatter.fill_mode = FillMode.UseSpecificColor
862
+ scatter.fill_color = plot.contour(0)
863
+ scatter.size = 1
864
+
865
+ # ensure consistent output between interactive (connected) and batch
866
+ plot.contour(0).levels.reset_to_nice()
867
+
868
+ tp.export.save_png('fieldmap_scatter.png', 600, supersample=3)
869
+
870
+ .. figure:: /_static/images/fieldmap_scatter.png
871
+ :width: 300px
872
+ :figwidth: 300px
873
+ """
874
+ def __init__(self, fieldmap):
875
+ super().__init__(fieldmap, sv.SCATTER)
876
+
877
+ @property
878
+ def show(self):
879
+ """`bool`: Show the scatter symbols.
880
+
881
+ Example usage::
882
+
883
+ >>> plot.show_scatter = True
884
+ >>> plot.fieldmap(2).scatter.show = True
885
+ """
886
+ return self._get_style(bool, sv.SHOW)
887
+
888
+ @show.setter
889
+ def show(self, value):
890
+ self._set_style(bool(value), sv.SHOW)
891
+
892
+ @property
893
+ def symbol_type(self):
894
+ """`SymbolType`: The `SymbolType` to use for this scatter plot.
895
+
896
+ Possible values are `SymbolType.Geometry` or `SymbolType.Text`. Example
897
+ usage::
898
+
899
+ >>> from tecplot.constant import SymbolType
900
+ >>> plot.fieldmap(0).scatter.symbol_type = SymbolType.Text
901
+ """
902
+ return symbol.Symbol(self)._symbol_type
903
+
904
+ @symbol_type.setter
905
+ def symbol_type(self, value):
906
+ symbol.Symbol(self)._symbol_type = value
907
+
908
+ def symbol(self, symbol_type=None):
909
+ """Returns a scatter symbol style object.
910
+
911
+ Parameters:
912
+ symbol_type (`SymbolType`, optional): The type of symbol to return.
913
+ By default, this will return the active symbol type which is
914
+ obtained from `FieldmapScatter.symbol_type`.
915
+
916
+ Returns: `TextScatterSymbol` or `GeometryScatterSymbol`
917
+
918
+ Example usage::
919
+
920
+ >>> from tecplot.constant import SymbolType
921
+ >>> plot.fieldmap(0).scatter.symbol_type = SymbolType.Text
922
+ >>> symbol = plot.fieldmap(0).scatter.symbol()
923
+ >>> symbol.text = 'a'
924
+ """
925
+ _dispatch = {
926
+ SymbolType.Text: symbol.TextScatterSymbol,
927
+ SymbolType.Geometry: symbol.GeometryScatterSymbol}
928
+ if symbol_type is None:
929
+ symbol_type = self.symbol_type
930
+ if isinstance(symbol_type, Iterable):
931
+ if not all(t is symbol_type[0] for t in symbol_type):
932
+ msg = 'Fieldmap scatter symbols are not all the same type'
933
+ raise TecplotLogicError(msg)
934
+ symbol_type = symbol_type[0]
935
+ return _dispatch[symbol_type](self)
936
+
937
+ @property
938
+ def size(self):
939
+ """`float`: Size of the symbols to draw.
940
+
941
+ Example usage::
942
+
943
+ >>> plot.fieldmap(0).scatter.size = 4
944
+ """
945
+ return self._get_style(float, sv.FRAMESIZE)
946
+
947
+ @size.setter
948
+ def size(self, value):
949
+ self._set_style(float(value), sv.FRAMESIZE)
950
+
951
+ @property
952
+ def size_by_variable(self):
953
+ """`bool`: Use a variable to determine relative size of symbols.
954
+
955
+ Example usage::
956
+
957
+ >>> plot.scatter.variable = dataset.variable('P')
958
+ >>> plot.fieldmap(0).scatter.size_by_variable = True
959
+
960
+ .. seealso:: `Scatter.variable`
961
+ """
962
+ return self._get_style(bool, sv.SIZEBYVARIABLE)
963
+
964
+ @size_by_variable.setter
965
+ def size_by_variable(self, value):
966
+ try:
967
+ self._set_style(bool(value), sv.SIZEBYVARIABLE)
968
+ except TecplotSystemError as e:
969
+ if str(e) == str(SetValueReturnCode.ContextError1):
970
+ msg = dedent('''\
971
+ A scatter variable must be set using the
972
+ plot.scatter.variable property.''')
973
+ raise TecplotLogicError(msg)
974
+ else:
975
+ raise
976
+
977
+ @property
978
+ def line_thickness(self):
979
+ """`float`: Width of the lines when drawing symbols.
980
+
981
+ Example usage::
982
+
983
+ >>> from tecplot.constant import SymbolType
984
+ >>> scatter = plot.fieldmap(0).scatter
985
+ >>> scatter.symbol_type = SymbolType.Geometry
986
+ >>> scatter.line_thickness = 1
987
+ """
988
+ return self._get_style(float, sv.LINETHICKNESS)
989
+
990
+ @line_thickness.setter
991
+ def line_thickness(self, value):
992
+ self._set_style(float(value), sv.LINETHICKNESS)
993
+
994
+ @property
995
+ def color(self):
996
+ """`Color` or `ContourGroup`: Line `Color` or `ContourGroup` of the drawn symbols.
997
+
998
+ This can be a solid color or a `ContourGroup` as obtained through the
999
+ ``plot.contour`` property. Note that changing style on the
1000
+ `ContourGroup` will affect all other fieldmaps in the same `Frame <layout.Frame>` that
1001
+ use it. Example usage::
1002
+
1003
+ >>> from tecplot.constant import Color
1004
+ >>> plot.fieldmap(1).scatter.color = Color.Blue
1005
+
1006
+ Example of setting the color from a `ContourGroup`::
1007
+
1008
+ >>> plot.fieldmap(1).scatter.color = plot.contour(1)
1009
+ """
1010
+ return color_spec(self._get_style(Color, sv.COLOR),
1011
+ self.parent.plot)
1012
+
1013
+ @color.setter
1014
+ def color(self, value):
1015
+ self._set_style(color_spec(value), sv.COLOR)
1016
+
1017
+ @property
1018
+ def fill_mode(self):
1019
+ """`FillMode`: Mode for the background color.
1020
+
1021
+ Options include: `FillMode.UseSpecificColor`, `FillMode.UseLineColor`,
1022
+ `FillMode.UseBackgroundColor` and `FillMode.None_`.
1023
+
1024
+ Example usage::
1025
+
1026
+ >>> from tecplot.constant import Color, SymbolType, FillMode
1027
+ >>> scatter = plot.fieldmap(0).scatter
1028
+ >>> scatter.symbol_type = SymbolType.Geometry
1029
+ >>> scatter.fill_mode = FillMode.UseSpecificColor
1030
+ >>> scatter.fill_color = Color.Red
1031
+ """
1032
+ return self._get_style(FillMode, sv.FILLMODE)
1033
+
1034
+ @fill_mode.setter
1035
+ def fill_mode(self, value):
1036
+ self._set_style(FillMode(value), sv.FILLMODE)
1037
+
1038
+ @property
1039
+ def fill_color(self):
1040
+ """`Color` or `ContourGroup`: Fill or background color.
1041
+
1042
+ The ``fill_mode`` attribute must be set accordingly::
1043
+
1044
+ >>> from tecplot.constant import Color, SymbolType, FillMode
1045
+ >>> scatter = plot.fieldmap(0).scatter
1046
+ >>> scatter.symbol_type = SymbolType.Geometry
1047
+ >>> scatter.fill_mode = FillMode.UseSpecificColor
1048
+ >>> scatter.fill_color = Color.Red
1049
+ """
1050
+ return color_spec(self._get_style(Color, sv.FILLCOLOR),
1051
+ self.parent.plot)
1052
+
1053
+ @fill_color.setter
1054
+ def fill_color(self, value):
1055
+ self._set_style(color_spec(value), sv.FILLCOLOR)
1056
+
1057
+
1058
+ class FieldmapSurfaces(session.SubStyle):
1059
+ """Plot surfaces from volume data.
1060
+
1061
+ This class controls viewing volume data as surfaces, either via a boundary
1062
+ surface or one or more planes along the ``I``, ``J``, ``K`` dimensions for
1063
+ ordered data:
1064
+
1065
+ .. code-block:: python
1066
+ :emphasize-lines: 34,40,43
1067
+
1068
+ import numpy as np
1069
+
1070
+ import tecplot as tp
1071
+ from tecplot.constant import *
1072
+ from tecplot.data.operate import execute_equation
1073
+
1074
+ # Get the active frame, setup a grid (30x30x30)
1075
+ # where each dimension ranges from 0 to 30.
1076
+ # Add variable P to the dataset and give
1077
+ # values to the data.
1078
+ frame = tp.active_frame()
1079
+ dataset = frame.dataset
1080
+ for v in ['X','Y','Z','P']:
1081
+ dataset.add_variable(v)
1082
+ zone = dataset.add_ordered_zone('Zone', (30,30,30))
1083
+ xx = np.linspace(0,30,30)
1084
+ for v,arr in zip(['X','Y','Z'],np.meshgrid(xx,xx,xx)):
1085
+ zone.values(v)[:] = arr.ravel()
1086
+ execute_equation('{P} = -10*{X} + {Y}**2 + {Z}**2')
1087
+
1088
+ # Enable 3D field plot and turn on contouring
1089
+ frame.plot_type = PlotType.Cartesian3D
1090
+ plot = frame.plot()
1091
+ plot.show_contour = True
1092
+
1093
+ # get a handle of the fieldmap for this zone
1094
+ fmap = plot.fieldmap(dataset.zone('Zone'))
1095
+
1096
+ # set the active contour group to flood by variable P
1097
+ fmap.contour.flood_contour_group.variable = dataset.variable('P')
1098
+ plot.contour(0).levels.reset_to_nice()
1099
+
1100
+ # show I and J-planes through the surface
1101
+ fmap.surfaces.surfaces_to_plot = SurfacesToPlot.IJPlanes
1102
+
1103
+ # show only the first and last I-planes
1104
+ # min defaults to 0, max defaults to -1
1105
+ # we set step to -1 which is equivalent
1106
+ # to the I-dimensions's max
1107
+ fmap.surfaces.i_range = None,None,-1
1108
+
1109
+ # show J-planes at indices: [5, 15, 25]
1110
+ fmap.surfaces.j_range = 5,25,10
1111
+
1112
+ # save image to file
1113
+ tp.export.save_png('fieldmap_surfaces_ij.png', 600, supersample=3)
1114
+
1115
+ .. figure:: /_static/images/fieldmap_surfaces_ij.png
1116
+ :width: 300px
1117
+ :figwidth: 300px
1118
+ """
1119
+ def __init__(self, fieldmap):
1120
+ super().__init__(fieldmap, sv.SURFACES)
1121
+
1122
+ @property
1123
+ def surfaces_to_plot(self):
1124
+ """`SurfacesToPlot`: The surfaces to show.
1125
+
1126
+ Possible values: `BoundaryFaces`, `ExposedCellFaces`, `IPlanes
1127
+ <SurfacesToPlot.IPlanes>`, `JPlanes <SurfacesToPlot.JPlanes>`, `KPlanes
1128
+ <SurfacesToPlot.KPlanes>`, `IJPlanes`, `JKPlanes`, `IKPlanes`,
1129
+ `IJKPlanes`, `All <SurfacesToPlot.All>`, the python built-in `None`.
1130
+
1131
+ Options such as `IJKPlanes` show planes from multiple dimensions. For
1132
+ example, the `IJPlanes` value shows both the ``I``-planes and the
1133
+ ``J``-planes. The following example shows a 3D field plot using faces
1134
+ on the boundary::
1135
+
1136
+ >>> from tecplot.constant import SurfacesToPlot
1137
+ >>> frame.plot_type = PlotType.Cartesian3D
1138
+ >>> srf = frame.plot().fieldmap(0).surfaces
1139
+ >>> srf.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
1140
+ """
1141
+ value = self._get_style(SurfacesToPlot, sv.SURFACESTOPLOT)
1142
+ if value == SurfacesToPlot.None_:
1143
+ return None
1144
+ else:
1145
+ return value
1146
+
1147
+ @surfaces_to_plot.setter
1148
+ def surfaces_to_plot(self, surfaces):
1149
+ if surfaces is None:
1150
+ surfaces = SurfacesToPlot.None_
1151
+ self._set_style(SurfacesToPlot(surfaces), sv.SURFACESTOPLOT)
1152
+
1153
+ @property
1154
+ def i_range(self):
1155
+ """`tuple` of `integers <int>` (min, max, step): `IndexRange` for the *I* dimension of ordered data.
1156
+
1157
+ This example shows ``I``-planes at ``i = [0, 2, 4, 6, 8, 10]``::
1158
+
1159
+ >>> from tecplot.constant import SurfacesToPlot
1160
+ >>> srf = frame.plot().fieldmap(0).surfaces
1161
+ >>> srf.surfaces_to_plot = SurfacesToPlot.IPlanes
1162
+ >>> srf.i_range = 0, 10, 2
1163
+ """
1164
+ return session.IndexRange(self, sv.IRANGE)
1165
+
1166
+ @i_range.setter
1167
+ def i_range(self, values):
1168
+ session.IndexRange(self, sv.IRANGE)[:] = values
1169
+
1170
+ @property
1171
+ def j_range(self):
1172
+ """`tuple` of `integers <int>` (min, max, step): `IndexRange` for the *J* dimension of ordered data.
1173
+
1174
+ This example shows all ``J``-planes starting with ``j = 10`` up to the
1175
+ maximum ``J``-plane of the associated `Zone <data_access>`::
1176
+
1177
+ >>> from tecplot.constant import SurfacesToPlot
1178
+ >>> srf = frame.plot().fieldmap(0).surfaces
1179
+ >>> srf.surfaces_to_plot = SurfacesToPlot.JPlanes
1180
+ >>> srf.j_range = 10, None, 1
1181
+ """
1182
+ return session.IndexRange(self, sv.JRANGE)
1183
+
1184
+ @j_range.setter
1185
+ def j_range(self, values):
1186
+ session.IndexRange(self, sv.JRANGE)[:] = values
1187
+
1188
+ @property
1189
+ def k_range(self):
1190
+ """`tuple` of `integers <int>` (min, max, step): `IndexRange` for the *K* dimension of ordered data.
1191
+
1192
+ This example shows all ``K``-planes starting with the first up to 5
1193
+ from the last ``K``-plane of the associated `Zone <data_access>`::
1194
+
1195
+ >>> from tecplot.constant import SurfacesToPlot
1196
+ >>> srf = frame.plot().fieldmap(0).surfaces
1197
+ >>> srf.surfaces_to_plot = SurfacesToPlot.KPlanes
1198
+ >>> srf.k_range = None, -5
1199
+ """
1200
+ return session.IndexRange(self, sv.KRANGE)
1201
+
1202
+ @k_range.setter
1203
+ def k_range(self, values):
1204
+ session.IndexRange(self, sv.KRANGE)[:] = values
1205
+
1206
+
1207
+ class FieldmapVector(session.SubStyle):
1208
+ """Field plot of arrows.
1209
+
1210
+ Before doing anything with vector plots, one must set the variables to be
1211
+ used for the ``(U, V, W)`` coordinates. This is done through the plot
1212
+ object. Once set, the vectors can be displayed and manipulated using this
1213
+ class:
1214
+
1215
+ .. code-block:: python
1216
+ :emphasize-lines: 24-26,33-37
1217
+
1218
+ import numpy as np
1219
+ import tecplot as tp
1220
+ from tecplot.data.operate import execute_equation
1221
+ from tecplot.constant import (PlotType, PointsToPlot, VectorType,
1222
+ ArrowheadStyle)
1223
+
1224
+ frame = tp.active_frame()
1225
+ dataset = frame.dataset
1226
+ for v in ['X','Y','Z','P','Q','R']:
1227
+ dataset.add_variable(v)
1228
+ zone = dataset.add_ordered_zone('Zone', (30,30,30))
1229
+ xx = np.linspace(0,30,30)
1230
+ for v,arr in zip(['X','Y','Z'],np.meshgrid(xx,xx,xx)):
1231
+ zone.values(v)[:] = arr.ravel()
1232
+ execute_equation('{P} = -10 * {X} + {Y}**2 + {Z}**2')
1233
+ execute_equation('{Q} = {X} - 10 * {Y} - {Z}**2')
1234
+ execute_equation('{R} = {X}**2 + {Y}**2 - {Z} ')
1235
+
1236
+ frame.plot_type = PlotType.Cartesian3D
1237
+ plot = frame.plot()
1238
+ plot.contour(0).variable = dataset.variable('P')
1239
+ plot.contour(0).colormap_name = 'Two Color'
1240
+ plot.contour(0).levels.reset_to_nice()
1241
+ plot.vector.u_variable = dataset.variable('P')
1242
+ plot.vector.v_variable = dataset.variable('Q')
1243
+ plot.vector.w_variable = dataset.variable('R')
1244
+ plot.show_vector = True
1245
+
1246
+ points = plot.fieldmap(0).points
1247
+ points.points_to_plot = PointsToPlot.AllNodes
1248
+ points.step = (5,3,2)
1249
+
1250
+ vector = plot.fieldmap(0).vector
1251
+ vector.show = True
1252
+ vector.vector_type = VectorType.MidAtPoint
1253
+ vector.arrowhead_style = ArrowheadStyle.Filled
1254
+ vector.color = plot.contour(0)
1255
+ vector.line_thickness = 0.4
1256
+
1257
+ # save image to file
1258
+ tp.export.save_png('fieldmap_vector.png', 600, supersample=3)
1259
+
1260
+ .. figure:: /_static/images/fieldmap_vector.png
1261
+ :width: 300px
1262
+ :figwidth: 300px
1263
+ """
1264
+ def __init__(self, fieldmap):
1265
+ super().__init__(fieldmap, sv.VECTOR)
1266
+
1267
+ @property
1268
+ def show(self):
1269
+ """`bool`: Enable drawing vectors on the plot.
1270
+
1271
+ Example usage::
1272
+
1273
+ >>> plot.show_vector = True
1274
+ >>> plot.fieldmap(0).vector.show = True
1275
+ """
1276
+ return self._get_style(bool, sv.SHOW)
1277
+
1278
+ @show.setter
1279
+ def show(self, value):
1280
+ self._set_style(bool(value), sv.SHOW)
1281
+
1282
+ @property
1283
+ def vector_type(self):
1284
+ """`VectorType`: Anchor point of the drawn vectors.
1285
+
1286
+ Possible values: `TailAtPoint`, `HeadAtPoint`, `MidAtPoint`, `HeadOnly`.
1287
+
1288
+ Example usage::
1289
+
1290
+ >>> from tecplot.constant import VectorType
1291
+ >>> plot.fieldmap(0).vector.vector_type = VectorType.MidAtPoint
1292
+ """
1293
+ return self._get_style(VectorType, sv.VECTORTYPE)
1294
+
1295
+ @vector_type.setter
1296
+ def vector_type(self, value):
1297
+ self._set_style(VectorType(value), sv.VECTORTYPE)
1298
+
1299
+ @property
1300
+ def tangent_only(self):
1301
+ """`bool`: Show only tangent vectors.
1302
+
1303
+ Set to `True` to display **only** the tangent component of vectors.
1304
+ Tangent vectors are drawn on 3D surfaces only where it is possible to
1305
+ determine a vector normal to the surface. A plot where multiple
1306
+ surfaces intersect each other using common nodes is a case where
1307
+ tangent vectors are not drawn because there is more than one normal to
1308
+ choose from. An example of this would be a volume ``IJK``-ordered zone
1309
+ where both the ``I`` and ``J``-planes are shown. If tangent vectors
1310
+ cannot be drawn, then regular vectors are plotted instead.
1311
+
1312
+ Example usage::
1313
+
1314
+ >>> plot.fieldmap(0).vector.tangent_only = True
1315
+ """
1316
+ return self._get_style(bool, sv.ISTANGENT)
1317
+
1318
+ @tangent_only.setter
1319
+ def tangent_only(self, value):
1320
+ self._set_style(bool(value), sv.ISTANGENT)
1321
+
1322
+ @property
1323
+ def color(self):
1324
+ """`Color` or `ContourGroup`: The `Color` or `ContourGroup` to use when drawing vectors.
1325
+
1326
+ FieldmapVectors can be a solid color or be colored by a `ContourGroup`
1327
+ as obtained through the ``plot.contour`` property. Note that changing
1328
+ style on this `ContourGroup` will affect all other fieldmaps on the
1329
+ same `Frame <layout.Frame>` that use it. Example usage::
1330
+
1331
+ >>> from tecplot.constant import Color
1332
+ >>> plot.fieldmap(1).vector.color = Color.Blue
1333
+
1334
+ Example of setting the color from a `ContourGroup`::
1335
+
1336
+ >>> plot.fieldmap(1).vector.color = plot.contour(1)
1337
+ """
1338
+ return color_spec(self._get_style(Color, sv.COLOR), self.parent.plot)
1339
+
1340
+ @color.setter
1341
+ def color(self, value):
1342
+ self._set_style(color_spec(value), sv.COLOR)
1343
+
1344
+ @property
1345
+ def arrowhead_style(self):
1346
+ """`ArrowheadStyle`: The `ArrowheadStyle` drawn.
1347
+
1348
+ Possible values: `Plain`, `Filled <ArrowheadStyle.Filled>`,
1349
+ `Hollow <ArrowheadStyle.Hollow>`.
1350
+
1351
+ Example usage::
1352
+
1353
+ >>> from tecplot.constant import ArrowheadStyle
1354
+ >>> plot.fieldmap(0).vector.arrowhead_style = ArrowheadStyle.Filled
1355
+ """
1356
+ return self._get_style(ArrowheadStyle, sv.ARROWHEADSTYLE)
1357
+
1358
+ @arrowhead_style.setter
1359
+ def arrowhead_style(self, value):
1360
+ self._set_style(ArrowheadStyle(value), sv.ARROWHEADSTYLE)
1361
+
1362
+ @property
1363
+ def line_pattern(self):
1364
+ """`LinePattern`: The `LinePattern` used to draw the arrow line.
1365
+
1366
+ Possible values: `Solid <LinePattern.Solid>`, `Dashed`, `DashDot`,
1367
+ `Dotted`, `LongDash`, `DashDotDot`.
1368
+
1369
+ Example usage::
1370
+
1371
+ >>> from tecplot.constant import LinePattern
1372
+ >>> vector = plot.fieldmap(0).vector
1373
+ >>> vector.line_pattern = LinePattern.DashDot
1374
+ """
1375
+ return self._get_style(LinePattern, sv.LINEPATTERN)
1376
+
1377
+ @line_pattern.setter
1378
+ def line_pattern(self, value):
1379
+ self._set_style(LinePattern(value), sv.LINEPATTERN)
1380
+
1381
+ @property
1382
+ def line_thickness(self):
1383
+ """`float` (percentage of `Frame <layout.Frame>` height): The width of the arrow line.
1384
+
1385
+ Example usage::
1386
+
1387
+ >>> from tecplot.constant import LinePattern
1388
+ >>> vector = plot.fieldmap(0).vector.line_thickness = 0.7
1389
+ """
1390
+ return self._get_style(float, sv.LINETHICKNESS)
1391
+
1392
+ @line_thickness.setter
1393
+ def line_thickness(self, value):
1394
+ self._set_style(float(value), sv.LINETHICKNESS)
1395
+
1396
+ @property
1397
+ def pattern_length(self):
1398
+ """`float` (percentage of `Frame <layout.Frame>` height): Length of the pattern used when drawing vector lines.
1399
+
1400
+ Example usage::
1401
+
1402
+ >>> from tecplot.constant import LinePattern
1403
+ >>> vector = plot.fieldmap(0).vector
1404
+ >>> vector.line_pattern = LinePattern.Dashed
1405
+ >>> vector.pattern_length = 3.5
1406
+ """
1407
+ return self._get_style(float, sv.PATTERNLENGTH)
1408
+
1409
+ @pattern_length.setter
1410
+ def pattern_length(self, value):
1411
+ self._set_style(float(value), sv.PATTERNLENGTH)
1412
+
1413
+
1414
+ class FieldmapCollection(session.Style):
1415
+ def __init__(self, plot, *indices):
1416
+ self._indices = set(tecutil.flatten_args(*indices))
1417
+ self.plot = plot
1418
+ super().__init__(sv.FIELDMAP, uniqueid=self.plot.frame.uid,
1419
+ objectset=self._indices)
1420
+
1421
+ @property
1422
+ def fieldmap_indices(self):
1423
+ """`list`: Read-only, sorted `list` of zero-based fieldmap indices."""
1424
+ return sorted(self._indices)
1425
+
1426
+ def __iter__(self):
1427
+ self._current_index = -1
1428
+ self._max_index = len(self._indices)
1429
+ return self
1430
+
1431
+ def __next__(self):
1432
+ self._current_index += 1
1433
+ if self._current_index < self._max_index:
1434
+ return self[self._current_index]
1435
+ raise StopIteration
1436
+
1437
+ def next(self): # if sys.version_info < (3,)
1438
+ return self.__next__()
1439
+
1440
+ def __eq__(self, that):
1441
+ return (isinstance(that, type(self)) and
1442
+ self.plot == that.plot and
1443
+ self._indices == that._indices)
1444
+
1445
+ def __ne__(self, that):
1446
+ return not (self == that)
1447
+
1448
+ def __iadd__(self, keys):
1449
+ self._indices |= self.plot._fieldmap_indices(keys)
1450
+ return self
1451
+
1452
+ def __isub__(self, keys):
1453
+ self._indices -= self.plot._fieldmap_indices(keys)
1454
+ return self
1455
+
1456
+ @property
1457
+ def group(self):
1458
+ """`int`: Zero-based group number for this `Fieldmap`.
1459
+
1460
+ This is a piece of auxiliary data and can be useful for identifying a
1461
+ subset of fieldmaps. For example, to loop over all fieldmaps that have
1462
+ group set to 4::
1463
+
1464
+ >>> plot.fieldmaps(0, 3).group = 4
1465
+ >>> for fmap in filter(lambda f: f.group == 4, plot.fieldmaps()):
1466
+ ... print(fmap.index)
1467
+ 0
1468
+ 3
1469
+ """
1470
+ return self._get_style(Index, sv.GROUP)
1471
+
1472
+ @group.setter
1473
+ def group(self, value):
1474
+ self._set_style(Index(value), sv.GROUP)
1475
+
1476
+ @property
1477
+ def show(self):
1478
+ """`bool`: Display the fielmaps in this collection on the plot.
1479
+
1480
+ Example turning on all fieldmaps on the plot::
1481
+
1482
+ >>> plot.fieldmaps().show = True
1483
+ """
1484
+ return tuple([i in self.plot.active_fieldmap_indices
1485
+ for i in self.fieldmap_indices])
1486
+
1487
+ @show.setter
1488
+ def show(self, value):
1489
+ assignment = AssignOp.PlusEquals if value else AssignOp.MinusEquals
1490
+ session.set_style(self._indices, sv.ACTIVEFIELDMAPS,
1491
+ assignmodifier=assignment,
1492
+ uniqueid=self.plot.frame.uid)
1493
+
1494
+ @property
1495
+ def contour(self):
1496
+ """`FieldmapContour`: Style including flooding, lines and line coloring.
1497
+ """
1498
+ return FieldmapContour(self)
1499
+
1500
+ @property
1501
+ def edge(self):
1502
+ """`FieldmapEdge`: Style control for boundary lines.
1503
+ """
1504
+ return FieldmapEdge(self)
1505
+
1506
+ @property
1507
+ def mesh(self):
1508
+ """`FieldmapMesh`: Style lines connecting neighboring data points.
1509
+ """
1510
+ return FieldmapMesh(self)
1511
+
1512
+ @property
1513
+ def scatter(self):
1514
+ """`FieldmapScatter`: Style for scatter plots.
1515
+ """
1516
+ return FieldmapScatter(self)
1517
+
1518
+ @property
1519
+ def surfaces(self):
1520
+ """`FieldmapSurfaces`: Control which surfaces to draw.
1521
+ """
1522
+ return FieldmapSurfaces(self)
1523
+
1524
+ @property
1525
+ def points(self):
1526
+ """`FieldmapPoints`: Control which points to draw.
1527
+ """
1528
+ return FieldmapPoints(self)
1529
+
1530
+ @property
1531
+ def vector(self):
1532
+ """`FieldmapVector`: Style for vector field plots using arrows.
1533
+ """
1534
+ return FieldmapVector(self)
1535
+
1536
+
1537
+ class Fieldmap(FieldmapCollection):
1538
+ def __init__(self, plot, index):
1539
+ self.index = index
1540
+ super().__init__(plot, index)
1541
+
1542
+ def _get_style(self, rettype, *svargs, **kwargs):
1543
+ return super()._get_style(rettype, *svargs, **kwargs)[0]
1544
+
1545
+ @property
1546
+ def show(self):
1547
+ """`bool`: Display this fieldmap on the plot.
1548
+
1549
+ Example usage::
1550
+
1551
+ >>> plot.fieldmap(0).show = True
1552
+
1553
+ .. seealso:: `Cartesian2DFieldmapCollection` or
1554
+ `Cartesian3DFieldmapCollection`
1555
+
1556
+ For optimized style control of several fieldmaps, it is recommended
1557
+ to use `Cartesian2DFieldmapCollection` or
1558
+ `Cartesian3DFieldmapCollection` objects.
1559
+ """
1560
+ return self._indices.issubset(self.plot.active_fieldmap_indices)
1561
+
1562
+ @show.setter
1563
+ def show(self, show):
1564
+ assignment = AssignOp.PlusEquals if show else AssignOp.MinusEquals
1565
+ session.set_style(self._indices, sv.ACTIVEFIELDMAPS,
1566
+ assignmodifier=assignment,
1567
+ uniqueid=self.plot.frame.uid)
1568
+
1569
+ @property
1570
+ def zones(self):
1571
+ """List of `zones <data_access>` used by this fieldmap.
1572
+
1573
+ Example usage::
1574
+
1575
+ >>> for zone in fieldmap.zones:
1576
+ ... print(zone.name)
1577
+ Zone 1
1578
+ Zone 2
1579
+ """
1580
+ with self.plot.frame.activated():
1581
+ i = next(iter(self._indices))
1582
+ success, zones_ptr = _tecutil.FieldMapGetZones(i + 1)
1583
+ if not success:
1584
+ raise TecplotSystemError()
1585
+ zones_indexset = cast(zones_ptr, IndexSet)
1586
+ zone_indices = set(zones_indexset)
1587
+ zones_indexset.dealloc()
1588
+ for index in zone_indices:
1589
+ yield self.plot.frame.dataset.zone(index)
1590
+
1591
+
1592
+ class FieldmapEffects(session.SubStyle):
1593
+ """Clipping and blanking style control.
1594
+
1595
+ This object controls value blanking and clipping from plane slices for
1596
+ this fieldmap.
1597
+ """
1598
+ def __init__(self, fieldmap):
1599
+ self.fieldmap = fieldmap
1600
+ super().__init__(fieldmap, sv.EFFECTS)
1601
+
1602
+ @property
1603
+ def value_blanking(self):
1604
+ """`bool`: Enable value blanking effect for this fieldmap.
1605
+
1606
+ Example usage::
1607
+
1608
+ >>> plot.fieldmap(0).effects.value_blanking = True
1609
+ """
1610
+ return self._get_style(bool, sv.USEVALUEBLANKING)
1611
+
1612
+ @value_blanking.setter
1613
+ def value_blanking(self, value):
1614
+ self._set_style(bool(value), sv.USEVALUEBLANKING)
1615
+
1616
+ @property
1617
+ def clip_planes(self):
1618
+ tecutil.api_moved('FieldmapEffects.clip_planes',
1619
+ 'FieldmapEffects3D.clip_planes',
1620
+ '1.2', '2020 R1', warning=True)
1621
+ return FieldmapEffects3D(self.fieldmap).clip_planes
1622
+
1623
+ @clip_planes.setter
1624
+ def clip_planes(self, values):
1625
+ tecutil.api_moved('FieldmapEffects.clip_planes',
1626
+ 'FieldmapEffects3D.clip_planes',
1627
+ '1.2', '2020 R1', warning=True)
1628
+ FieldmapEffects3D(self.fieldmap).clip_planes = values
1629
+
1630
+
1631
+ class FieldmapEffects3D(FieldmapEffects):
1632
+ """Lighting and translucency style control.
1633
+
1634
+ .. code-block:: python
1635
+ :emphasize-lines: 24-26
1636
+
1637
+ import os
1638
+
1639
+ import tecplot as tp
1640
+ from tecplot.constant import LightingEffect, PlotType, SurfacesToPlot
1641
+
1642
+ examples_dir = tp.session.tecplot_examples_directory()
1643
+ datafile = os.path.join(examples_dir, 'SimpleData', 'F18.plt')
1644
+ dataset = tp.data.load_tecplot(datafile)
1645
+ frame = dataset.frame
1646
+
1647
+ # Enable 3D field plot, turn on contouring and translucency
1648
+ frame.plot_type = PlotType.Cartesian3D
1649
+ plot = frame.plot()
1650
+ plot.show_contour = True
1651
+ plot.use_translucency = True
1652
+
1653
+ plot.contour(0).variable = dataset.variable('S')
1654
+
1655
+ # adjust effects for every fieldmap in this dataset
1656
+ fmaps = plot.fieldmaps()
1657
+ fmaps.contour.flood_contour_group = plot.contour(0)
1658
+ fmaps.surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
1659
+
1660
+ eff = fmaps.effects
1661
+ eff.lighting_effect = LightingEffect.Paneled
1662
+ eff.surface_translucency = 30
1663
+
1664
+ # ensure consistent output between interactive (connected) and batch
1665
+ plot.contour(0).levels.reset_to_nice()
1666
+
1667
+ # save image to file
1668
+ tp.export.save_png('fieldmap_effects3d.png', 600, supersample=3)
1669
+
1670
+ .. figure:: /_static/images/fieldmap_effects3d.png
1671
+ :width: 300px
1672
+ :figwidth: 300px
1673
+ """
1674
+
1675
+ @property
1676
+ def lighting_effect(self):
1677
+ """`LightingEffect`: The type of lighting effect to render.
1678
+
1679
+ Possible values:
1680
+
1681
+ `Paneled <LightingEffect.Paneled>`
1682
+ Within each cell, the color assigned to each area by shading or
1683
+ contour flooding is tinted by a shade constant across the cell.
1684
+ This shade is based on the orientation of the cell relative to your
1685
+ 3D light source.
1686
+
1687
+ `Gouraud <LightingEffect.Gouraud>`
1688
+ This plot type offers smoother, more continuous shading than
1689
+ `Paneled <LightingEffect.Paneled>` shading, but it results in
1690
+ slower plotting and larger vector images. `Gouraud
1691
+ <LightingEffect.Gouraud>` shading is not continuous across zone
1692
+ boundaries unless face neighbors are specified in the data and is
1693
+ not available for finite element volume zones when blanking is
1694
+ active in which case, the zone's lighting effect reverts to
1695
+ `Paneled <LightingEffect.Paneled>` shading in this case.
1696
+
1697
+ If ``IJK``-ordered data with `FieldmapSurfaces.surfaces_to_plot` is set
1698
+ to `SurfacesToPlot.ExposedCellFaces`, faces exposed by blanking will
1699
+ revert to `Paneled <LightingEffect.Paneled>` shading.
1700
+
1701
+ Example usage::
1702
+
1703
+ >>> from tecplot.constant import LightingEffect
1704
+ >>> effects = plot.fieldmap(0).effects
1705
+ >>> effects.lighting_effect = LightingEffect.Paneled
1706
+ """
1707
+ return self._get_style(LightingEffect, sv.LIGHTINGEFFECT)
1708
+
1709
+ @lighting_effect.setter
1710
+ def lighting_effect(self, value):
1711
+ self._set_style(LightingEffect(value), sv.LIGHTINGEFFECT)
1712
+
1713
+ @property
1714
+ def use_translucency(self):
1715
+ """`bool`: Enable translucency of all drawn surfaces for this fieldmap.
1716
+
1717
+ This enables translucency controlled by the ``surface_translucency``
1718
+ attribute::
1719
+
1720
+ >>> effects = plot.fieldmap(0).effects
1721
+ >>> effects.use_translucency = True
1722
+ >>> effects.surface_translucency = 50
1723
+ """
1724
+ return self._get_style(bool, sv.USETRANSLUCENCY)
1725
+
1726
+ @use_translucency.setter
1727
+ def use_translucency(self, value):
1728
+ self._set_style(bool(value), sv.USETRANSLUCENCY)
1729
+
1730
+ @property
1731
+ def surface_translucency(self):
1732
+ """`int` Translucency of all surfaces for this fieldmap in percent.
1733
+
1734
+ The ``use_translucency`` attribute must be set to `True`::
1735
+
1736
+ >>> effects = plot.fieldmap(0).effects
1737
+ >>> effects.use_translucency = True
1738
+ >>> effects.surface_translucency = 50
1739
+ """
1740
+ return self._get_style(int, sv.SURFACETRANSLUCENCY)
1741
+
1742
+ @surface_translucency.setter
1743
+ def surface_translucency(self, value):
1744
+ self._set_style(int(value), sv.SURFACETRANSLUCENCY)
1745
+
1746
+ def _validate_clip_planes(self, indices=None):
1747
+ """Warn if clip planes are Arbitrary, I, J or K-plane orientation."""
1748
+ valid_orientations = set([SliceSurface.XPlanes,
1749
+ SliceSurface.YPlanes,
1750
+ SliceSurface.ZPlanes])
1751
+ if __debug__:
1752
+ indices = indices or self.clip_planes or []
1753
+ plot = self.fieldmap.plot
1754
+ for index in indices:
1755
+ if plot.slice(index).orientation not in valid_orientations:
1756
+ msg = 'Slice clipping only supported for X, Y and Z-planes.'
1757
+ warnings.warn(msg, TecplotWarning)
1758
+
1759
+ @property
1760
+ def clip_planes(self):
1761
+ """`list` of `integers <int>` [0-5]: Slice groups to use for clipping.
1762
+
1763
+ Only slice groups 0 to 5 are available for clipping. Example usage::
1764
+
1765
+ >>> plot.fieldmap(0).effects.clip_planes = [0, 1, 2]
1766
+
1767
+ .. seealso:: `SliceGroup.clip`
1768
+ """
1769
+ return self._get_style(list, sv.USECLIPPLANES) or None
1770
+
1771
+ @clip_planes.setter
1772
+ def clip_planes(self, values):
1773
+ if values is None:
1774
+ values = list()
1775
+ if not isinstance(values, Iterable):
1776
+ values = [values]
1777
+ indices = []
1778
+ for v in values:
1779
+ if hasattr(v, '_indices'):
1780
+ indices.extend(v._indices)
1781
+ else:
1782
+ indices.append(v)
1783
+ indices = sorted(set(indices))
1784
+ self._validate_clip_planes(indices)
1785
+ if __debug__:
1786
+ if any(i < 0 or 6 <= i for i in indices):
1787
+ msg = 'Slice clipping only supported for slice groups 0-5'
1788
+ raise TecplotIndexError(msg)
1789
+ self._set_style(indices, sv.USECLIPPLANES,
1790
+ **{sv.ASSIGNMODIFIER: AssignOp.Equals})
1791
+
1792
+
1793
+ class FieldmapShade(session.SubStyle):
1794
+ """Fill color for displayed surfaces on 2D field plots.
1795
+
1796
+ Although most commonly used with 3D surfaces (see `FieldmapShade3D`), shade
1797
+ plots can be used to flood 2D plots with solid colors.
1798
+
1799
+ .. code-block:: python
1800
+ :emphasize-lines: 19
1801
+
1802
+ import os
1803
+ import random
1804
+ import tecplot
1805
+ from tecplot.constant import Color, PlotType
1806
+
1807
+ random.seed(1)
1808
+
1809
+ examples_dir = tecplot.session.tecplot_examples_directory()
1810
+ datafile = os.path.join(examples_dir, 'SimpleData', 'F18.plt')
1811
+ dataset = tecplot.data.load_tecplot(datafile)
1812
+ frame = dataset.frame
1813
+ frame.plot_type = PlotType.Cartesian2D
1814
+ plot = frame.plot()
1815
+
1816
+ for zone in dataset.zones():
1817
+ color = Color(random.randint(0,63))
1818
+ while color == Color.White:
1819
+ color = Color(random.randint(0,63))
1820
+ plot.fieldmap(zone).shade.color = color
1821
+
1822
+ tecplot.export.save_png('fieldmap_shade2d.png', 600, supersample=3)
1823
+
1824
+ .. figure:: /_static/images/fieldmap_shade2d.png
1825
+ :width: 300px
1826
+ :figwidth: 300px
1827
+ """
1828
+ def __init__(self, fieldmap):
1829
+ super().__init__(fieldmap, sv.SHADE)
1830
+
1831
+ @property
1832
+ def show(self):
1833
+ """`bool`: FieldmapShade the drawn surfaces.
1834
+
1835
+ Example usage::
1836
+
1837
+ >>> plot.fieldmap(0).shade.show = False
1838
+ """
1839
+ return self._get_style(bool, sv.SHOW)
1840
+
1841
+ @show.setter
1842
+ def show(self, value):
1843
+ self._set_style(bool(value), sv.SHOW)
1844
+
1845
+ @property
1846
+ def color(self):
1847
+ """`Color`: Fill `Color` of the shade.
1848
+
1849
+ Example usage::
1850
+
1851
+ >>> from tecplot.constant import Color
1852
+ >>> plot.fieldmap(0).shade.color = Color.Blue
1853
+ """
1854
+ return self._get_style(Color, sv.COLOR)
1855
+
1856
+ @color.setter
1857
+ def color(self, value):
1858
+ self._set_style(Color(value), sv.COLOR)
1859
+
1860
+
1861
+ class FieldmapShade3D(FieldmapShade):
1862
+ """Fill color for displayed surfaces on 3D field plots.
1863
+
1864
+ This class inherits all functionality and purpose from `FieldmapShade` and
1865
+ adds the ability to turn on or off the lighting effect. In 3D plots,
1866
+ fieldmap effects (translucency and lighting) cause color variation
1867
+ (shading) throughout the zones. Shading can can be useful in discerning the
1868
+ shape of the data:
1869
+
1870
+ .. code-block:: python
1871
+ :emphasize-lines: 21-22
1872
+
1873
+ import os
1874
+ import random
1875
+ import tecplot
1876
+ from tecplot.constant import Color, PlotType, SurfacesToPlot
1877
+
1878
+ random.seed(1)
1879
+
1880
+ examples_dir = tecplot.session.tecplot_examples_directory()
1881
+ datafile = os.path.join(examples_dir, 'SimpleData', 'F18.plt')
1882
+ dataset = tecplot.data.load_tecplot(datafile)
1883
+ frame = dataset.frame
1884
+ frame.plot_type = PlotType.Cartesian3D
1885
+ plot = frame.plot()
1886
+
1887
+ for zone in dataset.zones():
1888
+ color = Color(random.randint(0,63))
1889
+ while color == Color.White:
1890
+ color = Color(random.randint(0,63))
1891
+ fmap = plot.fieldmap(zone)
1892
+ fmap.surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
1893
+ fmap.shade.color = color
1894
+ fmap.shade.use_lighting_effect = False
1895
+
1896
+ tecplot.export.save_png('fieldmap_shade3d.png', 600, supersample=3)
1897
+
1898
+
1899
+ .. figure:: /_static/images/fieldmap_shade3d.png
1900
+ :width: 300px
1901
+ :figwidth: 300px
1902
+ """
1903
+
1904
+ @property
1905
+ def use_lighting_effect(self):
1906
+ """`bool`: Draw a lighting effect on the shaded surfaces.
1907
+
1908
+ Example usage::
1909
+
1910
+ >>> plot.fieldmap(0).shade.use_lighting_effect = False
1911
+ """
1912
+ return self._get_style(bool, sv.USELIGHTINGEFFECT)
1913
+
1914
+ @use_lighting_effect.setter
1915
+ def use_lighting_effect(self, value):
1916
+ self._set_style(bool(value), sv.USELIGHTINGEFFECT)
1917
+
1918
+
1919
+ class Cartesian2DFieldmapCollection(FieldmapCollection):
1920
+ """Style control for one or more 2D fieldmaps.
1921
+
1922
+ This class behaves like `Cartesian2DFieldmap` except that setting any
1923
+ underlying style will do so for all of the represented fieldmaps. The
1924
+ style properties are then always returned as a `tuple` of properties,
1925
+ one for each fieldmap, ordered by index number. This means there is an
1926
+ asymmetry between setting and getting any property under this object,
1927
+ illustrated by the following example::
1928
+
1929
+ >>> fmaps = plot.fieldmaps(0, 1, 2)
1930
+ >>> fmaps.show = True
1931
+ >>> print(fmaps.show)
1932
+ (True, True, True)
1933
+
1934
+ This is the preferred way to control the style of many fieldmaps as it
1935
+ is much faster to execute. All examples that set style on a single
1936
+ fieldmap like the following::
1937
+
1938
+ >>> plot.fieldmap(0).contour.show = True
1939
+
1940
+ may be converted to setting the same style on all fieldmaps like so::
1941
+
1942
+ >>> plot.fieldmaps().contour.show = True
1943
+
1944
+
1945
+ .. seealso:: `Cartesian2DFieldmap`
1946
+
1947
+ .. versionadded:: 1.1
1948
+ Fieldmap collection objects.
1949
+ """
1950
+ def __getitem__(self, index):
1951
+ return Cartesian2DFieldmap(self.plot, self.fieldmap_indices[index])
1952
+
1953
+ @property
1954
+ def effects(self):
1955
+ """`FieldmapEffects`: Style control for clipping and blanking effects.
1956
+ """
1957
+ return FieldmapEffects(self)
1958
+
1959
+ @property
1960
+ def shade(self):
1961
+ """`FieldmapShade`: Style control for surface shading.
1962
+ """
1963
+ return FieldmapShade(self)
1964
+
1965
+ @property
1966
+ def show_iso_surfaces(self):
1967
+ tecutil.api_moved('Fieldmap.show_iso_surfaces',
1968
+ 'Cartesian3DFieldmap.show_isosurfaces',
1969
+ '1.2', '2020 R1', warning=True)
1970
+ fr = self.plot.frame
1971
+ fmap3d = fr.plot(PlotType.Cartesian3D).fieldmaps(self._indices)
1972
+ return fmap3d.show_isosurfaces
1973
+
1974
+ @show_iso_surfaces.setter
1975
+ def show_iso_surfaces(self, show):
1976
+ tecutil.api_moved('Fieldmap.show_iso_surfaces',
1977
+ 'Cartesian3DFieldmap.show_isosurfaces',
1978
+ '1.2', '2020 R1', warning=True)
1979
+ fr = self.plot.frame
1980
+ fmap3d = fr.plot(PlotType.Cartesian3D).fieldmaps(self._indices)
1981
+ fmap3d.show_isosurfaces = show
1982
+
1983
+ @property
1984
+ def show_slices(self):
1985
+ tecutil.api_moved('Fieldmap.show_slices',
1986
+ 'Cartesian3DFieldmap.show_slices',
1987
+ '1.2', '2020 R1', warning=True)
1988
+ fr = self.plot.frame
1989
+ fmap3d = fr.plot(PlotType.Cartesian3D).fieldmaps(self._indices)
1990
+ return fmap3d.show_slices
1991
+
1992
+ @show_slices.setter
1993
+ def show_slices(self, show):
1994
+ tecutil.api_moved('Fieldmap.show_slices',
1995
+ 'Cartesian3DFieldmap.show_slices',
1996
+ '1.2', '2020 R1', warning=True)
1997
+ fr = self.plot.frame
1998
+ fmap3d = fr.plot(PlotType.Cartesian3D).fieldmaps(self._indices)
1999
+ fmap3d.show_slices = show
2000
+
2001
+ @property
2002
+ def show_streamtraces(self):
2003
+ tecutil.api_moved('Fieldmap.show_streamtraces',
2004
+ 'Cartesian3DFieldmap.show_streamtraces',
2005
+ '1.2', '2020 R1', warning=True)
2006
+ fr = self.plot.frame
2007
+ fmap3d = fr.plot(PlotType.Cartesian3D).fieldmaps(self._indices)
2008
+ return fmap3d.show_streamtraces
2009
+
2010
+ @show_streamtraces.setter
2011
+ def show_streamtraces(self, show):
2012
+ tecutil.api_moved('Fieldmap.show_streamtraces',
2013
+ 'Cartesian3DFieldmap.show_streamtraces',
2014
+ '1.2', '2020 R1', warning=True)
2015
+ fr = self.plot.frame
2016
+ fmap3d = fr.plot(PlotType.Cartesian3D).fieldmaps(self._indices)
2017
+ fmap3d.show_streamtraces = show
2018
+
2019
+
2020
+ class Cartesian3DFieldmapCollection(FieldmapCollection):
2021
+ """Style control for one or more 3D fieldmaps.
2022
+
2023
+ This class behaves like `Cartesian3DFieldmap` except that setting any
2024
+ underlying style will do so for all of the represented fieldmaps. The
2025
+ style properties are then always returned as a `tuple` of properties,
2026
+ one for each fieldmap, ordered by index number. This means there is an
2027
+ asymmetry between setting and getting any property under this object,
2028
+ illustrated by the following example::
2029
+
2030
+ >>> fmaps = plot.fieldmaps(0, 1, 2)
2031
+ >>> fmaps.show = True
2032
+ >>> print(fmaps.show)
2033
+ (True, True, True)
2034
+
2035
+ This is the preferred way to control the style of many fieldmaps as it
2036
+ is much faster to execute. All examples that set style on a single
2037
+ fieldmap like the following::
2038
+
2039
+ >>> plot.fieldmap(0).contour.show = True
2040
+
2041
+ may be converted to setting the same style on all fieldmaps like so::
2042
+
2043
+ >>> plot.fieldmaps().contour.show = True
2044
+
2045
+ .. seealso:: `Cartesian3DFieldmap`
2046
+
2047
+ .. versionadded:: 1.1
2048
+ Fieldmap collection objects.
2049
+
2050
+ The following example illustrates manipulating the style for a selection of
2051
+ fieldmaps associated with specific zones:
2052
+
2053
+ .. code-block:: python
2054
+ :emphasize-lines: 15-17
2055
+
2056
+ import os
2057
+ import numpy
2058
+ import tecplot
2059
+
2060
+ examples_dir = tecplot.session.tecplot_examples_directory()
2061
+ infile = os.path.join(examples_dir, 'SimpleData', 'F18.lay')
2062
+ tecplot.load_layout(infile)
2063
+ frame = tecplot.active_frame()
2064
+ plot = frame.plot()
2065
+ dataset = frame.dataset
2066
+
2067
+ plot.contour(0).colormap_name = 'GrayScale'
2068
+ plot.contour(0).legend.show = False
2069
+
2070
+ wings = [dataset.zone(name) for name in ['left wing', 'right wing']]
2071
+ fmaps = frame.plot().fieldmaps(wings)
2072
+ fmaps.contour.flood_contour_group = plot.contour(1)
2073
+
2074
+ plot.contour(1).colormap_name = 'Sequential - Yellow/Green/Blue'
2075
+ plot.contour(1).levels.reset_levels(numpy.linspace(-0.07, 0.07, 50))
2076
+
2077
+ tecplot.export.save_png('F18_wings.png', 600, supersample=3)
2078
+
2079
+ .. figure:: /_static/images/F18_wings.png
2080
+ :width: 300px
2081
+ :figwidth: 300px
2082
+ """
2083
+ def __getitem__(self, index):
2084
+ return Cartesian3DFieldmap(self.plot, self.fieldmap_indices[index])
2085
+
2086
+ @property
2087
+ def effects(self):
2088
+ """`FieldmapEffects3D`: Style control for blanking and lighting effects.
2089
+ """
2090
+ return FieldmapEffects3D(self)
2091
+
2092
+ @property
2093
+ def shade(self):
2094
+ """`FieldmapShade3D`: Style control for surface shading.
2095
+ """
2096
+ return FieldmapShade3D(self)
2097
+
2098
+ @property
2099
+ def show_iso_surfaces(self):
2100
+ tecutil.api_moved('Fieldmap.show_iso_surfaces',
2101
+ 'Cartesian3DFieldmap.show_isosurfaces',
2102
+ '1.2', '2020 R1', warning=True)
2103
+ return self.show_isosurfaces
2104
+
2105
+ @show_iso_surfaces.setter
2106
+ def show_iso_surfaces(self, show):
2107
+ tecutil.api_moved('Fieldmap.show_iso_surfaces',
2108
+ 'Cartesian3DFieldmap.show_isosurfaces',
2109
+ '1.2', '2020 R1', warning=True)
2110
+ self.show_isosurfaces = show
2111
+
2112
+ @property
2113
+ def show_isosurfaces(self):
2114
+ """`bool`: Enable drawing of Iso-surfaces."""
2115
+ return self._get_style(bool, sv.VOLUMEMODE, sv.VOLUMEOBJECTSTOPLOT,
2116
+ sv.SHOWISOSURFACES)
2117
+
2118
+ @show_isosurfaces.setter
2119
+ def show_isosurfaces(self, show):
2120
+ self._set_style(bool(show), sv.VOLUMEMODE, sv.VOLUMEOBJECTSTOPLOT,
2121
+ sv.SHOWISOSURFACES)
2122
+
2123
+ @property
2124
+ def show_slices(self):
2125
+ """`bool`: Enable drawing of slice surfaces."""
2126
+ return self._get_style(bool, sv.VOLUMEMODE, sv.VOLUMEOBJECTSTOPLOT,
2127
+ sv.SHOWSLICES)
2128
+
2129
+ @show_slices.setter
2130
+ def show_slices(self, show):
2131
+ self._set_style(bool(show), sv.VOLUMEMODE, sv.VOLUMEOBJECTSTOPLOT,
2132
+ sv.SHOWSLICES)
2133
+
2134
+ @property
2135
+ def show_streamtraces(self):
2136
+ """`bool`: Enable drawing of streamtraces."""
2137
+ return self._get_style(bool, sv.VOLUMEMODE, sv.VOLUMEOBJECTSTOPLOT,
2138
+ sv.SHOWSTREAMTRACES)
2139
+
2140
+ @show_streamtraces.setter
2141
+ def show_streamtraces(self, show):
2142
+ self._set_style(bool(show), sv.VOLUMEMODE, sv.VOLUMEOBJECTSTOPLOT,
2143
+ sv.SHOWSTREAMTRACES)
2144
+
2145
+
2146
+ class Cartesian2DFieldmap(Fieldmap, Cartesian2DFieldmapCollection):
2147
+ """Style control for a single 2D fieldmap.
2148
+
2149
+ .. seealso:: `Cartesian2DFieldmapCollection`
2150
+ """
2151
+ pass
2152
+
2153
+
2154
+ class Cartesian3DFieldmap(Fieldmap, Cartesian3DFieldmapCollection):
2155
+ """Style control for a single 3D fieldmap.
2156
+
2157
+ .. seealso:: `Cartesian3DFieldmapCollection`
2158
+ """
2159
+ pass