tadd scripts to visualize and animate output - Granular.jl - Julia package for … | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 5119861b022a058a35c8eff0b14e223597a03d3a | |
parent 891fd2b7c8829029c47ebaf65e9442afafc14a1c | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 12 Sep 2017 17:01:38 -0400 | |
add scripts to visualize and animate output | |
Diffstat: | |
A examples/logo.animate.sh | 2 ++ | |
A examples/logo.pvpython.py | 192 +++++++++++++++++++++++++++++… | |
2 files changed, 194 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/examples/logo.animate.sh b/examples/logo.animate.sh | |
t@@ -0,0 +1,2 @@ | |
+#!/bin/bash | |
+convert -delay 10 -transparent-color white -reverse -loop 0 logo/*.png logo/lo… | |
diff --git a/examples/logo.pvpython.py b/examples/logo.pvpython.py | |
t@@ -0,0 +1,192 @@ | |
+#### import the simple module from the paraview | |
+from paraview.simple import * | |
+#### disable automatic camera reset on 'Show' | |
+paraview.simple._DisableFirstRenderCameraReset() | |
+ | |
+# create a new 'XML Unstructured Grid Reader' | |
+logoicefloes = XMLUnstructuredGridReader(FileName=['./logo/logo.icefloes.1.vtu… | |
+logoicefloes.PointArrayStatus = ['Density [kg m^-3]', 'Thickness [m]', 'Diamet… | |
+ | |
+# get animation scene | |
+animationScene1 = GetAnimationScene() | |
+ | |
+# update animation scene based on data timesteps | |
+animationScene1.UpdateAnimationUsingDataTimeSteps() | |
+ | |
+# get active view | |
+renderView1 = GetActiveViewOrCreate('RenderView') | |
+# uncomment following to set a specific view size | |
+# renderView1.ViewSize = [2478, 1570] | |
+ | |
+# show data in view | |
+logoicefloesDisplay = Show(logoicefloes, renderView1) | |
+# trace defaults for the display properties. | |
+logoicefloesDisplay.Representation = 'Surface' | |
+logoicefloesDisplay.AmbientColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.ColorArrayName = [None, ''] | |
+logoicefloesDisplay.OSPRayScaleArray = 'Angular acceleration [rad s^-2]' | |
+logoicefloesDisplay.OSPRayScaleFunction = 'PiecewiseFunction' | |
+logoicefloesDisplay.SelectOrientationVectors = 'Angular acceleration [rad s^-2… | |
+logoicefloesDisplay.ScaleFactor = 6.050000000000001 | |
+logoicefloesDisplay.SelectScaleArray = 'Angular acceleration [rad s^-2]' | |
+logoicefloesDisplay.GlyphType = 'Arrow' | |
+logoicefloesDisplay.GlyphTableIndexArray = 'Angular acceleration [rad s^-2]' | |
+logoicefloesDisplay.DataAxesGrid = 'GridAxesRepresentation' | |
+logoicefloesDisplay.PolarAxes = 'PolarAxesRepresentation' | |
+logoicefloesDisplay.ScalarOpacityUnitDistance = 64.20669746996803 | |
+logoicefloesDisplay.GaussianRadius = 3.0250000000000004 | |
+logoicefloesDisplay.SetScaleArray = ['POINTS', 'Atmosphere drag coefficient (h… | |
+logoicefloesDisplay.ScaleTransferFunction = 'PiecewiseFunction' | |
+logoicefloesDisplay.OpacityArray = ['POINTS', 'Atmosphere drag coefficient (ho… | |
+logoicefloesDisplay.OpacityTransferFunction = 'PiecewiseFunction' | |
+ | |
+# init the 'GridAxesRepresentation' selected for 'DataAxesGrid' | |
+logoicefloesDisplay.DataAxesGrid.XTitleColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.DataAxesGrid.YTitleColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.DataAxesGrid.ZTitleColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.DataAxesGrid.GridColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.DataAxesGrid.XLabelColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.DataAxesGrid.YLabelColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.DataAxesGrid.ZLabelColor = [0.0, 0.0, 0.0] | |
+ | |
+# init the 'PolarAxesRepresentation' selected for 'PolarAxes' | |
+logoicefloesDisplay.PolarAxes.PolarAxisTitleColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.PolarAxes.PolarAxisLabelColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.PolarAxes.LastRadialAxisTextColor = [0.0, 0.0, 0.0] | |
+logoicefloesDisplay.PolarAxes.SecondaryRadialAxesTextColor = [0.0, 0.0, 0.0] | |
+ | |
+# reset view to fit data | |
+renderView1.ResetCamera() | |
+ | |
+#changing interaction mode based on data extents | |
+renderView1.InteractionMode = '2D' | |
+renderView1.CameraPosition = [30.5, 11.0, 10000.0] | |
+renderView1.CameraFocalPoint = [30.5, 11.0, 0.0] | |
+ | |
+# update the view to ensure updated data information | |
+renderView1.Update() | |
+ | |
+# create a new 'Glyph' | |
+glyph1 = Glyph(Input=logoicefloes, | |
+ GlyphType='Arrow') | |
+glyph1.Scalars = ['POINTS', 'Atmosphere drag coefficient (horizontal) [-]'] | |
+glyph1.Vectors = ['POINTS', 'Angular acceleration [rad s^-2]'] | |
+glyph1.ScaleFactor = 6.050000000000001 | |
+glyph1.GlyphTransform = 'Transform2' | |
+ | |
+# Properties modified on glyph1 | |
+glyph1.Scalars = ['POINTS', 'Diameter (areal) [m]'] | |
+glyph1.Vectors = ['POINTS', 'Angular position [rad]'] | |
+glyph1.ScaleMode = 'scalar' | |
+glyph1.ScaleFactor = 1.0 | |
+glyph1.GlyphMode = 'All Points' | |
+ | |
+# get color transfer function/color map for 'Diameterarealm' | |
+diameterarealmLUT = GetColorTransferFunction('Diameterarealm') | |
+ | |
+# show data in view | |
+glyph1Display = Show(glyph1, renderView1) | |
+# trace defaults for the display properties. | |
+glyph1Display.Representation = 'Surface' | |
+glyph1Display.AmbientColor = [0.0, 0.0, 0.0] | |
+glyph1Display.ColorArrayName = ['POINTS', 'Diameter (areal) [m]'] | |
+glyph1Display.LookupTable = diameterarealmLUT | |
+glyph1Display.OSPRayScaleArray = 'Diameter (areal) [m]' | |
+glyph1Display.OSPRayScaleFunction = 'PiecewiseFunction' | |
+glyph1Display.SelectOrientationVectors = 'GlyphVector' | |
+glyph1Display.ScaleFactor = 6.1000000000000005 | |
+glyph1Display.SelectScaleArray = 'Diameter (areal) [m]' | |
+glyph1Display.GlyphType = 'Arrow' | |
+glyph1Display.GlyphTableIndexArray = 'Diameter (areal) [m]' | |
+glyph1Display.DataAxesGrid = 'GridAxesRepresentation' | |
+glyph1Display.PolarAxes = 'PolarAxesRepresentation' | |
+glyph1Display.GaussianRadius = 3.0500000000000003 | |
+glyph1Display.SetScaleArray = ['POINTS', 'Diameter (areal) [m]'] | |
+glyph1Display.ScaleTransferFunction = 'PiecewiseFunction' | |
+glyph1Display.OpacityArray = ['POINTS', 'Diameter (areal) [m]'] | |
+glyph1Display.OpacityTransferFunction = 'PiecewiseFunction' | |
+ | |
+# init the 'GridAxesRepresentation' selected for 'DataAxesGrid' | |
+glyph1Display.DataAxesGrid.XTitleColor = [0.0, 0.0, 0.0] | |
+glyph1Display.DataAxesGrid.YTitleColor = [0.0, 0.0, 0.0] | |
+glyph1Display.DataAxesGrid.ZTitleColor = [0.0, 0.0, 0.0] | |
+glyph1Display.DataAxesGrid.GridColor = [0.0, 0.0, 0.0] | |
+glyph1Display.DataAxesGrid.XLabelColor = [0.0, 0.0, 0.0] | |
+glyph1Display.DataAxesGrid.YLabelColor = [0.0, 0.0, 0.0] | |
+glyph1Display.DataAxesGrid.ZLabelColor = [0.0, 0.0, 0.0] | |
+ | |
+# init the 'PolarAxesRepresentation' selected for 'PolarAxes' | |
+glyph1Display.PolarAxes.PolarAxisTitleColor = [0.0, 0.0, 0.0] | |
+glyph1Display.PolarAxes.PolarAxisLabelColor = [0.0, 0.0, 0.0] | |
+glyph1Display.PolarAxes.LastRadialAxisTextColor = [0.0, 0.0, 0.0] | |
+glyph1Display.PolarAxes.SecondaryRadialAxesTextColor = [0.0, 0.0, 0.0] | |
+ | |
+# show color bar/color legend | |
+glyph1Display.SetScalarBarVisibility(renderView1, True) | |
+ | |
+# update the view to ensure updated data information | |
+renderView1.Update() | |
+ | |
+# reset view to fit data | |
+renderView1.ResetCamera() | |
+ | |
+# Properties modified on glyph1 | |
+glyph1.GlyphType = 'Sphere' | |
+ | |
+# update the view to ensure updated data information | |
+renderView1.Update() | |
+ | |
+# hide color bar/color legend | |
+glyph1Display.SetScalarBarVisibility(renderView1, False) | |
+ | |
+# rescale color and/or opacity maps used to exactly fit the current data range | |
+glyph1Display.RescaleTransferFunctionToDataRange(False, True) | |
+ | |
+# Rescale transfer function | |
+diameterarealmLUT.RescaleTransferFunction(0.0, 5.0) | |
+ | |
+# get opacity transfer function/opacity map for 'Diameterarealm' | |
+diameterarealmPWF = GetOpacityTransferFunction('Diameterarealm') | |
+ | |
+# Rescale transfer function | |
+diameterarealmPWF.RescaleTransferFunction(0.0, 5.0) | |
+ | |
+# Apply a preset using its name. Note this may not work as expected when prese… | |
+diameterarealmLUT.ApplyPreset('Black, Blue and White', True) | |
+ | |
+# Hide orientation axes | |
+renderView1.OrientationAxesVisibility = 0 | |
+ | |
+# current camera placement for renderView1 | |
+renderView1.InteractionMode = '2D' | |
+renderView1.CameraPosition = [30.75, 10.99999962002039, 125.01319337485243] | |
+renderView1.CameraFocalPoint = [30.75, 10.99999962002039, 0.0] | |
+renderView1.CameraParallelScale = 20.56227912200389 | |
+ | |
+# save animation | |
+SaveAnimation('./logo/logo.avi', renderView1, ImageResolution=[1239, 785], | |
+ FrameRate=10, | |
+ FrameWindow=[0, 49]) | |
+ | |
+# current camera placement for renderView1 | |
+renderView1.InteractionMode = '2D' | |
+renderView1.CameraPosition = [30.75, 10.99999962002039, 125.01319337485243] | |
+renderView1.CameraFocalPoint = [30.75, 10.99999962002039, 0.0] | |
+renderView1.CameraParallelScale = 20.56227912200389 | |
+ | |
+# save animation | |
+SaveAnimation('./logo/logo.png', renderView1, ImageResolution=[1239, 785], | |
+ FrameRate=10, | |
+ FrameWindow=[0, 49]) | |
+ | |
+#### saving camera placements for all active views | |
+ | |
+# current camera placement for renderView1 | |
+renderView1.InteractionMode = '2D' | |
+renderView1.CameraPosition = [30.75, 10.99999962002039, 125.01319337485243] | |
+renderView1.CameraFocalPoint = [30.75, 10.99999962002039, 0.0] | |
+renderView1.CameraParallelScale = 20.56227912200389 | |
+ | |
+#### uncomment the following to render all views | |
+# RenderAllViews() | |
+# alternatively, if you want to write images, you can use SaveScreenshot(...). |