Example #1
0
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()
Example #2
0
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()
Example #3
0
    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)
Example #5
0
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)
Example #6
0
 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
Example #7
0
    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
Example #8
0
def SetPseudocolorAttributes(valMin, valMax):
    # The minimum and maximum values of color box for the variable values
    # are set as constant values valMin and valMax (i.e. not varying in time).

    pa = visit.PseudocolorAttributes()

    # options I like to set

    pa.minFlag = 1
    pa.min = valMin
    pa.maxFlag = 1
    pa.max = valMax

    # other options with default values

    pa.scaling = pa.Linear  # Linear, Log, Skew
    pa.skewFactor = 1
    pa.limitsMode = pa.OriginalData  # OriginalData, CurrentPlot
    pa.centering = pa.Natural  # Natural, Nodal, Zonal
    pa.colorTableName = "hot"
    pa.invertColorTable = 0
    pa.opacityType = pa.FullyOpaque  # ColorTable, FullyOpaque, Constant, Ramp, VariableRange
    pa.opacityVariable = ""
    pa.opacity = 1
    pa.opacityVarMin = 0
    pa.opacityVarMax = 1
    pa.opacityVarMinFlag = 0
    pa.opacityVarMaxFlag = 0
    pa.pointSize = 0.05
    pa.pointType = pa.Point  # Box, Axis, Icosahedron, Octahedron, Tetrahedron, SphereGeometry, Point, Sphere
    pa.pointSizeVarEnabled = 0
    pa.pointSizeVar = "default"
    pa.pointSizePixels = 2
    pa.lineType = pa.Line  # Line, Tube, Ribbon
    pa.lineStyle = pa.SOLID  # SOLID, DASH, DOT, DOTDASH
    pa.lineWidth = 0
    pa.tubeDisplayDensity = 10
    pa.tubeRadiusSizeType = pa.FractionOfBBox  # Absolute, FractionOfBBox
    pa.tubeRadiusAbsolute = 0.125
    pa.tubeRadiusBBox = 0.005
    pa.varyTubeRadius = 0
    pa.varyTubeRadiusVariable = ""
    pa.varyTubeRadiusFactor = 10
    pa.endPointType = pa.None  # None, Tails, Heads, Both
    pa.endPointStyle = pa.Spheres  # Spheres, Cones
    pa.endPointRadiusSizeType = pa.FractionOfBBox  # Absolute, FractionOfBBox
    pa.endPointRadiusAbsolute = 1
    pa.endPointRadiusBBox = 0.005
    pa.endPointRatio = 2
    pa.renderSurfaces = 1
    pa.renderWireframe = 0
    pa.renderPoints = 0
    pa.smoothingLevel = 0
    pa.legendFlag = 1
    pa.lightingFlag = 1

    visit.SetPlotOptions(pa)
Example #9
0
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()
Example #10
0
 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()
Example #11
0
    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()
Example #12
0
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)
Example #13
0
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)
Example #14
0
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()
Example #15
0
    def draw(self):
        print "drawing window %d of dimension %d"%(self.i,self.dim)
        v.SetActiveWindow(self.i)
        v.SetAnnotationAttributes(self.annot)

        if self.dim == 2:
            # add the slice
            assert self._slice is not None
            for i,plot in enumerate(self.plots):
                sliced = False
                for op in plot.operators:
                    if "slice" == op.oname:
                        sliced = True

                if not sliced:
                    print "slicing plot %d..."%i
                    v.SetActivePlots(i)
                    v.AddOperator("Slice")
                    sa = self._slice.toAttributes()
                    v.SetOperatorOptions(sa)
                    plot.operators.append(Operator("slice", "Slice", sa))
                

        if self.exaggeration is not None:
            print "exaggerating..."
            self._exaggerateVertical()

        # set the plot options
        for i, plot in enumerate(self.plots):
            print "setting plot options for plot %i..."%i
            v.SetActivePlots(i)
            v.SetPlotOptions(plot.patts)
        
        # set the view
        print "setting the view..."
        if self.dim == 2:
            v.SetView2D(self.view)
        else:
            v.SetView3D(self.view)

        print "drawing..."
        v.DrawPlots()
Example #16
0
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)
Example #17
0
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()
Example #18
0
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()
Example #19
0
 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()
Example #20
0
    def createPseudocolor(self, varname, display_name=None, cmap=None, 
                          limits=None, linewidth=None, legend=True, alpha=False):
        """Generic creation of pseudocolor"""
        if display_name is None:
            display_name = vrc.renameScalar(varname)

        if "temperature" in display_name:
            display_name = display_name.replace("[K]", "[C]")
            print "defining alias: %s = %s"%(display_name, varname)
            v.DefineScalarExpression(display_name, "%s - 273.15"%varname)
        elif display_name != varname:
            print "defining alias: %s = %s"%(display_name, varname)
            v.DefineScalarExpression(display_name, varname)

        v.AddPlot('Pseudocolor', display_name)
        pa = v.PseudocolorAttributes()

        # limits
        if limits is None:
            limits = vrc.getLimits(varname)

        if limits is not None:
            min = limits[0]
            max = limits[1]
            if min is not None:
                pa.minFlag = 1
                pa.min = min
            if max is not None:
                pa.maxFlag = 1
                pa.max = max

        # opacity
        if alpha:
            pa.opacity = 0
            pa.opacityType = pa.ColorTable

        # colormap
        if cmap is not None:
            reverse = cmap.endswith("_r")
            if reverse:
                cmap = cmap.strip("_r")
                pa.invertColorTable = 1
            pa.colorTableName = cmap

        # linewidth for 2D
        if linewidth is None:
            linewidth = vrc.rcParams['pseudocolor.linewidth']
        pa.lineWidth = linewidth

        # turn off legend for 2D surf
        if not legend:
            pa.legendFlag = 0

        v.SetPlotOptions(pa)
        pname = v.GetPlotList().GetPlots(v.GetNumPlots()-1).plotName
        if legend:
            plot = Plot(pname, 'Pseudocolor', pa, display_name)
        else:
            plot = Plot(pname, 'Pseudocolor', pa)
        self.plots.append(plot)
        return plot
Example #21
0
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
    ])
    return pr.parse_args()


if __name__ == '__main__':
    args = get_args()

    # Treat databases as time-varying
    v.SetTreatAllDBsAsTimeVarying(1)

    v.OpenDatabase(args.database + ' database')
    v.AddPlot('Volume', args.varname, 1, 1)

    if args.mesh:
        v.AddPlot('Mesh', 'mesh')
        matts = v.MeshAttributes()
        v.SetPlotOptions(matts)
    v.DrawPlots()

    # Set rendering type
    vatts = v.VolumeAttributes()
    if args.rndr == 'splatting':
        vatts.rendererType = vatts.Splatting
    elif args.rndr == 'raycast':
        vatts.rendererType = vatts.RayCasting
    elif args.rndr == 'texture':
        vatts.rendererType = vatts.Texture3D

    # Set scaling
    if args.scaling == 'lin':
        vatts.scaling = vatts.Linear
    elif args.scaling == 'log':
Example #23
0
def visit_plot_qcrit_wx_3d(xdmf_dir,
                           wx_range=(-5.0, 5.0),
                           q_value=0.1,
                           config_view=None,
                           out_dir=os.getcwd(),
                           out_prefix='wake3d_',
                           figsize=(1024, 1024),
                           visit_dir=None,
                           visit_arch='linux-x86_64',
                           state=None,
                           states=None,
                           states_range=[0, None, 1]):
    # Import VisIt package.
    if visit_dir is None:
        visit_dir = os.environ.get('VISIT_DIR')
        if visit_dir is None:
            raise ValueError('Provide VisIt installation path or '
                             'set env variable VISIT_DIR')
    sys.path.append(os.path.join(visit_dir, visit_arch, 'lib',
                                 'site-packages'))
    import visit

    visit.LaunchNowin()

    # Check version of VisIt.
    visit_check_version(visit.Version())

    # Define some variables to get the q_crit and wx_cc.
    p_xdmf_path = os.path.join(str(xdmf_dir), 'p.xmf')
    visit.OpenDatabase(p_xdmf_path, 0)
    visit.DefineScalarExpression("operators/ConnectedComponents/p Grid",
                                 "cell_constant(<p Grid>, 0.)")
    visit.DefineCurveExpression("operators/DataBinning/1D/p Grid",
                                "cell_constant(<p Grid>, 0)")
    visit.DefineScalarExpression("operators/DataBinning/2D/p Grid",
                                 "cell_constant(<p Grid>, 0)")
    visit.DefineScalarExpression("operators/DataBinning/3D/p Grid",
                                 "cell_constant(<p Grid>, 0)")
    visit.DefineScalarExpression("operators/Flux/p Grid",
                                 "cell_constant(<p Grid>, 0.)")
    visit.DefineCurveExpression("operators/Lineout/p",
                                "cell_constant(<p>, 0.)")
    visit.DefineCurveExpression(
        "operators/Lineout/time_derivative/p Grid_time",
        "cell_constant(time_derivative/p Grid_time, 0.)")
    visit.DefineCurveExpression(
        "operators/Lineout/time_derivative/p Grid_lasttime",
        "cell_constant(time_derivative/p Grid_lasttime, 0.)")
    visit.DefineCurveExpression("operators/Lineout/time_derivative/p",
                                "cell_constant(time_derivative/p, 0.)")
    visit.DefineScalarExpression("operators/ModelFit/model",
                                 "point_constant(<p Grid>, 0)")
    visit.DefineScalarExpression("operators/ModelFit/distance",
                                 "point_constant(<p Grid>, 0)")
    visit.DefineScalarExpression("operators/StatisticalTrends/Sum/p",
                                 "cell_constant(<p>, 0.)")
    visit.DefineScalarExpression("operators/StatisticalTrends/Mean/p",
                                 "cell_constant(<p>, 0.)")
    visit.DefineScalarExpression("operators/StatisticalTrends/Variance/p",
                                 "cell_constant(<p>, 0.)")
    visit.DefineScalarExpression("operators/StatisticalTrends/Std. Dev./p",
                                 "cell_constant(<p>, 0.)")
    visit.DefineScalarExpression("operators/StatisticalTrends/Slope/p",
                                 "cell_constant(<p>, 0.)")
    visit.DefineScalarExpression("operators/StatisticalTrends/Residuals/p",
                                 "cell_constant(<p>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Sum/time_derivative/p Grid_time",
        "cell_constant(<time_derivative/p Grid_time>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Sum/time_derivative/p Grid_lasttime",
        "cell_constant(<time_derivative/p Grid_lasttime>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Sum/time_derivative/p",
        "cell_constant(<time_derivative/p>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Mean/time_derivative/p Grid_time",
        "cell_constant(<time_derivative/p Grid_time>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Mean/time_derivative/p Grid_lasttime",
        "cell_constant(<time_derivative/p Grid_lasttime>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Mean/time_derivative/p",
        "cell_constant(<time_derivative/p>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Variance/time_derivative/p Grid_time",
        "cell_constant(<time_derivative/p Grid_time>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Variance/time_derivative/p Grid_lasttime",
        "cell_constant(<time_derivative/p Grid_lasttime>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Variance/time_derivative/p",
        "cell_constant(<time_derivative/p>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Std. Dev./time_derivative/p Grid_time",
        "cell_constant(<time_derivative/p Grid_time>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Std. Dev./time_derivative/p Grid_lasttime",
        "cell_constant(<time_derivative/p Grid_lasttime>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Std. Dev./time_derivative/p",
        "cell_constant(<time_derivative/p>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Slope/time_derivative/p Grid_time",
        "cell_constant(<time_derivative/p Grid_time>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Slope/time_derivative/p Grid_lasttime",
        "cell_constant(<time_derivative/p Grid_lasttime>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Slope/time_derivative/p",
        "cell_constant(<time_derivative/p>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Residuals/time_derivative/p Grid_time",
        "cell_constant(<time_derivative/p Grid_time>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Residuals/time_derivative/p Grid_lasttime",
        "cell_constant(<time_derivative/p Grid_lasttime>, 0.)")
    visit.DefineScalarExpression(
        "operators/StatisticalTrends/Residuals/time_derivative/p",
        "cell_constant(<time_derivative/p>, 0.)")
    visit.DefineVectorExpression("operators/SurfaceNormal/p Grid",
                                 "cell_constant(<p Grid>, 0.)")
    # Define cell-centered velocity vector field.
    ux_xdmf_path = os.path.join(str(xdmf_dir), 'u.xmf')
    uy_xdmf_path = os.path.join(str(xdmf_dir), 'v.xmf')
    uz_xdmf_path = os.path.join(str(xdmf_dir), 'w.xmf')
    vel_exp = ('{' +
               'pos_cmfe(<{}[0]id:u>, <p Grid>, 1.0),'.format(ux_xdmf_path) +
               'pos_cmfe(<{}[0]id:v>, <p Grid>, 0.0),'.format(uy_xdmf_path) +
               'pos_cmfe(<{}[0]id:w>, <p Grid>, 0.0)'.format(uz_xdmf_path) +
               '}')
    visit.DefineVectorExpression('velocity', vel_exp)
    # Define Q-criterion.
    qcrit_exp = ('q_criterion(' + 'gradient(velocity[0]),' +
                 'gradient(velocity[1]),' + 'gradient(velocity[2])' + ')')
    visit.DefineScalarExpression('q_crit', qcrit_exp)
    # Define cell-centered streamwise vorticity.
    wx_xdmf_path = os.path.join(str(xdmf_dir), 'wx.xmf')
    wx_exp = 'pos_cmfe(<{}[0]id:wx>, <p Grid>, 0.0)'.format(wx_xdmf_path)
    visit.DefineScalarExpression('wx_cc', wx_exp)

    # Add a pseudocolor of the cell-centered streamwise vorticity.
    visit.AddPlot('Pseudocolor', 'wx_cc', 1, 1)
    PseudocolorAtts = visit.PseudocolorAttributes()
    PseudocolorAtts.minFlag = 1
    PseudocolorAtts.min = wx_range[0]
    PseudocolorAtts.maxFlag = 1
    PseudocolorAtts.max = wx_range[1]
    PseudocolorAtts.colorTableName = 'viridis'
    PseudocolorAtts.invertColorTable = 1
    PseudocolorAtts.opacityType = PseudocolorAtts.Constant
    PseudocolorAtts.opacity = 0.8
    PseudocolorAtts.legendFlag = 0
    visit.SetPlotOptions(PseudocolorAtts)

    # Add an isosurface of the Q-criterion.
    visit.AddOperator('Isosurface', 1)
    IsosurfaceAtts = visit.IsosurfaceAttributes()
    IsosurfaceAtts.variable = 'q_crit'
    IsosurfaceAtts.contourMethod = IsosurfaceAtts.Value
    IsosurfaceAtts.contourValue = (q_value)
    IsosurfaceAtts.scaling = IsosurfaceAtts.Linear
    visit.SetOperatorOptions(IsosurfaceAtts, 1)

    # Remove info about user, time, database, and legend.
    AnnotationAtts = visit.AnnotationAttributes()
    AnnotationAtts.userInfoFlag = 0
    AnnotationAtts.databaseInfoFlag = 0
    AnnotationAtts.timeInfoFlag = 0
    AnnotationAtts.legendInfoFlag = 0
    AnnotationAtts.axes3D.visible = 0
    AnnotationAtts.axes3D.triadFlag = 1
    AnnotationAtts.axes3D.bboxFlag = 0
    visit.SetAnnotationAttributes(AnnotationAtts)

    # Parse the 3D view configuration file.
    if config_view is not None:
        with open(str(config_view), 'r') as infile:
            config_view = yaml.load(infile, Loader=yaml.FullLoader)
            config_view = config_view['View3DAtts']
    # Set attributes of the view.
    View3DAtts = visit.View3DAttributes()
    for key, value in config_view.items():
        if type(value) is list:
            value = tuple(value)
        setattr(View3DAtts, key, value)
    visit.SetView3D(View3DAtts)

    visit.SetActiveWindow(1)

    visit.Source(os.path.join(visit_dir, visit_arch, 'bin', 'makemovie.py'))
    visit.ToggleCameraViewMode()

    # Create output directory if necessary.
    if not os.path.isdir(str(out_dir)):
        os.makedirs(str(out_dir))

    # Loop over the states to render and save the plots.
    if state is not None:
        states = [state]
    elif states is None:
        if states_range[1] is None:
            states_range[1] = visit.TimeSliderGetNStates()
        else:
            states_range[1] += 1
        states = range(*states_range)

    for i, state in enumerate(states):
        print('[state {}] Rendering and saving figure ...'.format(state))
        visit.SetTimeSliderState(state)

        if i == 0:
            visit.DrawPlots()

        RenderingAtts = visit.RenderingAttributes()
        visit.SetRenderingAttributes(RenderingAtts)

        SaveWindowAtts = visit.SaveWindowAttributes()
        SaveWindowAtts.outputToCurrentDirectory = 0
        SaveWindowAtts.outputDirectory = str(out_dir)
        SaveWindowAtts.fileName = '{}{:0>4}'.format(out_prefix, state)
        SaveWindowAtts.family = 0
        SaveWindowAtts.format = SaveWindowAtts.PNG
        SaveWindowAtts.width = figsize[0]
        SaveWindowAtts.height = figsize[1]
        SaveWindowAtts.quality = 100
        SaveWindowAtts.resConstraint = SaveWindowAtts.NoConstraint
        visit.SetSaveWindowAttributes(SaveWindowAtts)

        visit.SaveWindow()

    os.remove('visitlog.py')
    visit.CloseComputeEngine()
    visit.Close()
    return
Example #24
0
def visit_plot_pseudocolor_2d(xdmf_path,
                              name,
                              value_range=(-5.0, 5.0),
                              curve2d_paths=None,
                              config_view=None,
                              out_dir=os.getcwd(),
                              out_prefix='wake2d_',
                              figsize=(1024, 1024),
                              visit_dir=None,
                              visit_arch='linux-x86_64',
                              state=None,
                              states=None,
                              states_range=[0, None, 1]):
    # Import VisIt package.
    if visit_dir is None:
        visit_dir = os.environ.get('VISIT_DIR')
        if visit_dir is None:
            raise ValueError('Provide VisIt installation path or '
                             'set env variable VISIT_DIR')
    sys.path.append(os.path.join(visit_dir, visit_arch, 'lib',
                                 'site-packages'))
    import visit

    visit.LaunchNowin()

    # Check version of VisIt.
    visit_check_version(visit.Version())

    # Create database correlation with optional Curve2D files.
    num_bodies = 0
    databases = [str(xdmf_path)]
    if curve2d_paths is not None:
        num_bodies = len(curve2d_paths)
        databases = [str(path) for path in curve2d_paths]
        databases.append(str(xdmf_path))
    visit.CreateDatabaseCorrelation('common', databases[num_bodies:], 0)

    # Open the file with the coordinates of the immersed boundary.
    if num_bodies > 0:
        for i in range(num_bodies):
            visit.OpenDatabase(databases[i], 0)
            # Add plot the mesh points.
            visit.AddPlot('Curve', 'curve', 1, 1)
            # Set attributes of the curve.
            CurveAtts = visit.CurveAttributes()
            CurveAtts.lineWidth = 1
            CurveAtts.curveColorSource = CurveAtts.Custom
            CurveAtts.curveColor = (0, 0, 0, 255)
            CurveAtts.showLegend = 0
            CurveAtts.showLabels = 0
            visit.SetPlotOptions(CurveAtts)

    # Open the XMF file for the spanwise-averaged z-component of the vorticity.
    visit.OpenDatabase(databases[-1], 0)
    # Add a pseudocolor plot of the scalar field.
    visit.AddPlot('Pseudocolor', name, 1, 1)
    # Set attributes of the pseudocolor.
    PseudocolorAtts = visit.PseudocolorAttributes()
    PseudocolorAtts.minFlag = 1
    PseudocolorAtts.min = value_range[0]
    PseudocolorAtts.maxFlag = 1
    PseudocolorAtts.max = value_range[1]
    PseudocolorAtts.colorTableName = 'viridis'
    visit.SetPlotOptions(PseudocolorAtts)

    # Parse the 2D view configuration file.
    if config_view is not None:
        with open(str(config_view), 'r') as infile:
            config_view = yaml.load(infile, Loader=yaml.FullLoader)
            config_view = config_view['View2DAtts']
    # Set attributes of the view.
    View2DAtts = visit.View2DAttributes()
    for key, value in config_view.items():
        if type(value) is list:
            value = tuple(value)
        setattr(View2DAtts, key, value)
    visit.SetView2D(View2DAtts)

    # Remove time and user info.
    AnnotationAtts = visit.AnnotationAttributes()
    AnnotationAtts.userInfoFlag = 0
    AnnotationAtts.timeInfoFlag = 1
    visit.SetAnnotationAttributes(AnnotationAtts)

    visit.SetActiveWindow(1)

    visit.Source(os.path.join(visit_dir, visit_arch, 'bin', 'makemovie.py'))
    visit.ToggleCameraViewMode()

    # Create output directory if necessary.
    if not os.path.isdir(str(out_dir)):
        os.makedirs(str(out_dir))

    # Loop over the states to render and save the plots.
    if state is not None:
        states = [state]
    elif states is None:
        if states_range[1] is None:
            states_range[1] = visit.TimeSliderGetNStates()
        else:
            states_range[1] += 1
        states = range(*states_range)

    for i, state in enumerate(states):
        print('[state {}] Rendering and saving figure ...'.format(state))
        visit.SetTimeSliderState(state)

        if i == 0:
            visit.DrawPlots()

        RenderingAtts = visit.RenderingAttributes()
        visit.SetRenderingAttributes(RenderingAtts)

        SaveWindowAtts = visit.SaveWindowAttributes()
        SaveWindowAtts.outputToCurrentDirectory = 0
        SaveWindowAtts.outputDirectory = str(out_dir)
        SaveWindowAtts.fileName = '{}{:0>4}'.format(out_prefix, state)
        SaveWindowAtts.family = 0
        SaveWindowAtts.format = SaveWindowAtts.PNG
        SaveWindowAtts.width = figsize[0]
        SaveWindowAtts.height = figsize[1]
        SaveWindowAtts.quality = 100
        SaveWindowAtts.resConstraint = SaveWindowAtts.NoConstraint
        visit.SetSaveWindowAttributes(SaveWindowAtts)

        visit.SaveWindow()

    os.remove('visitlog.py')
    visit.Close()
    return
Example #25
0
def visit_plot_contour_3d(xdmf_path,
                          name,
                          value_range=(-5.0, 5.0),
                          p3d_paths=None,
                          config_view=None,
                          out_dir=os.getcwd(),
                          out_prefix='wake3d_',
                          figsize=(1024, 1024),
                          visit_dir=None,
                          visit_arch='linux-x86_64',
                          state=None,
                          states=None,
                          states_range=[0, None, 1]):
    # Import VisIt package.
    if visit_dir is None:
        visit_dir = os.environ.get('VISIT_DIR')
        if visit_dir is None:
            raise ValueError('Provide VisIt installation path or '
                             'set env variable VISIT_DIR')
    sys.path.append(os.path.join(visit_dir, visit_arch, 'lib',
                                 'site-packages'))
    import visit

    visit.LaunchNowin()

    # Check version of VisIt.
    visit_check_version(visit.Version())

    # Create database correlation with optional Point3D files.
    num_bodies = 0
    databases = [str(xdmf_path)]
    if p3d_paths is not None:
        num_bodies = len(p3d_paths)
        databases = [str(path) for path in p3d_paths]
        databases.append(str(xdmf_path))
    visit.CreateDatabaseCorrelation('common', databases[num_bodies:], 0)

    # Open the file with the coordinates of the immersed boundary.
    if num_bodies > 0:
        for i in range(num_bodies):
            visit.OpenDatabase(databases[i], 0, 'Point3D_1.0')
            # Add plot the mesh points.
            visit.AddPlot('Mesh', 'points', 1, 1)
            # Set attributes of the mesh plot.
            MeshAtts = visit.MeshAttributes()
            MeshAtts.legendFlag = 0
            MeshAtts.meshColor = (255, 204, 0, 1.0 * 255)
            MeshAtts.meshColorSource = MeshAtts.MeshCustom
            MeshAtts.pointSize = 0.05
            MeshAtts.pointType = MeshAtts.Point
            MeshAtts.pointSizePixels = 2
            MeshAtts.opacity = 1
            visit.SetPlotOptions(MeshAtts)

    # Open the XMF file for the z-component of the vorticity.
    visit.OpenDatabase(databases[-1], 0)
    # Add the plot of the contour of the z-component of the vorticity.
    visit.AddPlot('Contour', name, 1, 1)
    # Set attributes of the contour.
    ContourAtts = visit.ContourAttributes()
    ContourAtts.contourNLevels = 2
    ContourAtts.SetMultiColor(0, (0, 51, 102, 0.6 * 255))
    ContourAtts.SetMultiColor(1, (255, 0, 0, 0.6 * 255))
    ContourAtts.legendFlag = 1
    ContourAtts.minFlag = 1
    ContourAtts.maxFlag = 1
    ContourAtts.min = value_range[0]
    ContourAtts.max = value_range[1]
    visit.SetPlotOptions(ContourAtts)

    # Parse the 3D view configuration file.
    if config_view is not None:
        with open(str(config_view), 'r') as infile:
            config_view = yaml.load(infile, Loader=yaml.FullLoader)
            config_view = config_view['View3DAtts']
    # Set attributes of the view.
    View3DAtts = visit.View3DAttributes()
    for key, value in config_view.items():
        if type(value) is list:
            value = tuple(value)
        setattr(View3DAtts, key, value)
    visit.SetView3D(View3DAtts)

    # Remove time and user info.
    AnnotationAtts = visit.AnnotationAttributes()
    AnnotationAtts.userInfoFlag = 0
    AnnotationAtts.timeInfoFlag = 0
    AnnotationAtts.axes3D.visible = 0
    AnnotationAtts.axes3D.triadFlag = 1
    AnnotationAtts.axes3D.bboxFlag = 0
    visit.SetAnnotationAttributes(AnnotationAtts)

    visit.SetActiveWindow(1)

    visit.Source(os.path.join(visit_dir, visit_arch, 'bin', 'makemovie.py'))
    visit.ToggleCameraViewMode()

    # Create output directory if necessary.
    if not os.path.isdir(str(out_dir)):
        os.makedirs(str(out_dir))

    # Loop over the states to render and save the plots.
    if state is not None:
        states = [state]
    elif states is None:
        if states_range[1] is None:
            states_range[1] = visit.TimeSliderGetNStates()
        else:
            states_range[1] += 1
        states = range(*states_range)

    for i, state in enumerate(states):
        print('[state {}] Rendering and saving figure ...'.format(state))
        visit.SetTimeSliderState(state)

        if i == 0:
            visit.DrawPlots()

        RenderingAtts = visit.RenderingAttributes()
        visit.SetRenderingAttributes(RenderingAtts)

        SaveWindowAtts = visit.SaveWindowAttributes()
        SaveWindowAtts.outputToCurrentDirectory = 0
        SaveWindowAtts.outputDirectory = str(out_dir)
        SaveWindowAtts.fileName = '{}{:0>4}'.format(out_prefix, state)
        SaveWindowAtts.family = 0
        SaveWindowAtts.format = SaveWindowAtts.PNG
        SaveWindowAtts.width = figsize[0]
        SaveWindowAtts.height = figsize[1]
        SaveWindowAtts.quality = 100
        SaveWindowAtts.resConstraint = SaveWindowAtts.NoConstraint
        visit.SetSaveWindowAttributes(SaveWindowAtts)

        visit.SaveWindow()

    os.remove('visitlog.py')
    visit.Close()
    return
# visit: open datafile and add pseudocolor plot of S(k)

visit.OpenDatabase(datafile)
visit.AddPlot("Pseudocolor", "S_k")

visit.HideToolbars()

# colorbar range

pa = visit.PseudocolorAttributes()
pa.minFlag = 1
pa.min = minSk
pa.maxFlag = 1
pa.max = maxSk
visit.SetPlotOptions(pa)

# x- and y-ranges of plot and position of plot

va = visit.View2DAttributes()
va.windowCoords = (kxlo, kxhi, kylo, kyhi)
va.viewportCoords = (0.06, 0.94, 0.11, 0.99)
visit.SetView2D(va)

# legend(colorbox) and user/database info on/off | axes

aa = visit.AnnotationAttributes()
aa.legendInfoFlag = 1
aa.userInfoFlag = 0
aa.databaseInfoFlag = 0
aa.axes2D.visible = 1
    def _updateDisplay(self,bSameDomain):
        print("")
        print("_updateDisplay() - start  ..... variable="+str(self._variable)+", plot="+str(self._currentPlot)+", op="+str(self._currentOperator)+", opEnabled="+str(self._operatorEnabled))
        #
        # remove old plot if not applicable
        #
        if (bSameDomain == False or (self._currentPlot != None and (self._variable == None or (self._currentPlot[1] != self._variable)))):
            print("    _updateDisplay() - removing plots and operators")
            visit.DeleteAllPlots()
            self._currentPlot = None
            visit.RemoveAllOperators()
            self._currentOperator = None

        #
        # remove old operator if not needed
        #
        if (self._currentOperator != None and self._operatorEnabled == False):
            print("    _updateDisplay() - removing operators, operatorEnabled is False")
            visit.RemoveAllOperators()
            self._currentOperator = None

        #
        # remove old operator if wrong type
        #
        if (self._currentOperator == "Slice" and self._operatorProject2d == False):
            print("    _updateDisplay() - removing operators, 'Slice' incompatible with project2d==False")
            visit.RemoveAllOperators()
            self._currentOperator = None
        if (self._currentOperator == "Clip" and self._operatorProject2d == True):
            print("    _updateDisplay() - removing operators, 'Clip' incompatible with project2d==True")
            visit.RemoveAllOperators()
            self._currentOperator = None

        #
        # add new plot if needed
        #
        if (self._variable != None and self._currentPlot == None):
            print("    _updateDisplay() - adding 'Pseudocolor' plot for variable '"+str(self._variable)+"'")
            print("    _updateDisplay() -- variable without str = ")
            print(self._variable)
            visit.AddPlot("Pseudocolor", str(self._variable))
            visit.SetPlotOptions(self._pseudocolorAttributes)
            self._currentPlot = ("Pseudocolor",str(self._variable))
            # Turn off display database name in plot window to reduce clutter
            attributes = visit.AnnotationAttributes()
            attributes.databaseInfoFlag=0
            visit.SetAnnotationAttributes(attributes)

        #
        # if operator needed, set operator attributes (add new operator if needed)
        #
        if (self._operatorEnabled == True and self._currentPlot != None):
            #
            # if no operator, then add one
            #
            if (self._currentOperator == None):
                if (self._operatorProject2d):
                    print("    _updateDisplay() - adding operator 'Slice'")
                    visit.AddOperator("Slice")
                    self._currentOperator = "Slice"
                else:
                    print("    _updateDisplay() - adding operator 'Clip'")
                    visit.AddOperator("Clip")
                    self._currentOperator = "Clip"
            
            #
            # set operator attributes
            #
            if (self._currentOperator == "Slice"):
                print("    _updateDisplay() - setting operator options for 'Slice'")
                visit.SetOperatorOptions(self._getSliceAttributes())
            else:
                print("    _updateDisplay() - setting operator options for 'Clip'")
                visit.SetOperatorOptions(self._getClipAttributes())		

        #
        # Redraw
        #
        print("    _updateDisplay() - redrawing")
        visit.DrawPlots()
        print("_updateDisplay() - end")
        print("")
Example #28
0
            SliceAtts = visit.SliceAttributes()
            SliceAtts.originType = SliceAtts.Point
            SliceAtts.originPoint = (0, 0, 0)
            SliceAtts.normal = (0, 0, -1)
            SliceAtts.axisType = SliceAtts.ZAxis
            SliceAtts.upAxis = (1, 0, 0)
            SliceAtts.project2d = 1
            SliceAtts.flip = 1
            visit.SetOperatorOptions(SliceAtts, 1)

            PseudocolorAtts = visit.PseudocolorAttributes()
            PseudocolorAtts.minFlag = 1
            PseudocolorAtts.min = 0.
            PseudocolorAtts.maxFlag = 1
            PseudocolorAtts.max = alpha
            visit.SetPlotOptions(PseudocolorAtts)

            View2DAtts = visit.View2DAttributes()
            View2DAtts.windowCoords = (-0.01, 0.07, 0, 1.58)
            View2DAtts.viewportCoords = (0.7, 0.95, 0.1, 0.95)
            visit.SetView2D(View2DAtts)

            AnnotationAtts = visit.AnnotationAttributes()
            AnnotationAtts.axes2D.autoSetTicks = 0
            AnnotationAtts.axes2D.autoSetScaling = 0
            AnnotationAtts.axes2D.tickLocation = AnnotationAtts.axes2D.Outside
            AnnotationAtts.axes2D.tickAxes = AnnotationAtts.axes2D.BottomLeft
            AnnotationAtts.axes2D.xAxis.title.visible = 0
            AnnotationAtts.axes2D.xAxis.label.visible = 0
            AnnotationAtts.axes2D.xAxis.tickMarks.visible = 0
            AnnotationAtts.axes2D.xAxis.grid = 0
Example #29
0
    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!")
Example #30
0
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)