Tecplot Tips

Extract Images

===========================

import os
os.chdir(r'F:\images\planes-bend')

import glob
flist=glob.glob('*planes.plt')

#flist = flist[0:5] # just for testing on 5 files and not all of them!
import tecplot as tp
from tecplot.exception import *
from tecplot.constant import *
# Uncomment the following line to connect to a running instance of Tecplot 360:
tp.session.connect()

#fname = 'p0.01_b0.02_planes.plt'
# 1. Load Data
for fname in flist: 
dataset = tp.data.load_tecplot(f'{fname}', read_data_option=2) 
# 3D view
plot = tp.active_frame().plot(PlotType.Cartesian3D)
plot.activate()

tp.active_frame().plot().fieldmap(0).show=True #inlet contour
tp.active_frame().plot().fieldmap(1).show=False
tp.active_frame().plot().fieldmap(2).show=False
tp.active_frame().plot().fieldmap(3).show=False
tp.active_frame().plot().fieldmap(4).show=False

bendName = [f'{fname[:-4]}_bendInlet',f'{fname[:-4]}_bend225',f'{fname[:-4]}_bend450',f'{fname[:-4]}_bend675',f'{fname[:-4]}_bendOutlet']
#select contour
tp.active_frame().plot().show_contour=True

#to show pressure set index to 4
#to show vel mag set index to 3 based on results file
tp.active_frame().plot().contour(0).variable_index=3 

tp.active_frame().plot().contour(0).legend.show=False
# tp.active_frame().plot().contour(0).colormap_name='Modified Rainbow - Dark ends'
#tp.active_frame().plot().contour(0).colormap_name='Diverging - Blue/Red'
tp.active_frame().plot().contour(0).colormap_name='Hot Metal'

tp.active_frame().plot().contour(0).levels.reset_to_nice(num_levels=81)
tp.active_frame().plot().axes.orientation_axis.show=False
tp.macro.execute_command('$!FrameLayout ShowBorder = No')

tp.active_frame().plot().show_shade=False
tp.active_frame().plot(PlotType.Cartesian3D).use_lighting_effect=False

tp.active_frame().plot().view.position=(0,tp.active_frame().plot().view.position[1],tp.active_frame().plot().view.position[2])
tp.active_frame().plot().view.position=(tp.active_frame().plot().view.position[0],0.1,tp.active_frame().plot().view.position[2])
tp.active_frame().plot().view.position=(tp.active_frame().plot().view.position[0],tp.active_frame().plot().view.position[1],0.1)
tp.active_frame().plot().view.psi=0
tp.active_frame().plot().view.theta=0


if dataset.num_zones ==7:
tp.active_frame().plot().fieldmap(5).show=False
tp.active_frame().plot().fieldmap(6).show=False
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[0]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)
tp.active_frame().plot().fieldmap(0).show=False
plot.view.psi = 157.5
tp.active_frame().plot().fieldmap(1).show=True
tp.active_frame().plot().fieldmap(2).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[1]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(1).show=False
tp.active_frame().plot().fieldmap(2).show=False
plot.view.psi = 135
tp.active_frame().plot().fieldmap(3).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[2]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(3).show=False
plot.view.psi = 112.5
tp.active_frame().plot().fieldmap(4).show=True
tp.active_frame().plot().fieldmap(5).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[3]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(4).show=False
tp.active_frame().plot().fieldmap(5).show=False
plot.view.psi = 90
tp.active_frame().plot().fieldmap(6).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[4]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

############################################################################# 
if dataset.num_zones ==6:
tp.active_frame().plot().fieldmap(5).show=False
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[0]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(0).show=False
plot.view.psi = 157.5
tp.active_frame().plot().fieldmap(1).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[1]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(1).show=False
plot.view.psi = 135
tp.active_frame().plot().fieldmap(2).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[2]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(2).show=False
plot.view.psi = 112.5
tp.active_frame().plot().fieldmap(3).show=True
tp.active_frame().plot().fieldmap(4).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[3]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

tp.active_frame().plot().fieldmap(3).show=False
tp.active_frame().plot().fieldmap(4).show=False
plot.view.psi = 90
tp.active_frame().plot().fieldmap(5).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[4]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

############################################################################# 
if dataset.num_zones ==5:
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[0]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)
for i in range(4):
plot.view.psi = 180-(22.5*(i+1))
tp.active_frame().plot().fieldmap(i).show=False
tp.active_frame().plot().fieldmap(i+1).show=True
tp.active_frame().plot().view.fit_data(consider_blanking=True)
tp.active_frame().plot().view.magnification=1
tp.export.save_jpeg(f'{bendName[i+1]}.jpg',
width=1920,
region=ExportRegion.CurrentFrame,
supersample=3,
quality=100,
encoding=JPEGEncoding.Standard)

 

Extract frames from video file
===========================

import cv2
print(cv2.__version__)
vidcap = cv2.VideoCapture(r'D:\_Local_Aero_Files\_Projects-AERO\tecplot-Files\transverse-slices-vel.mp4')
success,image = vidcap.read()
count = 0
success = True
while success:
cv2.imwrite("transverse-vel-%d.jpg" % count, image) # save frame as JPEG file
success,image = vidcap.read()
print (f'Read a new frame: {count}'), success
count += 1

 

How to calculate the velocity magnitude:
===========================
1. After importing Fluent data, some flow variables are not all passed on, in particular the velocity magnitude. To rectify,
2. Go to Analyze > Field Variables, and under Convective Variables, select the Velocity option, and click the Select button. Ensure that the velocity variables, are U, V, and W velocities to match the coordinate system. Then
3. Go to Analyze > Calculate Variables. Click the Select button, select Velocity Magnitude from the list, and click OK. Click Calculate. 4. The variable will now be available for selection

How to extract data from a line in Tecplot:
===========================
1. This is a handy tool which is a free add-on in Tecplot.
2. The Extract Precise Polyline add-on extracts a line of points defined by entering the (x,y,z) coordinates of a start and end points.
http://www.tecplottalk.com/addons/ExtPrec/
3. How to resize frames so export plots look nice:
4. Don’t you hate it when you export your lovely plot/x-y graph and its in a square shape format and there’s a whole load of whitespace above the plot.
5. To fix this go to Frame > Edit Active Frame and change the width and height of the frame. Then resize the plot!

Leave a Comment