Ejemplo n.º 1
0
 def isosurfacePlot(self, stay=False, samples=100, contours=50):
     visit.AddWindow()
     returned = []
     if len(visit.ListPlots()) > 0:
         visit.SetActivePlots(0)
         visit.HideActivePlots()
     p = visit.PseudocolorAttributes()
     q = visit.ResampleAttributes()
     r = visit.IsosurfaceAttributes()
     q.samplesX = samples
     q.samplesY = samples
     q.samplesZ = samples
     r.contourNLevels = contours
     plot = visit.AddPlot("Pseudocolor", "Heat")
     visit.AddOperator("Resample")
     # visit.AddOperator("Isosurface")
     visit.SetOperatorOptions(q)
     visit.SetOperatorOptions(r)
     visit.SetPlotOptions(p)
     visit.DrawPlots()
     returned.append(visit.SaveWindow())
     count = 0
     visit.AddOperator("Isosurface")
     visit.DrawPlots()
     time.sleep(60)
     returned.append(visit.SaveWindow())
     return returned
Ejemplo n.º 2
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.º 3
0
    def createSnowPseudocolor(self,
                              varname,
                              limits=None,
                              cmap=None,
                              window=None,
                              legend=False):
        """Simplified interface to create standard pseudocolors on the snow surface."""
        self.activateSurface()

        if window is not None:
            self.setActiveWindow(window)
        win = self.getActiveWindow()

        if cmap is None:
            cmap = "hot"

        pcolor = win.createPseudocolor(varname,
                                       limits=limits,
                                       cmap=cmap,
                                       legend=legend)

        # deform by surface vector
        v.AddOperator("Displace")
        da = v.DisplaceAttributes()
        da.variable = "snow_displace"
        v.SetOperatorOptions(da)
        pcolor.operators.append(Operator("displace", "Displace", da))
        return pcolor
Ejemplo n.º 4
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.º 5
0
 def test_query_02_kwargs(self):
     #add a threshold
     visit.AddOperator("Isovolume")
     iatts = visit.IsovolumeAttributes()
     iatts.lbound = 0.4
     iatts.ubound = 1e+37
     visit.SetOperatorOptions(iatts)
     visit.DrawPlots()
     res_v = query("Min", use_actual_data=True)
     self.assertTrue(abs(res_v - 0.3778594434261322) < 1e-5)
     res_v = query("Min", use_actual_data=False)
     self.assertTrue(abs(res_v - 0.02357020415365696) < 1e-5)
Ejemplo n.º 6
0
    def __get_isovol(self, lbound, ubound, i):
        """Gets the volume selection for isovolume and export just the
        outer surface of the volume as STL.

        Input:
        ------
            lbound: float, lower boundary value for the isovolume
            ubound: float, upper boundary value for the isovolume
            i: int, surface number
        """
        # generate isovolume
        v.AddOperator("Isovolume")
        att = v.IsovolumeAttributes()
        att.lbound = lbound
        att.ubound = ubound
        v.SetOperatorOptions(att)

        # set operator setting to only get surfaces meshes
        v.AddOperator("ExternalSurface")

        # draw plot
        v.DrawPlots()

        # export current volume to folder
        e = v.ExportDBAttributes()
        e.dirname = self.db + "/vols/"
        e.db_type = "STL"
        e.filename = str(i)
        e.variables = self.data
        export_res = v.ExportDatabase(e)

        # check if exporting was successful or not and adjust values
        if export_res == 0:
            # export not successful because there was no data
            # get new upper bound
            warn_message = "Warning: no data to export between " \
                + "{} and {}.\n".format(lbound, ubound) \
                + "Increasing upper bound to next selected level."
            warnings.warn(warn_message)
            if ubound == max(self.levels):
                # already at max so do not need to export more levels
                self.levels.remove(ubound)
                export_res = 1
            else:
                # update to next level to try again
                index = self.levels.index(ubound)
                ubound_old = ubound
                ubound = self.levels[index + 1]
                self.levels.remove(ubound_old)
        # delete the operators
        v.RemoveAllOperators()

        return export_res, ubound
Ejemplo n.º 7
0
    def _get_isovol(self, lbound, ubound, i):
        """Gets the volume selection for isovolume and export just the
        outer surface of the volume as STL.

        Input:
        ------
            lbound: float, lower boundary value for the isovolume
            ubound: float, upper boundary value for the isovolume
            i: int, surface number
        """

        # generate isovolume
        v.AddOperator("Isovolume")
        att = v.IsovolumeAttributes()
        att.lbound = lbound
        att.ubound = ubound
        v.SetOperatorOptions(att)

        # set operator setting to only get surfaces meshes
        v.AddOperator("ExternalSurface")

        # draw plot
        draw_res = v.DrawPlots()
        if draw_res == 0:
            sys.exit("Error with producing isovolume")

        # export current volume to folder
        e = v.ExportDBAttributes()
        e.dirname = self.db + "/vols/"
        e.db_type = "STL"
        e.filename = str(i)
        e.variables = self.data
        export_res = v.ExportDatabase(e)

        if export_res == 0:
            # export not successful because there was no data
            # get new upper bound
            warn_message = "Warning: no data to export between {} and {}.\n".format(lbound, ubound) \
                + "Increasing upper bound to next selected level."
            print(warn_message)
            if ubound in self.levels:
                self._update_levels(ubound)
            else:
                # it is the arbitrary upper level set and is not needed
                self._update_levels(self.levels[-1])

        # delete the operators
        v.RemoveAllOperators()

        return export_res, ubound
Ejemplo n.º 8
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.º 9
0
 def _exaggerateVertical(self):
     if self.dim == 3:
         self.view.axis3DScaleFlag = 1
         self.view.axis3DScales = (self.view.axis3DScales[0],
                                   self.view.axis3DScales[1],
                                   self.exaggeration)
     else:
         for i,plot in enumerate(self.plots):
             done = False
             for op in plot.operators:
                 if "exaggerate_vertical" == op.oname:
                     done = True
             if not done:
                 print "transforming plot %d..."%i
                 tr = v.TransformAttributes()
                 tr.doScale = 1
                 tr.scaleY = self.exaggeration
                 v.SetActivePlots(i)
                 v.AddOperator("Transform")
                 v.SetOperatorOptions(tr)
                 plot.operators.append(Operator("exaggerate_vertical", "Transform", tr))
Ejemplo n.º 10
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()
Ejemplo n.º 11
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
        ])
Ejemplo n.º 12
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.º 13
0
        # First fig

        for alpha in (0.05, 0.6):

            visit.AddPlot("Pseudocolor", "vol_frac_average", 1, 1)

            visit.AddOperator("Slice", 1)
            SliceAtts = visit.SliceAttributes()
            SliceAtts.originType = SliceAtts.Point
            SliceAtts.originPoint = (0, 0, 0)
            SliceAtts.normal = (0, 0, -1)
            SliceAtts.axisType = SliceAtts.ZAxis
            SliceAtts.upAxis = (1, 0, 0)
            SliceAtts.project2d = 1
            SliceAtts.flip = 1
            visit.SetOperatorOptions(SliceAtts, 1)

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

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

            AnnotationAtts = visit.AnnotationAttributes()
            AnnotationAtts.axes2D.autoSetTicks = 0
Ejemplo n.º 14
0
def make_movie( variableName, minValue, maxValue, inputDirectory, inputFileName, outputDirectory, outputFileName, colorTable="hot_desaturated", startFrame=-1, endFrame=-1 ):
   '''
   Function for making a movie
   
   Arguments:
   :param variableName                  Name of the variable
   :param minValue                      Minimum value of the variable
   :param maxValue                      Maximum value of the variable
   :param inputDirectory                Path to input vlsv/silo files
   :param inputFileName                 Name of the file(s) so for example if the filenames are bulk.0000.silo, bulk.0001.silo, .. then inputFileName=\"bulk.*.silo\""
   :param outputDirectory               Path to output directory
   :param outputFileName                Name of the output file
   :param colorTable="hot_desaturated"  Color table for the plots
   :param startFrame=-1                 Starting frame of the movie (-1 equals 0)
   :param endFrame=-1                   Starting frame of the movie (-1 equals last frame)
   '''
   # OPTIONS
   #################################################################
   # Input frame properties
   _startFrame = startFrame # Note: if _startFrame is set to -1 the start frame gets set to 0
   _endFrame = endFrame # Note: if _endFrame is set to -1 the _endFrame is automatically the number of frames in the database
   
   # Input variable
   _variableName = variableName
   minVariableValue = minValue
   maxVariableValue = maxValue
   colorTableName = colorTable
   
   # Input directory and file names
   #_outputDir = "/home/hannukse/MOVINGFRAME_MOVIES/AAJ_BZ_REMAKE/" # Set the output directory (Where .png s are saved)
   _outputDir = outputDirectory
   #_outputFileName = "BZ_FORESHOCK_2_" # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, ..
   _outputFileName = outputFileName # The file names for the png files.
   #databaseName = "localhost:/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/bulk.*.silo database" # For navigating to the silo files
   databaseName = "localhost:" + inputDirectory + inputFileName + " database" # For navigating to the silo files
   # Note: a slice of the plot in z-axis is taken automatically
   #################################################################

   # LaunchNowin(vdir=visitBinDirectory)
   #dx = speedX * frameInSeconds # Note: This is in meters per frame!
   #dy = speedY * frameInSeconds # Note: This is in meters per frame!
   #LaunchNowin(vdir="/usr/local/visit/bin")
   #Set up window and annotations
   #vis.LaunchNowin(vdir="/usr/local/visit/bin")
   vis.OpenDatabase(databaseName, 0)

   #Load settings
   visSettings.load_visit_settings()

   vis.AddPlot("Pseudocolor", _variableName, 1, 1) #CONTINUE
   vis.SetActivePlots(0)
   vis.PseudocolorAtts = vis.PseudocolorAttributes()
   vis.PseudocolorAtts.legendFlag = 1
   vis.PseudocolorAtts.lightingFlag = 1
   vis.PseudocolorAtts.minFlag = 1
   vis.PseudocolorAtts.maxFlag = 1
   vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural  # Natural, Nodal, Zonal
   vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear  # Linear, Log, Skew
   vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot  # OriginalData, CurrentPlot
   vis.PseudocolorAtts.min = minVariableValue
   vis.PseudocolorAtts.max = maxVariableValue
   vis.PseudocolorAtts.pointSize = 0.05
   vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
   vis.PseudocolorAtts.skewFactor = 1
   vis.PseudocolorAtts.opacity = 1
   vis.PseudocolorAtts.colorTableName = colorTableName
   vis.PseudocolorAtts.invertColorTable = 0
   vis.PseudocolorAtts.smoothingLevel = 0
   vis.PseudocolorAtts.pointSizeVarEnabled = 0
   vis.PseudocolorAtts.pointSizeVar = "default"
   vis.PseudocolorAtts.pointSizePixels = 2
   vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
   vis.PseudocolorAtts.lineWidth = 0
   vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit  # Explicit, ColorTable
   vis.SetPlotOptions(vis.PseudocolorAtts)

   
   vis.SetActivePlots(0)
   vis.AddOperator("Slice", 1)
   vis.SetActivePlots(0)
   vis.SliceAtts = vis.SliceAttributes()
   vis.SliceAtts.originType = vis.SliceAtts.Intercept  # Point, Intercept, Percent, Zone, Node
   vis.SliceAtts.originPoint = (0, 0, 0)
   vis.SliceAtts.originIntercept = 0
   vis.SliceAtts.originPercent = 0
   vis.SliceAtts.originZone = 0
   vis.SliceAtts.originNode = 0
   vis.SliceAtts.normal = (0, 0, 1)
   vis.SliceAtts.axisType = vis.SliceAtts.ZAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
   vis.SliceAtts.upAxis = (0, 1, 0)
   vis.SliceAtts.project2d = 1
   vis.SliceAtts.interactive = 1
   vis.SliceAtts.flip = 0
   vis.SliceAtts.originZoneDomain = 0
   vis.SliceAtts.originNodeDomain = 0
   vis.SliceAtts.meshName = "SpatialGrid"
   vis.SliceAtts.theta = 0
   vis.SliceAtts.phi = 90
   vis.SetOperatorOptions(vis.SliceAtts, 1)
   vis.DrawPlots()
   
   if _endFrame == -1:
      _endFrame = vis.TimeSliderGetNStates() - 1
   
   if _startFrame == -1:
      _startFrame = 0
   
   # Iterate through frames
   for i in range(_startFrame, _endFrame+1):
      vis.SetTimeSliderState(i)
      frame = i - _startFrame
      vis.SaveWindowAtts = vis.SaveWindowAttributes()
      vis.SaveWindowAtts.outputToCurrentDirectory = 0
      vis.SaveWindowAtts.outputDirectory = _outputDir
      vis.SaveWindowAtts.fileName = _outputFileName
      vis.SaveWindowAtts.family = 1
      vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
      vis.SaveWindowAtts.width = 3000
      vis.SaveWindowAtts.height = 3000
      vis.SaveWindowAtts.screenCapture = 0
      vis.SaveWindowAtts.saveTiled = 0
      vis.SaveWindowAtts.quality = 100
      vis.SaveWindowAtts.progressive = 0
      vis.SaveWindowAtts.binary = 0
      vis.SaveWindowAtts.stereo = 0
      vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
      vis.SaveWindowAtts.forceMerge = 0
      vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
      vis.SaveWindowAtts.advancedMultiWindowSave = 0
      vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
      vis.SaveWindow()
   vis.DeleteActivePlots()
   vis.CloseDatabase(databaseName)
   # Make the movie:
   #subprocess.call("./moviecompilescript.sh " + _outputDir + " " + _outputFileName)
   pyVisitPath = "pyVisit/"
   #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh")
   #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh " + _outputDir + " " + _outputFileName)
   framerate = "10"
   subprocess.call([pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh", _outputDir, _outputFileName, framerate])
Ejemplo n.º 15
0
    cc.perspective = 0
    v.SetView3D(cc)

    # Set box selection
    if args.bbox:
        v.AddOperator('Box')
        batts = v.BoxAttributes()
        batts.amount = batts.All  # Some, All
        batts.minx = args.bbox[0]
        batts.maxx = args.bbox[1]
        batts.miny = args.bbox[2]
        batts.maxy = args.bbox[3]
        batts.minz = args.bbox[4]
        batts.maxz = args.bbox[5]
        batts.inverse = 0
        v.SetOperatorOptions(batts)
        v.DrawPlots()

    # Set output options
    s = v.SaveWindowAttributes()
    if args.fmt == 'png':
        s.format = s.PNG
    elif args.r == 'bmp':
        s.format = s.BMP
    elif args.r == 'jpg':
        s.format = s.JPEG

    s.width = args.width
    s.height = args.height
    s.screenCapture = 0
    s.fileName = args.fname
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_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.º 18
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
    ])
Ejemplo n.º 19
0
# need to run with Python 2  (e.g., python2)
import sys

sys.path.append(
    "/home/robertsj/opt/visit/visit2_13_2.linux-x86_64/2.13.2/linux-x86_64/lib/site-packages/"
)
import visit

visit.Launch()
visit.ShowAllWindows()
visit.OpenDatabase("/home/robertsj/opt/visit/visit_data_files/CThead_mid.silo")
visit.AddPlot("Volume", "head")

visit.AddOperator("Slice")
s = visit.SliceAttributes()
s.originType = s.Intercept
s.axisType = s.ZAxis
s.originIntercept = 60.0
visit.SetOperatorOptions(s)
visit.DrawPlots()

visit.SaveWindow()
Ejemplo n.º 20
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.º 21
0
    Vi.HideActivePlots()

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

    # 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 images:
        Vi.SaveWindow()

    # Create the second plot of the XY plane slice.
    plane_slice_plotting(2, 2, "XY Plane", images)
Ejemplo n.º 22
0
def make_moving_frame_of_reference_line_plot(point1,
                                             point2,
                                             velocity,
                                             variable_name,
                                             input_directory,
                                             input_file_name,
                                             output_directory,
                                             output_file_name,
                                             start_frame=-1,
                                             end_frame=-1,
                                             frame_skip_dt=1.0):
    '''
   Function for making a line plot of some variable with a moving frame of reference
   :param point1              The starting point of the line (must be an array of size 3)
   :param point2              The ending point of the line (must be an array of size 3)
   :param velocity            The velocity vector of the frame of reference (must be an array of size 3)
   :param variable_name       Name of the variable (For ex \"rho\")
   :param input_directory     The path to the directory where the files are
   :param input_file_name     Name of the files (For ex \"bulk.*.silo\")
   :param output_directory    Directory where to output the movie
   :param output_file_name    Name of the outputted file (For ex \"RHOMOVIE\")
   :param start_frame         Starting frame for the movie (if -1, equals 0, -1 by default)
   :param end_frame           Ending frame for the movie (if -1, equals the last frame, -1 by default)
   :param frame_skip_dt       The number of seconds one skip in frame equals (1.0 by default) (Note: This may change depending on the run and should always be checked)
   '''
    if len(point1) != 3 or len(point2) != 3 or len(velocity) != 3:
        print "BAD INPUT IN make_moving_frame_of_reference_line_plot, POINT1, POINT2 AND VELOCITY MUST BE ARRAYS OF SIZE 3"

    # OPTIONS
    #################################################################
    # Input the boundary box for starting coordinates (Starting values)
    startX = point1[0]  # The left x-boundary of the box
    endX = point2[0]  # The right x-boundary of the box
    startY = point1[1]  # The bottom y-boundary of the box
    endY = point2[1]  # The upper y-boundary of the box
    startZ = poin1[2]  # The left z-boundary of the box
    endZ = point2[2]  # The right z-boundary of the box

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

    screenWidth = 3000
    screenHeight = 3000

    # Input speed in x and y direction
    speedX = velocity[0]  # Meters per second
    speedY = velocity[1]  # Meters per second
    speedZ = velocity[2]  # Meters per second

    # Input variable name
    # Note: needs to have operators/Lineout/ for visit to recognize it as line plot. Additionally, visit does not accept any '/' in the variable name which is why they're removed. The curve definitions are in loadvisitsettings.py and in there the curve expressions are defined so that there's no '/' in the variable name
    variableName = "operators/Lineout/" + variable_name.replace("/", "")

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

    dx = speedX * frameInSeconds  # Note: This is in meters per frame!
    dy = speedY * frameInSeconds  # Note: This is in meters per frame!
    dz = speedZ * frameInSeconds  # Note: This is in meters per frame!

    vis.OpenDatabase(databaseName, 0)
    #Load settings
    visSettings.load_visit_settings()

    vis.AddPlot("Curve", variableName, 1, 1)
    vis.LineoutAtts = vis.LineoutAttributes()
    vis.LineoutAtts.point1 = (startX, startY, 0)
    vis.LineoutAtts.point2 = (endX, endY, 0)
    vis.LineoutAtts.interactive = 0
    vis.LineoutAtts.ignoreGlobal = 0
    vis.LineoutAtts.samplingOn = 0
    vis.LineoutAtts.numberOfSamplePoints = 50
    vis.LineoutAtts.reflineLabels = 0
    vis.SetOperatorOptions(vis.LineoutAtts, 1)
    vis.CurveAtts = vis.CurveAttributes()
    vis.CurveAtts.showLines = 1
    vis.CurveAtts.lineStyle = vis.CurveAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
    vis.CurveAtts.lineWidth = 2
    vis.CurveAtts.showPoints = 1
    vis.CurveAtts.symbol = vis.CurveAtts.Point  # Point, TriangleUp, TriangleDown, Square, Circle, Plus, X
    vis.CurveAtts.pointSize = 5
    vis.CurveAtts.pointFillMode = vis.CurveAtts.Static  # Static, Dynamic
    vis.CurveAtts.pointStride = 1
    vis.CurveAtts.symbolDensity = 50
    vis.CurveAtts.curveColorSource = vis.CurveAtts.Custom  # Cycle, Custom
    vis.CurveAtts.curveColor = (0, 0, 0, 255)
    vis.CurveAtts.showLegend = 1
    vis.CurveAtts.showLabels = 0
    vis.CurveAtts.designator = ""
    vis.CurveAtts.doBallTimeCue = 0
    vis.CurveAtts.ballTimeCueColor = (0, 0, 0, 255)
    vis.CurveAtts.timeCueBallSize = 0.01
    vis.CurveAtts.doLineTimeCue = 0
    vis.CurveAtts.lineTimeCueColor = (0, 0, 0, 255)
    vis.CurveAtts.lineTimeCueWidth = 0
    vis.CurveAtts.doCropTimeCue = 0
    vis.CurveAtts.timeForTimeCue = 0
    vis.SetPlotOptions(vis.CurveAtts)
    vis.DrawPlots()

    # Iterate through frames
    for i in xrange(startFrame, endFrame + 1):
        vis.SetTimeSliderState(i)
        frame = i - startFrame
        vis.LineoutAtts = vis.LineoutAttributes()
        vis.LineoutAtts.point1 = (startX + frame * dx, startY + frame * dy, 0)
        vis.LineoutAtts.point2 = (endX + frame * dx, endY + frame * dy, 0)
        vis.LineoutAtts.interactive = 0
        vis.LineoutAtts.ignoreGlobal = 0
        vis.LineoutAtts.samplingOn = 0
        vis.LineoutAtts.numberOfSamplePoints = 50
        vis.LineoutAtts.reflineLabels = 0
        vis.SetOperatorOptions(vis.LineoutAtts, 1)
        vis.SaveWindowAtts = vis.SaveWindowAttributes()
        vis.SaveWindowAtts.outputToCurrentDirectory = 0
        vis.SaveWindowAtts.outputDirectory = outputDir
        vis.SaveWindowAtts.fileName = outputFileName
        vis.SaveWindowAtts.family = 1
        vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
        vis.SaveWindowAtts.width = screenWidth
        vis.SaveWindowAtts.height = screenHeight
        vis.SaveWindowAtts.screenCapture = 0
        vis.SaveWindowAtts.saveTiled = 0
        vis.SaveWindowAtts.quality = 80
        vis.SaveWindowAtts.progressive = 0
        vis.SaveWindowAtts.binary = 0
        vis.SaveWindowAtts.stereo = 0
        vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
        vis.SaveWindowAtts.forceMerge = 0
        vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
        vis.SaveWindowAtts.advancedMultiWindowSave = 0
        vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
        vis.SaveWindow()
    vis.DeleteActivePlots()
    vis.CloseDatabase(databaseName)
    # Make the movie:
    framerate = 5
    subprocess.call([
        pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh",
        outputDir, outputFileName, framerate
    ])
Ejemplo n.º 23
0
            Zs = np.linspace(Zmin, Zmax, num=N)

            visit.AddPlot("Pseudocolor", "vol_frac_average", 1, 1)

            visit.AddOperator("Clip", 1)
            ClipAtts = visit.ClipAttributes()
            ClipAtts.quality = ClipAtts.Fast  # Fast, Accurate
            ClipAtts.funcType = ClipAtts.Plane  # Plane, Sphere
            ClipAtts.plane1Status = 1
            ClipAtts.plane2Status = 0
            ClipAtts.plane3Status = 0
            ClipAtts.plane1Origin = (0, 0, 0)
            ClipAtts.plane1Normal = (0, 1, 0)
            ClipAtts.planeInverse = 1
            ClipAtts.planeToolControlledClipPlane = ClipAtts.Plane1  # None, Plane1, Plane2, Plane3
            visit.SetOperatorOptions(ClipAtts, 1)

            visit.AddOperator("Slice", 1)
            PseudocolorAtts = visit.PseudocolorAttributes()
            PseudocolorAtts.minFlag = 1
            PseudocolorAtts.min = 0.
            PseudocolorAtts.maxFlag = 1
            PseudocolorAtts.max = 0.05
            visit.SetPlotOptions(PseudocolorAtts)
            SliceAtts = visit.SliceAttributes()
            SliceAtts.originType = SliceAtts.Point
            SliceAtts.normal = (-1, 0, 0)
            SliceAtts.axisType = SliceAtts.XAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
            SliceAtts.upAxis = (0, 1, 0)
            SliceAtts.project2d = 1
Ejemplo n.º 24
0
def create_visit_point_movie(variableName,
                             minValue,
                             maxValue,
                             inputDirectory,
                             inputFileNames,
                             coordinates,
                             outputDirectory,
                             outputFileName,
                             colorTable="hot_desaturated"):
    '''
   Function for making a movie
   
   Arguments:
   :param variableName                  Name of the variable
   :param minValue                      Minimum value of the variable
   :param maxValue                      Maximum value of the variable
   :param inputDirectory                Path to input vlsv/silo files
   :param inputFileNames                Name of the files for example [\"bulk.00000.silo\", \"bulk.00001.silo\"]
   :param coordinates                   Coordinates corresponding to the files so for example [ [[0,0,0], [0,1,0]], [[2,1,2], [2,1,4]] ]
   :param outputDirectory               Path to output directory
   :param outputFileName                Name of the output file
   :param colorTable="hot_desaturated"  Color table for the plots
   '''
    coordinates = [coordinates]

    for i in range(len(inputFileNames)):
        # OPTIONS
        #################################################################

        # Input variable
        _variableName = variableName
        minVariableValue = minValue
        maxVariableValue = maxValue
        colorTableName = colorTable

        # Input directory and file names
        #_outputDir = "/home/hannukse/MOVINGFRAME_MOVIES/AAJ_BZ_REMAKE/" # Set the output directory (Where .png s are saved)
        _outputDir = outputDirectory
        #_outputFileName = "BZ_FORESHOCK_2_" # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, ..
        _outputFileName = outputFileName  # The file names for the png files.
        #databaseName = "localhost:/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/bulk.*.silo database" # For navigating to the silo files
        inputFileName = inputFileNames[i]
        databaseName = "localhost:" + inputDirectory + inputFileName  # For navigating to the silo files
        # Note: a slice of the plot in z-axis is taken automatically
        #################################################################
        # LaunchNowin(vdir=visitBinDirectory)
        #dx = speedX * frameInSeconds # Note: This is in meters per frame!
        #dy = speedY * frameInSeconds # Note: This is in meters per frame!
        #LaunchNowin(vdir="/usr/local/visit/bin")
        #Set up window and annotations
        #vis.LaunchNowin(vdir="/usr/local/visit/bin")

        inputFileName2 = "point.vtk"
        databaseName2 = "localhost:" + os.getcwd() + "/" + inputFileName2

        vis.OpenDatabase(databaseName, 0)
        #vis.ActiveDatabase("localhost:" + inputDirectory + inputFileName)
        #Load settings
        visSettings.load_visit_settings()
        vis.AddPlot("Pseudocolor", _variableName, 1, 1)  #CONTINUE
        vis.SetActivePlots(1)
        vis.PseudocolorAtts = vis.PseudocolorAttributes()
        vis.PseudocolorAtts.legendFlag = 1
        vis.PseudocolorAtts.lightingFlag = 1
        vis.PseudocolorAtts.minFlag = 1
        vis.PseudocolorAtts.maxFlag = 1
        vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural  # Natural, Nodal, Zonal
        vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear  # Linear, Log, Skew
        vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot  # OriginalData, CurrentPlot
        vis.PseudocolorAtts.min = minVariableValue
        vis.PseudocolorAtts.max = maxVariableValue
        vis.PseudocolorAtts.pointSize = 0.05
        vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
        vis.PseudocolorAtts.skewFactor = 1
        vis.PseudocolorAtts.opacity = 1
        vis.PseudocolorAtts.colorTableName = colorTableName
        vis.PseudocolorAtts.invertColorTable = 0
        vis.PseudocolorAtts.smoothingLevel = 0
        vis.PseudocolorAtts.pointSizeVarEnabled = 0
        vis.PseudocolorAtts.pointSizeVar = "default"
        vis.PseudocolorAtts.pointSizePixels = 2
        vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
        vis.PseudocolorAtts.lineWidth = 0
        vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit  # Explicit, ColorTable
        vis.SetPlotOptions(vis.PseudocolorAtts)

        vis.SetActivePlots(1)
        vis.AddOperator("Slice", 1)
        vis.SetActivePlots(1)
        vis.SliceAtts = vis.SliceAttributes()
        vis.SliceAtts.originType = vis.SliceAtts.Intercept  # Point, Intercept, Percent, Zone, Node
        vis.SliceAtts.originPoint = (0, 0, 0)
        vis.SliceAtts.originIntercept = 0
        vis.SliceAtts.originPercent = 0
        vis.SliceAtts.originZone = 0
        vis.SliceAtts.originNode = 0
        vis.SliceAtts.normal = (0, 0, 1)
        vis.SliceAtts.axisType = vis.SliceAtts.ZAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
        vis.SliceAtts.upAxis = (0, 1, 0)
        vis.SliceAtts.project2d = 1
        vis.SliceAtts.interactive = 1
        vis.SliceAtts.flip = 0
        vis.SliceAtts.originZoneDomain = 0
        vis.SliceAtts.originNodeDomain = 0
        vis.SliceAtts.meshName = "SpatialGrid"
        vis.SliceAtts.theta = 0
        vis.SliceAtts.phi = 90
        vis.SetOperatorOptions(vis.SliceAtts, 1)
        vis.DrawPlots()
        vis.SetActivePlots(0)

        for coordinate in coordinates[i]:
            print(str(coordinate))
            create_point_vtk(fileName=inputFileName2, coordinates=coordinate)
            vis.OpenDatabase(databaseName2, 0)
            vis.AddPlot("Mesh", "mesh", 1, 1)
            vis.SetActivePlots(vis.GetNumPlots())
            vis.MeshAtts = vis.MeshAttributes()
            vis.MeshAtts.legendFlag = 1
            vis.MeshAtts.lineStyle = vis.MeshAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
            vis.MeshAtts.lineWidth = 0
            vis.MeshAtts.meshColor = (0, 0, 0, 255)
            vis.MeshAtts.outlineOnlyFlag = 0
            vis.MeshAtts.errorTolerance = 0.01
            vis.MeshAtts.meshColorSource = vis.MeshAtts.Foreground  # Foreground, MeshCustom
            vis.MeshAtts.opaqueColorSource = vis.MeshAtts.Background  # Background, OpaqueCustom
            vis.MeshAtts.opaqueMode = vis.MeshAtts.Auto  # Auto, On, Off
            vis.MeshAtts.pointSize = 0.05
            vis.MeshAtts.opaqueColor = (255, 255, 255, 255)
            vis.MeshAtts.smoothingLevel = vis.MeshAtts.None  # None, Fast, High
            vis.MeshAtts.pointSizeVarEnabled = 0
            vis.MeshAtts.pointSizeVar = "default"
            vis.MeshAtts.pointType = vis.MeshAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
            vis.MeshAtts.showInternal = 0
            vis.MeshAtts.pointSizePixels = 10
            vis.MeshAtts.opacity = 1
            vis.SetPlotOptions(vis.MeshAtts)
            vis.DrawPlots()
            # Iterate through frames
            vis.SaveWindowAtts = vis.SaveWindowAttributes()
            vis.SaveWindowAtts.outputToCurrentDirectory = 0
            vis.SaveWindowAtts.outputDirectory = _outputDir
            vis.SaveWindowAtts.fileName = _outputFileName
            vis.SaveWindowAtts.family = 1
            vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
            vis.SaveWindowAtts.width = 3000
            vis.SaveWindowAtts.height = 3000
            vis.SaveWindowAtts.screenCapture = 0
            vis.SaveWindowAtts.saveTiled = 0
            vis.SaveWindowAtts.quality = 100
            vis.SaveWindowAtts.progressive = 0
            vis.SaveWindowAtts.binary = 0
            vis.SaveWindowAtts.stereo = 0
            vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
            vis.SaveWindowAtts.forceMerge = 0
            vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
            vis.SaveWindowAtts.advancedMultiWindowSave = 0
            vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
            vis.SaveWindow()
            vis.DeleteActivePlots()
        vis.DeleteActivePlots()
        vis.CloseDatabase(databaseName)
    vis.CloseDatabase(databaseName2)
    # Make the movie:
    #subprocess.call("./moviecompilescript.sh " + _outputDir + " " + _outputFileName)
    pyVisitPath = "pyVisit/"
    #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh")
    #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh " + _outputDir + " " + _outputFileName)
    framerate = "10"
    subprocess.call([
        pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh",
        _outputDir, _outputFileName, framerate
    ])
    # Delete the point vtk file:
    os.remove(os.getcwd() + "/" + inputFileName2)
Ejemplo n.º 25
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.º 26
0
def draw_point_picture(variableName,
                       minValue,
                       maxValue,
                       inputDirectory,
                       inputFileName,
                       coordinate,
                       outputDirectory,
                       outputFileName,
                       colorTable="hot_desaturated"):
    '''
   Function for making a visit plot with a point
   
   Arguments:
   :param variableName                  Name of the variable
   :param minValue                      Minimum value of the variable
   :param maxValue                      Maximum value of the variable
   :param inputDirectory                Path to input vlsv/silo files
   :param inputFileName                Name of the file, for example \"bulk.00000.silo\"
   :param coordinates                   Coordinates corresponding to the files so for example [ [[0,0,0], [0,1,0]], [[2,1,2], [2,1,4]] ]
   :param outputDirectory               Path to output directory
   :param outputFileName                Name of the output file
   :param colorTable="hot_desaturated"  Color table for the plots
   '''
    # OPTIONS
    #################################################################

    # Input variable
    _variableName = variableName
    minVariableValue = minValue
    maxVariableValue = maxValue
    colorTableName = colorTable

    # Input directory and file names
    _outputDir = outputDirectory
    _outputFileName = outputFileName  # The file names for the png files.
    databaseName = "localhost:" + inputDirectory + inputFileName  # For navigating to the silo files
    # Note: a slice of the plot in z-axis is taken automatically
    #################################################################

    inputFileName2 = "point.vtk"
    databaseName2 = "localhost:" + os.getcwd() + "/" + inputFileName2

    currentPlot = 0

    vis.OpenDatabase(databaseName, 0)
    #vis.ActiveDatabase("localhost:" + inputDirectory + inputFileName)
    #Load settings
    visSettings.load_visit_settings()
    vis.AddPlot("Pseudocolor", _variableName, 1, 1)  #CONTINUE
    vis.SetActivePlots(currentPlot)
    vis.PseudocolorAtts = vis.PseudocolorAttributes()
    vis.PseudocolorAtts.legendFlag = 1
    vis.PseudocolorAtts.lightingFlag = 1
    vis.PseudocolorAtts.minFlag = 1
    vis.PseudocolorAtts.maxFlag = 1
    vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural  # Natural, Nodal, Zonal
    vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear  # Linear, Log, Skew
    vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot  # OriginalData, CurrentPlot
    vis.PseudocolorAtts.min = minVariableValue
    vis.PseudocolorAtts.max = maxVariableValue
    vis.PseudocolorAtts.pointSize = 0.05
    vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
    vis.PseudocolorAtts.skewFactor = 1
    vis.PseudocolorAtts.opacity = 1
    vis.PseudocolorAtts.colorTableName = colorTableName
    vis.PseudocolorAtts.invertColorTable = 0
    vis.PseudocolorAtts.smoothingLevel = 0
    vis.PseudocolorAtts.pointSizeVarEnabled = 0
    vis.PseudocolorAtts.pointSizeVar = "default"
    vis.PseudocolorAtts.pointSizePixels = 2
    vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
    vis.PseudocolorAtts.lineWidth = 0
    vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit  # Explicit, ColorTable
    vis.SetPlotOptions(vis.PseudocolorAtts)

    vis.AddOperator("Slice", 1)
    vis.SliceAtts = vis.SliceAttributes()
    vis.SliceAtts.originType = vis.SliceAtts.Intercept  # Point, Intercept, Percent, Zone, Node
    vis.SliceAtts.originPoint = (0, 0, 0)
    vis.SliceAtts.originIntercept = 0
    vis.SliceAtts.originPercent = 0
    vis.SliceAtts.originZone = 0
    vis.SliceAtts.originNode = 0
    vis.SliceAtts.normal = (0, 0, 1)
    vis.SliceAtts.axisType = vis.SliceAtts.ZAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
    vis.SliceAtts.upAxis = (0, 1, 0)
    vis.SliceAtts.project2d = 1
    vis.SliceAtts.interactive = 1
    vis.SliceAtts.flip = 0
    vis.SliceAtts.originZoneDomain = 0
    vis.SliceAtts.originNodeDomain = 0
    vis.SliceAtts.meshName = "SpatialGrid"
    vis.SliceAtts.theta = 0
    vis.SliceAtts.phi = 90
    vis.SetOperatorOptions(vis.SliceAtts, 1)
    vis.DrawPlots()

    create_point_vtk(fileName=inputFileName2, coordinates=coordinate)
    vis.OpenDatabase(databaseName2, 0)
    currentPlot = currentPlot + 1
    vis.SetActivePlots(currentPlot)
    vis.AddPlot("Mesh", "mesh", 1, 1)
    vis.MeshAtts = vis.MeshAttributes()
    vis.MeshAtts.legendFlag = 1
    vis.MeshAtts.lineStyle = vis.MeshAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
    vis.MeshAtts.lineWidth = 0
    vis.MeshAtts.meshColor = (0, 0, 0, 255)
    vis.MeshAtts.outlineOnlyFlag = 0
    vis.MeshAtts.errorTolerance = 0.01
    vis.MeshAtts.meshColorSource = vis.MeshAtts.Foreground  # Foreground, MeshCustom
    vis.MeshAtts.opaqueColorSource = vis.MeshAtts.Background  # Background, OpaqueCustom
    vis.MeshAtts.opaqueMode = vis.MeshAtts.Auto  # Auto, On, Off
    vis.MeshAtts.pointSize = 0.05
    vis.MeshAtts.opaqueColor = (255, 255, 255, 255)
    vis.MeshAtts.smoothingLevel = vis.MeshAtts.None  # None, Fast, High
    vis.MeshAtts.pointSizeVarEnabled = 0
    vis.MeshAtts.pointSizeVar = "default"
    vis.MeshAtts.pointType = vis.MeshAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
    vis.MeshAtts.showInternal = 0
    vis.MeshAtts.pointSizePixels = 25
    vis.MeshAtts.opacity = 1
    vis.SetPlotOptions(vis.MeshAtts)
    vis.DrawPlots()
    vis.SaveWindowAtts = vis.SaveWindowAttributes()
    vis.SaveWindowAtts.outputToCurrentDirectory = 0
    vis.SaveWindowAtts.outputDirectory = _outputDir
    vis.SaveWindowAtts.fileName = _outputFileName
    vis.SaveWindowAtts.family = 1
    vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
    vis.SaveWindowAtts.width = 3000
    vis.SaveWindowAtts.height = 3000
    vis.SaveWindowAtts.screenCapture = 0
    vis.SaveWindowAtts.saveTiled = 0
    vis.SaveWindowAtts.quality = 100
    vis.SaveWindowAtts.progressive = 0
    vis.SaveWindowAtts.binary = 0
    vis.SaveWindowAtts.stereo = 0
    vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
    vis.SaveWindowAtts.forceMerge = 0
    vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
    vis.SaveWindowAtts.advancedMultiWindowSave = 0
    vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
    vis.SaveWindow()
    vis.SetActivePlots((0, 1))
    vis.DeleteActivePlots()
    vis.CloseDatabase(databaseName2)
    vis.CloseDatabase(databaseName)
Ejemplo n.º 27
0
def make_movie_auto(variableName,
                    boundaryBox,
                    vlsvFileName,
                    inputDirectory,
                    inputFileName,
                    outputDirectory,
                    outputFileName,
                    colorTableName="hot_desaturated",
                    startFrame=-1,
                    endFrame=-1,
                    thresholdCoefficient=0.6):
    '''
   Function for making a movie
   
   Arguments:
   :param variableName                  Name of the variable
   :param boundaryBox                   Box for collecting min and max threshold (The movie will focus on that area)
   :param vlsvFileName                  Name of a vlsv file where the function collects the threshold for the boundary box
   :param inputDirectory                Path to input vlsv/silo files
   :param inputFileName                 Name of the file(s) so for example if the filenames are bulk.0000.silo, bulk.0001.silo, .. then inputFileName=\"bulk.*.silo\""
   :param outputDirectory               Path to output directory
   :param outputFileName                Name of the output file
   :param colorTableName="hot_desaturated"  Color table for the plots
   :param thresholdCoefficient          Sets the coefficient for a covariant collected from the values from boundary box. The lower this is, the more focused the movie will be on the boundary box area
   :param startFrame=-1                 Starting frame of the movie (-1 equals 0)
   :param endFrame=-1                   Starting frame of the movie (-1 equals last frame)
   '''
    if thresholdCoefficient < 0:
        print("thresholdCoefficient must be non-negative!")
        return
    # OPTIONS
    #################################################################
    # Input frame properties
    _startFrame = startFrame  # Note: if _startFrame is set to -1 the start frame gets set to 0
    _endFrame = endFrame  # Note: if _endFrame is set to -1 the _endFrame is automatically the number of frames in the database

    # Input variable
    _variableName = variableName

    # Input directory and file names
    #_outputDir = "/home/hannukse/MOVINGFRAME_MOVIES/AAJ_BZ_REMAKE/" # Set the output directory (Where .png s are saved)
    _outputDir = outputDirectory
    #_outputFileName = "BZ_FORESHOCK_2_" # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, ..
    _outputFileName = outputFileName  # The file names for the png files.
    #databaseName = "localhost:/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/bulk.*.silo database" # For navigating to the silo files
    databaseName = "localhost:" + inputDirectory + inputFileName + " database"  # For navigating to the silo files
    # Note: a slice of the plot in z-axis is taken automatically
    #################################################################

    # Get the min and max values:
    # Get all cell ids within the boundary box:
    vlsvReader = VlsvReader(vlsvFileName)
    # Get global boundaries:
    # Get xmax, xmin and xcells_ini
    xmax = vlsvReader.read_parameter(name="xmax")
    xmin = vlsvReader.read_parameter(name="xmin")
    xcells = vlsvReader.read_parameter(name="xcells_ini")
    # Do the same for y
    ymax = vlsvReader.read_parameter(name="ymax")
    ymin = vlsvReader.read_parameter(name="ymin")
    ycells = vlsvReader.read_parameter(name="ycells_ini")
    # And for z
    zmax = vlsvReader.read_parameter(name="zmax")
    zmin = vlsvReader.read_parameter(name="zmin")
    zcells = vlsvReader.read_parameter(name="zcells_ini")
    #Calculate cell lengths:
    cell_lengths = np.array([(xmax - xmin) / (float)(xcells),
                             (ymax - ymin) / (float)(ycells),
                             (zmax - zmin) / (float)(zcells)])
    # Get cell indices:
    cell_indice_bounds = np.array([
        (int)(((float)(boundaryBox[0]) - xmin) / (float)(cell_lengths[0])),
        (int)(((float)(boundaryBox[1]) - xmin) / (float)(cell_lengths[0])),
        (int)(((float)(boundaryBox[2]) - ymin) / (float)(cell_lengths[1])),
        (int)(((float)(boundaryBox[3]) - ymin) / (float)(cell_lengths[1])),
        (int)(((float)(boundaryBox[4]) - zmin) / (float)(cell_lengths[2])),
        (int)(((float)(boundaryBox[5]) - zmin) / (float)(cell_lengths[2]))
    ])
    # Get every cell id within the boundary box:
    cellids = []
    cell_indice = np.array(
        [cell_indice_bounds[0], cell_indice_bounds[2], cell_indice_bounds[4]])
    while True:
        cellids.append(cell_indice[0] + cell_indice[1] * xcells +
                       cell_indice[2] * xcells * ycells + 1)
        if cell_indice[0] < cell_indice_bounds[1]:
            cell_indice[0] = cell_indice[0] + 1
        elif cell_indice[1] < cell_indice_bounds[3]:
            cell_indice[1] = cell_indice[1] + 1
            cell_indice[0] = cell_indice_bounds[0]
        elif cell_indice[2] < cell_indice_bounds[5]:
            cell_indice[2] = cell_indice[2] + 1
            cell_indice[1] = cell_indice_bounds[1]
            cell_indice[0] = cell_indice_bounds[0]
        else:
            # Indice out of bounds -- got all cell ids
            break
    # Convert cell ids into set:
    cellids = Set(cellids)
    cellidlocations = []
    # Get all of the cell ids locations:
    allcellids = vlsvReader.read(name="SpatialGrid", tag="MESH")
    for i in range(len(allcellids)):
        if allcellids[i] in cellids:
            #This cell id is within the user-given boundary
            cellidlocations.append(allcellids[i])
    # Get all of the values:
    allvalues = vlsvReader.read_variables(name=_variableName)
    values = []
    # Get the values of the cell ids within the boundary
    for i in cellidlocations:
        values.append(allvalues[i])
    # We now have all the cell ids (and their locations in the arrays) from the area, set min and max thresholds:
    meanValue = np.mean(values)
    standardDeviationValue = np.std(values)
    maxValue = meanValue + (
        float)(thresholdCoefficient) * standardDeviationValue
    minValue = meanValue - (
        float)(thresholdCoefficient) * standardDeviationValue
    # Put threshold values:
    minVariableValue = minValue
    maxVariableValue = maxValue

    # LaunchNowin(vdir=visitBinDirectory)
    #dx = speedX * frameInSeconds # Note: This is in meters per frame!
    #dy = speedY * frameInSeconds # Note: This is in meters per frame!
    #LaunchNowin(vdir="/usr/local/visit/bin")
    #Set up window and annotations
    #vis.LaunchNowin(vdir="/usr/local/visit/bin")
    vis.OpenDatabase(databaseName, 0)

    #Load settings
    visSettings.load_visit_settings()

    vis.AddPlot("Pseudocolor", _variableName, 1, 1)  #CONTINUE
    vis.SetActivePlots(0)
    vis.PseudocolorAtts = vis.PseudocolorAttributes()
    vis.PseudocolorAtts.legendFlag = 1
    vis.PseudocolorAtts.lightingFlag = 1
    vis.PseudocolorAtts.minFlag = 1
    vis.PseudocolorAtts.maxFlag = 1
    vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural  # Natural, Nodal, Zonal
    vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear  # Linear, Log, Skew
    vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot  # OriginalData, CurrentPlot
    vis.PseudocolorAtts.min = minVariableValue
    vis.PseudocolorAtts.max = maxVariableValue
    vis.PseudocolorAtts.pointSize = 0.05
    vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
    vis.PseudocolorAtts.skewFactor = 1
    vis.PseudocolorAtts.opacity = 1
    vis.PseudocolorAtts.colorTableName = colorTableName
    vis.PseudocolorAtts.invertColorTable = 0
    vis.PseudocolorAtts.smoothingLevel = 0
    vis.PseudocolorAtts.pointSizeVarEnabled = 0
    vis.PseudocolorAtts.pointSizeVar = "default"
    vis.PseudocolorAtts.pointSizePixels = 2
    vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
    vis.PseudocolorAtts.lineWidth = 0
    vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit  # Explicit, ColorTable
    vis.SetPlotOptions(vis.PseudocolorAtts)

    vis.SetActivePlots(0)
    vis.AddOperator("Slice", 1)
    vis.SetActivePlots(0)
    vis.SliceAtts = vis.SliceAttributes()
    vis.SliceAtts.originType = vis.SliceAtts.Intercept  # Point, Intercept, Percent, Zone, Node
    vis.SliceAtts.originPoint = (0, 0, 0)
    vis.SliceAtts.originIntercept = 0
    vis.SliceAtts.originPercent = 0
    vis.SliceAtts.originZone = 0
    vis.SliceAtts.originNode = 0
    vis.SliceAtts.normal = (0, 0, 1)
    vis.SliceAtts.axisType = vis.SliceAtts.ZAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
    vis.SliceAtts.upAxis = (0, 1, 0)
    vis.SliceAtts.project2d = 1
    vis.SliceAtts.interactive = 1
    vis.SliceAtts.flip = 0
    vis.SliceAtts.originZoneDomain = 0
    vis.SliceAtts.originNodeDomain = 0
    vis.SliceAtts.meshName = "SpatialGrid"
    vis.SliceAtts.theta = 0
    vis.SliceAtts.phi = 90
    vis.SetOperatorOptions(vis.SliceAtts, 1)
    vis.DrawPlots()

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

    if _startFrame == -1:
        _startFrame = 0

    # Iterate through frames
    for i in range(_startFrame, _endFrame + 1):
        vis.SetTimeSliderState(i)
        frame = i - _startFrame
        vis.SaveWindowAtts = vis.SaveWindowAttributes()
        vis.SaveWindowAtts.outputToCurrentDirectory = 0
        vis.SaveWindowAtts.outputDirectory = _outputDir
        vis.SaveWindowAtts.fileName = _outputFileName
        vis.SaveWindowAtts.family = 1
        vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
        vis.SaveWindowAtts.width = 3000
        vis.SaveWindowAtts.height = 300
        vis.SaveWindowAtts.screenCapture = 0
        vis.SaveWindowAtts.saveTiled = 0
        vis.SaveWindowAtts.quality = 100
        vis.SaveWindowAtts.progressive = 0
        vis.SaveWindowAtts.binary = 0
        vis.SaveWindowAtts.stereo = 0
        vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
        vis.SaveWindowAtts.forceMerge = 0
        vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
        vis.SaveWindowAtts.advancedMultiWindowSave = 0
        vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
        vis.SaveWindow()
    vis.DeleteActivePlots()
    vis.CloseDatabase(databaseName)
    # Make the movie:
    #subprocess.call("./moviecompilescript.sh " + _outputDir + " " + _outputFileName)
    pyVisitPath = "pyVisit/"
    #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh")
    #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh " + _outputDir + " " + _outputFileName)
    frameRate = "10"
    subprocess.call([
        pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh",
        _outputDir, _outputFileName, frameRate
    ])
Ejemplo n.º 28
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", "hardyglobal")
vs.AddOperator("Slice")
s = vs.SliceAttributes()
s.project2d = 0
s.originPoint = (0, 5, 0)
s.originType = s.Point
s.normal = (0, 1, 0)
s.upAxis = (-1, 0, 0)
vs.SetOperatorOptions(s)
vs.AddOperator("Reflect")
vs.DrawPlots()
# Now reflect before slicing. We’ll only get 1 slice plane
# instead of 2.
vs.DemoteOperator(1)
vs.DrawPlots()

d = input('Press anything to quit')
Ejemplo n.º 29
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.º 30
0
            timestep = str(aux[-1]).zfill(6)

            visit.OpenDatabase(db)

            for variable in variables:

                i = 0

                for location in locations:

                    i += 1

                    LineoutAtts = visit.LineoutAttributes()
                    LineoutAtts.point1 = location[0]
                    LineoutAtts.point2 = location[1]
                    LineoutAtts.samplingOn = 1
                    LineoutAtts.numberOfSamplePoints = 1000

                    visit.AddPlot("Curve", "operators/Lineout/" + variable)
                    visit.SetOperatorOptions(LineoutAtts, 1)
                    visit.DrawPlots()
                    e = visit.ExportDBAttributes()
                    e.filename = sim + '_' + case + '_' + timestep + '_' + variable
                    e.dirname = output_folder
                    e.db_type = "Curve2D"
                    visit.ExportDatabase(e)

                    visit.DeleteAllPlots()

            visit.CloseDatabase(db)