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的更多相关文章

  1. plotting and saving over line in paraView

    probe -- provides the field values in a particular location in space To save plotoverline to csv fil ...

  2. paraview显示指定时间段的时均图(两种方法)

    方法一: 首先计算以后会得到每个时刻的网格数据,如下图: 但是我们只想要比如最后2s的数据,如果直接导入,paraview会把从0s时刻的数据全部加载,做时均图的时候也就是对整个时间段做时均,不是我们 ...

  3. 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 ...

  4. CPU C-States Power Saving Modes

    http://www.hardwaresecrets.com/article/611 Everything You Need to Know About the CPU C-States Power ...

  5. Atitit 解决Unhandled event loop exception错误的办法

    Atitit 解决Unhandled event loop exception错误的办法 查看workspace/.metadata/.log org.eclipse.swt.SWTError: No ...

  6. Looper.prepare()和Looper.loop()

    什么时候需要 Looper Looper用于封装了android线程中的消息循环,默认情况下一个线程是不存在消息循环(message loop)的,需要调用Looper.prepare()来给线程创建 ...

  7. PostgreSQL-PL/pgSQL-cursor,loop

    将spam_keyword表word字段的字符全部拆分,只是利用过程语言完成循环的操作而已. create or replace function proc1() returns setof text ...

  8. archlinux 加载loop模块,且设定loop设备个数

    如果loop模块没有编译进内核就要先加载loop模块 modprobe loop 然后更改/etc/modprobe.d/modprobe.conf(有些文章写是在/etc/modprobe.conf ...

  9. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

随机推荐

  1. Can JavaScript connect with MySQL? 浏览器控制台的js采集数据结果持久化存储

    浏览器控制台的js采集数据结果持久化存储 how to open a file in javascript https://developer.mozilla.org/en-US/docs/Web/A ...

  2. 洛谷 p1625

    高精度 我以为这题必有高论,怎么想也想不出来,没想到竟是如此粗鄙做法. 我们写一个高精度模拟一下,然后枚举约数看是否能约分,由于我不会高精度除法,就抄了一发 其实这种两项之比和项数有关的数列是不能推通 ...

  3. bzoj1018

    线段树分治+并查集 线段树本身就是分治结构,碰见这种带删除修改的题目是再合适不过的,我们对于每段修改区间在线段树上打标记,每次路过就进行修改,叶子结点表及答案,先把所有修改在线段树上标记,然后dfs就 ...

  4. PCB genesis自制孔点 Font字体实现方法

    一.先看genesis原有Font字体 在PCB工程CAM加孔点字体要求时,通常我们直接用Geneis软件给我们提供了2种孔点字体canned_57与canned_67,但此字体可能不能满足各个工厂个 ...

  5. PCB genesis孔符制作实现方法

    一.先看genesis原始孔符 孔符的作用:用于表示孔径的大小的一种代号, 当孔径检测时,可以按分孔图中的孔符对应的孔径尺寸对孔径检测. 在实际PCB行业通常不使用原始(图形)孔符,而使用字母孔符(如 ...

  6. discuz的cutstr函数

    function cutstr($string, $length, $dot = ' ...') { if(strlen($string) <= $length) { return $strin ...

  7. SpringMVC+Jquery实现Ajax

    一.什么是Ajax? Ajax:异步的JavaScript和Json(这里XML改为了Json): 作用:用于完成网页局部刷新功能(修改少量数据只用局部刷新,不用再整个网页重新加载): 二.Sprin ...

  8. mysql中类型转换

    MySQL 的CAST()和CONVERT()函数可用来获取一个类型的值,并产生另一个类型的值 CAST(xxx AS 类型), CONVERT(xxx,类型) 二进制,同带binary前缀的效果 : ...

  9. nginx深入

    1.编译安装配置完成 /opt/nginx11/html/index.html 这是网页的首页文件 2. nginx.conf主配置文件学习 ############################# ...

  10. ACM_lowbit

    lowbit Time Limit: 2000/1000ms (Java/Others) Problem Description: long long ans = 0; for(int i = 1; ...