Exemple #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)
Exemple #2
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()
Exemple #3
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()
Exemple #4
0
def SetView2dAttributes(domain, viewport):
    # set x- and y-ranges of domain from domain argument (e.g. (0,64,0,64))
    # set relative position of plot from viewport (e.g. (0.06,0.94,0.11,0.99))

    va = visit.View2DAttributes()

    # options I like to set

    va.windowCoords = (domain.xlo, domain.xhi, domain.ylo, domain.yhi)
    va.viewportCoords = (viewport.xlo, viewport.xhi, viewport.ylo,
                         viewport.yhi)

    # other options with default values

    va.fullFrameActivationMode = va.Auto  # On, Off, Auto
    va.fullFrameAutoThreshold = 100
    va.xScale = va.LINEAR  # LINEAR, LOG
    va.yScale = va.LINEAR  # LINEAR, LOG
    va.windowValid = 1

    visit.SetView2D(va)
Exemple #5
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()
Exemple #6
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
# 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
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
def make_distribution_movie(cellids,
                            rotated,
                            inputDirectory,
                            outputDirectory,
                            outputFileName,
                            zoom=1.0,
                            viewNormal=[0.488281, 0.382966, -0.784167],
                            minThreshold=1e-18,
                            maxThreshold=1e37):
    '''Makes a distribution movie of some given distribution data
      Example usage:
      make_distribution_movie(cellids=[18302, 19432, 19042], rotated=True, inputDirectory=\"/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/\", outputDirectory=\"/home/hannukse/MOVIES/\", outputFileName=\"testmovie\", zoom=0.8, viewNormal=[0.488281, 0.382966, -0.784167], minThreshold=1e-17, maxThreshold=1.2e37)
      Note: viewNormal determines the angle of view (straight from visit)
   '''
    if len(viewNormal) != 3:
        print "ERROR, INVALID VIEWNORMAL LENGTH, SHOULD BE 3"
        return
    for cell in sorted(cellids):
        # OPTIONS
        ###########################################################
        cellid = str(cell)
        #databaseName = "localhost:/home/hannukse/meteo/lustre/tmp/hannuksela/AAM/velgrid.rotated." + cellid + ".*.silo database"
        if rotated == True:
            rotateFix = "rotated."
        else:
            rotateFix = ""
        inputFileName = "velgrid." + rotateFix + cellid + ".*.silo"
        databaseName = "localhost:" + inputDirectory + inputFileName + " database"
        outputDir = outputDirectory
        fileName = outputFileName + "_" + cellid + "_"
        WIDTH = 3000
        HEIGHT = 3000
        # Threshold values:
        # TODO: USE VLSV READER TO AUTOMATE THIS
        minimumThreshold = minThreshold
        maximumThreshold = maxThreshold
        ###########################################################

        vis.OpenDatabase(databaseName, 0)
        #Load settings
        visSettings.load_visit_settings()
        #Make a plot
        vis.AddPlot("Pseudocolor", "avgs", 1, 1)
        vis.SetActivePlots(0)
        vis.AddOperator("Threshold", 1)
        vis.ThresholdAtts = vis.ThresholdAttributes()
        vis.ThresholdAtts.outputMeshType = 0
        vis.ThresholdAtts.listedVarNames = ("default")
        vis.ThresholdAtts.zonePortions = (1)
        vis.ThresholdAtts.lowerBounds = (minimumThreshold)
        vis.ThresholdAtts.upperBounds = (maximumThreshold)
        vis.ThresholdAtts.defaultVarName = "avgs"
        vis.ThresholdAtts.defaultVarIsScalar = 1
        vis.SetOperatorOptions(vis.ThresholdAtts, 1)
        vis.DrawPlots()
        # Begin spontaneous state
        vis.View3DAtts = vis.View3DAttributes()
        vis.View3DAtts.viewNormal = (viewNormal[0], viewNormal[1],
                                     viewNormal[2])
        vis.View3DAtts.focus = (-634.56, 91.3781, -13.7891)
        vis.View3DAtts.viewUp = (-0.102795, 0.917551, 0.3841)
        vis.View3DAtts.viewAngle = 30
        vis.View3DAtts.parallelScale = 1.45614e+06
        vis.View3DAtts.nearPlane = -2.91228e+06
        vis.View3DAtts.farPlane = 2.91228e+06
        vis.View3DAtts.imagePan = (0, 0)
        vis.View3DAtts.imageZoom = zoom
        vis.View3DAtts.perspective = 1
        vis.View3DAtts.eyeAngle = 2
        vis.View3DAtts.centerOfRotationSet = 0
        vis.View3DAtts.centerOfRotation = (-634.56, 91.3781, -13.7891)
        vis.View3DAtts.axis3DScaleFlag = 0
        vis.View3DAtts.axis3DScales = (1, 1, 1)
        vis.View3DAtts.shear = (0, 0, 1)
        vis.SetView3D(vis.View3DAtts)
        # End spontaneous state
        vis.ViewCurveAtts = vis.ViewCurveAttributes()
        vis.ViewCurveAtts.domainCoords = (0, 1)
        vis.ViewCurveAtts.rangeCoords = (0, 1)
        vis.ViewCurveAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95)
        vis.ViewCurveAtts.domainScale = vis.ViewCurveAtts.LINEAR  # LINEAR, LOG
        vis.ViewCurveAtts.rangeScale = vis.ViewCurveAtts.LINEAR  # LINEAR, LOG
        vis.SetViewCurve(vis.ViewCurveAtts)
        vis.View2DAtts = vis.View2DAttributes()
        vis.View2DAtts.windowCoords = (0, 1, 0, 1)
        vis.View2DAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95)
        vis.View2DAtts.fullFrameActivationMode = vis.View2DAtts.Auto  # On, Off, Auto
        vis.View2DAtts.fullFrameAutoThreshold = 100
        vis.View2DAtts.xScale = vis.View2DAtts.LINEAR  # LINEAR, LOG
        vis.View2DAtts.yScale = vis.View2DAtts.LINEAR  # LINEAR, LOG
        vis.View2DAtts.windowValid = 0
        vis.SetView2D(vis.View2DAtts)
        vis.View3DAtts = vis.View3DAttributes()
        vis.View3DAtts.viewNormal = (viewNormal[0], viewNormal[1],
                                     viewNormal[2])
        vis.View3DAtts.focus = (-634.56, 91.3781, -13.7891)
        vis.View3DAtts.viewUp = (-0.102795, 0.917551, 0.3841)
        vis.View3DAtts.viewAngle = 30
        vis.View3DAtts.parallelScale = 1.45614e+06
        vis.View3DAtts.nearPlane = -2.91228e+06
        vis.View3DAtts.farPlane = 2.91228e+06
        vis.View3DAtts.imagePan = (0, 0)
        vis.View3DAtts.imageZoom = zoom
        vis.View3DAtts.perspective = 1
        vis.View3DAtts.eyeAngle = 2
        vis.View3DAtts.centerOfRotationSet = 0
        vis.View3DAtts.centerOfRotation = (-634.56, 91.3781, -13.7891)
        vis.View3DAtts.axis3DScaleFlag = 0
        vis.View3DAtts.axis3DScales = (1, 1, 1)
        vis.View3DAtts.shear = (0, 0, 1)
        vis.SetView3D(vis.View3DAtts)
        vis.ViewAxisArrayAtts = vis.ViewAxisArrayAttributes()
        vis.ViewAxisArrayAtts.domainCoords = (0, 1)
        vis.ViewAxisArrayAtts.rangeCoords = (0, 1)
        vis.ViewAxisArrayAtts.viewportCoords = (0.15, 0.9, 0.1, 0.85)
        vis.SetViewAxisArray(vis.ViewAxisArrayAtts)
        for i in range(0, vis.GetDatabaseNStates()):
            vis.SetTimeSliderState(i)
            vis.SaveWindowAtts = vis.SaveWindowAttributes()
            vis.SaveWindowAtts.outputToCurrentDirectory = 0
            vis.SaveWindowAtts.outputDirectory = outputDir
            vis.SaveWindowAtts.fileName = fileName
            vis.SaveWindowAtts.family = 1
            vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
            vis.SaveWindowAtts.width = WIDTH
            vis.SaveWindowAtts.height = HEIGHT
            vis.SaveWindowAtts.screenCapture = 0
            vis.SaveWindowAtts.saveTiled = 0
            vis.SaveWindowAtts.quality = 100
            vis.SaveWindowAtts.progressive = 0
            vis.SaveWindowAtts.binary = 0
            vis.SaveWindowAtts.stereo = 0
            vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
            vis.SaveWindowAtts.forceMerge = 0
            vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
            vis.SaveWindowAtts.advancedMultiWindowSave = 0
            vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
            vis.SaveWindow()
        vis.DeleteActivePlots()
        vis.CloseDatabase(databaseName)
        # Make the movie:
        framerate = 5
        subprocess.call([
            pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh",
            outputDir, fileName, framerate
        ])
Exemple #9
0
            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
            AnnotationAtts.axes2D.yAxis.title.visible = 0
            AnnotationAtts.axes2D.yAxis.label.visible = 1
            AnnotationAtts.axes2D.yAxis.tickMarks.visible = 1
            AnnotationAtts.axes2D.yAxis.tickMarks.majorMinimum = 0
            AnnotationAtts.axes2D.yAxis.tickMarks.majorMaximum = 1.58
Exemple #10
0
def make_moving_frame_of_reference_movie(x_begin,
                                         x_end,
                                         y_begin,
                                         y_end,
                                         speed_x,
                                         speed_y,
                                         variable_name,
                                         minThreshold,
                                         maxThreshold,
                                         input_directory,
                                         input_file_name,
                                         output_directory,
                                         output_file_name,
                                         color_table="hot_desaturated",
                                         start_frame=-1,
                                         end_frame=-1,
                                         frame_skip_dt=1.0):
    '''
   Function for making a movie with a moving frame of reference.
   :param x_begin             The starting frame's beginning x-coordinate
   :param x_end               The starting frame's ending x-coordinate
   :param y_begin             The starting frame's beginning x-coordinate
   :param y_end               The starting frame's ending y-coordinate
   :param speed_x             The speed at which the frame moves in the x direction
   :param speed_y             The speed at which the frame moves in the y direction
   :param variable_name       Name of the variable (For ex \"rho\")
   :param minThreshold        Minimum threshold for the variable
   :param maxThreshold        Maximum threshold for the variable
   :param input_directory     The path to the directory where the files are
   :param input_file_name     Name of the files (For ex \"bulk.*.silo\")
   :param output_directory    Directory where to output the movie
   :param output_file_name    Name of the outputted file (For ex \"RHOMOVIE\")
   :param color_table         Name of the color table (\"hot_desaturated\" by default)
   :param start_frame         Starting frame for the movie (if -1, equals 0, -1 by default)
   :param end_frame           Ending frame for the movie (if -1, equals the last frame, -1 by default)
   :param frame_skip_dt       The number of seconds one skip in frame equals (1.0 by default) (Note: This may change depending on the run and should always be checked)
   '''
    # OPTIONS
    #################################################################
    # Input the boundary box for starting coordinates (Starting values)
    startX = x_begin  # The left x-boundary of the box
    endX = x_end  # The right x-boundary of the box
    startY = y_begin  # The bottom y-boundary of the box
    endY = y_end  # The upper y-boundary of the box

    # Input frame properties
    startFrame = start_frame  # Note: if startFrame is set to -1 the start frame gets set to 0
    endFrame = end_frame  # Note: if endFrame is set to -1 the endFrame is automatically the number of frames in the database
    frameInSeconds = frame_skip_dt  # Set how many seconds one frame skip is

    # Input speed in x and y direction
    speedX = speed_x  # Meters per second
    speedY = speed_y  # Meters per second

    # Input variable
    variableName = variable_name
    minVariableValue = minThreshold
    maxVariableValue = maxThreshold
    colorTableName = color_table

    # Input directory and file names
    outputDir = output_directory  # Set the output directory (Where .png s are saved)
    outputFileName = output_file_name  # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, .
    databaseName = "localhost:" + input_directory + input_file_name + " database"  # For navigating to the silo files
    # visitBinDirectory = "/usr/local/visit/bin" #Nevermind this
    # Note: a slice of the plot in z-axis is taken automatically
    #################################################################

    # Launch visit
    visitBinDirectory = '/home/htest/visit/bin'
    vis.LaunchNowin(vdir=visitBinDirectory)
    dx = speedX * frameInSeconds  # Note: This is in meters per frame!
    dy = speedY * frameInSeconds  # Note: This is in meters per frame!
    #Set up window and annotations
    vis.OpenDatabase(databaseName, 0)
    #Load settings
    visSettings.load_visit_settings()

    vis.AddPlot("Pseudocolor", variableName, 1, 1)
    vis.SetActivePlots(0)
    vis.PseudocolorAtts = vis.PseudocolorAttributes()
    vis.PseudocolorAtts.legendFlag = 1
    vis.PseudocolorAtts.lightingFlag = 1
    vis.PseudocolorAtts.minFlag = 1
    vis.PseudocolorAtts.maxFlag = 1
    vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural  # Natural, Nodal, Zonal
    vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear  # Linear, Log, Skew
    vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot  # OriginalData, CurrentPlot
    vis.PseudocolorAtts.min = minVariableValue
    vis.PseudocolorAtts.max = maxVariableValue
    vis.PseudocolorAtts.pointSize = 0.05
    vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
    vis.PseudocolorAtts.skewFactor = 1
    vis.PseudocolorAtts.opacity = 1
    vis.PseudocolorAtts.colorTableName = color_table
    vis.PseudocolorAtts.invertColorTable = 0
    vis.PseudocolorAtts.smoothingLevel = 0
    vis.PseudocolorAtts.pointSizeVarEnabled = 0
    vis.PseudocolorAtts.pointSizeVar = "default"
    vis.PseudocolorAtts.pointSizePixels = 2
    vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
    vis.PseudocolorAtts.lineWidth = 0
    vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit  # Explicit, ColorTable
    vis.SetPlotOptions(vis.PseudocolorAtts)
    vis.SetActivePlots(0)
    vis.AddOperator("Slice", 1)
    vis.AddOperator("Threshold", 1)
    vis.ThresholdAtts = vis.ThresholdAttributes()
    vis.ThresholdAtts.outputMeshType = 0
    vis.ThresholdAtts.listedVarNames = ("Boundary_type")
    vis.ThresholdAtts.zonePortions = (1)
    vis.ThresholdAtts.lowerBounds = (1)
    vis.ThresholdAtts.upperBounds = (1)
    vis.ThresholdAtts.defaultVarName = variableName
    vis.ThresholdAtts.defaultVarIsScalar = 1
    vis.SetOperatorOptions(vis.ThresholdAtts, 1)
    vis.ThresholdAtts = vis.ThresholdAttributes()
    vis.ThresholdAtts.outputMeshType = 0
    vis.ThresholdAtts.listedVarNames = ("Boundary_type")
    vis.ThresholdAtts.zonePortions = (1)
    vis.ThresholdAtts.lowerBounds = (1)
    vis.ThresholdAtts.upperBounds = (1)
    vis.ThresholdAtts.defaultVarName = variableName
    vis.ThresholdAtts.defaultVarIsScalar = 1
    vis.SetOperatorOptions(vis.ThresholdAtts, 1)
    vis.SetActivePlots(0)
    vis.SliceAtts = vis.SliceAttributes()
    vis.SliceAtts.originType = vis.SliceAtts.Intercept  # Point, Intercept, Percent, Zone, Node
    vis.SliceAtts.originPoint = (0, 0, 0)
    vis.SliceAtts.originIntercept = 0
    vis.SliceAtts.originPercent = 0
    vis.SliceAtts.originZone = 0
    vis.SliceAtts.originNode = 0
    vis.SliceAtts.normal = (0, 0, 1)
    vis.SliceAtts.axisType = vis.SliceAtts.ZAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
    vis.SliceAtts.upAxis = (0, 1, 0)
    vis.SliceAtts.project2d = 1
    vis.SliceAtts.interactive = 1
    vis.SliceAtts.flip = 0
    vis.SliceAtts.originZoneDomain = 0
    vis.SliceAtts.originNodeDomain = 0
    vis.SliceAtts.meshName = "SpatialGrid"
    vis.SliceAtts.theta = 0
    vis.SliceAtts.phi = 90
    vis.SetOperatorOptions(vis.SliceAtts, 1)
    vis.DrawPlots()

    if endFrame == -1:
        endFrame = vis.TimeSliderGetNStates() - 1

    if startFrame == -1:
        startFrame = 0

    # Iterate through frames
    for i in xrange(startFrame, endFrame + 1):
        vis.SetTimeSliderState(i)
        frame = i - startFrame
        vis.View2DAtts = vis.View2DAttributes()
        vis.View2DAtts.windowCoords = (startX + frame * dx, endX + frame * dx,
                                       startY + frame * dy, endY + frame * dy)
        vis.View2DAtts.viewportCoords = (0.2, 0.95, 0.15, 0.95)
        vis.View2DAtts.fullFrameActivationMode = vis.View2DAtts.Auto  # On, Off, Auto
        vis.View2DAtts.fullFrameAutoThreshold = 100
        vis.View2DAtts.xScale = vis.View2DAtts.LINEAR  # LINEAR, LOG
        vis.View2DAtts.yScale = vis.View2DAtts.LINEAR  # LINEAR, LOG
        vis.View2DAtts.windowValid = 1
        vis.SetView2D(vis.View2DAtts)
        vis.SaveWindowAtts = vis.SaveWindowAttributes()
        vis.SaveWindowAtts.outputToCurrentDirectory = 0
        vis.SaveWindowAtts.outputDirectory = outputDir
        vis.SaveWindowAtts.fileName = outputFileName
        vis.SaveWindowAtts.family = 1
        vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
        vis.SaveWindowAtts.width = 1024
        vis.SaveWindowAtts.height = 1024
        vis.SaveWindowAtts.screenCapture = 0
        vis.SaveWindowAtts.saveTiled = 0
        vis.SaveWindowAtts.quality = 100
        vis.SaveWindowAtts.progressive = 0
        vis.SaveWindowAtts.binary = 0
        vis.SaveWindowAtts.stereo = 0
        vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
        vis.SaveWindowAtts.forceMerge = 0
        vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
        vis.SaveWindowAtts.advancedMultiWindowSave = 0
        vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
        vis.SaveWindow()
    vis.DeleteActivePlots()
    vis.CloseDatabase(databaseName)
    # Make the movie:
    framerate = 7
    subprocess.call([
        pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh",
        outputDir, outputFileName, framerate
    ])
Exemple #11
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
Exemple #12
0
import sys
# visit
sys.path.append("/home/neo/visit/2.11.0/linux-x86_64/lib/site-packages")
import visit as vs

vs.Launch()
vs.OpenDatabase("visit-data/noise.silo")
vs.AddPlot("Pseudocolor", "hgslice")
vs.AddPlot("Mesh", "Mesh2D")
vs.AddPlot("Label", "hgslice")
vs.DrawPlots()
print "The current view is:", vs.GetView2D()
# Get an initialized 2D view object.
v = vs.GetView2D()
v.windowCoords = (-7.67964, -3.21856, 2.66766, 7.87724)
vs.SetView2D(v)

d = input('Press anything to quit')