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,1302 @@
1
+ from builtins import int, str, super
2
+
3
+ from ..tecutil import _tecutil
4
+ from ..constant import *
5
+ from ..exception import *
6
+ from .. import legend, session, tecutil, text
7
+ from ..tecutil import Index, flatten_args, lock, lock_attributes, sv
8
+
9
+
10
+ class ContourColormapOverride(session.Style):
11
+ """Assigns contour bands to specific color.
12
+
13
+ Specific contour bands can be assigned a unique basic color. This is useful
14
+ for forcing a particular region to use blue, for example, to designate an
15
+ area of water. You can define up to 16 color overrides:
16
+
17
+ .. code-block:: python
18
+ :emphasize-lines: 29,32-36
19
+
20
+ from os import path
21
+ import tecplot as tp
22
+ from tecplot.constant import *
23
+
24
+ # load the data
25
+ examples_dir = tp.session.tecplot_examples_directory()
26
+ datafile = path.join(examples_dir, 'SimpleData', 'HeatExchanger.plt')
27
+ dataset = tp.data.load_tecplot(datafile)
28
+
29
+ # set plot type to 2D field plot
30
+ frame = tp.active_frame()
31
+ frame.plot_type = PlotType.Cartesian2D
32
+ plot = frame.plot()
33
+
34
+ # show boundary faces and contours
35
+ surfaces = plot.fieldmap(0).surfaces
36
+ surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
37
+ plot.show_contour = True
38
+
39
+ # by default, contour 0 is the one that's shown,
40
+ # set the contour's variable, colormap and number of levels
41
+ contour = plot.contour(0)
42
+ contour.variable = dataset.variable('T(K)')
43
+ contour.colormap_name = 'Sequential - Yellow/Green/Blue'
44
+ contour.levels.reset(9)
45
+
46
+ # turn on colormap overrides for this contour
47
+ contour_filter = contour.colormap_filter
48
+ contour_filter.show_overrides = True
49
+
50
+ # turn on override 0, coloring the first 4 levels red
51
+ contour_override = contour_filter.override(0)
52
+ contour_override.show = True
53
+ contour_override.color = Color.Red
54
+ contour_override.start_level = 7
55
+ contour_override.end_level = 8
56
+
57
+ # save image to file
58
+ tp.export.save_png('contour_override.png', 600, supersample=3)
59
+
60
+ .. figure:: /_static/images/contour_override.png
61
+ :width: 300px
62
+ :figwidth: 300px
63
+ """
64
+ def __init__(self, index, colormap_filter):
65
+ self.index = Index(index)
66
+ self.colormap_filter = colormap_filter
67
+ super().__init__(colormap_filter._sv, sv.COLORMAPOVERRIDE,
68
+ **colormap_filter._kw)
69
+
70
+ @property
71
+ def show(self):
72
+ """`bool`: Include this colormap override when filter is shown.
73
+
74
+ Example usage::
75
+
76
+ >>> colormap_filter = plot.contour(0).colormap_filter
77
+ >>> cmap_override = colormap_filter.override(0)
78
+ >>> cmap_override.show = True
79
+ """
80
+ return self._get_style(bool, sv.INCLUDE)
81
+
82
+ @show.setter
83
+ def show(self, show):
84
+ self._set_style(bool(show), sv.INCLUDE)
85
+
86
+ @property
87
+ def color(self):
88
+ """`Color`: Color which will override the colormap.
89
+
90
+ Example usage::
91
+
92
+ >>> from tecplot.constant import Color
93
+ >>> colormap_filter = plot.contour(0).colormap_filter
94
+ >>> cmap_override = colormap_filter.override(0)
95
+ >>> cmap_override.color = Color.Blue
96
+ """
97
+ return self._get_style(Color, sv.COLOR)
98
+
99
+ @color.setter
100
+ def color(self,value):
101
+ self._set_style(Color(value), sv.COLOR)
102
+
103
+ @property
104
+ def start_level(self):
105
+ """`int`: First level to override.
106
+
107
+ Example usage::
108
+
109
+ >>> colormap_filter = plot.contour(0).colormap_filter
110
+ >>> cmap_override = colormap_filter.override(0)
111
+ >>> cmap_override.start_level = 2
112
+ """
113
+ return self._get_style(int, sv.STARTLEVEL)
114
+
115
+ @start_level.setter
116
+ def start_level(self,value):
117
+ self._set_style(int(value), sv.STARTLEVEL)
118
+
119
+ @property
120
+ def end_level(self):
121
+ """`int`: Last level to override.
122
+
123
+ Example usage::
124
+
125
+ >>> colormap_filter = plot.contour(0).colormap_filter
126
+ >>> cmap_override = colormap_filter.override(0)
127
+ >>> cmap_override.end_level = 2
128
+ """
129
+ return self._get_style(int, sv.ENDLEVEL)
130
+
131
+ @end_level.setter
132
+ def end_level(self,value):
133
+ self._set_style(int(value), sv.ENDLEVEL)
134
+
135
+
136
+ class ContourColormapZebraShade(session.Style):
137
+ """This filter sets a uniform color for every other band.
138
+
139
+ Setting the color to `None` turns the bands off and makes them
140
+ transparent:
141
+
142
+ .. code-block:: python
143
+ :emphasize-lines: 20-22
144
+
145
+ from os import path
146
+ import numpy as np
147
+ import tecplot as tp
148
+ from tecplot.constant import Color, SurfacesToPlot
149
+
150
+ # load the data
151
+ examples_dir = tp.session.tecplot_examples_directory()
152
+ datafile = path.join(examples_dir,'SimpleData','Pyramid.plt')
153
+ dataset = tp.data.load_tecplot(datafile)
154
+
155
+ # show boundary faces and contours
156
+ plot = tp.active_frame().plot()
157
+ surfaces = plot.fieldmap(0).surfaces
158
+ surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
159
+ plot.show_contour = True
160
+ plot.show_shade = False
161
+
162
+ # set zebra filter on and make the zebra contours transparent
163
+ cont0 = plot.contour(0)
164
+ zebra = cont0.colormap_filter.zebra_shade
165
+ zebra.show = True
166
+ zebra.transparent = True
167
+
168
+ # ensure consistent output between interactive (connected) and batch
169
+ cont0.levels.reset_to_nice()
170
+
171
+ tp.export.save_png('contour_zebra.png', 600, supersample=3)
172
+
173
+ .. figure:: /_static/images/contour_zebra.png
174
+ :width: 300px
175
+ :figwidth: 300px
176
+ """
177
+ def __init__(self, colormap_filter):
178
+ self.colormap_filter = colormap_filter
179
+ super().__init__(colormap_filter._sv, sv.ZEBRA,
180
+ uniqueid=self.colormap_filter.contour.plot.frame.uid,
181
+ offset1=self.colormap_filter.contour.index)
182
+
183
+ @property
184
+ def show(self):
185
+ """`bool`: Show zebra shading in this `ContourGroup`.
186
+
187
+ Example usage::
188
+
189
+ >>> cmap_filter = plot.contour(0).colormap_filter
190
+ >>> cmap_filter.zebra_shade.show = True
191
+ """
192
+ return self._get_style(bool, sv.INCLUDE)
193
+
194
+ @show.setter
195
+ def show(self,value):
196
+ self._set_style(bool(value), sv.INCLUDE)
197
+
198
+ @property
199
+ def color(self):
200
+ """`Color`: Color of the zebra shading.
201
+
202
+ Example usage::
203
+
204
+ >>> from tecplot.constant import Color
205
+ >>> filter = plot.contour(0).colormap_filter
206
+ >>> zebra = filter.zebra_shade
207
+ >>> zebra.show = True
208
+ >>> zebra.color = Color.Blue
209
+ """
210
+ return self._get_style(Color, sv.COLOR)
211
+
212
+ @color.setter
213
+ def color(self, value):
214
+ self._set_style(Color(value), sv.COLOR)
215
+
216
+ @property
217
+ def transparent(self):
218
+ """`bool`: Set the the zebra bands to be transparent.
219
+
220
+ Example usage::
221
+
222
+ >>> filter = plot.contour(0).colormap_filter
223
+ >>> zebra = filter.zebra_shade
224
+ >>> zebra.show = True
225
+ >>> zebra.transparent = True
226
+ """
227
+ return self._get_style(bool, sv.ISTRANSPARENT)
228
+
229
+ @transparent.setter
230
+ def transparent(self, value):
231
+ self._set_style(bool(value), sv.ISTRANSPARENT)
232
+
233
+
234
+ class ContourGroupStyle(session.Style):
235
+ def __init__(self, contour, *svargs):
236
+ kw = dict(uniqueid=contour.plot.frame.uid, offset1=contour.index)
237
+ super().__init__(contour._sv, *svargs, **kw)
238
+
239
+
240
+ class ContourColorCutoff(ContourGroupStyle):
241
+ """Color-mapped value limits to display.
242
+
243
+ This lets you specify a range within which contour flooding and
244
+ multi-colored objects, such as scatter symbols, are displayed:
245
+
246
+ .. code-block:: python
247
+ :emphasize-lines: 17-22
248
+
249
+ import os
250
+ import tecplot as tp
251
+ from tecplot.constant import PlotType, SurfacesToPlot
252
+
253
+ # load the data
254
+ examples_dir = tp.session.tecplot_examples_directory()
255
+ datafile = os.path.join(examples_dir,'SimpleData','Pyramid.plt')
256
+ dataset = tp.data.load_tecplot(datafile)
257
+
258
+ # show boundary faces and contours
259
+ plot = tp.active_frame().plot()
260
+ surfaces = plot.fieldmap(0).surfaces
261
+ surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
262
+ plot.show_contour = True
263
+
264
+ # cutoff contour flooding outside min/max range
265
+ cutoff = plot.contour(0).color_cutoff
266
+ cutoff.include_min = True
267
+ cutoff.min = 0.5
268
+ cutoff.include_max = True
269
+ cutoff.max = 1.0
270
+ cutoff.inverted = True
271
+
272
+ # ensure consistent output between interactive (connected) and batch
273
+ plot.contour(0).levels.reset_to_nice()
274
+
275
+ tp.export.save_png('contour_color_cutoff.png',600)
276
+
277
+ .. figure:: /_static/images/contour_color_cutoff.png
278
+ :width: 300px
279
+ :figwidth: 300px
280
+ """
281
+ def __init__(self, contour):
282
+ self.contour = contour
283
+ super().__init__(contour, sv.COLORCUTOFF)
284
+
285
+ @property
286
+ def include_min(self):
287
+ """`bool`: Use the minimum cutoff value.
288
+
289
+ Example usage::
290
+
291
+ >>> plot.contour(0).color_cutoff.include_min = True
292
+ >>> plot.contour(0).color_cutoff.min = 3.14
293
+ """
294
+ return self._get_style(bool, sv.INCLUDEMIN)
295
+
296
+ @include_min.setter
297
+ def include_min(self, value):
298
+ self._set_style(bool(value), sv.INCLUDEMIN)
299
+
300
+ @property
301
+ def include_max(self):
302
+ """`bool`: Use the maximum cutoff value.
303
+
304
+ Thie example turns off the maximum cutoff::
305
+
306
+ >>> plot.contour(0).color_cutoff.include_max = False
307
+ """
308
+ return self._get_style(bool, sv.INCLUDEMAX)
309
+
310
+ @include_max.setter
311
+ def include_max(self, value):
312
+ self._set_style(bool(value), sv.INCLUDEMAX)
313
+
314
+ @property
315
+ def min(self):
316
+ """`float` or `None`: The minimum cutoff value.
317
+
318
+ The ``include_min`` must be set to `True`::
319
+
320
+ >>> plot.contour(0).color_cutoff.include_min = True
321
+ >>> plot.contour(0).color_cutoff.min = 3.14
322
+ """
323
+ return self._get_style(float, sv.RANGEMIN)
324
+
325
+ @min.setter
326
+ def min(self,value):
327
+ self._set_style(float(value), sv.RANGEMIN)
328
+
329
+ @property
330
+ def max(self):
331
+ """`float` or `None`: The maximum cutoff value.
332
+
333
+ The ``include_max`` must be set to `True`::
334
+
335
+ >>> plot.contour(0).color_cutoff.include_max = True
336
+ >>> plot.contour(0).color_cutoff.max = None
337
+ """
338
+ return self._get_style(float, sv.RANGEMAX)
339
+
340
+ @max.setter
341
+ def max(self,value):
342
+ self._set_style(float(value), sv.RANGEMAX)
343
+
344
+ @property
345
+ def inverted(self):
346
+ """`bool`: Cuts values outside the range instead of inside.
347
+
348
+ .. code-block:: python
349
+
350
+ >>> plot.contour(0).color_cutoff.inverted = True
351
+ """
352
+ return self._get_style(bool, sv.INVERTCUTOFF)
353
+
354
+ @inverted.setter
355
+ def inverted(self,value):
356
+ self._set_style(bool(value), sv.INVERTCUTOFF)
357
+
358
+
359
+ class ContourColormapFilter(ContourGroupStyle):
360
+ """Controls how the colormap is rendered for a given contour.
361
+
362
+ .. code-block:: python
363
+ :emphasize-lines: 27-31
364
+
365
+ from os import path
366
+ import tecplot as tp
367
+ from tecplot.constant import *
368
+
369
+ # load the data
370
+ examples_dir = tp.session.tecplot_examples_directory()
371
+ datafile = path.join(examples_dir,'SimpleData','HeatExchanger.plt')
372
+ ds = tp.data.load_tecplot(datafile)
373
+
374
+ # set plot type to 2D field plot
375
+ frame = tp.active_frame()
376
+ frame.plot_type = PlotType.Cartesian2D
377
+ plot = frame.plot()
378
+
379
+ # show boundary faces and contours
380
+ surfaces = plot.fieldmap(0).surfaces
381
+ surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
382
+ plot.show_contour = True
383
+
384
+ # by default, contour 0 is the one that's shown,
385
+ # set the contour's variable, colormap and number of levels
386
+ contour = plot.contour(0)
387
+ contour.variable = ds.variable('P(N)')
388
+
389
+ # cycle through the colormap three times and reversed
390
+ # show a faithful (non-approximate) continuous distribution
391
+ contour_filter = contour.colormap_filter
392
+ contour_filter.num_cycles = 3
393
+ contour_filter.reversed = True
394
+ contour_filter.fast_continuous_flood = False
395
+ contour_filter.distribution = ColorMapDistribution.Continuous
396
+
397
+ # ensure consistent output between interactive (connected) and batch
398
+ contour.levels.reset_to_nice()
399
+
400
+ # save image to file
401
+ tp.export.save_png('contour_filtered.png', 600, supersample=3)
402
+
403
+ .. figure:: /_static/images/contour_filtered.png
404
+ :width: 300px
405
+ :figwidth: 300px
406
+ """
407
+ def __init__(self, contour):
408
+ self.contour = contour
409
+ super().__init__(self.contour, sv.COLORMAPFILTER)
410
+
411
+ def override(self, index):
412
+ """Returns a `ContourColormapOverride` object by index.
413
+
414
+ Parameters:
415
+ index (`int`): The index of the colormap override object.
416
+
417
+ Returns:
418
+ `ContourColormapOverride`: The class controlling the specific
419
+ contour colormap override requested by index.
420
+
421
+ Example::
422
+
423
+ >>> cmap_override = plot.contour(0).colormap_filter.override(0)
424
+ >>> cmap_override.show = True
425
+ """
426
+ return ContourColormapOverride(index, self)
427
+
428
+ @property
429
+ def zebra_shade(self):
430
+ """`ContourColormapZebraShade`: Returns a `ContourColormapZebraShade` filtering object.
431
+
432
+ Example usage::
433
+
434
+ >>> zebra = plot.contour(0).colormap_filter.zebra_shade
435
+ >>> zebra.show = True
436
+ """
437
+ return ContourColormapZebraShade(self)
438
+
439
+ @property
440
+ def show_overrides(self):
441
+ """`bool`: Enable the colormap overrides in this contour group.
442
+
443
+ The overrides themselves must be turned on as well for this
444
+ to have an effect on the resulting plot::
445
+
446
+ >>> contour = plot.contour(0)
447
+ >>> cmap_filter = contour.colormap_filter
448
+ >>> cmap_filter.show_overrides = True
449
+ >>> cmap_filter.override(0).show = True
450
+ """
451
+ return self._get_style(bool, sv.COLORMAPOVERRIDEACTIVE)
452
+
453
+ @show_overrides.setter
454
+ def show_overrides(self, show):
455
+ self._set_style(bool(show), sv.COLORMAPOVERRIDEACTIVE)
456
+
457
+ @property
458
+ def num_cycles(self):
459
+ """`int`: Number of cycles to repeat the colormap.
460
+
461
+ >>> plot.contour(0).colormap_filter.num_cycles = 3
462
+ """
463
+ return self._get_style(int, sv.COLORMAPCYCLES)
464
+
465
+ @num_cycles.setter
466
+ def num_cycles(self,value):
467
+ self._set_style(int(value), sv.COLORMAPCYCLES)
468
+
469
+ @property
470
+ def distribution(self):
471
+ """`ColorMapDistribution`: Rendering style of the colormap.
472
+
473
+ Possible values:
474
+
475
+ `Banded`
476
+ A solid color is assigned for all values within the band between
477
+ two levels.
478
+
479
+ `Continuous`
480
+ The color distribution assigns linearly varying colors to all
481
+ multi-colored objects or contour flooded regions.
482
+
483
+ Example::
484
+
485
+ >>> from tecplot.constant import ColorMapDistribution
486
+ >>> cmap_filter = plot.contour(0).colormap_filter
487
+ >>> cmap_filter.distribution = ColorMapDistribution.Banded
488
+ """
489
+ return self._get_style(ColorMapDistribution, sv.COLORMAPDISTRIBUTION)
490
+
491
+ @distribution.setter
492
+ def distribution(self,value):
493
+ self._set_style(ColorMapDistribution(value), sv.COLORMAPDISTRIBUTION)
494
+
495
+ @property
496
+ def reversed(self):
497
+ """`bool`: Reverse the colormap.
498
+
499
+ >>> plot.contour(0).colormap_filter.reversed = True
500
+ """
501
+ return self._get_style(bool, sv.REVERSECOLORMAP)
502
+
503
+ @reversed.setter
504
+ def reversed(self,value):
505
+ self._set_style(bool(value), sv.REVERSECOLORMAP)
506
+
507
+ @property
508
+ def fast_continuous_flood(self):
509
+ """`bool`: Use a fast approximation to continuously flood the colormap.
510
+
511
+ Causes each cell to be flooded using interpolation between the color
512
+ values at each node. When the transition from a color at one node to
513
+ another node crosses over the boundary between control points in the
514
+ color spectrum, fast flooding may produce colors not in the spectrum.
515
+ Setting this to `False` is slower, but more accurate::
516
+
517
+ >>> cmap_filter = plot.contour(0).colormap_filter
518
+ >>> cmap_filter.fast_continuous_flood = True
519
+ """
520
+ return self._get_style(bool, sv.USEFASTAPPROXCONTINUOUSFLOOD)
521
+
522
+ @fast_continuous_flood.setter
523
+ def fast_continuous_flood(self,value):
524
+ self._set_style(bool(value), sv.USEFASTAPPROXCONTINUOUSFLOOD)
525
+
526
+ @property
527
+ def continuous_min(self):
528
+ """`float`: Lower limit for continuous colormap flooding.
529
+
530
+ Example usage::
531
+
532
+ >>> from tecplot.constant import ColorMapDistribution
533
+ >>> cmap_filter = plot.contour(0).colormap_filter
534
+ >>> cmap_filter.distribution = ColorMapDistribution.Continuous
535
+ >>> cmap_filter.continuous_min = 3.1415
536
+ """
537
+ return self._get_style(float, sv.CONTINUOUSCOLOR, sv.CMIN)
538
+
539
+ @continuous_min.setter
540
+ def continuous_min(self, value):
541
+ self._set_style(float(value), sv.CONTINUOUSCOLOR, sv.CMIN)
542
+
543
+ @property
544
+ def continuous_max(self):
545
+ """`float`: Upper limit for continuous colormap flooding.
546
+
547
+ Example set the limits to the (min, max) of a variable in a specific
548
+ zone::
549
+
550
+ >>> from tecplot.constant import ColorMapDistribution
551
+ >>> cmap_filter = plot.contour(0).colormap_filter
552
+ >>> cmap_filter.distribution = ColorMapDistribution.Continuous
553
+ >>> pressure = dataset.variable('Pressure').values('My Zone')
554
+ >>> cmap_filter.continuous_min = pressure.min()
555
+ >>> cmap_filter.continuous_max = pressure.max()
556
+ """
557
+ return self._get_style(float, sv.CONTINUOUSCOLOR, sv.CMAX)
558
+
559
+ @continuous_max.setter
560
+ def continuous_max(self, value):
561
+ self._set_style(float(value), sv.CONTINUOUSCOLOR, sv.CMAX)
562
+
563
+
564
+ class ContourLabels(ContourGroupStyle):
565
+ """Contour line label style, position and alignment control.
566
+
567
+ These are labels that identify particular contour levels either by value or
568
+ optionally, by number starting from one. The plot type must be lines or
569
+ lines and flood in order to see them:
570
+
571
+ .. code-block:: python
572
+ :emphasize-lines: 18-23
573
+
574
+ from os import path
575
+ import tecplot as tp
576
+ from tecplot.constant import Color, ContourType, SurfacesToPlot
577
+
578
+ # load the data
579
+ examples_dir = tp.session.tecplot_examples_directory()
580
+ datafile = path.join(examples_dir,'SimpleData','Pyramid.plt')
581
+ dataset = tp.data.load_tecplot(datafile)
582
+
583
+ # show boundary faces and contours
584
+ plot = tp.active_frame().plot()
585
+ plot.fieldmap(0).contour.contour_type = ContourType.Lines
586
+ surfaces = plot.fieldmap(0).surfaces
587
+ surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
588
+ plot.show_contour = True
589
+
590
+ # set contour label style
591
+ contour_labels = plot.contour(0).labels
592
+ contour_labels.show = True
593
+ contour_labels.auto_align = False
594
+ contour_labels.color = Color.Blue
595
+ contour_labels.background_color = Color.White
596
+ contour_labels.margin = 20
597
+
598
+ # ensure consistent output between interactive (connected) and batch
599
+ plot.contour(0).levels.reset_to_nice()
600
+
601
+ tp.export.save_png('contour_labels.png', 600, supersample=3)
602
+
603
+ .. figure:: /_static/images/contour_labels.png
604
+ :width: 300px
605
+ :figwidth: 300px
606
+ """
607
+ def __init__(self, contour):
608
+ self.contour = contour
609
+ super().__init__(self.contour, sv.LABELS)
610
+
611
+ @property
612
+ def show(self):
613
+ """`bool`: Show the contour line labels.
614
+
615
+ Contour lines must be on for this to have any effect::
616
+
617
+ >>> from tecplot.constant import ContourType
618
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
619
+ >>> plot.contour(0).labels.show = True
620
+ """
621
+ return self._get_style(bool, sv.SHOW)
622
+
623
+ @show.setter
624
+ def show(self,value):
625
+ self._set_style(bool(value), sv.SHOW)
626
+
627
+ @property
628
+ def auto_align(self):
629
+ """`bool`: Automatically align the labels with the contour lines.
630
+
631
+ This causes the flow of the text to be aligned with the contour lines.
632
+ Otherwise, the labels are aligned with the frame::
633
+
634
+ >>> from tecplot.constant import ContourType
635
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
636
+ >>> plot.contour(0).labels.show = True
637
+ >>> plot.contour(0).labels.auto_align = False
638
+ """
639
+ return self._get_style(bool, sv.ALIGNAUTOLABELS)
640
+
641
+ @auto_align.setter
642
+ def auto_align(self,value):
643
+ self._set_style(bool(value), sv.ALIGNAUTOLABELS)
644
+
645
+ @property
646
+ def spacing(self):
647
+ """`float`: Spacing between labels along the contour lines.
648
+
649
+ This is the distance between each label along each contour line
650
+ in percentage of the frame height::
651
+
652
+ >>> from tecplot.constant import ContourType
653
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
654
+ >>> plot.contour(0).labels.show = True
655
+ >>> plot.contour(0).labels.spacing = 20
656
+ """
657
+ return self._get_style(float, sv.AUTOLABELSPACING)
658
+
659
+ @spacing.setter
660
+ def spacing(self,value):
661
+ self._set_style(float(value), sv.AUTOLABELSPACING)
662
+
663
+ @property
664
+ def step(self):
665
+ """`int`: Number of contour lines from one label to the next.
666
+
667
+ This is the number of contour bands between lines that are to be
668
+ labeled::
669
+
670
+ >>> from tecplot.constant import ContourType
671
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
672
+ >>> plot.contour(0).labels.show = True
673
+ >>> plot.contour(0).labels.step = 4
674
+ """
675
+ return self._get_style(int, sv.AUTOLEVELSKIP)
676
+
677
+ @step.setter
678
+ def step(self,value):
679
+ self._set_style(int(value), sv.AUTOLEVELSKIP)
680
+
681
+ @property
682
+ def font(self):
683
+ """`text.Font`: `text.Font` used to show the labels.
684
+
685
+ Example::
686
+
687
+ >>> from tecplot.constant import Color, ContourType
688
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
689
+ >>> plot.contour(0).labels.show = True
690
+ >>> plot.contour(0).labels.font.size = 3.5
691
+ """
692
+ return text.Font(self)
693
+
694
+ @property
695
+ def color(self):
696
+ """`Color`: Text color of the labels.
697
+
698
+ Example::
699
+
700
+ >>> from tecplot.constant import Color, ContourType
701
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
702
+ >>> plot.contour(0).labels.show = True
703
+ >>> plot.contour(0).labels.color Color.Blue
704
+ """
705
+ return self._get_style(Color, sv.COLOR)
706
+
707
+ @color.setter
708
+ def color(self,value):
709
+ self._set_style(Color(value), sv.COLOR)
710
+
711
+ @property
712
+ def filled(self):
713
+ """`bool`: Fill the background area behind the text labels.
714
+
715
+ The background can be filled with a color or disabled (made
716
+ transparent) by setting this property to `False`::
717
+
718
+ >>> from tecplot.constant import Color, ContourType
719
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
720
+ >>> plot.contour(0).labels.show = True
721
+ >>> plot.contour(0).labels.filled = True
722
+ >>> plot.contour(0).labels.background_color = Color.Blue
723
+ >>> plot.contour(1).labels.show = True
724
+ >>> plot.contour(1).labels.filled = False
725
+ """
726
+ return self._get_style(bool, sv.ISFILLED)
727
+
728
+ @filled.setter
729
+ def filled(self, value):
730
+ self._set_style(bool(value), sv.ISFILLED)
731
+
732
+ @property
733
+ def background_color(self):
734
+ """`Color`: Background fill color behind the text labels.
735
+
736
+ The ``filled`` attribute must be set to `True`::
737
+
738
+ >>> from tecplot.constant import Color, ContourType
739
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
740
+ >>> plot.contour(0).labels.show = True
741
+ >>> plot.contour(0).labels.background_color = Color.Blue
742
+ """
743
+ return self._get_style(Color, sv.FILLCOLOR)
744
+ @background_color.setter
745
+ def background_color(self,value):
746
+ self._set_style(Color(value), sv.FILLCOLOR)
747
+
748
+ @property
749
+ def auto_generate(self):
750
+ """`bool`: Automatically generate labels along contour lines.
751
+
752
+ This causes a new set of contour labels to be created at each redraw::
753
+
754
+ >>> from tecplot.constant import Color, ContourType
755
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
756
+ >>> plot.contour(0).labels.show = True
757
+ >>> plot.contour(0).labels.auto_generate = True
758
+ """
759
+ return self._get_style(bool, sv.GENERATEAUTOLABELS)
760
+
761
+ @auto_generate.setter
762
+ def auto_generate(self,value):
763
+ self._set_style(bool(value), sv.GENERATEAUTOLABELS)
764
+
765
+ @property
766
+ def label_by_level(self):
767
+ """`bool`: Use the contour numbers as the label instead of the data value.
768
+
769
+ Contour level numbers start from one when drawn. Example usage::
770
+
771
+ >>> from tecplot.constant import Color, ContourType
772
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
773
+ >>> plot.contour(0).labels.show = True
774
+ >>> plot.contour(0).labels.label_by_level = True
775
+ """
776
+ return not self._get_style(bool, sv.LABELWITHVALUE)
777
+
778
+ @label_by_level.setter
779
+ def label_by_level(self,value):
780
+ self._set_style(not bool(value), sv.LABELWITHVALUE)
781
+
782
+ @property
783
+ def margin(self):
784
+ """`float` in percentage of the text height.: Spacing around the text and the filled background area.
785
+
786
+ Contour numbers start from one when drawn. Example usage::
787
+
788
+ >>> from tecplot.constant import Color, ContourType
789
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
790
+ >>> plot.contour(0).labels.show = True
791
+ >>> plot.contour(0).labels.background_color = Color.Yellow
792
+ >>> plot.contour(0).labels.margin = 20
793
+ """
794
+ return self._get_style(float, sv.MARGIN)
795
+
796
+ @margin.setter
797
+ def margin(self,value):
798
+ self._set_style(float(value), sv.MARGIN)
799
+
800
+ @property
801
+ def format(self):
802
+ """`LabelFormat`: Number formatting for contour labels.
803
+
804
+ Example usage::
805
+
806
+ >>> from tecplot.constant import NumberFormat
807
+ >>> contour = plot.contour(0)
808
+ >>> contour.labels.format.format_type = NumberFormat.Integer
809
+ """
810
+ return text.LabelFormat(self)
811
+
812
+
813
+ @lock_attributes
814
+ class ContourLevels(object):
815
+ """List of contour level values.
816
+
817
+ A contour level is a value at which contour lines are drawn, or for banded
818
+ contour flooding, the border between different colors of flooding.
819
+ Initially, each contour group consists of approximately 10 levels evenly
820
+ spaced over the *z* coordinate in the `Frame <layout.Frame>`'s `Dataset <data.Dataset>`. These values can
821
+ be manipulated with the `ContourLevels` object obtained via the
822
+ `ContourGroup.levels` attribute:
823
+
824
+ .. code-block:: python
825
+ :emphasize-lines: 11-12
826
+
827
+ from os import path
828
+ import numpy as np
829
+ import tecplot as tp
830
+
831
+ # load layout
832
+ examples_dir = tp.session.tecplot_examples_directory()
833
+ example_layout = path.join(examples_dir,'SimpleData','3ElementWing.lpk')
834
+ tp.load_layout(example_layout)
835
+ frame = tp.active_frame()
836
+
837
+ levels = frame.plot().contour(0).levels
838
+ levels.reset_levels(np.linspace(55000,115000,61))
839
+
840
+ # save image to file
841
+ tp.export.save_png('contour_adjusted_levels.png', 600, supersample=3)
842
+
843
+ .. figure:: /_static/images/contour_adjusted_levels.png
844
+ :width: 300px
845
+ :figwidth: 300px
846
+
847
+ .. note::
848
+
849
+ The streamtraces in the plot above is a side-effect of settings in
850
+ layout file used. For more information about streamtraces, see the
851
+ `plot.Streamtraces` class reference.
852
+ """
853
+ def __init__(self, contour):
854
+ self.contour = contour
855
+
856
+ @lock()
857
+ def _ContourLevelX(self, arglist):
858
+ arglist[sv.CONTOURGROUP] = self.contour.index+1
859
+ with self.contour.plot.frame.activated():
860
+ _tecutil.ContourLevelX(arglist)
861
+
862
+ def _data(self):
863
+ with self.contour.plot.frame.activated():
864
+ success,n,values = _tecutil.ContourGetLevels(self.contour.index+1)
865
+ if not success:
866
+ raise TecplotLogicError('Could not query contour levels.')
867
+ return [values[i] for i in range(n)]
868
+
869
+ def __len__(self):
870
+ return len(self._data())
871
+
872
+ def __iter__(self):
873
+ for i in self._data():
874
+ yield i
875
+
876
+ def __getitem__(self,i):
877
+ return self._data()[i]
878
+
879
+ def add(self, *values):
880
+ """Adds new levels to the existing list.
881
+
882
+ Parameters:
883
+ *values (`floats <float>`): The level values to be added to the
884
+ `ContourGroup`.
885
+
886
+ The values added are inserted into the list of levels in ascending
887
+ order::
888
+
889
+ >>> levels = plot.contour(0).levels
890
+ >>> list(levels)
891
+ [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
892
+ >>> levels.add(3.14159)
893
+ >>> list(levels)
894
+ [0.0, 1.0, 2.0, 3.0, 3.14159, 4.0, 5.0]
895
+ """
896
+ values = flatten_args(*values)
897
+ with tecutil.ArgList() as arglist:
898
+ arglist[sv.CONTOURLEVELACTION] = ContourLevelAction.Add
899
+ arglist[sv.NUMVALUES] = len(values)
900
+ arglist[sv.RAWDATA] = map(float, values)
901
+ self._ContourLevelX(arglist)
902
+
903
+ def reset(self, num_levels=15):
904
+ """Resets the levels to the number specified.
905
+
906
+ Parameters:
907
+ num_levels (`int`): Number of levels. (default: 10)
908
+
909
+ This will reset the contour levels to a set of evenly
910
+ distributed values spanning the entire range of the currently
911
+ selected contouring variable::
912
+
913
+ >>> plot.contour(0).levels.reset(30)
914
+ """
915
+ with tecutil.ArgList() as arglist:
916
+ arglist[sv.CONTOURLEVELACTION] = ContourLevelAction.Reset
917
+ arglist[sv.NUMVALUES] = int(num_levels)
918
+ self._ContourLevelX(arglist)
919
+
920
+ def reset_levels(self, *values):
921
+ """Resets the levels to the values specified.
922
+
923
+ Parameters:
924
+ *values (`floats <float>`): The level values to be added to the
925
+ `ContourGroup`.
926
+
927
+ This method replaces the current set of contour levels with a new set.
928
+ Here, we set the levels to go from 0 to 100 in steps of 5::
929
+
930
+ >>> plot.contour(0).levels.reset_levels(*range(0,101,5))
931
+ """
932
+ values = flatten_args(*values)
933
+ with tecutil.ArgList() as arglist:
934
+ arglist[sv.CONTOURLEVELACTION] = ContourLevelAction.New
935
+ arglist[sv.NUMVALUES] = len(values)
936
+ arglist[sv.RAWDATA] = map(float, values)
937
+ self._ContourLevelX(arglist)
938
+
939
+ def reset_to_nice(self, num_levels=15):
940
+ """Approximately resets the levels to the number specified.
941
+
942
+ Parameters:
943
+ num_levels (`int`): Approximate number of levels to
944
+ create. (default: 15)
945
+
946
+ This will reset the contour levels to a set of evenly distributed
947
+ values that approximately spans the range of the currently selected
948
+ contouring variable. Exact range and number of levels will be
949
+ adjusted to make the contour levels have "nice" values::
950
+
951
+ >>> plot.contour(0).levels.reset_to_nice(50)
952
+ """
953
+ with tecutil.ArgList() as arglist:
954
+ arglist[sv.CONTOURLEVELACTION] = ContourLevelAction.ResetToNice
955
+ arglist[sv.APPROXNUMVALUES] = int(num_levels)
956
+ self._ContourLevelX(arglist)
957
+
958
+ def delete_range(self, min_value, max_value):
959
+ """Inclusively, deletes all levels within a specified range.
960
+
961
+ Parameters:
962
+ min_value (`float`): Minimum value to remove.
963
+ max_value (`float`): Maximum value to remove.
964
+
965
+ This method deletes all contour levels between the specified minimum
966
+ and maximum values of the contour variable (inclusive)::
967
+
968
+ >>> plot.contour(0).levels.delete_range(0.5, 1.5)
969
+ """
970
+ with tecutil.ArgList() as arglist:
971
+ arglist[sv.CONTOURLEVELACTION] = ContourLevelAction.DeleteRange
972
+ arglist[sv.RANGEMIN] = float(min_value)
973
+ arglist[sv.RANGEMAX] = float(max_value)
974
+ self._ContourLevelX(arglist)
975
+
976
+ def delete_nearest(self, value):
977
+ """Removes the level closest to the specified value.
978
+
979
+ Parameters:
980
+ value (`float`): Value of the level to remove.
981
+
982
+ This method deletes the contour level with the value nearest the
983
+ supplied value::
984
+
985
+ >>> plot.contour(0).levels.delete_nearest(3.14)
986
+ """
987
+ with tecutil.ArgList() as arglist:
988
+ arglist[sv.CONTOURLEVELACTION] = ContourLevelAction.DeleteNearest
989
+ arglist[sv.RANGEMIN] = float(value)
990
+ self._ContourLevelX(arglist)
991
+
992
+
993
+ class ContourLines(ContourGroupStyle):
994
+ """Contour line style.
995
+
996
+ This object sets the style of the contour lines once turned on:
997
+
998
+ .. code-block:: python
999
+ :emphasize-lines: 19-22
1000
+
1001
+ from os import path
1002
+ import tecplot as tp
1003
+ from tecplot.constant import (ContourLineMode, ContourType,
1004
+ SurfacesToPlot)
1005
+
1006
+ # load the data
1007
+ examples_dir = tp.session.tecplot_examples_directory()
1008
+ datafile = path.join(examples_dir,'SimpleData','Pyramid.plt')
1009
+ dataset = tp.data.load_tecplot(datafile)
1010
+
1011
+ # show boundary faces and contours
1012
+ plot = tp.active_frame().plot()
1013
+ plot.fieldmap(0).contour.contour_type = ContourType.Lines
1014
+ surfaces = plot.fieldmap(0).surfaces
1015
+ surfaces.surfaces_to_plot = SurfacesToPlot.BoundaryFaces
1016
+ plot.show_contour = True
1017
+
1018
+ # set contour line style
1019
+ contour_lines = plot.contour(0).lines
1020
+ contour_lines.mode = ContourLineMode.SkipToSolid
1021
+ contour_lines.step = 4
1022
+ contour_lines.pattern_length = 2
1023
+
1024
+ # ensure consistent output between interactive (connected) and batch
1025
+ plot.contour(0).levels.reset_to_nice()
1026
+
1027
+ tp.export.save_png('contour_lines.png', 600, supersample=3)
1028
+
1029
+ .. figure:: /_static/images/contour_lines.png
1030
+ :width: 300px
1031
+ :figwidth: 300px
1032
+ """
1033
+ def __init__(self, contour):
1034
+ self.contour = contour
1035
+ super().__init__(self.contour, sv.CONTOURLINESTYLE)
1036
+
1037
+ @property
1038
+ def mode(self):
1039
+ """`ContourLineMode`: Type of lines to draw on the plot (`ContourLineMode`).
1040
+
1041
+ Possible values:
1042
+
1043
+ `UseZoneLineType`
1044
+ For each zone, draw the contour lines using the line pattern
1045
+ and pattern length specified in the `FieldmapContour` for the
1046
+ parent `Fieldmap`. If you are adding contour lines to
1047
+ polyhedral zones, the patterns will not be continuous from one
1048
+ cell to the next and the pattern will restart at every cell
1049
+ boundary.
1050
+ `SkipToSolid`
1051
+ Draw dashed lines between each pair of solid lines which are
1052
+ spaced out by the `ContourLines.step` property. This will
1053
+ override any line pattern or thickness setting in the parent
1054
+ `Fieldmap`'s `FieldmapContour` object.
1055
+ `DashNegative`
1056
+ Draw lines of positive contour variable value as solid lines
1057
+ and lines of negative contour variable value as dashed lines.
1058
+ This will override any line pattern or thickness setting in the
1059
+ parent `Fieldmap`'s `FieldmapContour` object.
1060
+
1061
+ Example::
1062
+
1063
+ >>> from tecplot.constant import ContourLineMode
1064
+ >>> lines = plot.contour(0).lines
1065
+ >>> lines.mode = ContourLineMode.DashNegative
1066
+ """
1067
+ return self._get_style(ContourLineMode, sv.CONTOURLINEMODE)
1068
+
1069
+ @mode.setter
1070
+ def mode(self,value):
1071
+ self._set_style(ContourLineMode(value), sv.CONTOURLINEMODE)
1072
+
1073
+ @property
1074
+ def step(self):
1075
+ """`int`: Number of lines to step for `SkipToSolid` line mode (`int`).
1076
+
1077
+ Example::
1078
+
1079
+ >>> from tecplot.constant import ContourLineMode
1080
+ >>> lines = plot.contour(0).lines
1081
+ >>> lines.mode = ContourLineMode.SkipToSolid
1082
+ >>> lines.step = 5
1083
+ """
1084
+ return self._get_style(int, sv.LINESKIP)
1085
+
1086
+ @step.setter
1087
+ def step(self,value):
1088
+ self._set_style(int(value), sv.LINESKIP)
1089
+
1090
+ @property
1091
+ def pattern_length(self):
1092
+ """`float`: Length of dashed lines and space between dashes (`float`).
1093
+
1094
+ The length is in percentage of the frame height::
1095
+
1096
+ >>> from tecplot.constant import ContourLineMode
1097
+ >>> lines = plot.contour(0).lines
1098
+ >>> lines.mode = ContourLineMode.SkipToSolid
1099
+ >>> lines.step = 5
1100
+ >>> lines.pattern_length = 5
1101
+ """
1102
+ return self._get_style(float, sv.PATTERNLENGTH)
1103
+
1104
+ @pattern_length.setter
1105
+ def pattern_length(self,value):
1106
+ self._set_style(float(value), sv.PATTERNLENGTH)
1107
+
1108
+
1109
+ class ContourGroup(session.Style):
1110
+ """Contouring of a variable using a colormap.
1111
+
1112
+ This object controls the style for a specific contour group within
1113
+ a `Frame <layout.Frame>`. Contour levels, colormap and contour lines are accessed
1114
+ through this class:
1115
+
1116
+ .. code-block:: python
1117
+ :emphasize-lines: 10-14
1118
+
1119
+ from os import path
1120
+ import tecplot as tp
1121
+ from tecplot.constant import *
1122
+
1123
+ # load data
1124
+ examples_dir = tp.session.tecplot_examples_directory()
1125
+ datafile = path.join(examples_dir,'SimpleData','CircularContour.plt')
1126
+ dataset = tp.data.load_tecplot(datafile)
1127
+ plot = dataset.frame.plot()
1128
+ plot.show_contour = True
1129
+
1130
+ contour = plot.contour(0)
1131
+ contour.variable = dataset.variable('Mix')
1132
+ contour.colormap_name = 'Magma'
1133
+
1134
+ # ensure consistent output between interactive (connected) and batch
1135
+ contour.levels.reset_to_nice()
1136
+
1137
+ # save image to file
1138
+ tp.export.save_png('contour_magma.png', 600, supersample=3)
1139
+
1140
+ .. figure:: /_static/images/contour_magma.png
1141
+ :width: 300px
1142
+ :figwidth: 300px
1143
+
1144
+ There are a fixed number of contour groups available for each plot. Others
1145
+ can be enabled and modified by specifying an index other than zero::
1146
+
1147
+ >>> contour3 = plot.contour(3)
1148
+ >>> contour3.variable = dataset.variable('U')
1149
+ """
1150
+ def __init__(self, index, plot):
1151
+ if __debug__:
1152
+ assert 0 <= index < 8, 'Contour index out of range (must be < 8)'
1153
+ self.index = Index(index)
1154
+ self.plot = plot
1155
+ super().__init__(sv.GLOBALCONTOUR, uniqueid=self.plot.frame.uid,
1156
+ offset1=self.index)
1157
+
1158
+ def __eq__(self, obj):
1159
+ return (self.index == obj.index) and (self.plot == obj.plot)
1160
+
1161
+ @property
1162
+ def variable_index(self):
1163
+ """Zero-based index of the `Variable` being contoured.
1164
+
1165
+ .. code-block:: python
1166
+
1167
+ >>> plot.contour(0).variable_index = dataset.variable('P').index
1168
+
1169
+ The `Dataset <data.Dataset>` attached to this contour group's `Frame <layout.Frame>` is used::
1170
+
1171
+ >>> contour = plot.contour(0)
1172
+ >>> contour_var = frame.dataset.variable(contour.variable_index)
1173
+ >>> contour_var.index == contour.variable_index
1174
+ True
1175
+ """
1176
+ return self._get_style(Index, sv.VAR)
1177
+
1178
+ @variable_index.setter
1179
+ def variable_index(self, index):
1180
+ # Use the TecUtil X function to set the variable.
1181
+ # By using the X function to set the contour variable, we can set
1182
+ # the initialization mode to 'NiceResetLevels",
1183
+ # which is the GUI default.
1184
+ with lock():
1185
+ with tecutil.ArgList() as arglist:
1186
+ arglist[sv.VAR] = index + 1
1187
+ arglist[sv.CONTOURGROUP] = self.index + 1
1188
+ arglist[sv.LEVELINITMODE] = \
1189
+ ContourLevelsInitializationMode.NiceResetLevels
1190
+ if not _tecutil.ContourSetVariableX(arglist):
1191
+ raise TecplotSystemError()
1192
+
1193
+ @property
1194
+ def variable(self):
1195
+ """The `Variable` being contoured.
1196
+
1197
+ The variable must belong to the `Dataset <data.Dataset>` attached to the `Frame <layout.Frame>`
1198
+ that holds this `ContourGroup`. Example usage::
1199
+
1200
+ >>> plot.contour(0).variable = dataset.variable('P')
1201
+ """
1202
+ return self.plot.frame.dataset.variable(self.variable_index)
1203
+
1204
+ @variable.setter
1205
+ def variable(self, variable):
1206
+ if __debug__:
1207
+ if variable not in self.plot.frame.dataset:
1208
+ raise TecplotLogicError('Variable not in dataset.')
1209
+ self.variable_index = variable.index
1210
+
1211
+ @property
1212
+ def color_cutoff(self):
1213
+ """`ContourColorCutoff`: `ContourColorCutoff` object controlling color cutoff min/max.
1214
+
1215
+ >>> cutoff = plot.contour(0).color_cutoff
1216
+ >>> cutoff.min = 3.14
1217
+ """
1218
+ return ContourColorCutoff(self)
1219
+
1220
+ @property
1221
+ def colormap_filter(self):
1222
+ """`ContourColormapFilter`: `ContourColormapFilter` object controlling colormap style properties.
1223
+
1224
+ >>> plot.contour(0).colormap_filter.reverse = True
1225
+ """
1226
+ return ContourColormapFilter(self)
1227
+
1228
+ @property
1229
+ def labels(self):
1230
+ """`ContourLabels`: `ContourLabels` object controlling contour line labels.
1231
+
1232
+ Lines must be turned on through the associated fieldmap object
1233
+ for style changes to be meaningful::
1234
+
1235
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
1236
+ >>> plot.contour(0).labels.show = True
1237
+ """
1238
+ return ContourLabels(self)
1239
+
1240
+ @property
1241
+ def legend(self):
1242
+ """`ContourLegend`: `ContourLegend` associated with this `ContourGroup`.
1243
+
1244
+ This object controls the attributes of the contour legend associated
1245
+ with this `ContourGroup`.
1246
+
1247
+ Example usage::
1248
+
1249
+ >>> plot.contour(0).legend.show = True
1250
+ """
1251
+ return legend.ContourLegend(self)
1252
+
1253
+ @property
1254
+ def levels(self):
1255
+ """`ContourLevels`: `ContourLevels` holding the list of contour levels.
1256
+
1257
+ This object controls the values of the contour levels. Values can
1258
+ be added, deleted or overridden completely::
1259
+
1260
+ >>> plot.contour(0).levels.reset_to_nice(15)
1261
+ """
1262
+ return ContourLevels(self)
1263
+
1264
+ @property
1265
+ def lines(self):
1266
+ """`ContourLines`: `ContourLines` object controlling contour line style.
1267
+
1268
+ Lines must be turned on through the associated fieldmap object
1269
+ for style changes to be meaningful::
1270
+
1271
+ >>> plot.fieldmap(0).contour.contour_type = ContourType.Lines
1272
+ >>> plot.contour(0).lines.mode = ContourLineMode.DashNegative
1273
+ """
1274
+ return ContourLines(self)
1275
+
1276
+ @property
1277
+ def default_num_levels(self):
1278
+ """`int`: Default target number (`int`) of levels used when resetting.
1279
+
1280
+ Example::
1281
+
1282
+ >>> plot.contour(0).default_num_levels = 20
1283
+ """
1284
+ return self._get_style(int, sv.DEFNUMLEVELS)
1285
+
1286
+ @default_num_levels.setter
1287
+ def default_num_levels(self, value):
1288
+ self._set_style(int(value), sv.DEFNUMLEVELS)
1289
+
1290
+ @property
1291
+ def colormap_name(self):
1292
+ """`str`: The name of the colormap (`str`) to be used.
1293
+
1294
+ Example::
1295
+
1296
+ >>> plot.contour(0).colormap_name = 'Sequential - Yellow/Green/Blue'
1297
+ """
1298
+ return self._get_style(str, sv.COLORMAPNAME)
1299
+
1300
+ @colormap_name.setter
1301
+ def colormap_name(self,value):
1302
+ self._set_style(str(value), sv.COLORMAPNAME)