# trace generated using paraview version 5.9.1

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
firstnum=[0, 64,87,107,130,145,175,210,260,279,430,460,493,529,570,646,757,914,1430]
secnum=[63,86,106,129,144,174,209,259,278,429,459,492,528,569,645,756,913,1429,2147] 
for j in range(0,len(firstnum)):
	inum=firstnum[j]
	fnum=secnum[j]
	numframe=fnum-inum
	basedir='/mnt/sdb/Research/GATS/MURI/cases/GW20/A_0_9/xz1_vtk_vortmag/xz1_vtk_%d_%d/' % (inum,fnum)

# create a new 'Legacy VTK Reader'
	xz1vtkseries = LegacyVTKReader(registrationName='xz1.vtk.series', FileNames=[basedir+'xz1.vtk.series'])

# get animation scene
	animationScene1 = GetAnimationScene()

# update animation scene based on data timesteps
	animationScene1.UpdateAnimationUsingDataTimeSteps()

# get active view
	renderView1 = GetActiveViewOrCreate('RenderView')

# show data in view
	xz1vtkseriesDisplay = Show(xz1vtkseries, renderView1, 'UniformGridRepresentation')

# get color transfer function/color map for 'vortmag'
	vortmagLUT = GetColorTransferFunction('vortmag')
	vortmagLUT.RGBPoints = [-0.853814959526062, 0.231373, 0.298039, 0.752941, 0.0, 0.865003, 0.865003, 0.865003, 0.853814959526062, 0.705882, 0.0156863, 0.14902]
	vortmagLUT.ScalarRangeInitialized = 1.0

# get opacity transfer function/opacity map for 'vortmag'
	vortmagPWF = GetOpacityTransferFunction('vortmag')
	vortmagPWF.Points = [-0.853814959526062, 0.0, 0.5, 0.0, 0.853814959526062, 1.0, 0.5, 0.0]
	vortmagPWF.ScalarRangeInitialized = 1

# trace defaults for the display properties.
	xz1vtkseriesDisplay.Representation = 'Surface'
	xz1vtkseriesDisplay.ColorArrayName = ['POINTS', 'vort-mag']
	xz1vtkseriesDisplay.LookupTable = vortmagLUT
	xz1vtkseriesDisplay.SelectTCoordArray = 'None'
	xz1vtkseriesDisplay.SelectNormalArray = 'None'
	xz1vtkseriesDisplay.SelectTangentArray = 'None'
	xz1vtkseriesDisplay.OSPRayScaleArray = 'vort-mag'
	xz1vtkseriesDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
	xz1vtkseriesDisplay.SelectOrientationVectors = 'None'
	xz1vtkseriesDisplay.ScaleFactor = 0.30000000000000004
	xz1vtkseriesDisplay.SelectScaleArray = 'vort-mag'
	xz1vtkseriesDisplay.GlyphType = 'Arrow'
	xz1vtkseriesDisplay.GlyphTableIndexArray = 'vort-mag'
	xz1vtkseriesDisplay.GaussianRadius = 0.015
	xz1vtkseriesDisplay.SetScaleArray = ['POINTS', 'vort-mag']
	xz1vtkseriesDisplay.ScaleTransferFunction = 'PiecewiseFunction'
	xz1vtkseriesDisplay.OpacityArray = ['POINTS', 'vort-mag']
	xz1vtkseriesDisplay.OpacityTransferFunction = 'PiecewiseFunction'
	xz1vtkseriesDisplay.DataAxesGrid = 'GridAxesRepresentation'
	xz1vtkseriesDisplay.PolarAxes = 'PolarAxesRepresentation'
	xz1vtkseriesDisplay.ScalarOpacityUnitDistance = 0.07439543028860106
	xz1vtkseriesDisplay.ScalarOpacityFunction = vortmagPWF
	xz1vtkseriesDisplay.OpacityArrayName = ['POINTS', 'vort-mag']
	xz1vtkseriesDisplay.IsosurfaceValues = [0.0]
	xz1vtkseriesDisplay.SliceFunction = 'Plane'
	xz1vtkseriesDisplay.Slice = 80

# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
	xz1vtkseriesDisplay.ScaleTransferFunction.Points = [-0.853814959526062, 0.0, 0.5, 0.0, 0.853814959526062, 1.0, 0.5, 0.0]

# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
	xz1vtkseriesDisplay.OpacityTransferFunction.Points = [-0.853814959526062, 0.0, 0.5, 0.0, 0.853814959526062, 1.0, 0.5, 0.0]

# init the 'Plane' selected for 'SliceFunction'
	xz1vtkseriesDisplay.SliceFunction.Origin = [0.0, 0.0, 0.5]

# reset view to fit data
	renderView1.ResetCamera()

#changing interaction mode based on data extents
	renderView1.InteractionMode = '2D'
	renderView1.CameraPosition = [0.0, 10000.0, 0.5]
	renderView1.CameraFocalPoint = [0.0, 0.0, 0.5]
	renderView1.CameraViewUp = [1.0, 0.0, 0.0]

# get the material library
	materialLibrary1 = GetMaterialLibrary()
	
# show color bar/color legend
	xz1vtkseriesDisplay.SetScalarBarVisibility(renderView1, True)

# update the view to ensure updated data information
	renderView1.Update()

# reset view to fit data
	renderView1.ResetCamera()

# get color legend/bar for vortmagLUT in view renderView1
	vortmagLUTColorBar = GetScalarBar(vortmagLUT, renderView1)
	vortmagLUTColorBar.Title = '$|\\omega|$'
	vortmagLUTColorBar.ComponentTitle = ''

# change scalar bar placement
	vortmagLUTColorBar.Orientation = 'Horizontal'
	#vortmagLUTColorBar.WindowLocation = 'AnyLocation'
	vortmagLUTColorBar.Position = [0.35, 0.16]
	vortmagLUTColorBar.ScalarBarLength = 0.3

# Rescale transfer function
	vortmagLUT.RescaleTransferFunction(0, 10.0)

# Rescale transfer function
	vortmagPWF.RescaleTransferFunction(0, 10.0)

# Properties modified on vortmagLUTColorBar
	vortmagLUTColorBar.TitleFontFamily = 'Times'
	vortmagLUTColorBar.LabelFontFamily = 'Times'
	vortmagLUTColorBar.RangeLabelFormat = '%-#2.1f'

# create a new 'Annotate Time Filter'
	annotateTimeFilter1 = AnnotateTimeFilter(registrationName='AnnotateTimeFilter1', Input=xz1vtkseries)
# show data in view
	annotateTimeFilter1Display = Show(annotateTimeFilter1, renderView1, 'TextSourceRepresentation')
# Properties modified on annotateTimeFilter1Display
	annotateTimeFilter1Display.Position = [0.45, 0.7]
# Properties modified on annotateTimeFilter1
	annotateTimeFilter1.Format = 'Time: %6.2f $\\tau_b$'
# Properties modified on annotateTimeFilter1Display
	annotateTimeFilter1Display.FontFamily = 'Times'
# update the view to ensure updated data information
	renderView1.Update()
# reset view to fit data
	renderView1.ResetCamera()

# get layout
	layout1 = GetLayout()

# layout/tab size in pixels
	layout1.SetSize(914, 695)

# current camera placement for renderView1
	renderView1.InteractionMode = '2D'
	renderView1.CameraPosition = [0.0, -6.109051323707208, 0.5]
	renderView1.CameraFocalPoint = [0.0, 0.0, 0.5]
	renderView1.CameraViewUp = [0.0, 0.0, 1.0]
	renderView1.CameraParallelScale = 1.5811388300841898

# save animation
	SaveAnimation(basedir+'xz_vortmag_%d_%d.avi' %(inum,fnum), renderView1, ImageResolution=[912, 692],
	    FrameRate=24,
	    FrameWindow=[0, numframe])

	ResetSession()

# get active view
#	renderView1_1 = GetActiveViewOrCreate('RenderView')

#================================================================
# addendum: following script captures some of the application
# state to faithfully reproduce the visualization during playback
#================================================================

# get layout
#	layout1_1 = GetLayout()
	
#--------------------------------
# saving layout sizes for layouts

# layout/tab size in pixels
#	layout1_1.SetSize(914, 695)

#--------------------------------------------
# uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
