def clear(time): plasma_file = vtk_path + plasma_file_head + str(time) + '.vtk' paraxial_file = vtk_path + paraxial_file_head + str(time) + '.vtk' fullwave_file = vtk_path + fullwave_file_head + str(time) + '.vtk' vi.DeleteAllPlots() vi.CloseDatabase(plasma_file) vi.CloseDatabase(paraxial_file) vi.CloseDatabase(fullwave_file)
def test_plot_direct(self): w = Window() ult.plot(db) obase = pjoin(output_dir, "test.ult.plot.direct.render") w.render(obase=obase, res=[200, 200]) self.assertTrue(os.path.isfile(obase + ".png")) WindowManager.cleanup_windows() visit.DeleteAllPlots() visit.CloseDatabase(db)
def test_python(self): visit.OpenDatabase(db) visit.AddPlot("Pseudocolor", "d") visit.DrawPlots() exprs.clear() exprs.define_python("test_vpe", file=vpe_file, args=["d"]) visit.Query("Max") r1 = visit.GetQueryOutputValue() visit.ChangeActivePlotsVar("test_vpe") visit.Query("Max") r2 = visit.GetQueryOutputValue() visit.ChangeActivePlotsVar("d") self.assertTrue(r1 * r1 - r2 < 1e-2) exprs.clear() visit.DeleteAllPlots() visit.CloseDatabase(db)
def tearDown(self): # clean up visit.DeleteAllPlots() visit.CloseDatabase(self.data_path) visit.CloseComputeEngine()
def tearDown(self): visit.DeleteAllPlots() visit.CloseDatabase(db) visit.CloseComputeEngine()
def make_distribution_movie(cellids, rotated, inputDirectory, outputDirectory, outputFileName, zoom=1.0, viewNormal=[0.488281, 0.382966, -0.784167], minThreshold=1e-18, maxThreshold=1e37): '''Makes a distribution movie of some given distribution data Example usage: make_distribution_movie(cellids=[18302, 19432, 19042], rotated=True, inputDirectory=\"/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/\", outputDirectory=\"/home/hannukse/MOVIES/\", outputFileName=\"testmovie\", zoom=0.8, viewNormal=[0.488281, 0.382966, -0.784167], minThreshold=1e-17, maxThreshold=1.2e37) Note: viewNormal determines the angle of view (straight from visit) ''' if len(viewNormal) != 3: print "ERROR, INVALID VIEWNORMAL LENGTH, SHOULD BE 3" return for cell in sorted(cellids): # OPTIONS ########################################################### cellid = str(cell) #databaseName = "localhost:/home/hannukse/meteo/lustre/tmp/hannuksela/AAM/velgrid.rotated." + cellid + ".*.silo database" if rotated == True: rotateFix = "rotated." else: rotateFix = "" inputFileName = "velgrid." + rotateFix + cellid + ".*.silo" databaseName = "localhost:" + inputDirectory + inputFileName + " database" outputDir = outputDirectory fileName = outputFileName + "_" + cellid + "_" WIDTH = 3000 HEIGHT = 3000 # Threshold values: # TODO: USE VLSV READER TO AUTOMATE THIS minimumThreshold = minThreshold maximumThreshold = maxThreshold ########################################################### vis.OpenDatabase(databaseName, 0) #Load settings visSettings.load_visit_settings() #Make a plot vis.AddPlot("Pseudocolor", "avgs", 1, 1) vis.SetActivePlots(0) vis.AddOperator("Threshold", 1) vis.ThresholdAtts = vis.ThresholdAttributes() vis.ThresholdAtts.outputMeshType = 0 vis.ThresholdAtts.listedVarNames = ("default") vis.ThresholdAtts.zonePortions = (1) vis.ThresholdAtts.lowerBounds = (minimumThreshold) vis.ThresholdAtts.upperBounds = (maximumThreshold) vis.ThresholdAtts.defaultVarName = "avgs" vis.ThresholdAtts.defaultVarIsScalar = 1 vis.SetOperatorOptions(vis.ThresholdAtts, 1) vis.DrawPlots() # Begin spontaneous state vis.View3DAtts = vis.View3DAttributes() vis.View3DAtts.viewNormal = (viewNormal[0], viewNormal[1], viewNormal[2]) vis.View3DAtts.focus = (-634.56, 91.3781, -13.7891) vis.View3DAtts.viewUp = (-0.102795, 0.917551, 0.3841) vis.View3DAtts.viewAngle = 30 vis.View3DAtts.parallelScale = 1.45614e+06 vis.View3DAtts.nearPlane = -2.91228e+06 vis.View3DAtts.farPlane = 2.91228e+06 vis.View3DAtts.imagePan = (0, 0) vis.View3DAtts.imageZoom = zoom vis.View3DAtts.perspective = 1 vis.View3DAtts.eyeAngle = 2 vis.View3DAtts.centerOfRotationSet = 0 vis.View3DAtts.centerOfRotation = (-634.56, 91.3781, -13.7891) vis.View3DAtts.axis3DScaleFlag = 0 vis.View3DAtts.axis3DScales = (1, 1, 1) vis.View3DAtts.shear = (0, 0, 1) vis.SetView3D(vis.View3DAtts) # End spontaneous state vis.ViewCurveAtts = vis.ViewCurveAttributes() vis.ViewCurveAtts.domainCoords = (0, 1) vis.ViewCurveAtts.rangeCoords = (0, 1) vis.ViewCurveAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) vis.ViewCurveAtts.domainScale = vis.ViewCurveAtts.LINEAR # LINEAR, LOG vis.ViewCurveAtts.rangeScale = vis.ViewCurveAtts.LINEAR # LINEAR, LOG vis.SetViewCurve(vis.ViewCurveAtts) vis.View2DAtts = vis.View2DAttributes() vis.View2DAtts.windowCoords = (0, 1, 0, 1) vis.View2DAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) vis.View2DAtts.fullFrameActivationMode = vis.View2DAtts.Auto # On, Off, Auto vis.View2DAtts.fullFrameAutoThreshold = 100 vis.View2DAtts.xScale = vis.View2DAtts.LINEAR # LINEAR, LOG vis.View2DAtts.yScale = vis.View2DAtts.LINEAR # LINEAR, LOG vis.View2DAtts.windowValid = 0 vis.SetView2D(vis.View2DAtts) vis.View3DAtts = vis.View3DAttributes() vis.View3DAtts.viewNormal = (viewNormal[0], viewNormal[1], viewNormal[2]) vis.View3DAtts.focus = (-634.56, 91.3781, -13.7891) vis.View3DAtts.viewUp = (-0.102795, 0.917551, 0.3841) vis.View3DAtts.viewAngle = 30 vis.View3DAtts.parallelScale = 1.45614e+06 vis.View3DAtts.nearPlane = -2.91228e+06 vis.View3DAtts.farPlane = 2.91228e+06 vis.View3DAtts.imagePan = (0, 0) vis.View3DAtts.imageZoom = zoom vis.View3DAtts.perspective = 1 vis.View3DAtts.eyeAngle = 2 vis.View3DAtts.centerOfRotationSet = 0 vis.View3DAtts.centerOfRotation = (-634.56, 91.3781, -13.7891) vis.View3DAtts.axis3DScaleFlag = 0 vis.View3DAtts.axis3DScales = (1, 1, 1) vis.View3DAtts.shear = (0, 0, 1) vis.SetView3D(vis.View3DAtts) vis.ViewAxisArrayAtts = vis.ViewAxisArrayAttributes() vis.ViewAxisArrayAtts.domainCoords = (0, 1) vis.ViewAxisArrayAtts.rangeCoords = (0, 1) vis.ViewAxisArrayAtts.viewportCoords = (0.15, 0.9, 0.1, 0.85) vis.SetViewAxisArray(vis.ViewAxisArrayAtts) for i in range(0, vis.GetDatabaseNStates()): vis.SetTimeSliderState(i) vis.SaveWindowAtts = vis.SaveWindowAttributes() vis.SaveWindowAtts.outputToCurrentDirectory = 0 vis.SaveWindowAtts.outputDirectory = outputDir vis.SaveWindowAtts.fileName = fileName vis.SaveWindowAtts.family = 1 vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY vis.SaveWindowAtts.width = WIDTH vis.SaveWindowAtts.height = HEIGHT vis.SaveWindowAtts.screenCapture = 0 vis.SaveWindowAtts.saveTiled = 0 vis.SaveWindowAtts.quality = 100 vis.SaveWindowAtts.progressive = 0 vis.SaveWindowAtts.binary = 0 vis.SaveWindowAtts.stereo = 0 vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate vis.SaveWindowAtts.forceMerge = 0 vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions vis.SaveWindowAtts.advancedMultiWindowSave = 0 vis.SetSaveWindowAttributes(vis.SaveWindowAtts) vis.SaveWindow() vis.DeleteActivePlots() vis.CloseDatabase(databaseName) # Make the movie: framerate = 5 subprocess.call([ pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh", outputDir, fileName, framerate ])
def viewit(): tl = visit.CreateAnnotationObject("Text2D") tl.position = (.08, .93) tl.height = .026 tl.fontFamily = 0 tl.fontBold = 1 tl.fontShadow = 1 visit.DeleteAllPlots() k = 30000 kMax = 40001 while k < kMax: filename = "scalar" + str(k) + ".Point3D" print "opening database file: " + filename status = visit.OpenDatabase(filename, 0, "Point3D") if status != 1: print "Could not open " + filename return status = visit.AddPlot("Pseudocolor", "density") visit.DrawPlots() pca = visit.GetPlotOptions() pca.colorTableName = "density" pca.invertColorTable = 1 pca.minFlag = 1 pca.maxFlag = 1 pca.min = -.21 pca.max = .21 # visit.SetPlotOptions(pca) names = visit.GetAnnotationObjectNames() print names lastName = names[-1] print "lastName = " + lastName legend = visit.GetAnnotationObject(lastName) legend.numTicks = 3 legend.managePosition = 0 legend.position = (.1, .88) legend.orientation = 1 legend.drawMinMax = 0 legend.drawTitle = 0 legend.drawLabels = "Labels" legend.suppliedLabels = (" -.15", " 0.", " .15") legend.fontHeight = .024 legend.numberFormat = "%#-9.2g" legend.fontFamily = 2 legend.fontBold = 1 tl.text = "Density Fluctuation - Step " + str(k) tl.visible = 1 visit.SaveWindow() k = k + 1000 if k < kMax: tl.visible = 0 visit.DeleteAllPlots() visit.CloseDatabase(filename)
def unloadSources(self): v.DeleteAllPlots() if self.subsurface_src is not None: v.CloseDatabase(self.subsurface_src) if self.surface_src is not None: v.CloseDatabase(self.surface_src)
def create_visit_point_movie(variableName, minValue, maxValue, inputDirectory, inputFileNames, coordinates, outputDirectory, outputFileName, colorTable="hot_desaturated"): ''' Function for making a movie Arguments: :param variableName Name of the variable :param minValue Minimum value of the variable :param maxValue Maximum value of the variable :param inputDirectory Path to input vlsv/silo files :param inputFileNames Name of the files for example [\"bulk.00000.silo\", \"bulk.00001.silo\"] :param coordinates Coordinates corresponding to the files so for example [ [[0,0,0], [0,1,0]], [[2,1,2], [2,1,4]] ] :param outputDirectory Path to output directory :param outputFileName Name of the output file :param colorTable="hot_desaturated" Color table for the plots ''' coordinates = [coordinates] for i in range(len(inputFileNames)): # OPTIONS ################################################################# # Input variable _variableName = variableName minVariableValue = minValue maxVariableValue = maxValue colorTableName = colorTable # Input directory and file names #_outputDir = "/home/hannukse/MOVINGFRAME_MOVIES/AAJ_BZ_REMAKE/" # Set the output directory (Where .png s are saved) _outputDir = outputDirectory #_outputFileName = "BZ_FORESHOCK_2_" # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, .. _outputFileName = outputFileName # The file names for the png files. #databaseName = "localhost:/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/bulk.*.silo database" # For navigating to the silo files inputFileName = inputFileNames[i] databaseName = "localhost:" + inputDirectory + inputFileName # For navigating to the silo files # Note: a slice of the plot in z-axis is taken automatically ################################################################# # LaunchNowin(vdir=visitBinDirectory) #dx = speedX * frameInSeconds # Note: This is in meters per frame! #dy = speedY * frameInSeconds # Note: This is in meters per frame! #LaunchNowin(vdir="/usr/local/visit/bin") #Set up window and annotations #vis.LaunchNowin(vdir="/usr/local/visit/bin") inputFileName2 = "point.vtk" databaseName2 = "localhost:" + os.getcwd() + "/" + inputFileName2 vis.OpenDatabase(databaseName, 0) #vis.ActiveDatabase("localhost:" + inputDirectory + inputFileName) #Load settings visSettings.load_visit_settings() vis.AddPlot("Pseudocolor", _variableName, 1, 1) #CONTINUE vis.SetActivePlots(1) vis.PseudocolorAtts = vis.PseudocolorAttributes() vis.PseudocolorAtts.legendFlag = 1 vis.PseudocolorAtts.lightingFlag = 1 vis.PseudocolorAtts.minFlag = 1 vis.PseudocolorAtts.maxFlag = 1 vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural # Natural, Nodal, Zonal vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear # Linear, Log, Skew vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot vis.PseudocolorAtts.min = minVariableValue vis.PseudocolorAtts.max = maxVariableValue vis.PseudocolorAtts.pointSize = 0.05 vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point # Box, Axis, Icosahedron, Point, Sphere vis.PseudocolorAtts.skewFactor = 1 vis.PseudocolorAtts.opacity = 1 vis.PseudocolorAtts.colorTableName = colorTableName vis.PseudocolorAtts.invertColorTable = 0 vis.PseudocolorAtts.smoothingLevel = 0 vis.PseudocolorAtts.pointSizeVarEnabled = 0 vis.PseudocolorAtts.pointSizeVar = "default" vis.PseudocolorAtts.pointSizePixels = 2 vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.PseudocolorAtts.lineWidth = 0 vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit # Explicit, ColorTable vis.SetPlotOptions(vis.PseudocolorAtts) vis.SetActivePlots(1) vis.AddOperator("Slice", 1) vis.SetActivePlots(1) vis.SliceAtts = vis.SliceAttributes() vis.SliceAtts.originType = vis.SliceAtts.Intercept # Point, Intercept, Percent, Zone, Node vis.SliceAtts.originPoint = (0, 0, 0) vis.SliceAtts.originIntercept = 0 vis.SliceAtts.originPercent = 0 vis.SliceAtts.originZone = 0 vis.SliceAtts.originNode = 0 vis.SliceAtts.normal = (0, 0, 1) vis.SliceAtts.axisType = vis.SliceAtts.ZAxis # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi vis.SliceAtts.upAxis = (0, 1, 0) vis.SliceAtts.project2d = 1 vis.SliceAtts.interactive = 1 vis.SliceAtts.flip = 0 vis.SliceAtts.originZoneDomain = 0 vis.SliceAtts.originNodeDomain = 0 vis.SliceAtts.meshName = "SpatialGrid" vis.SliceAtts.theta = 0 vis.SliceAtts.phi = 90 vis.SetOperatorOptions(vis.SliceAtts, 1) vis.DrawPlots() vis.SetActivePlots(0) for coordinate in coordinates[i]: print(str(coordinate)) create_point_vtk(fileName=inputFileName2, coordinates=coordinate) vis.OpenDatabase(databaseName2, 0) vis.AddPlot("Mesh", "mesh", 1, 1) vis.SetActivePlots(vis.GetNumPlots()) vis.MeshAtts = vis.MeshAttributes() vis.MeshAtts.legendFlag = 1 vis.MeshAtts.lineStyle = vis.MeshAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.MeshAtts.lineWidth = 0 vis.MeshAtts.meshColor = (0, 0, 0, 255) vis.MeshAtts.outlineOnlyFlag = 0 vis.MeshAtts.errorTolerance = 0.01 vis.MeshAtts.meshColorSource = vis.MeshAtts.Foreground # Foreground, MeshCustom vis.MeshAtts.opaqueColorSource = vis.MeshAtts.Background # Background, OpaqueCustom vis.MeshAtts.opaqueMode = vis.MeshAtts.Auto # Auto, On, Off vis.MeshAtts.pointSize = 0.05 vis.MeshAtts.opaqueColor = (255, 255, 255, 255) vis.MeshAtts.smoothingLevel = vis.MeshAtts.None # None, Fast, High vis.MeshAtts.pointSizeVarEnabled = 0 vis.MeshAtts.pointSizeVar = "default" vis.MeshAtts.pointType = vis.MeshAtts.Point # Box, Axis, Icosahedron, Point, Sphere vis.MeshAtts.showInternal = 0 vis.MeshAtts.pointSizePixels = 10 vis.MeshAtts.opacity = 1 vis.SetPlotOptions(vis.MeshAtts) vis.DrawPlots() # Iterate through frames vis.SaveWindowAtts = vis.SaveWindowAttributes() vis.SaveWindowAtts.outputToCurrentDirectory = 0 vis.SaveWindowAtts.outputDirectory = _outputDir vis.SaveWindowAtts.fileName = _outputFileName vis.SaveWindowAtts.family = 1 vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY vis.SaveWindowAtts.width = 3000 vis.SaveWindowAtts.height = 3000 vis.SaveWindowAtts.screenCapture = 0 vis.SaveWindowAtts.saveTiled = 0 vis.SaveWindowAtts.quality = 100 vis.SaveWindowAtts.progressive = 0 vis.SaveWindowAtts.binary = 0 vis.SaveWindowAtts.stereo = 0 vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate vis.SaveWindowAtts.forceMerge = 0 vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions vis.SaveWindowAtts.advancedMultiWindowSave = 0 vis.SetSaveWindowAttributes(vis.SaveWindowAtts) vis.SaveWindow() vis.DeleteActivePlots() vis.DeleteActivePlots() vis.CloseDatabase(databaseName) vis.CloseDatabase(databaseName2) # Make the movie: #subprocess.call("./moviecompilescript.sh " + _outputDir + " " + _outputFileName) pyVisitPath = "pyVisit/" #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh") #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh " + _outputDir + " " + _outputFileName) framerate = "10" subprocess.call([ pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh", _outputDir, _outputFileName, framerate ]) # Delete the point vtk file: os.remove(os.getcwd() + "/" + inputFileName2)
def make_moving_frame_of_reference_movie(x_begin, x_end, y_begin, y_end, speed_x, speed_y, variable_name, minThreshold, maxThreshold, input_directory, input_file_name, output_directory, output_file_name, color_table="hot_desaturated", start_frame=-1, end_frame=-1, frame_skip_dt=1.0): ''' Function for making a movie with a moving frame of reference. :param x_begin The starting frame's beginning x-coordinate :param x_end The starting frame's ending x-coordinate :param y_begin The starting frame's beginning x-coordinate :param y_end The starting frame's ending y-coordinate :param speed_x The speed at which the frame moves in the x direction :param speed_y The speed at which the frame moves in the y direction :param variable_name Name of the variable (For ex \"rho\") :param minThreshold Minimum threshold for the variable :param maxThreshold Maximum threshold for the variable :param input_directory The path to the directory where the files are :param input_file_name Name of the files (For ex \"bulk.*.silo\") :param output_directory Directory where to output the movie :param output_file_name Name of the outputted file (For ex \"RHOMOVIE\") :param color_table Name of the color table (\"hot_desaturated\" by default) :param start_frame Starting frame for the movie (if -1, equals 0, -1 by default) :param end_frame Ending frame for the movie (if -1, equals the last frame, -1 by default) :param frame_skip_dt The number of seconds one skip in frame equals (1.0 by default) (Note: This may change depending on the run and should always be checked) ''' # OPTIONS ################################################################# # Input the boundary box for starting coordinates (Starting values) startX = x_begin # The left x-boundary of the box endX = x_end # The right x-boundary of the box startY = y_begin # The bottom y-boundary of the box endY = y_end # The upper y-boundary of the box # Input frame properties startFrame = start_frame # Note: if startFrame is set to -1 the start frame gets set to 0 endFrame = end_frame # Note: if endFrame is set to -1 the endFrame is automatically the number of frames in the database frameInSeconds = frame_skip_dt # Set how many seconds one frame skip is # Input speed in x and y direction speedX = speed_x # Meters per second speedY = speed_y # Meters per second # Input variable variableName = variable_name minVariableValue = minThreshold maxVariableValue = maxThreshold colorTableName = color_table # Input directory and file names outputDir = output_directory # Set the output directory (Where .png s are saved) outputFileName = output_file_name # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, . databaseName = "localhost:" + input_directory + input_file_name + " database" # For navigating to the silo files # visitBinDirectory = "/usr/local/visit/bin" #Nevermind this # Note: a slice of the plot in z-axis is taken automatically ################################################################# # Launch visit visitBinDirectory = '/home/htest/visit/bin' vis.LaunchNowin(vdir=visitBinDirectory) dx = speedX * frameInSeconds # Note: This is in meters per frame! dy = speedY * frameInSeconds # Note: This is in meters per frame! #Set up window and annotations vis.OpenDatabase(databaseName, 0) #Load settings visSettings.load_visit_settings() vis.AddPlot("Pseudocolor", variableName, 1, 1) vis.SetActivePlots(0) vis.PseudocolorAtts = vis.PseudocolorAttributes() vis.PseudocolorAtts.legendFlag = 1 vis.PseudocolorAtts.lightingFlag = 1 vis.PseudocolorAtts.minFlag = 1 vis.PseudocolorAtts.maxFlag = 1 vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural # Natural, Nodal, Zonal vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear # Linear, Log, Skew vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot vis.PseudocolorAtts.min = minVariableValue vis.PseudocolorAtts.max = maxVariableValue vis.PseudocolorAtts.pointSize = 0.05 vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point # Box, Axis, Icosahedron, Point, Sphere vis.PseudocolorAtts.skewFactor = 1 vis.PseudocolorAtts.opacity = 1 vis.PseudocolorAtts.colorTableName = color_table vis.PseudocolorAtts.invertColorTable = 0 vis.PseudocolorAtts.smoothingLevel = 0 vis.PseudocolorAtts.pointSizeVarEnabled = 0 vis.PseudocolorAtts.pointSizeVar = "default" vis.PseudocolorAtts.pointSizePixels = 2 vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.PseudocolorAtts.lineWidth = 0 vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit # Explicit, ColorTable vis.SetPlotOptions(vis.PseudocolorAtts) vis.SetActivePlots(0) vis.AddOperator("Slice", 1) vis.AddOperator("Threshold", 1) vis.ThresholdAtts = vis.ThresholdAttributes() vis.ThresholdAtts.outputMeshType = 0 vis.ThresholdAtts.listedVarNames = ("Boundary_type") vis.ThresholdAtts.zonePortions = (1) vis.ThresholdAtts.lowerBounds = (1) vis.ThresholdAtts.upperBounds = (1) vis.ThresholdAtts.defaultVarName = variableName vis.ThresholdAtts.defaultVarIsScalar = 1 vis.SetOperatorOptions(vis.ThresholdAtts, 1) vis.ThresholdAtts = vis.ThresholdAttributes() vis.ThresholdAtts.outputMeshType = 0 vis.ThresholdAtts.listedVarNames = ("Boundary_type") vis.ThresholdAtts.zonePortions = (1) vis.ThresholdAtts.lowerBounds = (1) vis.ThresholdAtts.upperBounds = (1) vis.ThresholdAtts.defaultVarName = variableName vis.ThresholdAtts.defaultVarIsScalar = 1 vis.SetOperatorOptions(vis.ThresholdAtts, 1) vis.SetActivePlots(0) vis.SliceAtts = vis.SliceAttributes() vis.SliceAtts.originType = vis.SliceAtts.Intercept # Point, Intercept, Percent, Zone, Node vis.SliceAtts.originPoint = (0, 0, 0) vis.SliceAtts.originIntercept = 0 vis.SliceAtts.originPercent = 0 vis.SliceAtts.originZone = 0 vis.SliceAtts.originNode = 0 vis.SliceAtts.normal = (0, 0, 1) vis.SliceAtts.axisType = vis.SliceAtts.ZAxis # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi vis.SliceAtts.upAxis = (0, 1, 0) vis.SliceAtts.project2d = 1 vis.SliceAtts.interactive = 1 vis.SliceAtts.flip = 0 vis.SliceAtts.originZoneDomain = 0 vis.SliceAtts.originNodeDomain = 0 vis.SliceAtts.meshName = "SpatialGrid" vis.SliceAtts.theta = 0 vis.SliceAtts.phi = 90 vis.SetOperatorOptions(vis.SliceAtts, 1) vis.DrawPlots() if endFrame == -1: endFrame = vis.TimeSliderGetNStates() - 1 if startFrame == -1: startFrame = 0 # Iterate through frames for i in xrange(startFrame, endFrame + 1): vis.SetTimeSliderState(i) frame = i - startFrame vis.View2DAtts = vis.View2DAttributes() vis.View2DAtts.windowCoords = (startX + frame * dx, endX + frame * dx, startY + frame * dy, endY + frame * dy) vis.View2DAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) vis.View2DAtts.fullFrameActivationMode = vis.View2DAtts.Auto # On, Off, Auto vis.View2DAtts.fullFrameAutoThreshold = 100 vis.View2DAtts.xScale = vis.View2DAtts.LINEAR # LINEAR, LOG vis.View2DAtts.yScale = vis.View2DAtts.LINEAR # LINEAR, LOG vis.View2DAtts.windowValid = 1 vis.SetView2D(vis.View2DAtts) vis.SaveWindowAtts = vis.SaveWindowAttributes() vis.SaveWindowAtts.outputToCurrentDirectory = 0 vis.SaveWindowAtts.outputDirectory = outputDir vis.SaveWindowAtts.fileName = outputFileName vis.SaveWindowAtts.family = 1 vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY vis.SaveWindowAtts.width = 1024 vis.SaveWindowAtts.height = 1024 vis.SaveWindowAtts.screenCapture = 0 vis.SaveWindowAtts.saveTiled = 0 vis.SaveWindowAtts.quality = 100 vis.SaveWindowAtts.progressive = 0 vis.SaveWindowAtts.binary = 0 vis.SaveWindowAtts.stereo = 0 vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate vis.SaveWindowAtts.forceMerge = 0 vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions vis.SaveWindowAtts.advancedMultiWindowSave = 0 vis.SetSaveWindowAttributes(vis.SaveWindowAtts) vis.SaveWindow() vis.DeleteActivePlots() vis.CloseDatabase(databaseName) # Make the movie: framerate = 7 subprocess.call([ pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh", outputDir, outputFileName, framerate ])
def make_moving_frame_of_reference_line_plot(point1, point2, velocity, variable_name, input_directory, input_file_name, output_directory, output_file_name, start_frame=-1, end_frame=-1, frame_skip_dt=1.0): ''' Function for making a line plot of some variable with a moving frame of reference :param point1 The starting point of the line (must be an array of size 3) :param point2 The ending point of the line (must be an array of size 3) :param velocity The velocity vector of the frame of reference (must be an array of size 3) :param variable_name Name of the variable (For ex \"rho\") :param input_directory The path to the directory where the files are :param input_file_name Name of the files (For ex \"bulk.*.silo\") :param output_directory Directory where to output the movie :param output_file_name Name of the outputted file (For ex \"RHOMOVIE\") :param start_frame Starting frame for the movie (if -1, equals 0, -1 by default) :param end_frame Ending frame for the movie (if -1, equals the last frame, -1 by default) :param frame_skip_dt The number of seconds one skip in frame equals (1.0 by default) (Note: This may change depending on the run and should always be checked) ''' if len(point1) != 3 or len(point2) != 3 or len(velocity) != 3: print "BAD INPUT IN make_moving_frame_of_reference_line_plot, POINT1, POINT2 AND VELOCITY MUST BE ARRAYS OF SIZE 3" # OPTIONS ################################################################# # Input the boundary box for starting coordinates (Starting values) startX = point1[0] # The left x-boundary of the box endX = point2[0] # The right x-boundary of the box startY = point1[1] # The bottom y-boundary of the box endY = point2[1] # The upper y-boundary of the box startZ = poin1[2] # The left z-boundary of the box endZ = point2[2] # The right z-boundary of the box # Input frame properties startFrame = start_frame # Note: if startFrame is set to -1 the start frame gets set to 0 endFrame = end_frame # Note: if endFrame is set to -1 the endFrame is automatically the number of frames in the database frameInSeconds = frame_skip_dt # Set how many seconds one frame skip is screenWidth = 3000 screenHeight = 3000 # Input speed in x and y direction speedX = velocity[0] # Meters per second speedY = velocity[1] # Meters per second speedZ = velocity[2] # Meters per second # Input variable name # Note: needs to have operators/Lineout/ for visit to recognize it as line plot. Additionally, visit does not accept any '/' in the variable name which is why they're removed. The curve definitions are in loadvisitsettings.py and in there the curve expressions are defined so that there's no '/' in the variable name variableName = "operators/Lineout/" + variable_name.replace("/", "") # Input directory and file names outputDir = output_directory # Set the output directory (Where .png s are saved) outputFileName = output_file_name # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, .. databaseName = "localhost:" + input_directory + input_file_name + " database" # For navigating to the silo files # visitBinDirectory = "/usr/lvariableNameocal/visit/bin" #Nevermind this # Note: a slice of the plot in z-axis is taken automatically ################################################################# dx = speedX * frameInSeconds # Note: This is in meters per frame! dy = speedY * frameInSeconds # Note: This is in meters per frame! dz = speedZ * frameInSeconds # Note: This is in meters per frame! vis.OpenDatabase(databaseName, 0) #Load settings visSettings.load_visit_settings() vis.AddPlot("Curve", variableName, 1, 1) vis.LineoutAtts = vis.LineoutAttributes() vis.LineoutAtts.point1 = (startX, startY, 0) vis.LineoutAtts.point2 = (endX, endY, 0) vis.LineoutAtts.interactive = 0 vis.LineoutAtts.ignoreGlobal = 0 vis.LineoutAtts.samplingOn = 0 vis.LineoutAtts.numberOfSamplePoints = 50 vis.LineoutAtts.reflineLabels = 0 vis.SetOperatorOptions(vis.LineoutAtts, 1) vis.CurveAtts = vis.CurveAttributes() vis.CurveAtts.showLines = 1 vis.CurveAtts.lineStyle = vis.CurveAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.CurveAtts.lineWidth = 2 vis.CurveAtts.showPoints = 1 vis.CurveAtts.symbol = vis.CurveAtts.Point # Point, TriangleUp, TriangleDown, Square, Circle, Plus, X vis.CurveAtts.pointSize = 5 vis.CurveAtts.pointFillMode = vis.CurveAtts.Static # Static, Dynamic vis.CurveAtts.pointStride = 1 vis.CurveAtts.symbolDensity = 50 vis.CurveAtts.curveColorSource = vis.CurveAtts.Custom # Cycle, Custom vis.CurveAtts.curveColor = (0, 0, 0, 255) vis.CurveAtts.showLegend = 1 vis.CurveAtts.showLabels = 0 vis.CurveAtts.designator = "" vis.CurveAtts.doBallTimeCue = 0 vis.CurveAtts.ballTimeCueColor = (0, 0, 0, 255) vis.CurveAtts.timeCueBallSize = 0.01 vis.CurveAtts.doLineTimeCue = 0 vis.CurveAtts.lineTimeCueColor = (0, 0, 0, 255) vis.CurveAtts.lineTimeCueWidth = 0 vis.CurveAtts.doCropTimeCue = 0 vis.CurveAtts.timeForTimeCue = 0 vis.SetPlotOptions(vis.CurveAtts) vis.DrawPlots() # Iterate through frames for i in xrange(startFrame, endFrame + 1): vis.SetTimeSliderState(i) frame = i - startFrame vis.LineoutAtts = vis.LineoutAttributes() vis.LineoutAtts.point1 = (startX + frame * dx, startY + frame * dy, 0) vis.LineoutAtts.point2 = (endX + frame * dx, endY + frame * dy, 0) vis.LineoutAtts.interactive = 0 vis.LineoutAtts.ignoreGlobal = 0 vis.LineoutAtts.samplingOn = 0 vis.LineoutAtts.numberOfSamplePoints = 50 vis.LineoutAtts.reflineLabels = 0 vis.SetOperatorOptions(vis.LineoutAtts, 1) vis.SaveWindowAtts = vis.SaveWindowAttributes() vis.SaveWindowAtts.outputToCurrentDirectory = 0 vis.SaveWindowAtts.outputDirectory = outputDir vis.SaveWindowAtts.fileName = outputFileName vis.SaveWindowAtts.family = 1 vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY vis.SaveWindowAtts.width = screenWidth vis.SaveWindowAtts.height = screenHeight vis.SaveWindowAtts.screenCapture = 0 vis.SaveWindowAtts.saveTiled = 0 vis.SaveWindowAtts.quality = 80 vis.SaveWindowAtts.progressive = 0 vis.SaveWindowAtts.binary = 0 vis.SaveWindowAtts.stereo = 0 vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate vis.SaveWindowAtts.forceMerge = 0 vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions vis.SaveWindowAtts.advancedMultiWindowSave = 0 vis.SetSaveWindowAttributes(vis.SaveWindowAtts) vis.SaveWindow() vis.DeleteActivePlots() vis.CloseDatabase(databaseName) # Make the movie: framerate = 5 subprocess.call([ pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh", outputDir, outputFileName, framerate ])
def cleanup_windows(self): WindowManager.cleanup_windows() visit.CloseDatabase(db) visit.CloseComputeEngine()
def make_movie( variableName, minValue, maxValue, inputDirectory, inputFileName, outputDirectory, outputFileName, colorTable="hot_desaturated", startFrame=-1, endFrame=-1 ): ''' Function for making a movie Arguments: :param variableName Name of the variable :param minValue Minimum value of the variable :param maxValue Maximum value of the variable :param inputDirectory Path to input vlsv/silo files :param inputFileName Name of the file(s) so for example if the filenames are bulk.0000.silo, bulk.0001.silo, .. then inputFileName=\"bulk.*.silo\"" :param outputDirectory Path to output directory :param outputFileName Name of the output file :param colorTable="hot_desaturated" Color table for the plots :param startFrame=-1 Starting frame of the movie (-1 equals 0) :param endFrame=-1 Starting frame of the movie (-1 equals last frame) ''' # OPTIONS ################################################################# # Input frame properties _startFrame = startFrame # Note: if _startFrame is set to -1 the start frame gets set to 0 _endFrame = endFrame # Note: if _endFrame is set to -1 the _endFrame is automatically the number of frames in the database # Input variable _variableName = variableName minVariableValue = minValue maxVariableValue = maxValue colorTableName = colorTable # Input directory and file names #_outputDir = "/home/hannukse/MOVINGFRAME_MOVIES/AAJ_BZ_REMAKE/" # Set the output directory (Where .png s are saved) _outputDir = outputDirectory #_outputFileName = "BZ_FORESHOCK_2_" # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, .. _outputFileName = outputFileName # The file names for the png files. #databaseName = "localhost:/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/bulk.*.silo database" # For navigating to the silo files databaseName = "localhost:" + inputDirectory + inputFileName + " database" # For navigating to the silo files # Note: a slice of the plot in z-axis is taken automatically ################################################################# # LaunchNowin(vdir=visitBinDirectory) #dx = speedX * frameInSeconds # Note: This is in meters per frame! #dy = speedY * frameInSeconds # Note: This is in meters per frame! #LaunchNowin(vdir="/usr/local/visit/bin") #Set up window and annotations #vis.LaunchNowin(vdir="/usr/local/visit/bin") vis.OpenDatabase(databaseName, 0) #Load settings visSettings.load_visit_settings() vis.AddPlot("Pseudocolor", _variableName, 1, 1) #CONTINUE vis.SetActivePlots(0) vis.PseudocolorAtts = vis.PseudocolorAttributes() vis.PseudocolorAtts.legendFlag = 1 vis.PseudocolorAtts.lightingFlag = 1 vis.PseudocolorAtts.minFlag = 1 vis.PseudocolorAtts.maxFlag = 1 vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural # Natural, Nodal, Zonal vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear # Linear, Log, Skew vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot vis.PseudocolorAtts.min = minVariableValue vis.PseudocolorAtts.max = maxVariableValue vis.PseudocolorAtts.pointSize = 0.05 vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point # Box, Axis, Icosahedron, Point, Sphere vis.PseudocolorAtts.skewFactor = 1 vis.PseudocolorAtts.opacity = 1 vis.PseudocolorAtts.colorTableName = colorTableName vis.PseudocolorAtts.invertColorTable = 0 vis.PseudocolorAtts.smoothingLevel = 0 vis.PseudocolorAtts.pointSizeVarEnabled = 0 vis.PseudocolorAtts.pointSizeVar = "default" vis.PseudocolorAtts.pointSizePixels = 2 vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.PseudocolorAtts.lineWidth = 0 vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit # Explicit, ColorTable vis.SetPlotOptions(vis.PseudocolorAtts) vis.SetActivePlots(0) vis.AddOperator("Slice", 1) vis.SetActivePlots(0) vis.SliceAtts = vis.SliceAttributes() vis.SliceAtts.originType = vis.SliceAtts.Intercept # Point, Intercept, Percent, Zone, Node vis.SliceAtts.originPoint = (0, 0, 0) vis.SliceAtts.originIntercept = 0 vis.SliceAtts.originPercent = 0 vis.SliceAtts.originZone = 0 vis.SliceAtts.originNode = 0 vis.SliceAtts.normal = (0, 0, 1) vis.SliceAtts.axisType = vis.SliceAtts.ZAxis # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi vis.SliceAtts.upAxis = (0, 1, 0) vis.SliceAtts.project2d = 1 vis.SliceAtts.interactive = 1 vis.SliceAtts.flip = 0 vis.SliceAtts.originZoneDomain = 0 vis.SliceAtts.originNodeDomain = 0 vis.SliceAtts.meshName = "SpatialGrid" vis.SliceAtts.theta = 0 vis.SliceAtts.phi = 90 vis.SetOperatorOptions(vis.SliceAtts, 1) vis.DrawPlots() if _endFrame == -1: _endFrame = vis.TimeSliderGetNStates() - 1 if _startFrame == -1: _startFrame = 0 # Iterate through frames for i in range(_startFrame, _endFrame+1): vis.SetTimeSliderState(i) frame = i - _startFrame vis.SaveWindowAtts = vis.SaveWindowAttributes() vis.SaveWindowAtts.outputToCurrentDirectory = 0 vis.SaveWindowAtts.outputDirectory = _outputDir vis.SaveWindowAtts.fileName = _outputFileName vis.SaveWindowAtts.family = 1 vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY vis.SaveWindowAtts.width = 3000 vis.SaveWindowAtts.height = 3000 vis.SaveWindowAtts.screenCapture = 0 vis.SaveWindowAtts.saveTiled = 0 vis.SaveWindowAtts.quality = 100 vis.SaveWindowAtts.progressive = 0 vis.SaveWindowAtts.binary = 0 vis.SaveWindowAtts.stereo = 0 vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate vis.SaveWindowAtts.forceMerge = 0 vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions vis.SaveWindowAtts.advancedMultiWindowSave = 0 vis.SetSaveWindowAttributes(vis.SaveWindowAtts) vis.SaveWindow() vis.DeleteActivePlots() vis.CloseDatabase(databaseName) # Make the movie: #subprocess.call("./moviecompilescript.sh " + _outputDir + " " + _outputFileName) pyVisitPath = "pyVisit/" #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh") #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh " + _outputDir + " " + _outputFileName) framerate = "10" subprocess.call([pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh", _outputDir, _outputFileName, framerate])
timestep = str(aux[-1]).zfill(6) visit.OpenDatabase(db) for variable in variables: i = 0 for location in locations: i += 1 LineoutAtts = visit.LineoutAttributes() LineoutAtts.point1 = location[0] LineoutAtts.point2 = location[1] LineoutAtts.samplingOn = 1 LineoutAtts.numberOfSamplePoints = 1000 visit.AddPlot("Curve", "operators/Lineout/" + variable) visit.SetOperatorOptions(LineoutAtts, 1) visit.DrawPlots() e = visit.ExportDBAttributes() e.filename = sim + '_' + case + '_' + timestep + '_' + variable e.dirname = output_folder e.db_type = "Curve2D" visit.ExportDatabase(e) visit.DeleteAllPlots() visit.CloseDatabase(db)
def make_movie_auto(variableName, boundaryBox, vlsvFileName, inputDirectory, inputFileName, outputDirectory, outputFileName, colorTableName="hot_desaturated", startFrame=-1, endFrame=-1, thresholdCoefficient=0.6): ''' Function for making a movie Arguments: :param variableName Name of the variable :param boundaryBox Box for collecting min and max threshold (The movie will focus on that area) :param vlsvFileName Name of a vlsv file where the function collects the threshold for the boundary box :param inputDirectory Path to input vlsv/silo files :param inputFileName Name of the file(s) so for example if the filenames are bulk.0000.silo, bulk.0001.silo, .. then inputFileName=\"bulk.*.silo\"" :param outputDirectory Path to output directory :param outputFileName Name of the output file :param colorTableName="hot_desaturated" Color table for the plots :param thresholdCoefficient Sets the coefficient for a covariant collected from the values from boundary box. The lower this is, the more focused the movie will be on the boundary box area :param startFrame=-1 Starting frame of the movie (-1 equals 0) :param endFrame=-1 Starting frame of the movie (-1 equals last frame) ''' if thresholdCoefficient < 0: print("thresholdCoefficient must be non-negative!") return # OPTIONS ################################################################# # Input frame properties _startFrame = startFrame # Note: if _startFrame is set to -1 the start frame gets set to 0 _endFrame = endFrame # Note: if _endFrame is set to -1 the _endFrame is automatically the number of frames in the database # Input variable _variableName = variableName # Input directory and file names #_outputDir = "/home/hannukse/MOVINGFRAME_MOVIES/AAJ_BZ_REMAKE/" # Set the output directory (Where .png s are saved) _outputDir = outputDirectory #_outputFileName = "BZ_FORESHOCK_2_" # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, .. _outputFileName = outputFileName # The file names for the png files. #databaseName = "localhost:/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/bulk.*.silo database" # For navigating to the silo files databaseName = "localhost:" + inputDirectory + inputFileName + " database" # For navigating to the silo files # Note: a slice of the plot in z-axis is taken automatically ################################################################# # Get the min and max values: # Get all cell ids within the boundary box: vlsvReader = VlsvReader(vlsvFileName) # Get global boundaries: # Get xmax, xmin and xcells_ini xmax = vlsvReader.read_parameter(name="xmax") xmin = vlsvReader.read_parameter(name="xmin") xcells = vlsvReader.read_parameter(name="xcells_ini") # Do the same for y ymax = vlsvReader.read_parameter(name="ymax") ymin = vlsvReader.read_parameter(name="ymin") ycells = vlsvReader.read_parameter(name="ycells_ini") # And for z zmax = vlsvReader.read_parameter(name="zmax") zmin = vlsvReader.read_parameter(name="zmin") zcells = vlsvReader.read_parameter(name="zcells_ini") #Calculate cell lengths: cell_lengths = np.array([(xmax - xmin) / (float)(xcells), (ymax - ymin) / (float)(ycells), (zmax - zmin) / (float)(zcells)]) # Get cell indices: cell_indice_bounds = np.array([ (int)(((float)(boundaryBox[0]) - xmin) / (float)(cell_lengths[0])), (int)(((float)(boundaryBox[1]) - xmin) / (float)(cell_lengths[0])), (int)(((float)(boundaryBox[2]) - ymin) / (float)(cell_lengths[1])), (int)(((float)(boundaryBox[3]) - ymin) / (float)(cell_lengths[1])), (int)(((float)(boundaryBox[4]) - zmin) / (float)(cell_lengths[2])), (int)(((float)(boundaryBox[5]) - zmin) / (float)(cell_lengths[2])) ]) # Get every cell id within the boundary box: cellids = [] cell_indice = np.array( [cell_indice_bounds[0], cell_indice_bounds[2], cell_indice_bounds[4]]) while True: cellids.append(cell_indice[0] + cell_indice[1] * xcells + cell_indice[2] * xcells * ycells + 1) if cell_indice[0] < cell_indice_bounds[1]: cell_indice[0] = cell_indice[0] + 1 elif cell_indice[1] < cell_indice_bounds[3]: cell_indice[1] = cell_indice[1] + 1 cell_indice[0] = cell_indice_bounds[0] elif cell_indice[2] < cell_indice_bounds[5]: cell_indice[2] = cell_indice[2] + 1 cell_indice[1] = cell_indice_bounds[1] cell_indice[0] = cell_indice_bounds[0] else: # Indice out of bounds -- got all cell ids break # Convert cell ids into set: cellids = Set(cellids) cellidlocations = [] # Get all of the cell ids locations: allcellids = vlsvReader.read(name="SpatialGrid", tag="MESH") for i in range(len(allcellids)): if allcellids[i] in cellids: #This cell id is within the user-given boundary cellidlocations.append(allcellids[i]) # Get all of the values: allvalues = vlsvReader.read_variables(name=_variableName) values = [] # Get the values of the cell ids within the boundary for i in cellidlocations: values.append(allvalues[i]) # We now have all the cell ids (and their locations in the arrays) from the area, set min and max thresholds: meanValue = np.mean(values) standardDeviationValue = np.std(values) maxValue = meanValue + ( float)(thresholdCoefficient) * standardDeviationValue minValue = meanValue - ( float)(thresholdCoefficient) * standardDeviationValue # Put threshold values: minVariableValue = minValue maxVariableValue = maxValue # LaunchNowin(vdir=visitBinDirectory) #dx = speedX * frameInSeconds # Note: This is in meters per frame! #dy = speedY * frameInSeconds # Note: This is in meters per frame! #LaunchNowin(vdir="/usr/local/visit/bin") #Set up window and annotations #vis.LaunchNowin(vdir="/usr/local/visit/bin") vis.OpenDatabase(databaseName, 0) #Load settings visSettings.load_visit_settings() vis.AddPlot("Pseudocolor", _variableName, 1, 1) #CONTINUE vis.SetActivePlots(0) vis.PseudocolorAtts = vis.PseudocolorAttributes() vis.PseudocolorAtts.legendFlag = 1 vis.PseudocolorAtts.lightingFlag = 1 vis.PseudocolorAtts.minFlag = 1 vis.PseudocolorAtts.maxFlag = 1 vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural # Natural, Nodal, Zonal vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear # Linear, Log, Skew vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot vis.PseudocolorAtts.min = minVariableValue vis.PseudocolorAtts.max = maxVariableValue vis.PseudocolorAtts.pointSize = 0.05 vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point # Box, Axis, Icosahedron, Point, Sphere vis.PseudocolorAtts.skewFactor = 1 vis.PseudocolorAtts.opacity = 1 vis.PseudocolorAtts.colorTableName = colorTableName vis.PseudocolorAtts.invertColorTable = 0 vis.PseudocolorAtts.smoothingLevel = 0 vis.PseudocolorAtts.pointSizeVarEnabled = 0 vis.PseudocolorAtts.pointSizeVar = "default" vis.PseudocolorAtts.pointSizePixels = 2 vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.PseudocolorAtts.lineWidth = 0 vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit # Explicit, ColorTable vis.SetPlotOptions(vis.PseudocolorAtts) vis.SetActivePlots(0) vis.AddOperator("Slice", 1) vis.SetActivePlots(0) vis.SliceAtts = vis.SliceAttributes() vis.SliceAtts.originType = vis.SliceAtts.Intercept # Point, Intercept, Percent, Zone, Node vis.SliceAtts.originPoint = (0, 0, 0) vis.SliceAtts.originIntercept = 0 vis.SliceAtts.originPercent = 0 vis.SliceAtts.originZone = 0 vis.SliceAtts.originNode = 0 vis.SliceAtts.normal = (0, 0, 1) vis.SliceAtts.axisType = vis.SliceAtts.ZAxis # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi vis.SliceAtts.upAxis = (0, 1, 0) vis.SliceAtts.project2d = 1 vis.SliceAtts.interactive = 1 vis.SliceAtts.flip = 0 vis.SliceAtts.originZoneDomain = 0 vis.SliceAtts.originNodeDomain = 0 vis.SliceAtts.meshName = "SpatialGrid" vis.SliceAtts.theta = 0 vis.SliceAtts.phi = 90 vis.SetOperatorOptions(vis.SliceAtts, 1) vis.DrawPlots() if _endFrame == -1: _endFrame = vis.TimeSliderGetNStates() - 1 if _startFrame == -1: _startFrame = 0 # Iterate through frames for i in range(_startFrame, _endFrame + 1): vis.SetTimeSliderState(i) frame = i - _startFrame vis.SaveWindowAtts = vis.SaveWindowAttributes() vis.SaveWindowAtts.outputToCurrentDirectory = 0 vis.SaveWindowAtts.outputDirectory = _outputDir vis.SaveWindowAtts.fileName = _outputFileName vis.SaveWindowAtts.family = 1 vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY vis.SaveWindowAtts.width = 3000 vis.SaveWindowAtts.height = 300 vis.SaveWindowAtts.screenCapture = 0 vis.SaveWindowAtts.saveTiled = 0 vis.SaveWindowAtts.quality = 100 vis.SaveWindowAtts.progressive = 0 vis.SaveWindowAtts.binary = 0 vis.SaveWindowAtts.stereo = 0 vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate vis.SaveWindowAtts.forceMerge = 0 vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions vis.SaveWindowAtts.advancedMultiWindowSave = 0 vis.SetSaveWindowAttributes(vis.SaveWindowAtts) vis.SaveWindow() vis.DeleteActivePlots() vis.CloseDatabase(databaseName) # Make the movie: #subprocess.call("./moviecompilescript.sh " + _outputDir + " " + _outputFileName) pyVisitPath = "pyVisit/" #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh") #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh " + _outputDir + " " + _outputFileName) frameRate = "10" subprocess.call([ pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh", _outputDir, _outputFileName, frameRate ])
def run(conf): ''' Visualises clusters of a given run. :param conf: :return: ''' #pp = pprint.PrettyPrinter() #pp.pprint(conf) # Make sure the global configuration is in place utils.run_global_visit_configuration(conf) #pdb.set_trace() clusterConf = utils.getValueForKeyPath(conf, 'postprocessing.clusters') if not clusterConf: print "No configuration for cluster postprocessing. Nothing to do." return 0 visitConf = utils.getValueForKeyPath(clusterConf, 'visit') if not visitConf: print "No configuration for visuals. Nothing to do." return 0 views = utils.getValueForKeyPath(visitConf, 'views') # Set up background gradient, axis labels etc. utils.setAnnotations(visitConf, 'annotationAttributes') # Set view and annotation attributes utils.setAnnotations(conf, 'postprocessing.clusters.visit.annotations') if not utils.getValueForKeyPath(conf, 'resume'): print "Removing results from previous runs" subprocess.call( "rm -rf images movies *.vtk *.vtr *tracking*.png *source*.png", shell=True) else: print "Removing intermediary files from previous runs" subprocess.call("rm -f *.vtk *.vtr *.vtu", shell=True) # Figure out the ending for the cluster vtk files conversion_config = utils.getValueForKeyPath( conf, 'postprocessing.clusters.meanie3D-cfm2vtk') if "--write-as-xml" in conversion_config: cluster_vtk_extension = ".vtu" else: cluster_vtk_extension = ".vtk" # Glob the netcdf directory or find the single file uses_time = utils.getValueForKeyPath(conf, 'uses_time') print "Current work directory: " + os.path.abspath(os.getcwd()) if uses_time: print "Processing file " + conf['source_directory'] netcdf_file = conf['source_directory'] else: print "Processing files in directory " + conf['source_directory'] netcdf_files = sorted(glob.glob(conf['source_directory'] + "/*.nc")) # Keep track of number of images to allow # forced re-set in time to circumvent the # Visit memory leak image_count = 0 index_range = [] if uses_time: t1 = int(utils.getValueForKeyPath(conf, 'start_time_index')) t2 = int(utils.getValueForKeyPath(conf, 'end_time_index')) index_range = range(t1, t2 + 1) else: index_range = range(len(netcdf_files)) time_index = -1 for index in index_range: # construct the cluster filename and find it # in the cluster directory if not uses_time: netcdf_file = netcdf_files[index] else: time_index = index netcdf_path, filename = os.path.split(netcdf_file) basename = os.path.splitext(filename)[0] if uses_time: basename = basename + "-" + str(time_index) cluster_file = conf[ 'cluster_directory'] + os.path.sep + basename + "-clusters.nc" # cluster file gets it's basename from the input file rather than the cluster file cluster_vtk_file = os.path.splitext( filename)[0] + "-clusters" + cluster_vtk_extension # label and displacement files are based on the cluster file name label_vtk_file = basename + "-clusters-centers.vtk" displacement_vtk_file = basename + "-clusters-displacements.vtk" print "netcdf_file = " + netcdf_file print "cluster_file = " + cluster_file # check if the files both exist if not os.path.exists(cluster_file): print "Cluster file does not exist. Skipping." continue # predict the filenames for checking on resume number_postfix = str(image_count).rjust(4, '0') source_open = False skip_source = False if conf['resume'] == True: exists = utils.images_exist(visitConf['views'], "source", image_count) if exists == "all": print "Source visualization " + number_postfix + " exists. Skipping." skip_source = True elif exists == "partial": print "Deleting partial visualization " + number_postfix utils.delete_images(conf, "source", image_count) if skip_source == False: if utils.getValueForKeyPath(clusterConf, 'createSourceMovie'): # Add ancillary background data utils.plotMapdata(visitConf, 'map') # Add timestamp if utils.getValueForKeyPath(clusterConf, 'showDateTime'): utils.add_datetime(clusterConf, netcdf_file, time_index) # Add source data and threshold it print "Plotting source data ..." start_time = time.time() utils.addPseudocolorPlots(netcdf_file, visitConf, 'source.plots', time_index) source_open = True visit.DrawPlots() utils.saveImagesForViews(views, "source") visit.DeleteAllPlots() visit.ClearWindow() print " done. (%.2f seconds)" % (time.time() - start_time) if utils.getValueForKeyPath(clusterConf, 'visualiseClusters'): skip = False if conf['resume'] == True: exists = utils.images_exist(visitConf['views'], "tracking", image_count) if exists == "all": print "Cluster visualization " + number_postfix + " exists. Skipping." skip = True elif exists == "partial": print "Deleting partial cluster visualization " + number_postfix utils.delete_images(conf, "tracking", image_count) if skip == False: # Run the conversion print "-- Converting clusters to .vtr --" start_time = time.time() params = "-f %s %s" \ % (cluster_file,utils.getValueForKeyPath(conf,'postprocessing.clusters.meanie3D-cfm2vtk')) if utils.getValueForKeyPath( conf, 'postprocessing.clusters.showDisplacementVectors'): params += " --write-displacement-vectors" if utils.getValueForKeyPath(conf, 'data.vtkDimensions'): vtkDimString = ",".join( utils.getValueForKeyPath(conf, 'data.vtkDimensions')) params += " --vtk-dimensions=%s" % vtkDimString # pdb.set_trace(); print "meanie3D-cfm2vtk %s" % params meanie3D.app.external.execute_command('meanie3D-cfm2vtk', params) print " done. (%.2f seconds)" % (time.time() - start_time) # Move cluster output file to individual file if uses_time: cluster_vtk_file_dst = basename + "-clusters.vtk" os.rename(cluster_vtk_file, cluster_vtk_file_dst) cluster_vtk_file = cluster_vtk_file_dst print "-- Rendering cluster scene --" start_time = time.time() # Add ancillary background data utils.plotMapdata(visitConf, 'map') # Add timestamp if utils.getValueForKeyPath(clusterConf, 'showDateTime'): utils.add_datetime(clusterConf, netcdf_file, time_index) # Add background source data if utils.getValueForKeyPath(clusterConf, 'showSourceBackground'): utils.addPseudocolorPlots(netcdf_file, visitConf, 'sourceBackground.plots', time_index) source_open = True # Add the clusters add_clusters(cluster_vtk_file, conf) # Add modes as labels labelConf = utils.getValueForKeyPath(visitConf, 'label') if labelConf: utils.addLabelPlot(label_vtk_file, labelConf) # Add displacement vectors if utils.getValueForKeyPath(clusterConf, 'showDisplacementVectors'): vectorConf = utils.getValueForKeyPath( visitConf, 'displacementVectors') if vectorConf: utils.addVectorPlot(displacement_vtk_file, vectorConf) visit.DrawPlots() utils.saveImagesForViews(views, "tracking") print " done. (%.2f seconds)" % (time.time() - start_time) # clean up visit.DeleteAllPlots() visit.ClearWindow() if source_open: visit.CloseDatabase(netcdf_file) visit.CloseDatabase(label_vtk_file) utils.close_pattern(basename + "*.vtr") utils.close_pattern(basename + "*.vtk") utils.close_pattern(basename + "*.vtu") if utils.getValueForKeyPath(conf, 'cleanup_vtk'): subprocess.call("rm -f *.vt*", shell=True) # periodically kill computing engine to # work around the memory leak fix image_count = image_count + 1 # TODO: check if this is still necessary and re-implement if it is. #if image_count % 100 == 0: # visit.CloseComputeEngine() # close mapstuff # TODO: might need to keep track of open database files and # close them. # Use imagemagick to use image sequences to make movies movieFormats = utils.getValueForKeyPath(clusterConf, 'movieFormats') if utils.getValueForKeyPath(clusterConf, 'createSourceMovie'): utils.createMoviesForViews(views, "source", movieFormats) if utils.getValueForKeyPath(clusterConf, 'createClusterMovie'): utils.createMoviesForViews(views, "tracking", movieFormats) # clean up print "Cleaning up ..." subprocess.call("mkdir images", shell=True) subprocess.call("mv *tracking_*.png images", shell=True) subprocess.call("mv *source_*.png images", shell=True) subprocess.call("mkdir movies", shell=True) subprocess.call("mv *source*.gif *tracking*.gif *.m4v movies", shell=True) if utils.getValueForKeyPath(conf, 'cleanup_vtk'): subprocess.call("rm -f *.vt* visitlog.py", shell=True) return
def draw_point_picture(variableName, minValue, maxValue, inputDirectory, inputFileName, coordinate, outputDirectory, outputFileName, colorTable="hot_desaturated"): ''' Function for making a visit plot with a point Arguments: :param variableName Name of the variable :param minValue Minimum value of the variable :param maxValue Maximum value of the variable :param inputDirectory Path to input vlsv/silo files :param inputFileName Name of the file, for example \"bulk.00000.silo\" :param coordinates Coordinates corresponding to the files so for example [ [[0,0,0], [0,1,0]], [[2,1,2], [2,1,4]] ] :param outputDirectory Path to output directory :param outputFileName Name of the output file :param colorTable="hot_desaturated" Color table for the plots ''' # OPTIONS ################################################################# # Input variable _variableName = variableName minVariableValue = minValue maxVariableValue = maxValue colorTableName = colorTable # Input directory and file names _outputDir = outputDirectory _outputFileName = outputFileName # The file names for the png files. databaseName = "localhost:" + inputDirectory + inputFileName # For navigating to the silo files # Note: a slice of the plot in z-axis is taken automatically ################################################################# inputFileName2 = "point.vtk" databaseName2 = "localhost:" + os.getcwd() + "/" + inputFileName2 currentPlot = 0 vis.OpenDatabase(databaseName, 0) #vis.ActiveDatabase("localhost:" + inputDirectory + inputFileName) #Load settings visSettings.load_visit_settings() vis.AddPlot("Pseudocolor", _variableName, 1, 1) #CONTINUE vis.SetActivePlots(currentPlot) vis.PseudocolorAtts = vis.PseudocolorAttributes() vis.PseudocolorAtts.legendFlag = 1 vis.PseudocolorAtts.lightingFlag = 1 vis.PseudocolorAtts.minFlag = 1 vis.PseudocolorAtts.maxFlag = 1 vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural # Natural, Nodal, Zonal vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear # Linear, Log, Skew vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot # OriginalData, CurrentPlot vis.PseudocolorAtts.min = minVariableValue vis.PseudocolorAtts.max = maxVariableValue vis.PseudocolorAtts.pointSize = 0.05 vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point # Box, Axis, Icosahedron, Point, Sphere vis.PseudocolorAtts.skewFactor = 1 vis.PseudocolorAtts.opacity = 1 vis.PseudocolorAtts.colorTableName = colorTableName vis.PseudocolorAtts.invertColorTable = 0 vis.PseudocolorAtts.smoothingLevel = 0 vis.PseudocolorAtts.pointSizeVarEnabled = 0 vis.PseudocolorAtts.pointSizeVar = "default" vis.PseudocolorAtts.pointSizePixels = 2 vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.PseudocolorAtts.lineWidth = 0 vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit # Explicit, ColorTable vis.SetPlotOptions(vis.PseudocolorAtts) vis.AddOperator("Slice", 1) vis.SliceAtts = vis.SliceAttributes() vis.SliceAtts.originType = vis.SliceAtts.Intercept # Point, Intercept, Percent, Zone, Node vis.SliceAtts.originPoint = (0, 0, 0) vis.SliceAtts.originIntercept = 0 vis.SliceAtts.originPercent = 0 vis.SliceAtts.originZone = 0 vis.SliceAtts.originNode = 0 vis.SliceAtts.normal = (0, 0, 1) vis.SliceAtts.axisType = vis.SliceAtts.ZAxis # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi vis.SliceAtts.upAxis = (0, 1, 0) vis.SliceAtts.project2d = 1 vis.SliceAtts.interactive = 1 vis.SliceAtts.flip = 0 vis.SliceAtts.originZoneDomain = 0 vis.SliceAtts.originNodeDomain = 0 vis.SliceAtts.meshName = "SpatialGrid" vis.SliceAtts.theta = 0 vis.SliceAtts.phi = 90 vis.SetOperatorOptions(vis.SliceAtts, 1) vis.DrawPlots() create_point_vtk(fileName=inputFileName2, coordinates=coordinate) vis.OpenDatabase(databaseName2, 0) currentPlot = currentPlot + 1 vis.SetActivePlots(currentPlot) vis.AddPlot("Mesh", "mesh", 1, 1) vis.MeshAtts = vis.MeshAttributes() vis.MeshAtts.legendFlag = 1 vis.MeshAtts.lineStyle = vis.MeshAtts.SOLID # SOLID, DASH, DOT, DOTDASH vis.MeshAtts.lineWidth = 0 vis.MeshAtts.meshColor = (0, 0, 0, 255) vis.MeshAtts.outlineOnlyFlag = 0 vis.MeshAtts.errorTolerance = 0.01 vis.MeshAtts.meshColorSource = vis.MeshAtts.Foreground # Foreground, MeshCustom vis.MeshAtts.opaqueColorSource = vis.MeshAtts.Background # Background, OpaqueCustom vis.MeshAtts.opaqueMode = vis.MeshAtts.Auto # Auto, On, Off vis.MeshAtts.pointSize = 0.05 vis.MeshAtts.opaqueColor = (255, 255, 255, 255) vis.MeshAtts.smoothingLevel = vis.MeshAtts.None # None, Fast, High vis.MeshAtts.pointSizeVarEnabled = 0 vis.MeshAtts.pointSizeVar = "default" vis.MeshAtts.pointType = vis.MeshAtts.Point # Box, Axis, Icosahedron, Point, Sphere vis.MeshAtts.showInternal = 0 vis.MeshAtts.pointSizePixels = 25 vis.MeshAtts.opacity = 1 vis.SetPlotOptions(vis.MeshAtts) vis.DrawPlots() vis.SaveWindowAtts = vis.SaveWindowAttributes() vis.SaveWindowAtts.outputToCurrentDirectory = 0 vis.SaveWindowAtts.outputDirectory = _outputDir vis.SaveWindowAtts.fileName = _outputFileName vis.SaveWindowAtts.family = 1 vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY vis.SaveWindowAtts.width = 3000 vis.SaveWindowAtts.height = 3000 vis.SaveWindowAtts.screenCapture = 0 vis.SaveWindowAtts.saveTiled = 0 vis.SaveWindowAtts.quality = 100 vis.SaveWindowAtts.progressive = 0 vis.SaveWindowAtts.binary = 0 vis.SaveWindowAtts.stereo = 0 vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits # None, PackBits, Jpeg, Deflate vis.SaveWindowAtts.forceMerge = 0 vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions # NoConstraint, EqualWidthHeight, ScreenProportions vis.SaveWindowAtts.advancedMultiWindowSave = 0 vis.SetSaveWindowAttributes(vis.SaveWindowAtts) vis.SaveWindow() vis.SetActivePlots((0, 1)) vis.DeleteActivePlots() vis.CloseDatabase(databaseName2) vis.CloseDatabase(databaseName)
f.write(response.read()) print("Successfully downloaded example silo") visit.LaunchNowin() saveatts = visit.SaveWindowAttributes() saveatts.fileName = 'result-visit.png' saveatts.family = 0 saveatts.width = 1024 saveatts.height = 768 saveatts.resConstraint = saveatts.NoConstraint saveatts.outputToCurrentDirectory = 1 visit.SetSaveWindowAttributes(saveatts) visit.OpenDatabase('example.silo') visit.AddPlot('Contour', 'density') c = visit.ContourAttributes() c.colorType = c.ColorByColorTable c.colorTableName = "hot" visit.SetPlotOptions(c) visit.DrawPlots() v = visit.GetView3D() v.viewNormal = (-0.554924, 0.703901, 0.443377) v.viewUp = (0.272066, -0.3501, 0.896331) visit.SetView3D(v) visit.SaveWindow() visit.DeleteAllPlots() visit.CloseDatabase('example.silo') print("Successfully rendered output raster") print("All done!")
print("Results saved in result.silo") # Visualise result.silo using VisIt import visit visit.LaunchNowin() saveatts = visit.SaveWindowAttributes() saveatts.fileName = 'result-visit.png' saveatts.family = 0 saveatts.width = 1024 saveatts.height = 768 saveatts.resConstraint = saveatts.NoConstraint saveatts.outputToCurrentDirectory = 1 visit.SetSaveWindowAttributes(saveatts) visit.OpenDatabase('result.silo') visit.AddPlot('Contour', 'susceptibility') c=visit.ContourAttributes() c.colorType=c.ColorByColorTable c.colorTableName = "hot" visit.SetPlotOptions(c) visit.DrawPlots() v=visit.GetView3D() v.viewNormal=(-0.554924, 0.703901, 0.443377) v.viewUp=(0.272066, -0.3501, 0.896331) visit.SetView3D(v) visit.SaveWindow() subprocess.call(["cloud", "upload", "result-visit.png", "result-visit.png", "--set-acl=public-read"]) visit.DeleteAllPlots() visit.CloseDatabase('result.silo')