saving snaps iteratively with for loop in Paraview
Goal:
read data 1 and slice, then save pressure, velocity contours, close data, then do loop for the aforementioned steps.
****************************************************************
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
for Num in range(36,47):
# create a new 'EnSight Reader' and assign it to a variable, 'transientcase'
transientcase = EnSightReader(CaseFileName='/home/kaiming/Documents/ZJU_Projects/Jet/data/transient_%i.case' %(Num+1))
transientcase.PointArrays = [ 'density','v', 'pressure', 'temperature']
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# set a specific view size
renderView1.ViewSize = [1022, 837]
# get color transfer function/color map for 'density'
densityLUT = GetColorTransferFunction('density')
densityLUT.LockDataRange = 1
# get opacity transfer function/opacity map for 'density'
densityPWF = GetOpacityTransferFunction('density')
# show data in view
transientcaseDisplay = Show(transientcase, renderView1)
# trace defaults for the display properties.
transientcaseDisplay.ColorArrayName = ['POINTS', 'density']
transientcaseDisplay.LookupTable = densityLUT
transientcaseDisplay.GlyphType = 'Arrow'
transientcaseDisplay.ScalarOpacityUnitDistance = 0.0016420380639339577
# reset view to fit data
renderView1.ResetCamera()
# show color bar/color legend
transientcaseDisplay.SetScalarBarVisibility(renderView1, False)
# get opacity transfer function/opacity map for 'density'
densityPWF = GetOpacityTransferFunction('density')
# reset view to fit data
renderView1.ResetCamera()
#################
## slice
################
# create a new 'Slice'
slice1 = Slice(Input=transientcase)
slice1.SliceType = 'Plane'
slice1.SliceOffsetValues = [0.0]
# init the 'Plane' selected for 'SliceType'
slice1.SliceType.Origin = [-0.21849990739250558, 0.0, 0.0]
# Properties modified on slice1.SliceType
slice1.SliceType.Origin = [0.0, 0.0, 0.0]
slice1.SliceType.Normal = [0.0, 0.0, 1.0]
# show data in view
slice1Display = Show(slice1, renderView1)
# trace defaults for the display properties.
slice1Display.ColorArrayName = ['POINTS', 'density']
slice1Display.LookupTable = densityLUT
slice1Display.GlyphType = 'Arrow'
# hide data in view
Hide(transientcase, renderView1)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# set active source
SetActiveSource(transientcase)
# reset view to fit data
renderView1.ResetCamera()
# current camera placement for renderView1
renderView1.CameraPosition = [-0.3656950276430585, -0.000908563692513454, 0.21027127790890924]
renderView1.CameraFocalPoint = [-0.3656950276430585, -0.000908563692513454, 0.0]
renderView1.CameraParallelScale = 0.25006857916835856
# *****************
# change legend layout, and its font color, position
# *****************
# get color legend for 'densityLUT' in view 'renderView1'
densityLUTColorBar = GetScalarBar(densityLUT, renderView1)
# Properties modified on densityLUTColorBar
densityLUTColorBar.AutoOrient = 0
densityLUTColorBar.RangeLabelFormat = '%.2f'
## legend orientation
densityLUTColorBar.Orientation = 'Horizontal'
## legend normalized position
densityLUTColorBar.Position = [0.3, 0.2]
# change label color to 'black'
densityLUTColorBar.LabelColor = [1.0, 1.0, 1.0]
# change titile color to 'black'
densityLUTColorBar.TitleColor = [1.0, 1.0, 1.0]
# ***************
# set Background color as 'White'
renderView1.Background =[1,1,1]
# get layout
viewLayout1 = GetLayout()
# set a specific view size
renderView1.ViewSize = [1022, 837]
# current camera placement for renderView1
renderView1.CameraPosition = [-0.3656950276430585, -0.000908563692513454, 0.21027127790890924]
renderView1.CameraFocalPoint = [-0.3656950276430585, -0.000908563692513454, 0.0]
renderView1.CameraParallelScale = 0.25006857916835856
# save screenshot
SaveScreenshot('/home/kaiming/Documents/ZJU_Projects/Jet/paraview/tem/d_%s.png' %(Num+1), layout=viewLayout1, magnification=1, quality=100)
#################
# pressure contour
##################
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, False)
# set active source
SetActiveSource(slice1)
# set scalar coloring
ColorBy(slice1Display, ('POINTS', 'pressure'))
# rescale color and/or opacity maps used to include current data range
slice1Display.RescaleTransferFunctionToDataRange(True)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'pressure'
pressureLUT = GetColorTransferFunction('pressure')
pressureLUT.LockDataRange = 1
# get opacity transfer function/opacity map for 'pressure'
pressurePWF = GetOpacityTransferFunction('pressure')
# set active source
SetActiveSource(transientcase)
# *****************
# change legend layout, and its font color, position
# *****************
# get color legend for 'pressureLUT' in view 'renderView1'
pressureLUTColorBar = GetScalarBar(pressureLUT, renderView1)
# Properties modified on vLUTColorBar
pressureLUTColorBar.AutoOrient = 0
pressureLUTColorBar.RangeLabelFormat = '%.2f'
## legend orientation
pressureLUTColorBar.Orientation = 'Horizontal'
## legend normalized position
pressureLUTColorBar.Position = [0.3, 0.2]
# change label color to 'black'
pressureLUTColorBar.LabelColor = [1.0, 1.0, 1.0]
# change titile color to 'black'
pressureLUTColorBar.TitleColor = [1.0, 1.0, 1.0]
# ***************
# current camera placement for renderView1
# current camera placement for renderView1
renderView1.CameraPosition = [-0.3656950276430585, -0.000908563692513454, 0.21027125790890924]
renderView1.CameraFocalPoint = [-0.3656950276430585, -0.000908563692513454, 0.0]
renderView1.CameraParallelScale = 0.25006857916835856
# save screenshot
SaveScreenshot('/home/kaiming/Documents/ZJU_Projects/Jet/paraview/tem/p_%s.png' %(Num+1), layout=viewLayout1, magnification=1, quality=100)
######################
# #temperature contour
######################
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, False)
# set active source
SetActiveSource(slice1)
# set scalar coloring
ColorBy(slice1Display, ('POINTS', 'temperature'))
# rescale color and/or opacity maps used to include current data range
slice1Display.RescaleTransferFunctionToDataRange(True)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'termperature'
temperatureLUT = GetColorTransferFunction('temperature')
temperatureLUT.LockDataRange = 1
# get opacity transfer function/opacity map for 'temperature'
temperaturePWF = GetOpacityTransferFunction('temperature')
# ******
# legend layout, and its font color, position
# *****
temperatureLUTColorBar = GetScalarBar(temperatureLUT, renderView1)
# Properties modified on vLUTColorBar
temperatureLUTColorBar.AutoOrient = 0
temperatureLUTColorBar.RangeLabelFormat = '%.2f'
## legend orientation
temperatureLUTColorBar.Orientation = 'Horizontal'
## legend normalized position
temperatureLUTColorBar.Position = [0.3, 0.2]
# label color to 'black'
temperatureLUTColorBar.LabelColor = [1.0, 1.0, 1.0]
# change 'titile' color to 'black'
temperatureLUTColorBar.TitleColor = [1.0, 1.0, 1.0]
# *****************
# set active source
SetActiveSource(transientcase)
# current camera placement for renderView1
# current camera placement for renderView1
renderView1.CameraPosition = [-0.3656950276430585, -0.000908563692513454, 0.21027127790890924]
renderView1.CameraFocalPoint = [-0.3656950276430585, -0.000908563692513454, 0.0]
renderView1.CameraParallelScale = 0.25006857917835856
# save screenshot
SaveScreenshot('/home/kaiming/Documents/ZJU_Projects/Jet/paraview/tem/t_%s.png' %(Num+1), layout=viewLayout1, magnification=1, quality=100)
# *****************
# Velocity
# ****************
# show color legend
slice1Display.SetScalarBarVisibility(renderView1, False)
# set active source
SetActiveSource(slice1)
# set scalar coloring
ColorBy(slice1Display, ('POINTS', 'v'))
# rescale color and/or opacity maps used to include current data range
slice1Display.RescaleTransferFunctionToDataRange(True)
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'v'
vLUT = GetColorTransferFunction('v')
vLUT.LockDataRange = 1
# get opacity transfer function/opacity map for 'v'
vPWF = GetOpacityTransferFunction('v')
# *****************
# change legend layout, and its font color, position
# *****************
# get color legend for 'densityLUT' in view 'renderView1'
vLUTColorBar = GetScalarBar(vLUT, renderView1)
# Properties modified on vLUTColorBar
vLUTColorBar.AutoOrient = 0
vLUTColorBar.RangeLabelFormat = '%.2f'
## legend orientation
vLUTColorBar.Orientation = 'Horizontal'
## legend normalized position
vLUTColorBar.Position = [0.3, 0.2]
# change label color to 'black'
vLUTColorBar.LabelColor = [1.0, 1.0, 1.0]
# change titile color to 'black'
vLUTColorBar.TitleColor = [1.0, 1.0, 1.0]
# ***************
# set active source
SetActiveSource(transientcase)
# current camera placement for renderView1
# current camera placement for renderView1
renderView1.CameraPosition = [-0.3656950276430585, -0.000908563692513454, 0.21027125790890924]
renderView1.CameraFocalPoint = [-0.3656950276430585, -0.000908563692513454, 0.0]
renderView1.CameraParallelScale = 0.25006857916835856
# save screenshot
SaveScreenshot('/home/kaiming/Documents/ZJU_Projects/Jet/paraview/tem/v_%s.png' %(Num+1), layout=viewLayout1, magnification=1, quality=100)
#### saving camera placements for all active views
# show color bar/color legend
slice1Display.SetScalarBarVisibility(renderView1, False)
# current camera placement for renderView1
renderView1.CameraPosition = [-0.3656950276430585, -0.000908563692513454, 0.21027127790890924]
renderView1.CameraFocalPoint = [-0.3656950276430585, -0.000908563692513454, 0.0]
renderView1.CameraParallelScale = 0.25006857916835856
Disconnect()
Connect()
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
saving snaps iteratively with for loop in Paraview的更多相关文章
- plotting and saving over line in paraView
probe -- provides the field values in a particular location in space To save plotoverline to csv fil ...
- paraview显示指定时间段的时均图(两种方法)
方法一: 首先计算以后会得到每个时刻的网格数据,如下图: 但是我们只想要比如最后2s的数据,如果直接导入,paraview会把从0s时刻的数据全部加载,做时均图的时候也就是对整个时间段做时均,不是我们 ...
- Multi-tasking RTOS for microprocessors with limited memory by saving only a single return address per task during context switching
A real-time operating system (RTOS) for use with minimal-memory controllers has a kernel for managin ...
- CPU C-States Power Saving Modes
http://www.hardwaresecrets.com/article/611 Everything You Need to Know About the CPU C-States Power ...
- Atitit 解决Unhandled event loop exception错误的办法
Atitit 解决Unhandled event loop exception错误的办法 查看workspace/.metadata/.log org.eclipse.swt.SWTError: No ...
- Looper.prepare()和Looper.loop()
什么时候需要 Looper Looper用于封装了android线程中的消息循环,默认情况下一个线程是不存在消息循环(message loop)的,需要调用Looper.prepare()来给线程创建 ...
- PostgreSQL-PL/pgSQL-cursor,loop
将spam_keyword表word字段的字符全部拆分,只是利用过程语言完成循环的操作而已. create or replace function proc1() returns setof text ...
- archlinux 加载loop模块,且设定loop设备个数
如果loop模块没有编译进内核就要先加载loop模块 modprobe loop 然后更改/etc/modprobe.d/modprobe.conf(有些文章写是在/etc/modprobe.conf ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
随机推荐
- PX4/Pixhawk---高速成为开发人员(Windows)
1 高速成为开发人员新手教程(翻译)---官方 1.1 编译环境之版本号控制系统 (1)安装MSysGIT 安装完毕后,配置GIT. 安装注意 安装过程中除了以下一步外,其它的步骤都採用默认安 ...
- GoLang笔记-数组和切片,本质是就是长度不可变的可变的区别
数组 Arrays 数组是内置(build-in)类型,是一组同类型数据的集合,它是值类型,通过从0开始的下标索引访问元素值.在初始化后长度是固定的,无法修改其长度.当作为方法的入参传入时将复制一份数 ...
- mysql_mssql_access_2017年最新手机号段归属地数据库(17年4月更新)360569记录
mysql,mssql,access 三种格式免费分享给大家,末尾有下载地址 2017年4月最新版手机号段归属地,也叫手机归属地数据库 共360569条记录,三种格式:MYSQL,MSSQL,acc ...
- Linux基础命令第二波
第1章 Linux启动过程 开机自检(BIOS)##硬件检查 MBR引导 GRUB菜单(选择不同的内核) 加载内核 运行init进程(Linux系统里面第一个进程) 读取/etc/inittab配置文 ...
- css的一些命名规范
网页制作中规范使用DIV+CSS命名规则,可以改善优化功效特别是团队合作时候可以提供合作制作效率,具体DIV CSS命名规则CSS命名大全内容篇. 常用DIV+CSS命名大全集合,即CSS命名规则 D ...
- scrapy安装及基本使用
前端html, css, js 相关知识 数据库运用 http协议的了解 前后台联动 蜘蛛中间件.下载中间件 下载中间件的地方可以写各种反爬的策略 1.使用pip安装, pip3 install sc ...
- MyEclipse找不到install new software
Window->Preferences->Capabilities-> classic update(勾选即可) 勾选后会出现software updates,下面按照help-&g ...
- Java保存错误日志信息
我们平时在撸代码的时候,有时候需要将某个代码块的具体错误信息保存到数据库或文件中,以便日后方便快速的查找问题. 使用e.printStackTrace(),我们可以将信息保存在具体的变量中,然后写入数 ...
- 小小的IP,大大的耦合,你痛过吗?
什么是耦合? 耦合,是架构中,本来不相干的代码.模块.服务.系统因为某些原因联系在一起,各自独立性差,影响则相互影响,变动则相互变动的一种架构状态. 感官上,怎么发现系统中的耦合? 作为技术人,每每在 ...
- Android 升级安装APK兼容Android7.0,解决FileUriExposedException
我们在开发app时避免不了需要添加应用内升级功能.当app启动时,如果检测到最新版本,将apk安装包从服务器下载下来,执行安装.安装apk的代码一般写法如下,网上随处可以搜到 public stati ...