def createMesh(self, color='w', opacity=0.15, silo=False): _colors = dict( w=(255, 255, 255, 255), k=(0, 0, 0, 255), gray=(175, 175, 175), ) if silo: v.AddPlot('Mesh', "mesh") else: v.AddPlot('Mesh', "Mesh") ma = v.MeshAttributes() ma.legendFlag = 0 ma.meshColor = _colors[color] ma.meshColorSource = ma.MeshCustom if (opacity < 1.): ma.opaqueMode = ma.On ma.opacity = opacity v.SetPlotOptions(ma) pname = v.GetPlotList().GetPlots(v.GetNumPlots() - 1).plotName if silo: plot = Plot(pname, 'mesh', ma) else: plot = Plot(pname, 'Mesh', ma) self.nonplots.append(plot) return plot
def setup_visit(plot_variable_data, db_name): print 'Opening database...' # Get the complete database name including directory path, db file # pattern and extension, followed by the word database # Example: db_filename = './output*.vtk database' visit.OpenDatabase(db_name) # Getting the list of current variables db_meta_data = visit.GetMetaData(db_name) scalar_list = [db_meta_data.GetScalars(i).name for i in range(db_meta_data.GetNumScalars())] vector_list = [db_meta_data.GetVectors(i).name for i in range(db_meta_data.GetNumVectors())] for vec in vector_list: scalar_list.append(vec + '_magnitude') # Check if current variable name exists in the database. If no, then # res becomes 0. Hence, we need to define a scalar expression for the # current variable if plot_variable_data['plot variable'] in scalar_list or \ plot_variable_data['plot variable'] in vector_list: visit.AddPlot(plot_variable_data['plot type'], \ plot_variable_data['plot variable']) else: print 'No existing variable of that name' visit.DefineScalarExpression(plot_variable_data['plot variable'], \ plot_variable_data['plot variable definition']) visit.AddPlot(plot_variable_data['plot type'], \ plot_variable_data['plot variable']) if plot_variable_data['plot type'] == 'Pseudocolor': p = visit.PseudocolorAttributes() p.SetCentering(1) p.colorTableName = 'hot_desaturated' # p.colorTableName = 'rainbow' visit.SetPlotOptions(p)
def make_slide(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' print('opening plamsa file:' + plasma_file) sts = vi.OpenDatabase(plasma_file,0,'VTK') if (sts != 1): print('open file failed! error code:' + str(sts)) return sts = vi.AddPlot('Pseudocolor','cutoff') vi.DrawPlots() po = vi.GetPlotOptions() vi.LoadAttribute(plasma_attr_file,po) vi.SetPlotOptions(po) print('opening paraxial file:' + paraxial_file) sts = vi.OpenDatabase(paraxial_file,0,'VTK') if (sts != 1): print('open file failed! error code:' + str(sts)) return sts = vi.AddPlot('Pseudocolor','Er_para') vi.DrawPlots() po = vi.GetPlotOptions() vi.LoadAttribute(wave_attr_file,po) vi.SetPlotOptions(po) print('opening fullwave file:' + fullwave_file) sts = vi.OpenDatabase(fullwave_file,0,'VTK') if (sts != 1): print('open file failed! error code:' + str(sts)) return sts = vi.AddPlot('Pseudocolor','Er_fullw') vi.DrawPlots() po = vi.GetPlotOptions() vi.LoadAttribute(wave_attr_file,po) vi.SetPlotOptions(po) view_attr = vi.GetView3D() vi.LoadAttribute(view_attr_file,view_attr) vi.SetView3D(view_attr) anno_attr = vi.GetAnnotationAttributes() vi.LoadAttribute(annotation_attr_file,anno_attr) vi.SetAnnotationAttributes(anno_attr) anno_names = vi.GetAnnotationObjectNames() for name in anno_names: legend = vi.GetAnnotationObject(name) legend.numberFormat = "%# -9.2g" legend.drawMinMax = 0 legend.controlTicks = 1 legend.numTicks = 3 vi.SaveWindow()
def setup_workspace(self, file): define_flow_vpe("flow", pjoin(examples_dir, file), "pyocl_ops", 0, 0) visit.AddPlot("Pseudocolor", "flow") visit.DrawPlots() visit.DefineScalarExpression("check", "flow - ((d + p)^2.0 + (d-p)^2.0)") visit.AddPlot("Pseudocolor", "check") visit.DrawPlots()
def test_visit(): import visit VISIT_ARGS = os.environ.get('VISIT_ARGS', ["-nosplash"]) if isinstance(VISIT_ARGS, str): VISIT_ARGS = VISIT_ARGS.split() for arg in VISIT_ARGS: visit.AddArgument(arg) visit.Launch() print "visit is installed in", os.path.dirname(visit.__file__) print "visit version", visit.Version() visit.ResetView() v3D = visit.GetView3D() v3D.SetViewUp(0, 0, 1) v3D.SetViewNormal(-0.5, -0.8, 0.4) v3D.SetImageZoom(1.0) visit.SetView3D(v3D) aa = visit.AnnotationAttributes() aa.SetAxesType(2) # outside edges aa.SetDatabaseInfoFlag(False) aa.SetUserInfoFlag(False) visit.SetAnnotationAttributes(aa) t = visit.CreateAnnotationObject("Text2D") t.SetText("Hello VisIt!") t.SetPosition(0.4, 0.9) # (0,0) is lower left corner t.SetFontFamily(0) # 0: Arial, 1: Courier, 2: Times t.SetWidth(0.25) # 25% t.SetTextColor((0, 0, 0)) t.SetUseForegroundForTextColor(False) t.SetVisible(True) visit.OpenDatabase("tmp_.vtk") visit.AddPlot("Mesh", "scalars") ma = visit.MeshAttributes() visit.SetPlotOptions(ma) visit.AddPlot("Pseudocolor", "scalars") pa = visit.PseudocolorAttributes() visit.SetPlotOptions(pa) visit.RedrawWindow() visit.DrawPlots() wait()
def test_get_isovol(): """test get_isovol""" r = np.full(3, False) db = test_dir + "/test-isovol/" iv = ivdb.IvDb(levels=levels, data=data, db=db) if isdir(db): shutil.rmtree(db) mkdir(db) mkdir(db + '/vols/') # launch VisIt import visit try: visit.LaunchNowin() except: pass visit.OpenDatabase(test_mesh) visit.AddPlot('Pseudocolor', data) # run __get_isovol lbound = 5 ubound = 15 i = 1 export_res, ubound_out = iv._IvDb__get_isovol(lbound, ubound, i) # close VisIt visit.CloseComputeEngine() # check returned values if export_res == 1: r[0] = True if ubound_out == ubound: r[1] = True # check that vol file produced are the same gen_vol = db + "/vols/1.stl" exp_vol = exp_vols_dir + "/1.stl" r[2] = filecmp.cmp(gen_vol, exp_vol) shutil.rmtree(db) assert (all(r))
def generate_vols(self, filename): """Generates the isosurface volumes between the level values. Data files are exported as STLs and saved in the folder db. Files will be named based on their index corresponding to their level values (0.stl is lowest values). Input: ------ filename: string, path to vtk file with the mesh """ # create folder for database self.__make_db_dir() # launch VisIt try: v.LaunchNowin() except: pass # open file v.OpenDatabase(filename) # read data using meshio to get min and max and make sure levels are # within data bounds: arbmin, arbmax, mins, maxs = self.__check_data(filename) self.xmin = mins[0] self.ymin = mins[1] self.zmin = mins[2] self.xmax = maxs[0] self.ymax = maxs[1] self.zmax = maxs[2] self.levels.append(arbmax) # plot the pseudocolor data in order to get volumes v.AddPlot("Pseudocolor", self.data) v.DrawPlots() # iterate over all isovolume levels for i, l in enumerate(self.levels): res = 0 while res == 0: # lower bound if i == 0: lbound = arbmin else: lbound = self.levels[i - 1] # upper bound ubound = self.levels[i] # get volume # res = 0 if no level found (should update to next level) res, ubound = self.__get_isovol(lbound, ubound, i) # delete plots v.DeleteAllPlots() # close visit v.CloseComputeEngine()
def plotEnergyLinear(localPowerAllDB): data = visit.OpenDatabase(localPowerAllDB, 0, 'Vs') visit.AddPlot('Curve', 'Energy') AnnotationAtts = visit.AnnotationAttributes() AnnotationAtts.axes2D.yAxis.grid = 0 AnnotationAtts.axes2D.xAxis.grid = 0 AnnotationAtts.axes2D.xAxis.title.userTitle = 1 AnnotationAtts.axes2D.xAxis.title.userUnits = 1 AnnotationAtts.axes2D.xAxis.title.title = "z" AnnotationAtts.axes2D.xAxis.title.units = "m" AnnotationAtts.axes2D.yAxis.title.userTitle = 1 AnnotationAtts.axes2D.yAxis.title.userUnits = 1 AnnotationAtts.axes2D.yAxis.title.title = "Energy" AnnotationAtts.axes2D.yAxis.title.units = "J" AnnotationAtts.userInfoFlag = 0 AnnotationAtts.databaseInfoFlag = 0 AnnotationAtts.legendInfoFlag = 0 visit.SetAnnotationAttributes(AnnotationAtts) visit.DrawPlots() CurveAtts = visit.CurveAttributes() CurveAtts.showLines = 1 CurveAtts.lineStyle = CurveAtts.SOLID # SOLID, DASH, DOT, DOTDASH CurveAtts.lineWidth = 2 CurveAtts.curveColorSource = CurveAtts.Custom # Cycle, Custom CurveAtts.curveColor = (255, 0, 0, 255) CurveAtts.showLabels = 0 CurveAtts.showLegend = 0 visit.SetPlotOptions(CurveAtts)
def DrawPlot(iWindow, plotInfo): # choose window visit.SetActiveWindow(iWindow) # open database visit.OpenDatabase(plotInfo.databaseName) # create pseudocolor plot visit.AddPlot("Pseudocolor", plotInfo.variableName) # set pseudocolor attributes SetPseudocolorAttributes(plotInfo.valMin, plotInfo.valMax) # set view2d attributtes SetView2dAttributes(plotInfo.domain, plotInfo.viewport) # set annotation attributes SetAnnotationAttributes(plotInfo.domain, plotInfo.legendInfo) # set legend SetLegend(plotInfo.legendInfo) # set time text SetTimeText(plotInfo.timeTextInfo) # draw plot visit.DrawPlots()
def plotPowNorm(localPowerAllDB): data=visit.OpenDatabase(localPowerAllDB,0,'Vs') visit.AddPlot('Pseudocolor','power_SI_Norm') visit.DrawPlots() View2DAtts = visit.View2DAttributes() # View2DAtts.windowCoords = (0, 30, 0, 15.0796) # View2DAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) # View2DAtts.fullFrameAutoThreshold = 100 View2DAtts.xScale = View2DAtts.LINEAR # LINEAR, LOG View2DAtts.yScale = View2DAtts.LINEAR # LINEAR, LOG View2DAtts.windowValid = 1 View2DAtts.fullFrameActivationMode = View2DAtts.On # On, Off, Auto #View2DAtts.fullFrameAutoThreshold = 100 visit.SetView2D(View2DAtts) visit.ResetView() AnnotationAtts = visit.AnnotationAttributes() AnnotationAtts.userInfoFlag = 0 AnnotationAtts.databaseInfoFlag = 0 AnnotationAtts.axes2D.xAxis.title.userTitle = 1 AnnotationAtts.axes2D.xAxis.title.userUnits = 1 AnnotationAtts.axes2D.xAxis.title.title = "ct-z" AnnotationAtts.axes2D.xAxis.title.units = "m" AnnotationAtts.axes2D.yAxis.title.userTitle = 1 AnnotationAtts.axes2D.yAxis.title.userUnits = 1 AnnotationAtts.axes2D.yAxis.title.title = "z" AnnotationAtts.axes2D.yAxis.title.units = "m" # AnnotationAtts.legendInfoFlag = 0 visit.SetAnnotationAttributes(AnnotationAtts)
def isosurfacePlot(self, stay=False, samples=100, contours=50): visit.AddWindow() returned = [] if len(visit.ListPlots()) > 0: visit.SetActivePlots(0) visit.HideActivePlots() p = visit.PseudocolorAttributes() q = visit.ResampleAttributes() r = visit.IsosurfaceAttributes() q.samplesX = samples q.samplesY = samples q.samplesZ = samples r.contourNLevels = contours plot = visit.AddPlot("Pseudocolor", "Heat") visit.AddOperator("Resample") # visit.AddOperator("Isosurface") visit.SetOperatorOptions(q) visit.SetOperatorOptions(r) visit.SetPlotOptions(p) visit.DrawPlots() returned.append(visit.SaveWindow()) count = 0 visit.AddOperator("Isosurface") visit.DrawPlots() time.sleep(60) returned.append(visit.SaveWindow()) return returned
def createContour(self, varname, value, color=None, linewidth=None): """Generic creation of a single contour without a legend""" v.AddPlot('Contour', varname) ca = v.ContourAttributes() ca.contourMethod = ca.Value ca.contourValue = (value,) ca.colorType = ca.ColorBySingleColor if color is None: color = vrc.rcParams['contour.color'] if type(color) is str: color = vc.common_colors[color] ca.singleColor = color if linewidth is None: linewidth = vrc.rcParams['contour.linewidth'] ca.lineWidth = linewidth # turn off legend for 2D surf ca.legendFlag = 0 v.SetPlotOptions(ca) pname = v.GetPlotList().GetPlots(v.GetNumPlots()-1).plotName plot = Plot(pname, 'Contour', ca) self.plots.append(plot) return plot
def TimeSeriesS1(): visit.AddPlot('Curve', 's1') visit.AddPlot('Curve', 's2') visit.DrawPlots() visit.AddWindow() visit.AddPlot('Curve', 'pAverage') visit.DrawPlots() visit.SetActiveWindow(1) AnnotationAtts = visit.AnnotationAttributes() AnnotationAtts.axes2D.yAxis.grid = 1 AnnotationAtts.axes2D.xAxis.grid = 1 AnnotationAtts.axes2D.xAxis.title.userTitle = 1 AnnotationAtts.axes2D.xAxis.title.userUnits = 1 AnnotationAtts.axes2D.xAxis.title.title = "Position along the machine s" AnnotationAtts.axes2D.xAxis.title.units = "m" visit.SetAnnotationAttributes(AnnotationAtts) visit.DrawPlots()
def LoadContourPlot(self): (windowid,filename,var) = self.GetDetails() if windowid is None: return wid = viswinmapper[windowid] visit.SetActiveWindow(wid) visit.DeleteAllPlots() visit.OpenDatabase(filename) visit.AddPlot("Contour",var) visit.DrawPlots()
def binPhase(eDB): visit.OpenDatabase(eDB, 0) visit.AddPlot("Pseudocolor", "operators/DataBinning/2D/electrons", 1, 1) DataBinningAtts = visit.DataBinningAttributes() DataBinningAtts.numDimensions = DataBinningAtts.Two # One, Two, Three DataBinningAtts.dim1BinBasedOn = DataBinningAtts.Variable # X, Y, Z, Variable DataBinningAtts.dim1Var = "electrons_zSI" DataBinningAtts.dim1SpecifyRange = 1 DataBinningAtts.dim1MinRange = 0 DataBinningAtts.dim1MaxRange = 1.0E-7 DataBinningAtts.dim1NumBins = 100 DataBinningAtts.dim2BinBasedOn = DataBinningAtts.Variable # X, Y, Z, Variable DataBinningAtts.dim2Var = "electrons_gamma" DataBinningAtts.dim2SpecifyRange = 1 DataBinningAtts.dim2MinRange = 0.991 DataBinningAtts.dim2MaxRange = 1.005 DataBinningAtts.dim2NumBins = 100 DataBinningAtts.outOfBoundsBehavior = DataBinningAtts.Clamp # Clamp, Discard DataBinningAtts.reductionOperator = DataBinningAtts.Sum # Average, Minimum, Maximum, StandardDeviation, Variance, Sum, Count, RMS, PDF DataBinningAtts.varForReduction = "electrons_chargeSI" DataBinningAtts.emptyVal = 0 DataBinningAtts.outputType = DataBinningAtts.OutputOnBins # OutputOnBins, OutputOnInputMesh DataBinningAtts.removeEmptyValFromCurve = 1 visit.SetOperatorOptions(DataBinningAtts, 1) visit.SetTimeSliderState(0) visit.SetTimeSliderState(1) PseudocolorAtts = visit.PseudocolorAttributes() PseudocolorAtts.centering = PseudocolorAtts.Nodal # Natural, Nodal, Zonal PseudocolorAtts.opacityType = PseudocolorAtts.Ramp # ColorTable, FullyOpaque, Constant, Ramp, VariableRange PseudocolorAtts.colorTableName = "hot_desaturated" visit.SetPlotOptions(PseudocolorAtts) View2DAtts = visit.View2DAttributes() View2DAtts.fullFrameActivationMode = View2DAtts.On # View2DAtts.fullFrameAutoThreshold = 100 visit.SetView2D(View2DAtts) visit.ResetView() AnnotationAtts = visit.AnnotationAttributes() AnnotationAtts.axes2D.yAxis.grid = 0 AnnotationAtts.axes2D.xAxis.grid = 0 AnnotationAtts.axes2D.xAxis.title.userTitle = 1 AnnotationAtts.axes2D.xAxis.title.userUnits = 1 AnnotationAtts.axes2D.xAxis.title.title = "ct-z" AnnotationAtts.axes2D.xAxis.title.units = "m" AnnotationAtts.axes2D.yAxis.title.userTitle = 1 AnnotationAtts.axes2D.yAxis.title.userUnits = 1 AnnotationAtts.axes2D.yAxis.title.title = "gamma" AnnotationAtts.axes2D.yAxis.title.units = "" AnnotationAtts.userInfoFlag = 0 AnnotationAtts.databaseInfoFlag = 0 # AnnotationAtts.legendInfoFlag = 0 visit.SetAnnotationAttributes(AnnotationAtts) visit.DrawPlots()
def pseudocolorPlot(self): visit.AddWindow() returned = [] if len(visit.ListPlots()) > 0: visit.SetActivePlots(0) visit.HideActivePlots() p = visit.PseudocolorAttributes() plot = visit.AddPlot("Pseudocolor", "Heat") visit.SetPlotOptions(p) visit.DrawPlots() return visit.SaveWindow()
def plot(dbfile=None): if not dbfile is None: visit.OpenDatabase(dbfile) else: wi = visit.GetWindowInformation() dbfile = wi.activeSource md = visit.GetMetaData(dbfile) ncrvs = md.GetNumCurves() cnames = [md.GetCurves(i).name for i in xrange(ncrvs)] cnames.sort() for cname in cnames: visit.AddPlot("Curve", cname) visit.DrawPlots()
def setup_visit(plot_variable_data, db_name): print 'Opening database...' # Get the complete database name including directory path, db file # pattern and extension, followed by the word database # Example: db_filename = './output*.vtk database' visit.OpenDatabase(db_name) # Getting the list of current variables db_meta_data = visit.GetMetaData(db_name) scalar_list = [ db_meta_data.GetScalars(i).name for i in range(db_meta_data.GetNumScalars()) ] vector_list = [ db_meta_data.GetVectors(i).name for i in range(db_meta_data.GetNumVectors()) ] for vec in vector_list: scalar_list.append(vec + '_magnitude') # Check if current variable name exists in the database. If no, then # res becomes 0. Hence, we need to define a scalar expression for the # current variable if plot_variable_data['plot variable'] in scalar_list or \ plot_variable_data['plot variable'] in vector_list: visit.AddPlot(plot_variable_data['plot type'], \ plot_variable_data['plot variable']) else: print 'No existing variable of that name' visit.DefineScalarExpression(plot_variable_data['plot variable'], \ plot_variable_data['plot variable definition']) visit.AddPlot(plot_variable_data['plot type'], \ plot_variable_data['plot variable']) # Making mesh transparent and overlaying it on the plot visit.AddPlot('Mesh', 'mesh') p = visit.MeshAttributes() p.SetOpacity(0.25) visit.SetPlotOptions(p)
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 _plot_pseudocolor(self): """Plots the data on a pseudocolor plot to use.""" # add the pseudocolor plot to contour v.AddPlot("Pseudocolor", self.data) att = v.PseudocolorAttributes() # min/max for the pseudocolor plot att.minFlag = True att.min = self.minN att.maxFlag = True att.max = self.maxN # plot v.SetPlotOptions(att) v.DrawPlots()
def plotEnergy(localPowerAllDB): # Get upper and lower limits for energy plots h5in = tables.open_file(localPowerAllDB, 'r') minZ = h5in.root.zSeries._v_attrs.vsLowerBounds maxZ = h5in.root.zSeries._v_attrs.vsUpperBounds h5in.close() data = visit.OpenDatabase(localPowerAllDB, 0, 'Vs') visit.AddPlot('Curve', 'Energy', 1, 1) # For log scale equivalent plot ViewCurveAtts = visit.ViewCurveAttributes() ViewCurveAtts.domainScale = ViewCurveAtts.LINEAR # LINEAR, LOG ViewCurveAtts.rangeScale = ViewCurveAtts.LOG # LINEAR, LOG visit.SetViewCurve(ViewCurveAtts) visit.DrawPlots() ViewCurveAtts.domainCoords = (minZ, maxZ) ViewCurveAtts.rangeCoords = (-12, 2) ViewCurveAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) visit.SetViewCurve(ViewCurveAtts) visit.DrawPlots() AnnotationAtts = visit.AnnotationAttributes() AnnotationAtts.axes2D.yAxis.grid = 1 AnnotationAtts.axes2D.xAxis.grid = 1 AnnotationAtts.axes2D.xAxis.title.userTitle = 1 AnnotationAtts.axes2D.xAxis.title.userUnits = 1 AnnotationAtts.axes2D.xAxis.title.title = "z" AnnotationAtts.axes2D.xAxis.title.units = "m" AnnotationAtts.axes2D.yAxis.title.userTitle = 1 AnnotationAtts.axes2D.yAxis.title.userUnits = 1 AnnotationAtts.axes2D.yAxis.title.title = "Energy" AnnotationAtts.axes2D.yAxis.title.units = "J" AnnotationAtts.userInfoFlag = 0 AnnotationAtts.databaseInfoFlag = 0 AnnotationAtts.legendInfoFlag = 0 visit.SetAnnotationAttributes(AnnotationAtts) visit.DrawPlots() CurveAtts = visit.CurveAttributes() CurveAtts.showLines = 1 CurveAtts.lineStyle = CurveAtts.SOLID # SOLID, DASH, DOT, DOTDASH CurveAtts.lineWidth = 2 CurveAtts.curveColorSource = CurveAtts.Custom # Cycle, Custom CurveAtts.curveColor = (51, 153, 102, 255) CurveAtts.showLegend = 0 CurveAtts.showLabels = 0 visit.SetPlotOptions(CurveAtts)
def current(): visit.OpenDatabase(iDB, 0) visit.AddPlot("Curve", "beamCurrent", 1, 1) visit.DrawPlots() # Begin spontaneous state ViewCurveAtts = visit.ViewCurveAttributes() ViewCurveAtts.domainCoords = (-0.0240932, 29.972) ViewCurveAtts.rangeCoords = (0, 22000) ViewCurveAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) ViewCurveAtts.domainScale = ViewCurveAtts.LINEAR # LINEAR, LOG ViewCurveAtts.rangeScale = ViewCurveAtts.LINEAR # LINEAR, LOG visit.SetViewCurve(ViewCurveAtts) # End spontaneous state ViewCurveAtts = visit.ViewCurveAttributes() ViewCurveAtts.domainCoords = (-0.0240932, 29.972) ViewCurveAtts.rangeCoords = (0, 22000) ViewCurveAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) ViewCurveAtts.domainScale = ViewCurveAtts.LINEAR # LINEAR, LOG ViewCurveAtts.rangeScale = ViewCurveAtts.LINEAR # LINEAR, LOG visit.SetViewCurve(ViewCurveAtts) AnnotationAtts = visit.AnnotationAttributes() AnnotationAtts.axes2D.yAxis.grid = 0 AnnotationAtts.axes2D.xAxis.grid = 0 AnnotationAtts.axes2D.xAxis.title.userTitle = 1 AnnotationAtts.axes2D.xAxis.title.userUnits = 1 AnnotationAtts.axes2D.xAxis.title.title = "z2bar" AnnotationAtts.axes2D.xAxis.title.units = "cooperation lengths" AnnotationAtts.axes2D.yAxis.title.userTitle = 1 AnnotationAtts.axes2D.yAxis.title.userUnits = 1 AnnotationAtts.axes2D.yAxis.title.title = "Current" AnnotationAtts.axes2D.yAxis.title.units = "A" AnnotationAtts.userInfoFlag = 0 AnnotationAtts.databaseInfoFlag = 0 AnnotationAtts.legendInfoFlag = 0 visit.SetAnnotationAttributes(AnnotationAtts) CurveAtts = visit.CurveAttributes() CurveAtts.showLines = 1 CurveAtts.lineStyle = CurveAtts.SOLID # SOLID, DASH, DOT, DOTDASH CurveAtts.lineWidth = 2 CurveAtts.curveColorSource = CurveAtts.Custom # Cycle, Custom CurveAtts.curveColor = (51, 153, 102, 255) CurveAtts.showLegend = 0 CurveAtts.showLabels = 0 visit.SetPlotOptions(CurveAtts)
def PhaseSpace(x1, x2, dumpNo): visit.AddWindow() ScatAttrs = visit.ScatterAttributes() ScatAttrs.var1 = x1 ScatAttrs.var2 = x2 # ScatAttrs.var1Role = visit.ScatterAtts.Coordinate0 # ScatAttrs.var2Role = visit.ScatterAtts.Coordinate1 # ScatAttrs.var3Role = visit.ScatterAtts.None # ScatAttsr.var4Role = visit.ScatterAtts.None ScatAttrs.SetVar1Role(0) #coord 0 ScatAttrs.SetVar2Role(1) #coord 1 ScatAttrs.SetVar3Role(4) #none ScatAttrs.SetVar4Role(4) #none ScatAttrs.scaleCube = 0 visit.AddPlot('Scatter', x1, 1, 1) visit.SetPlotOptions(ScatAttrs) visit.SetTimeSliderState(dumpNo) visit.DrawPlots()
def LoadExtremeValueAnalysisPlot(self): (windowid,filename,var) = self.GetDetails() if windowid is None: return wid = viswinmapper[windowid] visit.SetActiveWindow(wid) visit.DeleteAllPlots() visit.OpenDatabase(filename, 0) visit.AddPlot("Pseudocolor", var, 1, 1) #visit.AddOperator("Box", 1) #visit.SetActivePlots(0) #visit.SetActivePlots(0) #BoxAtts = visit.BoxAttributes() #BoxAtts.amount = BoxAtts.Some # Some, All #BoxAtts.minx = 90 #BoxAtts.maxx = 100 #BoxAtts.miny = -10 #BoxAtts.maxy = 10 #BoxAtts.minz = 0 #BoxAtts.maxz = 1 #visit.SetOperatorOptions(BoxAtts, 1) visit.AddOperator("ExtremeValueAnalysis") visit.DrawPlots()
def test_get_isovol_nodata(): """test get_isovol no data present""" r = np.full(6, False) db = test_dir + "/test-isovol-nodata/" iv = ivdb.IvDb(levels=[5, 15, 25, 28, 35], data=data, db=db) if isdir(db): shutil.rmtree(db) mkdir(db) mkdir(db + '/vols/') # launch VisIt import visit try: visit.LaunchNowin() except: pass visit.OpenDatabase(test_mesh) visit.AddPlot('Pseudocolor', data) # run __get_isovol lbound = 25 ubound = 28 i = 3 with warnings.catch_warnings(record=True) as w: export_res, ubound_out = iv._IvDb__get_isovol(lbound, ubound, i) # close VisIt visit.CloseComputeEngine() # check returned/changed values if export_res == 0: r[0] = True if ubound_out == 35: r[1] = True if iv.levels == [5, 15, 25, 35]: r[2] = True gen_vol = db + "/vols/3.stl" if not isfile(gen_vol): # no file should be generated r[3] = True r[4:6] = __check_warning(w, ["no data to export between"], 1) shutil.rmtree(db) assert (all(r))
def surfIntens(fDB): visit.OpenDatabase(fDB, 0) visit.AddPlot("Pseudocolor", "operators/DataBinning/2D/meshScaled", 1, 1) DataBinningAtts = visit.DataBinningAttributes() DataBinningAtts.numDimensions = DataBinningAtts.Two # One, Two, Three DataBinningAtts.dim1BinBasedOn = DataBinningAtts.X # X, Y, Z, Variable DataBinningAtts.dim1Var = "default" DataBinningAtts.dim1SpecifyRange = 0 DataBinningAtts.dim1MinRange = 0 DataBinningAtts.dim1MaxRange = 1 DataBinningAtts.dim1NumBins = 85 DataBinningAtts.dim2BinBasedOn = DataBinningAtts.Y # X, Y, Z, Variable DataBinningAtts.dim2Var = "default" DataBinningAtts.dim2SpecifyRange = 0 DataBinningAtts.dim2MinRange = 0 DataBinningAtts.dim2MaxRange = 1 DataBinningAtts.dim2NumBins = 85 DataBinningAtts.dim3BinBasedOn = DataBinningAtts.Variable # X, Y, Z, Variable DataBinningAtts.dim3Var = "default" DataBinningAtts.dim3SpecifyRange = 0 DataBinningAtts.dim3MinRange = 0 DataBinningAtts.dim3MaxRange = 1 DataBinningAtts.dim3NumBins = 50 DataBinningAtts.outOfBoundsBehavior = DataBinningAtts.Clamp # Clamp, Discard DataBinningAtts.reductionOperator = DataBinningAtts.Average # Average, Minimum, Maximum, StandardDeviation, Variance, Sum, Count, RMS, PDF DataBinningAtts.varForReduction = "intensityScaled" DataBinningAtts.emptyVal = 0 DataBinningAtts.outputType = DataBinningAtts.OutputOnBins # OutputOnBins, OutputOnInputMesh DataBinningAtts.removeEmptyValFromCurve = 1 visit.SetOperatorOptions(DataBinningAtts, 1) View2DAtts = visit.View2DAttributes() View2DAtts.fullFrameActivationMode = View2DAtts.On # View2DAtts.fullFrameAutoThreshold = 100 visit.SetView2D(View2DAtts) visit.ResetView() PseudocolorAtts = visit.PseudocolorAttributes() PseudocolorAtts.centering = PseudocolorAtts.Nodal # Natural, Nodal, Zonal visit.SetPlotOptions(PseudocolorAtts) visit.DrawPlots()
def bunching(): #visit.OpenDatabase("localhost:/home/tml/tmp/test/build/examples/simple/1D/OptCommV165pp65-70/fig2/f2main_bunching1st_0_* database", 0) visit.OpenDatabase(iDB, 0) visit.AddPlot("Curve", "bunchingFundamental", 1, 1) visit.SetTimeSliderState(0) # Begin spontaneous state ViewCurveAtts = visit.ViewCurveAttributes() ViewCurveAtts.domainCoords = (0, 29.8745) ViewCurveAtts.rangeCoords = (0, 0.75) ViewCurveAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95) ViewCurveAtts.domainScale = ViewCurveAtts.LINEAR # LINEAR, LOG ViewCurveAtts.rangeScale = ViewCurveAtts.LINEAR # LINEAR, LOG visit.SetViewCurve(ViewCurveAtts) AnnotationAtts = visit.AnnotationAttributes() AnnotationAtts.axes2D.yAxis.grid = 0 AnnotationAtts.axes2D.xAxis.grid = 0 AnnotationAtts.axes2D.xAxis.title.userTitle = 1 AnnotationAtts.axes2D.xAxis.title.userUnits = 1 AnnotationAtts.axes2D.xAxis.title.title = "z2bar" AnnotationAtts.axes2D.xAxis.title.units = "cooperation lengths" AnnotationAtts.axes2D.yAxis.title.userTitle = 1 AnnotationAtts.axes2D.yAxis.title.userUnits = 1 AnnotationAtts.axes2D.yAxis.title.title = "bunching" AnnotationAtts.axes2D.yAxis.title.units = "" AnnotationAtts.userInfoFlag = 0 AnnotationAtts.databaseInfoFlag = 0 AnnotationAtts.legendInfoFlag = 0 visit.SetAnnotationAttributes(AnnotationAtts) CurveAtts = visit.CurveAttributes() CurveAtts.showLines = 1 CurveAtts.lineStyle = CurveAtts.SOLID # SOLID, DASH, DOT, DOTDASH CurveAtts.lineWidth = 2 CurveAtts.curveColorSource = CurveAtts.Custom # Cycle, Custom CurveAtts.curveColor = (51, 153, 102, 255) CurveAtts.showLegend = 0 CurveAtts.showLabels = 0 visit.SetPlotOptions(CurveAtts) visit.DrawPlots()
def main(): args = Argv() wfile = args[0] dbfile = pjoin("tests","_data","rect2d.silo") fset = "pyocl_ops" plat = 0 dev = 0 if len(args) > 1: dbfile = args[1] if len(args) > 2: fset = args[2] if len(args) > 3: plat = int(args[3]) if len(args) > 4: dev = int(args[4]) visit.OpenDatabase(dbfile) define_flow_vpe("flow", expr=wfile, filter_set=fset, platform_id=plat, device_id=dev) visit.AddPlot("Pseudocolor","flow") visit.DrawPlots()
def scatterPlot(self, coords=["var00", "var01", "var02", "var03"], colorTable="hot", pixelSize=5, stay=False): visit.AddWindow() if len(visit.ListPlots()) > 0: visit.SetActivePlots(0) visit.HideActivePlots() plot = visit.AddPlot("Scatter", coords[0]) p = visit.ScatterAttributes() # Variables if coords[1]: p.var2 = coords[1] if coords[2]: p.var3 = coords[2] if coords[3]: p.var4 = coords[3] #Role Variable Roles take intergers as inputs, not strings p.var1Role = 0 p.var2Role = 1 p.var3Role = 2 p.var4Role = 3 p.scaleCube = 0 #p.colorType = "ColorByColorTable" p.pointSizePixels = pixelSize p.colorTableName = colorTable #p.colorScaling = "Log" v = visit.GetView3D() v.viewNormal = (-0.571619, 0.405393, 0.713378) v.viewUp = (0.308049, 0.911853, -0.271346) visit.SetPlotOptions(p) visit.SetView3D(v) visit.DrawPlots() count = 0 time.sleep(5) return visit.SaveWindow()
with open('example.silo', 'wb') as f: 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")