8 August 2018 · Scripts
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)
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