Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liangwang0734/fac652a5e3d6ac89986443e171caec59 to your computer and use it in GitHub Desktop.
Save liangwang0734/fac652a5e3d6ac89986443e171caec59 to your computer and use it in GitHub Desktop.
slice_sphere_gkeyll_v1_paraview_v5.5.0rc2.py
# trace generated using paraview version 5.5.0
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
folder = "/scratch/gpfs/lw6/mercury/test/"
fname_in = "mercury_v2_q_6.h5"
fname_out = "slice_sphere_0.xmf"
fname_img = "slice_sphere_0.png"
print("Loading file...")
mercury_v2_q_6h5 = VisItVsReader(FileName=[folder + fname_in])
mercury_v2_q_6h5.MeshStatus = ['StructGrid']
mercury_v2_q_6h5.CellArrayStatus = ['StructGridField_0']
print("Creating slice...")
slice1 = Slice(Input=mercury_v2_q_6h5)
slice1.SliceType = 'Sphere'
slice1.SliceOffsetValues = [0.0]
slice1.SliceType.Radius = 3659550.0
print("Saving sliced data...")
SaveData(folder + fname_out, proxy=slice1)
print("Creating view...")
renderView1 = GetActiveViewOrCreate('RenderView')
# # uncomment following to set a specific view size
# # renderView1.ViewSize = [1216, 781]
print("Creating slice display...")
slice1Display = Show(slice1, renderView1)
print("Set slice display properties...")
# trace defaults for the display properties.
slice1Display.Representation = 'Surface'
slice1Display.ColorArrayName = [None, '']
slice1Display.OSPRayScaleFunction = 'PiecewiseFunction'
slice1Display.SelectOrientationVectors = 'None'
slice1Display.ScaleFactor = 731910.0
slice1Display.SelectScaleArray = 'None'
slice1Display.GlyphType = 'Arrow'
slice1Display.GlyphTableIndexArray = 'None'
slice1Display.GaussianRadius = 36595.5
slice1Display.SetScaleArray = [None, '']
slice1Display.ScaleTransferFunction = 'PiecewiseFunction'
slice1Display.OpacityArray = [None, '']
slice1Display.OpacityTransferFunction = 'PiecewiseFunction'
slice1Display.DataAxesGrid = 'GridAxesRepresentation'
slice1Display.SelectionCellLabelFontFile = ''
slice1Display.SelectionPointLabelFontFile = ''
slice1Display.PolarAxes = 'PolarAxesRepresentation'
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
slice1Display.DataAxesGrid.XTitleFontFile = ''
slice1Display.DataAxesGrid.YTitleFontFile = ''
slice1Display.DataAxesGrid.ZTitleFontFile = ''
slice1Display.DataAxesGrid.XLabelFontFile = ''
slice1Display.DataAxesGrid.YLabelFontFile = ''
slice1Display.DataAxesGrid.ZLabelFontFile = ''
print("renderView1.Update")
# update the view to ensure updated data information
renderView1.Update()
ColorBy(slice1Display, ('CELLS', 'StructGridField_0'))
# rescale color and/or opacity maps used to include current data range
slice1Display.RescaleTransferFunctionToDataRange(True, False)
slice1Display.SetScalarBarVisibility(renderView1, True)
structGridField_0LUT = GetColorTransferFunction('StructGridField_0')
# reset view to fit data bounds
# renderView1.ResetCamera()
renderView1.ResetCamera(-3659550.0, 3659550.0, -3657781.4244, 3657781.4244, -3659550.0, 3659550.0)
# current camera placement for renderView1
renderView1.CameraPosition = [0.0, -2.0256265997886658e-08, 24486241.370854452]
renderView1.CameraFocalPoint = [0.0, -2.0256265997886658e-08, 0.0]
renderView1.CameraParallelScale = 6337505.609754387
print("Saving screenshot...")
SaveScreenshot(folder + fname_img, renderView1, ImageResolution=[1216, 781])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment