Ejemplo n.º 1
0
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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
def plane_slice_plotting(window_number, axis_number, label, images, timestamp):
    """
    Copy the Mesh, Pseudocolor, and Contour plots into a new VisIt window and
    slice through the proper axis.

    Input:
    ______
      window_number: int
          The number of the window to open (2,3, or 4).
      axis_number: int
          The number of the axis to slice through (0 for X, 1 for Y, 2 for Z).
      label: str
          The title of the plane slice.
      images: boolean
          Whether or not to save images of the plot windows.
      timestamp: boolean
          Whether or not to keep the timestamp on plot window images.

    Returns:
    ________
      none
    """

    # Open a new window with all three plots.
    Vi.AddWindow()
    Vi.CopyPlotsToWindow(1, window_number)

    # Create the plane slice plot by activating the mesh, pseudocolor, and contour plots.
    Vi.SetActiveWindow(window_number)
    Vi.SetActivePlots((0, 1, 2))

    # Remove the clip and slice operators from previous plot windows.
    Vi.RemoveAllOperators()

    # Add a slice through the proper axis.
    Vi.AddOperator("Slice", 1)
    s = Vi.SliceAttributes()
    s.axisType = axis_number
    Vi.SetOperatorOptions(s)

    # Include a label for each plane slice plot.
    banner = Vi.CreateAnnotationObject("Text2D")
    banner.position = (0.45, 0.92)
    banner.text = label
    banner.height = 0.05

    # Include the CNERG logo in the bottom left corner of the plot.
    image = Vi.CreateAnnotationObject("Image")
    image.image = os.path.dirname(os.path.abspath(__file__)) + "/cnerg.jpg"
    image.position = (0.02, 0.02)
    image.width = 10
    image.height = 10

    Vi.DrawPlots()
    if images:
        if timestamp:
            attributes = Vi.GetAnnotationAttributes()
            attributes.userInfoFlag = 0
            Vi.SetAnnotationAttributes(attributes)
        Vi.SaveWindow()
Ejemplo n.º 4
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()
Ejemplo n.º 5
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()
Ejemplo n.º 6
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()
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
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()
Ejemplo n.º 9
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)
Ejemplo n.º 10
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()
Ejemplo n.º 11
0
 def __save_window(self, obase, res, ores, screen_cap, ts):
     prev_lvl = visit.SuppressMessages(2)
     res = [int(v) for v in res]
     if ores is None:
         ores = res
     obase = os.path.abspath(obase)
     odir, ofile = os.path.split(obase)
     if ts is None:
         print "[rendering %s/%s.png]" % (odir, ofile)
         tmp_ofile = "%s___.tmp" % ofile
     else:
         print "[rendering %s/%s%04d.png]" % (odir, ofile, ts)
         tmp_ofile = "%s.%04d___.tmp" % (ofile, ts)
     sa = visit.SaveWindowAttributes()
     sa.outputToCurrentDirectory = 0
     sa.outputDirectory = odir
     sa.fileName = tmp_ofile
     sa.format = sa.PNG
     sa.width, sa.height = res
     sa.screenCapture = 0
     sa.saveTiled = 0
     sa.resConstraint = sa.NoConstraint
     visit.SetSaveWindowAttributes(sa)
     a = visit.GetAnnotationAttributes()
     a.userInfoFlag = 0
     visit.SetAnnotationAttributes(a)
     fname = visit.SaveWindow()
     if fname == "/dev/null/SaveWindow_Error.txt" or not os.path.isfile(
             fname):
         raise VisItException("Error saving window.")
     des = fname[:fname.find("___.tmp")]
     des += ".png"
     shutil.move(fname, des)
     if ores[0] != res[0] or ores[1] != res[1]:
         stargs = (res[0], res[1], ores[0], ores[1])
         print "[resizing output (from %dx%d to %dx%d)]" % stargs
         sexe("convert -resize %dx%d %s %s" % (ores[0], ores[1], des, des))
     visit.SuppressMessages(prev_lvl)
     return des
Ejemplo n.º 12
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()
Ejemplo n.º 13
0
aa.axes2D.xAxis.label.visible = 0
aa.axes2D.xAxis.tickMarks.visible = 1
aa.axes2D.xAxis.tickMarks.majorMinimum = kxlo
aa.axes2D.xAxis.tickMarks.majorMaximum = kxhi
aa.axes2D.xAxis.tickMarks.minorSpacing = (kxhi - kxlo) / 16.
aa.axes2D.xAxis.tickMarks.majorSpacing = (kxhi - kxlo) / 4.
aa.axes2D.xAxis.grid = 1
aa.axes2D.yAxis.title.visible = 0
aa.axes2D.yAxis.label.visible = 0
aa.axes2D.yAxis.tickMarks.visible = 1
aa.axes2D.yAxis.tickMarks.majorMinimum = kylo
aa.axes2D.yAxis.tickMarks.majorMaximum = kyhi
aa.axes2D.yAxis.tickMarks.minorSpacing = (kyhi - kylo) / 16.
aa.axes2D.yAxis.tickMarks.majorSpacing = (kyhi - kylo) / 4.
aa.axes2D.yAxis.grid = 1
visit.SetAnnotationAttributes(aa)

# colorbox setting

legend = visit.GetAnnotationObject(visit.GetPlotList().GetPlots(0).plotName)
legend.active = 1
legend.managePosition = 0
legend.position = (0.5, 0.08)
legend.xScale = 1.2
legend.yScale = 0.4
legend.orientation = legend.HorizontalBottom  # VerticalRight, VerticalLeft, HorizontalTop, HorizontalBottom
legend.controlTicks = 1
legend.numTicks = 5
legend.minMaxInclusive = 1
legend.drawLabels = legend.Values  # None, Values, Labels, Both
legend.numberFormat = "%.2f"
Ejemplo n.º 14
0
def SetAnnotationAttributes(domain, legendInfo):
    # turn on legend (i.e. color bar)
    # turn off user and database info
    # turn on x- and y-axes with ticks but turn off all annotations

    aa = visit.AnnotationAttributes()

    # options I like to set

    if legendInfo.visible:
        aa.legendInfoFlag = 1
    else:
        aa.legendInfoFlag = 0
    aa.userInfoFlag = 0
    aa.databaseInfoFlag = 0

    # aa.axes2D.visible = 1
    aa.axes2D.visible = 0
    aa.axes2D.autoSetTicks = 0
    aa.axes2D.autoSetScaling = 0
    aa.axes2D.lineWidth = 0
    aa.axes2D.tickLocation = aa.axes2D.Inside  # Inside, Outside, Both
    aa.axes2D.tickAxes = aa.axes2D.All  # Off, Bottom, Left, BottomLeft, All

    aa.axes2D.xAxis.title.visible = 0
    aa.axes2D.xAxis.label.visible = 0
    aa.axes2D.xAxis.tickMarks.visible = 1
    aa.axes2D.xAxis.tickMarks.majorMinimum = domain.xlo
    aa.axes2D.xAxis.tickMarks.majorMaximum = domain.xhi
    aa.axes2D.xAxis.tickMarks.minorSpacing = (domain.xhi - domain.xlo) / 16.
    aa.axes2D.xAxis.tickMarks.majorSpacing = (domain.xhi - domain.xlo) / 4.
    aa.axes2D.xAxis.grid = 1

    aa.axes2D.yAxis.title.visible = 0
    aa.axes2D.yAxis.label.visible = 0
    aa.axes2D.yAxis.tickMarks.visible = 1
    aa.axes2D.yAxis.tickMarks.majorMinimum = domain.ylo
    aa.axes2D.yAxis.tickMarks.majorMaximum = domain.yhi
    aa.axes2D.yAxis.tickMarks.minorSpacing = (domain.yhi - domain.ylo) / 16.
    aa.axes2D.yAxis.tickMarks.majorSpacing = (domain.yhi - domain.ylo) / 4.
    aa.axes2D.yAxis.grid = 1

    # other options with default values

    aa.backgroundColor = (255, 255, 255, 255)
    aa.foregroundColor = (0, 0, 0, 255)
    aa.gradientBackgroundStyle = aa.Radial  # TopToBottom, BottomToTop, LeftToRight, RightToLeft, Radial
    aa.gradientColor1 = (0, 0, 255, 255)
    aa.gradientColor2 = (0, 0, 0, 255)
    aa.backgroundMode = aa.Solid  # Solid, Gradient, Image, ImageSphere

    aa.axes2D.xAxis.title.font.font = aa.axes2D.xAxis.title.font.Courier  # Arial, Courier, Times
    aa.axes2D.xAxis.title.font.scale = 1
    aa.axes2D.xAxis.title.font.useForegroundColor = 1
    aa.axes2D.xAxis.title.font.color = (0, 0, 0, 255)
    aa.axes2D.xAxis.title.font.bold = 1
    aa.axes2D.xAxis.title.font.italic = 1
    aa.axes2D.xAxis.title.userTitle = 0
    aa.axes2D.xAxis.title.userUnits = 0
    aa.axes2D.xAxis.title.title = "X-Axis"
    aa.axes2D.xAxis.title.units = ""
    aa.axes2D.xAxis.label.font.font = aa.axes2D.xAxis.label.font.Courier  # Arial, Courier, Times
    aa.axes2D.xAxis.label.font.scale = 1
    aa.axes2D.xAxis.label.font.useForegroundColor = 1
    aa.axes2D.xAxis.label.font.color = (0, 0, 0, 255)
    aa.axes2D.xAxis.label.font.bold = 1
    aa.axes2D.xAxis.label.font.italic = 1
    aa.axes2D.xAxis.label.scaling = 0

    aa.axes2D.yAxis.title.font.font = aa.axes2D.yAxis.title.font.Courier  # Arial, Courier, Times
    aa.axes2D.yAxis.title.font.scale = 1
    aa.axes2D.yAxis.title.font.useForegroundColor = 1
    aa.axes2D.yAxis.title.font.color = (0, 0, 0, 255)
    aa.axes2D.yAxis.title.font.bold = 1
    aa.axes2D.yAxis.title.font.italic = 1
    aa.axes2D.yAxis.title.userTitle = 0
    aa.axes2D.yAxis.title.userUnits = 0
    aa.axes2D.yAxis.title.title = "Y-Axis"
    aa.axes2D.yAxis.title.units = ""
    aa.axes2D.yAxis.label.font.font = aa.axes2D.yAxis.label.font.Courier  # Arial, Courier, Times
    aa.axes2D.yAxis.label.font.scale = 1
    aa.axes2D.yAxis.label.font.useForegroundColor = 1
    aa.axes2D.yAxis.label.font.color = (0, 0, 0, 255)
    aa.axes2D.yAxis.label.font.bold = 1
    aa.axes2D.yAxis.label.font.italic = 1
    aa.axes2D.yAxis.label.scaling = 0

    visit.SetAnnotationAttributes(aa)
Ejemplo n.º 15
0
    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("")
Ejemplo n.º 16
0
def visit_plot_qcrit_wx_3d(xdmf_path,
                           qcrit_vals=(6.0, 1.0),
                           wx_lims=(-5.0, 5.0),
                           config_view=None,
                           out_dir=os.getcwd(),
                           prefix='qcrit_wx_3d_',
                           figsize=(1024, 1024),
                           state=None,
                           states=None,
                           states_range=[0, None, 1]):
    """Plot the 3D isosurface of the Q-criterion at 2 values.

    The first isosurface is colored by the streamwise vorticity.
    The second isosurface is colored with a single color (grey).

    Parameters
    ----------
    xdmf_path : str
        Path of the XDMF file with information about the Q-criterion and
        the streamwise vorticity.
    qcrit_vals : tuple, optional
        Values of the Q-criterion to display as a tuple of 2 floats;
        default is (6.0, 1.0).
    wx_lims : tuple, optional
        Limits of the color range for the streamwise vorticity
        as a tuple of 2 floats; default is (-5.0, 5.0).
    config_view : str, optional
        Path of the YAML file with the configuration of the view;
        default is None (use default VisIt view).
    out_dir : str, optional
        Output directory in which figures will be saved;
        default is the present working directory.
    prefix : str, optional
        Output filename prefix; default is "qcrit_wx_3d_".
    figsize : tuple
        Figure width and height (in pixels); default is (1024, 1024).
    state : int, optional
        Single state index to render;
        default is None (i.e., render multiple states).
    states : list, optional
        List of states to render; default is None (i.e., render all states).
    states_range : list, optional
        Start, end, and step indices for states to render;
        default is [0, None, 1] (i.e., render all states).

    """
    visit_initialize()

    # Open database from XDMF file.
    visit.OpenDatabase(xdmf_path, 0)

    # Add a pseudocolor of the streamwise vorticity.
    visit.AddPlot('Pseudocolor', 'wx_cc', 1, 0)
    PseudocolorAtts = visit.PseudocolorAttributes()
    PseudocolorAtts.minFlag, PseudocolorAtts.maxFlag = 1, 1
    PseudocolorAtts.min, PseudocolorAtts.max = wx_lims
    PseudocolorAtts.colorTableName = 'viridis'
    PseudocolorAtts.invertColorTable = 0
    visit.SetPlotOptions(PseudocolorAtts)

    # Add isosurface of the Q-criterion (colored by streamwise vorticity).
    visit.AddOperator('Isosurface', 0)
    IsosurfaceAtts = visit.IsosurfaceAttributes()
    IsosurfaceAtts.contourMethod = IsosurfaceAtts.Value
    IsosurfaceAtts.contourValue = (qcrit_vals[0])
    IsosurfaceAtts.variable = 'qcrit'
    visit.SetOperatorOptions(IsosurfaceAtts, 0)

    # Add single-value contour of the Q-criterion.
    visit.AddPlot('Contour', 'qcrit', 1, 0)
    ContourAtts = visit.ContourAttributes()
    ContourAtts.colorType = ContourAtts.ColorBySingleColor
    ContourAtts.legendFlag = 0
    ContourAtts.singleColor = (128, 128, 128, 153)  # grey
    ContourAtts.contourNLevels = 1
    ContourAtts.minFlag, ContourAtts.maxFlag = 1, 1
    ContourAtts.min, ContourAtts.max = qcrit_vals[1], qcrit_vals[1]
    visit.SetPlotOptions(ContourAtts)

    # Remove some annotations; keep triad.
    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)

    # Define state indices to render.
    states = visit_get_states(state=state,
                              states=states,
                              states_range=states_range)

    # Render states and save figures to files.
    visit_render_save_states(states,
                             config_view=config_view,
                             out_dir=out_dir,
                             prefix=prefix,
                             figsize=figsize)

    visit_finalize()
Ejemplo n.º 17
0
def visit_config(geometry_file, data_file, args):
    """
    Convert geometry file to stl, convert data file to vtk, load each file
    into VisIt, and create and load a session file containing four plot windows.
        1) A cube with a slice through an octant.
        2) XY plane slice through the centroid.
        3) XZ plane slice through the centroid.
        4) YZ plane slice through the centroid.
    Each window has a mesh plot with the "STL_mesh" variable, a Pseudocolor plot
    with the "TALLY_TAG" variable, and the second, third, and fourth windows have
    Contour plots with the "ERROR_TAG" variable. If the user has indicated to,
    launch VisIt and load the session file.

    Input:
    ______
       geometry_file: h5m file
           User supplied geometry file.
       data_file: h5m or vtk file
           User supplied data file.
       args: Namespace
           User supplied geometry file location, data file location, and
           indication if the user wants images of the plot windows with a
           timestamp and the session file saved and opened in VisIt.

    Returns:
    ________
       None
    """

    # Create a list of dictionaries indicating the data, plot, and variable in VisIt.
    Files = [{
        "file_name": data_file,
        "plot_type": "Pseudocolor",
        "data_tag": "TALLY_TAG"
    }, {
        "file_name": data_file,
        "plot_type": "Contour",
        "data_tag": "ERROR_TAG"
    }, {
        "file_name": geometry_file,
        "plot_type": "Mesh",
        "data_tag": "STL_mesh"
    }]

    # Launch VisIt and add appropriate plots.
    Vi.LaunchNowin()
    for file in Files:
        Vi.OpenDatabase(file["file_name"])
        Vi.AddPlot(file["plot_type"], file["data_tag"])

    # Hide the contour plot in the first plot window.
    Vi.SetActivePlots(1)
    Vi.HideActivePlots()

    # Create the plot of the cube by activating the mesh and pseudocolor plots.
    Vi.SetActivePlots((0, 2))

    # Set the view normal to the first octant.
    v = Vi.GetView3D()
    v.viewNormal = (1, 1, 1)
    Vi.SetView3D(v)

    # Apply a clip through the first octant.
    Vi.AddOperator("Clip")
    c = Vi.ClipAttributes()
    c.plane1Origin = (40, 40, 40)
    c.plane1Normal = (1, 1, 1)
    Vi.SetOperatorOptions(c)

    # Include the CNERG logo in the bottom left corner of the plot.
    image = Vi.CreateAnnotationObject("Image")
    image.image = os.path.dirname(os.path.abspath(__file__)) + "/cnerg.jpg"
    image.position = (0.02, 0.02)
    image.width = 10
    image.height = 10

    Vi.DrawPlots()
    if args.images:
        if args.timestamp:
            attributes = Vi.GetAnnotationAttributes()
            attributes.userInfoFlag = 0
            Vi.SetAnnotationAttributes(attributes)
        Vi.SaveWindow()

    # Create the second plot of the XY plane slice.
    plane_slice_plotting(2, 2, "XY Plane", args.images, args.timestamp)

    # Create the third plot of the XZ plane slice.
    plane_slice_plotting(3, 1, "XZ Plane", args.images, args.timestamp)

    # Create the fourth plot of the YZ plane slice.
    plane_slice_plotting(4, 0, "ZY Plane", args.images, args.timestamp)

    # Display the four windows in a 2x2 grid.
    Vi.SetWindowLayout(4)

    # Save the session file with the default VisIt output to the current directory.
    visit_output = "VisitDefaultOutput.session"
    Vi.SaveSession(visit_output)
    Vi.Close()

    # Retrieve the path to the VisIt session file.
    session_file_path = os.path.join(os.getcwd(), visit_output)

    # If the user has indicated to, open the session file with the VisIt GUI.
    if args.openvisit:
        os.system("visit -sessionfile {} &".format(session_file_path))

    # If the user has indicated to, remove the session file after VisIt has opened.
    if not args.sessionfile:
        os.system("sleep 10; rm {}".format(session_file_path))
Ejemplo n.º 18
0
def visit_plot_qcrit_wx_3d_direct(xdmf_path,
                                  wx_range=(-5.0, 5.0),
                                  q_value=0.1,
                                  config_view=None,
                                  out_dir=os.getcwd(),
                                  out_prefix='qcrit_wx_',
                                  figsize=(1024, 1024),
                                  state=None,
                                  states=None,
                                  states_range=[0, None, 1]):
    visit_initialize()

    visit.OpenDatabase(str(xdmf_path), 0)

    # 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 = 0
    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 = 'qcrit'
    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:
        View3DAtts = visit_get_view(config_view, '3D')
    visit.SetView3D(View3DAtts)

    visit.SetActiveWindow(1)

    states = visit_get_states(state=state,
                              states=states,
                              states_range=states_range)
    visit_render_save_states(states,
                             out_dir=out_dir,
                             out_prefix=out_prefix,
                             figsize=figsize)

    visit_finalize()
    return
Ejemplo n.º 19
0
def SetAnnotations():
    import visit
    AnnotationAtts = AnnotationAttributes()
    AnnotationAtts.axes3D.visible = 0
    AnnotationAtts.axes3D.autoSetTicks = 1
    AnnotationAtts.axes3D.autoSetScaling = 1
    AnnotationAtts.axes3D.lineWidth = 0
    AnnotationAtts.axes3D.tickLocation = AnnotationAtts.axes3D.Inside  # Inside, Outside, Both
    AnnotationAtts.axes3D.axesType = AnnotationAtts.axes3D.ClosestTriad  # ClosestTriad, FurthestTriad, OutsideEdges, StaticTriad, StaticEdges
    AnnotationAtts.axes3D.triadFlag = 1
    AnnotationAtts.axes3D.bboxFlag = 0
    AnnotationAtts.axes3D.xAxis.title.visible = 0
    AnnotationAtts.axes3D.xAxis.title.font.font = AnnotationAtts.axes3D.xAxis.title.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes3D.xAxis.title.font.scale = 1
    AnnotationAtts.axes3D.xAxis.title.font.useForegroundColor = 1
    AnnotationAtts.axes3D.xAxis.title.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes3D.xAxis.title.font.bold = 0
    AnnotationAtts.axes3D.xAxis.title.font.italic = 0
    AnnotationAtts.axes3D.xAxis.title.userTitle = 0
    AnnotationAtts.axes3D.xAxis.title.userUnits = 0
    AnnotationAtts.axes3D.xAxis.title.title = "X-Axis"
    AnnotationAtts.axes3D.xAxis.title.units = ""
    AnnotationAtts.axes3D.xAxis.label.visible = 0
    AnnotationAtts.axes3D.xAxis.label.font.font = AnnotationAtts.axes3D.xAxis.label.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes3D.xAxis.label.font.scale = 1
    AnnotationAtts.axes3D.xAxis.label.font.useForegroundColor = 1
    AnnotationAtts.axes3D.xAxis.label.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes3D.xAxis.label.font.bold = 0
    AnnotationAtts.axes3D.xAxis.label.font.italic = 0
    AnnotationAtts.axes3D.xAxis.label.scaling = 0
    AnnotationAtts.axes3D.xAxis.tickMarks.visible = 1
    AnnotationAtts.axes3D.xAxis.tickMarks.majorMinimum = 0
    AnnotationAtts.axes3D.xAxis.tickMarks.majorMaximum = 1
    AnnotationAtts.axes3D.xAxis.tickMarks.minorSpacing = 0.02
    AnnotationAtts.axes3D.xAxis.tickMarks.majorSpacing = 0.2
    AnnotationAtts.axes3D.xAxis.grid = 0
    AnnotationAtts.axes3D.yAxis.title.visible = 0
    AnnotationAtts.axes3D.yAxis.title.font.font = AnnotationAtts.axes3D.yAxis.title.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes3D.yAxis.title.font.scale = 1
    AnnotationAtts.axes3D.yAxis.title.font.useForegroundColor = 1
    AnnotationAtts.axes3D.yAxis.title.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes3D.yAxis.title.font.bold = 0
    AnnotationAtts.axes3D.yAxis.title.font.italic = 0
    AnnotationAtts.axes3D.yAxis.title.userTitle = 0
    AnnotationAtts.axes3D.yAxis.title.userUnits = 0
    AnnotationAtts.axes3D.yAxis.title.title = "Y-Axis"
    AnnotationAtts.axes3D.yAxis.title.units = ""
    AnnotationAtts.axes3D.yAxis.label.visible = 0
    AnnotationAtts.axes3D.yAxis.label.font.font = AnnotationAtts.axes3D.yAxis.label.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes3D.yAxis.label.font.scale = 1
    AnnotationAtts.axes3D.yAxis.label.font.useForegroundColor = 1
    AnnotationAtts.axes3D.yAxis.label.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes3D.yAxis.label.font.bold = 0
    AnnotationAtts.axes3D.yAxis.label.font.italic = 0
    AnnotationAtts.axes3D.yAxis.label.scaling = 0
    AnnotationAtts.axes3D.yAxis.tickMarks.visible = 1
    AnnotationAtts.axes3D.yAxis.tickMarks.majorMinimum = 0
    AnnotationAtts.axes3D.yAxis.tickMarks.majorMaximum = 1
    AnnotationAtts.axes3D.yAxis.tickMarks.minorSpacing = 0.02
    AnnotationAtts.axes3D.yAxis.tickMarks.majorSpacing = 0.2
    AnnotationAtts.axes3D.yAxis.grid = 0
    AnnotationAtts.axes3D.zAxis.title.visible = 0
    AnnotationAtts.axes3D.zAxis.title.font.font = AnnotationAtts.axes3D.zAxis.title.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes3D.zAxis.title.font.scale = 1
    AnnotationAtts.axes3D.zAxis.title.font.useForegroundColor = 1
    AnnotationAtts.axes3D.zAxis.title.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes3D.zAxis.title.font.bold = 0
    AnnotationAtts.axes3D.zAxis.title.font.italic = 0
    AnnotationAtts.axes3D.zAxis.title.userTitle = 0
    AnnotationAtts.axes3D.zAxis.title.userUnits = 0
    AnnotationAtts.axes3D.zAxis.title.title = "Z-Axis"
    AnnotationAtts.axes3D.zAxis.title.units = ""
    AnnotationAtts.axes3D.zAxis.label.visible = 0
    AnnotationAtts.axes3D.zAxis.label.font.font = AnnotationAtts.axes3D.zAxis.label.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes3D.zAxis.label.font.scale = 1
    AnnotationAtts.axes3D.zAxis.label.font.useForegroundColor = 1
    AnnotationAtts.axes3D.zAxis.label.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes3D.zAxis.label.font.bold = 0
    AnnotationAtts.axes3D.zAxis.label.font.italic = 0
    AnnotationAtts.axes3D.zAxis.label.scaling = 0
    AnnotationAtts.axes3D.zAxis.tickMarks.visible = 1
    AnnotationAtts.axes3D.zAxis.tickMarks.majorMinimum = 0
    AnnotationAtts.axes3D.zAxis.tickMarks.majorMaximum = 1
    AnnotationAtts.axes3D.zAxis.tickMarks.minorSpacing = 0.02
    AnnotationAtts.axes3D.zAxis.tickMarks.majorSpacing = 0.2
    AnnotationAtts.axes3D.zAxis.grid = 0
    AnnotationAtts.axes3D.setBBoxLocation = 1
    #AnnotationAtts.axes3D.bboxLocation = (-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
    AnnotationAtts.userInfoFlag = 0
    AnnotationAtts.userInfoFont.font = AnnotationAtts.userInfoFont.Arial  # Arial, Courier, Times
    AnnotationAtts.userInfoFont.scale = 1
    AnnotationAtts.userInfoFont.useForegroundColor = 1
    AnnotationAtts.userInfoFont.color = (0, 0, 0, 255)
    AnnotationAtts.userInfoFont.bold = 0
    AnnotationAtts.userInfoFont.italic = 0
    AnnotationAtts.databaseInfoFlag = 1
    AnnotationAtts.timeInfoFlag = 1
    AnnotationAtts.databaseInfoFont.font = AnnotationAtts.databaseInfoFont.Arial  # Arial, Courier, Times
    AnnotationAtts.databaseInfoFont.scale = 1
    AnnotationAtts.databaseInfoFont.useForegroundColor = 1
    AnnotationAtts.databaseInfoFont.color = (0, 0, 0, 255)
    AnnotationAtts.databaseInfoFont.bold = 0
    AnnotationAtts.databaseInfoFont.italic = 0
    AnnotationAtts.databaseInfoExpansionMode = AnnotationAtts.File  # File, Directory, Full, Smart, SmartDirectory
    AnnotationAtts.databaseInfoTimeScale = 1
    AnnotationAtts.databaseInfoTimeOffset = 0
    AnnotationAtts.legendInfoFlag = 1
    AnnotationAtts.backgroundColor = (255, 255, 255, 255)
    AnnotationAtts.foregroundColor = (0, 0, 0, 255)
    AnnotationAtts.gradientBackgroundStyle = AnnotationAtts.Radial  # TopToBottom, BottomToTop, LeftToRight, RightToLeft, Radial
    AnnotationAtts.gradientColor1 = (0, 0, 255, 255)
    AnnotationAtts.gradientColor2 = (0, 0, 0, 255)
    AnnotationAtts.backgroundMode = AnnotationAtts.Solid  # Solid, Gradient, Image, ImageSphere
    AnnotationAtts.backgroundImage = ""
    AnnotationAtts.imageRepeatX = 1
    AnnotationAtts.imageRepeatY = 1
    AnnotationAtts.axesArray.visible = 1
    AnnotationAtts.axesArray.ticksVisible = 1
    AnnotationAtts.axesArray.autoSetTicks = 1
    AnnotationAtts.axesArray.autoSetScaling = 1
    AnnotationAtts.axesArray.lineWidth = 0
    AnnotationAtts.axesArray.axes.title.visible = 1
    AnnotationAtts.axesArray.axes.title.font.font = AnnotationAtts.axesArray.axes.title.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axesArray.axes.title.font.scale = 1
    AnnotationAtts.axesArray.axes.title.font.useForegroundColor = 1
    AnnotationAtts.axesArray.axes.title.font.color = (0, 0, 0, 255)
    AnnotationAtts.axesArray.axes.title.font.bold = 0
    AnnotationAtts.axesArray.axes.title.font.italic = 0
    AnnotationAtts.axesArray.axes.title.userTitle = 0
    AnnotationAtts.axesArray.axes.title.userUnits = 0
    AnnotationAtts.axesArray.axes.title.title = ""
    AnnotationAtts.axesArray.axes.title.units = ""
    AnnotationAtts.axesArray.axes.label.visible = 1
    AnnotationAtts.axesArray.axes.label.font.font = AnnotationAtts.axesArray.axes.label.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axesArray.axes.label.font.scale = 1
    AnnotationAtts.axesArray.axes.label.font.useForegroundColor = 1
    AnnotationAtts.axesArray.axes.label.font.color = (0, 0, 0, 255)
    AnnotationAtts.axesArray.axes.label.font.bold = 0
    AnnotationAtts.axesArray.axes.label.font.italic = 0
    AnnotationAtts.axesArray.axes.label.scaling = 0
    AnnotationAtts.axesArray.axes.tickMarks.visible = 1
    AnnotationAtts.axesArray.axes.tickMarks.majorMinimum = 0
    AnnotationAtts.axesArray.axes.tickMarks.majorMaximum = 1
    AnnotationAtts.axesArray.axes.tickMarks.minorSpacing = 0.02
    AnnotationAtts.axesArray.axes.tickMarks.majorSpacing = 0.2
    AnnotationAtts.axesArray.axes.grid = 0
    visit.SetAnnotationAttributes(AnnotationAtts)
    return 0
Ejemplo n.º 20
0
        aatts.axes3D.triadFlag = 1
    else:
        aatts.axes3D.triadFlag = 0
    aatts.axes3D.bboxFlag = 0
    aatts.userInfoFlag = 0
    aatts.timeInfoFlag = 0
    aatts.legendInfoFlag = 0
    aatts.databaseInfoFlag = 0
    if args.time:
        aatts.timeInfoFlag = 1
    if args.legend:
        aatts.legendInfoFlag = 1
    if args.dbase:
        aatts.databaseInfoFlag = 1

    v.SetAnnotationAttributes(aatts)

    # Set initial view
    cc = v.GetView3D()
    cc.viewNormal = tuple(args.normal)  # View x-plane
    cc.viewUp = (0, 0, 1)  # Z-axis points up
    cc.imageZoom = args.zoom
    cc.imagePan = tuple(args.pan)
    cc.perspective = 0
    v.SetView3D(cc)

    # Set box selection
    if args.bbox:
        v.AddOperator('Box')
        batts = v.BoxAttributes()
        batts.amount = batts.All  # Some, All
Ejemplo n.º 21
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
Ejemplo n.º 22
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
Ejemplo n.º 23
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
Ejemplo n.º 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=None,
                              figsize=(1024, 1024),
                              state=None,
                              states=None,
                              states_range=[0, None, 1]):
    visit_initialize()

    # 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:
        View2DAtts = visit_get_view(config_view, '2D')
    visit.SetView2D(View2DAtts)

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

    visit.SetActiveWindow(1)

    states = visit_get_states(state=state,
                              states=states,
                              states_range=states_range)
    if out_prefix is None:
        out_prefix = name + '_'
    visit_render_save_states(states,
                             out_dir=out_dir,
                             out_prefix=out_prefix,
                             figsize=figsize)

    visit_finalize()
    return
Ejemplo n.º 25
0
def SetAnnotations():
    import visit
    AnnotationAtts = AnnotationAttributes()
    AnnotationAtts.axes2D.visible = 1
    AnnotationAtts.axes2D.autoSetTicks = 1
    AnnotationAtts.axes2D.autoSetScaling = 1
    AnnotationAtts.axes2D.lineWidth = 0
    AnnotationAtts.axes2D.tickLocation = AnnotationAtts.axes2D.Outside  # Inside, Outside, Both
    AnnotationAtts.axes2D.tickAxes = AnnotationAtts.axes2D.BottomLeft  # Off, Bottom, Left, BottomLeft, All
    AnnotationAtts.axes2D.xAxis.title.visible = 0
    AnnotationAtts.axes2D.xAxis.title.font.font = AnnotationAtts.axes2D.xAxis.title.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes2D.xAxis.title.font.scale = 1
    AnnotationAtts.axes2D.xAxis.title.font.useForegroundColor = 1
    AnnotationAtts.axes2D.xAxis.title.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes2D.xAxis.title.font.bold = 0
    AnnotationAtts.axes2D.xAxis.title.font.italic = 1
    AnnotationAtts.axes2D.xAxis.title.userTitle = 0
    AnnotationAtts.axes2D.xAxis.title.userUnits = 0
    AnnotationAtts.axes2D.xAxis.title.title = "X-Axis"
    AnnotationAtts.axes2D.xAxis.title.units = ""
    AnnotationAtts.axes2D.xAxis.label.visible = 0
    AnnotationAtts.axes2D.xAxis.label.font.font = AnnotationAtts.axes2D.xAxis.label.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes2D.xAxis.label.font.scale = 1
    AnnotationAtts.axes2D.xAxis.label.font.useForegroundColor = 1
    AnnotationAtts.axes2D.xAxis.label.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes2D.xAxis.label.font.bold = 0
    AnnotationAtts.axes2D.xAxis.label.font.italic = 1
    AnnotationAtts.axes2D.xAxis.label.scaling = 0
    AnnotationAtts.axes2D.xAxis.tickMarks.visible = 1
    AnnotationAtts.axes2D.xAxis.tickMarks.majorMinimum = 0
    AnnotationAtts.axes2D.xAxis.tickMarks.majorMaximum = 1
    AnnotationAtts.axes2D.xAxis.tickMarks.minorSpacing = 0.02
    AnnotationAtts.axes2D.xAxis.tickMarks.majorSpacing = 0.2
    AnnotationAtts.axes2D.xAxis.grid = 0
    AnnotationAtts.axes2D.yAxis.title.visible = 0
    AnnotationAtts.axes2D.yAxis.title.font.font = AnnotationAtts.axes2D.yAxis.title.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes2D.yAxis.title.font.scale = 1
    AnnotationAtts.axes2D.yAxis.title.font.useForegroundColor = 1
    AnnotationAtts.axes2D.yAxis.title.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes2D.yAxis.title.font.bold = 0
    AnnotationAtts.axes2D.yAxis.title.font.italic = 1
    AnnotationAtts.axes2D.yAxis.title.userTitle = 0
    AnnotationAtts.axes2D.yAxis.title.userUnits = 0
    AnnotationAtts.axes2D.yAxis.title.title = "Y-Axis"
    AnnotationAtts.axes2D.yAxis.title.units = ""
    AnnotationAtts.axes2D.yAxis.label.visible = 0
    AnnotationAtts.axes2D.yAxis.label.font.font = AnnotationAtts.axes2D.yAxis.label.font.Arial  # Arial, Courier, Times
    AnnotationAtts.axes2D.yAxis.label.font.scale = 1
    AnnotationAtts.axes2D.yAxis.label.font.useForegroundColor = 1
    AnnotationAtts.axes2D.yAxis.label.font.color = (0, 0, 0, 255)
    AnnotationAtts.axes2D.yAxis.label.font.bold = 0
    AnnotationAtts.axes2D.yAxis.label.font.italic = 1
    AnnotationAtts.axes2D.yAxis.label.scaling = 0
    AnnotationAtts.axes2D.yAxis.tickMarks.visible = 1
    AnnotationAtts.axes2D.yAxis.tickMarks.majorMinimum = 0
    AnnotationAtts.axes2D.yAxis.tickMarks.majorMaximum = 1
    AnnotationAtts.axes2D.yAxis.tickMarks.minorSpacing = 0.02
    AnnotationAtts.axes2D.yAxis.tickMarks.majorSpacing = 0.2
    AnnotationAtts.axes2D.yAxis.grid = 0
    AnnotationAtts.userInfoFlag = 0
    AnnotationAtts.userInfoFont.font = AnnotationAtts.userInfoFont.Arial  # Arial, Courier, Times
    AnnotationAtts.userInfoFont.scale = 1
    AnnotationAtts.userInfoFont.useForegroundColor = 1
    AnnotationAtts.userInfoFont.color = (0, 0, 0, 255)
    AnnotationAtts.userInfoFont.bold = 0
    AnnotationAtts.userInfoFont.italic = 0
    AnnotationAtts.databaseInfoFlag = 0
    AnnotationAtts.timeInfoFlag = 1
    AnnotationAtts.databaseInfoFont.font = AnnotationAtts.databaseInfoFont.Arial  # Arial, Courier, Times
    AnnotationAtts.databaseInfoFont.scale = 1
    AnnotationAtts.databaseInfoFont.useForegroundColor = 1
    AnnotationAtts.databaseInfoFont.color = (0, 0, 0, 255)
    AnnotationAtts.databaseInfoFont.bold = 0
    AnnotationAtts.databaseInfoFont.italic = 0
    AnnotationAtts.databaseInfoExpansionMode = AnnotationAtts.File  # File, Directory, Full, Smart, SmartDirectory
    AnnotationAtts.databaseInfoTimeScale = 1
    AnnotationAtts.databaseInfoTimeOffset = 0
    AnnotationAtts.legendInfoFlag = 0

    visit.SetAnnotationAttributes(AnnotationAtts)
    return 0
Ejemplo n.º 26
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=None,
                          figsize=(1024, 1024),
                          state=None,
                          states=None,
                          states_range=[0, None, 1]):
    visit_initialize()

    # 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:
        View3DAtts = visit_get_view(config_view, '3D')
    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)

    states = visit_get_states(state=state,
                              states=states,
                              states_range=states_range)
    if out_prefix is None:
        out_prefix = name + '_'
    visit_render_save_states(states,
                             out_dir=out_dir,
                             out_prefix=out_prefix,
                             figsize=figsize)

    visit_finalize()
    return
Ejemplo n.º 27
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='qcrit_wx_',
                           figsize=(1024, 1024),
                           state=None,
                           states=None,
                           states_range=[0, None, 1]):
    visit_initialize()

    # 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)
    # 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_expr = ('{' +
                '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_expr)
    # Define Q-criterion.
    qcrit_expr = ('q_criterion(' + 'gradient(velocity[0]),' +
                  'gradient(velocity[1]),' + 'gradient(velocity[2])' + ')')
    visit.DefineScalarExpression('q_crit', qcrit_expr)
    # 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 = 0
    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:
        View3DAtts = visit_get_view(config_view, '3D')
    visit.SetView3D(View3DAtts)

    visit.SetActiveWindow(1)

    states = visit_get_states(state=state,
                              states=states,
                              states_range=states_range)
    visit_render_save_states(states,
                             out_dir=out_dir,
                             out_prefix=out_prefix,
                             figsize=figsize)

    visit_finalize()
    return
Ejemplo n.º 28
0
annot_attr.axes3D.xAxis.title.title = "X"
annot_attr.axes3D.xAxis.title.font.scale = 1.5

annot_attr.axes3D.yAxis.title.userTitle = True
annot_attr.axes3D.yAxis.title.title = "Y"
annot_attr.axes3D.yAxis.title.font.scale = 1.5

annot_attr.axes3D.zAxis.title.userTitle = True
annot_attr.axes3D.zAxis.title.title = "image * gauss"
annot_attr.axes3D.zAxis.title.font.scale = 1.5
annot_attr.axes3D.zAxis.tickMarks.visible = False
annot_attr.axes3D.zAxis.label.visible = False

annot_attr.userInfoFlag = False
annot_attr.databaseInfoFlag = False
visit.SetAnnotationAttributes(annot_attr)

## Set plot Annotations:
p = visit.GetAnnotationObjectNames()[0]
psc_ann = visit.GetAnnotationObject(p)
psc_ann.drawTitle = False
psc_ann.managePosition = False
psc_ann.position = (0.05, 0.98)
psc_ann.orientation = psc_ann.HorizontalTop

## SaveWindow attributes
swa = visit.SaveWindowAttributes()
#swa.outputToCurrentDirectory = False
#swa.outputDirectory = "2d_filter_frames"
#swa.format = swa.JPEG
#swa.quality = 100