Ejemplo n.º 1
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.º 2
0
def make_slide(time):
    plasma_file = vtk_path + plasma_file_head + str(time) +'.vtk'
    paraxial_file = vtk_path + paraxial_file_head + str(time) + '.vtk'
    fullwave_file = vtk_path + fullwave_file_head + str(time) + '.vtk'
    
    print('opening plamsa file:' + plasma_file)
    sts = vi.OpenDatabase(plasma_file,0,'VTK')
    if (sts != 1):
        print('open file failed! error code:' + str(sts))
        return
    
    sts = vi.AddPlot('Pseudocolor','cutoff')
    vi.DrawPlots()
    po = vi.GetPlotOptions()
    vi.LoadAttribute(plasma_attr_file,po)
    vi.SetPlotOptions(po)
    
    print('opening paraxial file:' + paraxial_file)
    sts = vi.OpenDatabase(paraxial_file,0,'VTK')
    if (sts != 1):
        print('open file failed! error code:' + str(sts))
        return
    
    sts = vi.AddPlot('Pseudocolor','Er_para')
    vi.DrawPlots()
    po = vi.GetPlotOptions()
    vi.LoadAttribute(wave_attr_file,po)
    vi.SetPlotOptions(po)
    
    print('opening fullwave file:' + fullwave_file)
    sts = vi.OpenDatabase(fullwave_file,0,'VTK')
    if (sts != 1):
        print('open file failed! error code:' + str(sts))
        return
    
    sts = vi.AddPlot('Pseudocolor','Er_fullw')
    vi.DrawPlots()
    po = vi.GetPlotOptions()
    vi.LoadAttribute(wave_attr_file,po)
    vi.SetPlotOptions(po)
    
    view_attr = vi.GetView3D()
    vi.LoadAttribute(view_attr_file,view_attr)
    vi.SetView3D(view_attr)
    
    anno_attr = vi.GetAnnotationAttributes()
    vi.LoadAttribute(annotation_attr_file,anno_attr)
    vi.SetAnnotationAttributes(anno_attr)
    
    anno_names = vi.GetAnnotationObjectNames()
    for name in anno_names:
        legend = vi.GetAnnotationObject(name)
        legend.numberFormat = "%# -9.2g"
        legend.drawMinMax = 0
        legend.controlTicks = 1
        legend.numTicks = 3
         
        
    vi.SaveWindow()
Ejemplo n.º 3
0
    def write_window(f, prefix):
        # Window setup
        f.write('width, height = %d, %d\n' %
                visit.GetWindowInformation().windowSize)
        f.write(
            'win = GetGlobalAttributes().windows[GetGlobalAttributes().activeWindow]\n'
        )
        f.write('ResizeWindow(win, width, height)\n')
        f.write('SetActiveWindow(win) # Synchronize\n')
        f.write('size = GetWindowInformation().windowSize\n')
        f.write('if width < size[0] or height < size[1]:\n')
        f.write(
            '    ResizeWindow(win, width + (size[0] - width), height + (size[1] - height))\n'
        )

        f.write('DeleteAllPlots()\n')
        f.write('for name in GetAnnotationObjectNames():\n')
        f.write('    DeleteAnnotationObject(name)\n')
        f.write('\n')

        # Write the plots.
        write_plots(f)
        f.write('DrawPlots()\n\n')

        # Set the view
        f.write('# Set the view\n')
        if visit.GetWindowInformation().viewDimension == 1:
            view = visit.GetViewCurve()
        elif visit.GetWindowInformation().viewDimension == 2:
            view = visit.GetView2D()
        else:
            view = visit.GetView3D()
        write_state_object(f, view, "view")
        if visit.GetWindowInformation().viewDimension == 1:
            f.write('SetViewCurve(view)\n')
        elif visit.GetWindowInformation().viewDimension == 2:
            f.write('SetView2D(view)\n')
        else:
            f.write('SetView3D(view)\n')
        f.write('\n')

        # Get the annotation attributes
        f.write('# Set the annotation attributes\n')
        annot = visit.GetAnnotationAttributes()
        if write_state_object_diffs(f, annot, visit.AnnotationAttributes(),
                                    "annot"):
            f.write('SetAnnotationAttributes(annot)\n\n')
        else:
            f.write('#SetAnnotationAttributes(annot)\n\n')

        set_annotation_objects(f, prefix)
Ejemplo n.º 4
0
 def __save_window(self, obase, res, ores, screen_cap, ts):
     prev_lvl = visit.SuppressMessages(2)
     res = [int(v) for v in res]
     if ores is None:
         ores = res
     obase = os.path.abspath(obase)
     odir, ofile = os.path.split(obase)
     if ts is None:
         print "[rendering %s/%s.png]" % (odir, ofile)
         tmp_ofile = "%s___.tmp" % ofile
     else:
         print "[rendering %s/%s%04d.png]" % (odir, ofile, ts)
         tmp_ofile = "%s.%04d___.tmp" % (ofile, ts)
     sa = visit.SaveWindowAttributes()
     sa.outputToCurrentDirectory = 0
     sa.outputDirectory = odir
     sa.fileName = tmp_ofile
     sa.format = sa.PNG
     sa.width, sa.height = res
     sa.screenCapture = 0
     sa.saveTiled = 0
     sa.resConstraint = sa.NoConstraint
     visit.SetSaveWindowAttributes(sa)
     a = visit.GetAnnotationAttributes()
     a.userInfoFlag = 0
     visit.SetAnnotationAttributes(a)
     fname = visit.SaveWindow()
     if fname == "/dev/null/SaveWindow_Error.txt" or not os.path.isfile(
             fname):
         raise VisItException("Error saving window.")
     des = fname[:fname.find("___.tmp")]
     des += ".png"
     shutil.move(fname, des)
     if ores[0] != res[0] or ores[1] != res[1]:
         stargs = (res[0], res[1], ores[0], ores[1])
         print "[resizing output (from %dx%d to %dx%d)]" % stargs
         sexe("convert -resize %dx%d %s %s" % (ores[0], ores[1], des, des))
     visit.SuppressMessages(prev_lvl)
     return des
Ejemplo n.º 5
0
        k = k + 1000

        if k < kMax:
            tl.visible = 0
            visit.DeleteAllPlots()
            visit.CloseDatabase(filename)


#  tl.visible = 0

# Here is the main
windowA = visit.SaveWindowAttributes()
windowA.format = windowA.JPEG
windowA.progressive = 1
windowA.width = 807
windowA.height = 908
windowA.fileName = "fdensity"
#windowA.outputDirectory = "/global/u2/e/efeibush/gtc/flow/flow3/compare/densityimages"
windowA.outputToCurrentDirectory = 1
#windowA.screenCapture = 1
visit.SetSaveWindowAttributes(windowA)

#a = visit.ListPlots()
b = visit.SetActivePlots(0)

anot = visit.GetAnnotationAttributes()
anot.databaseInfoFlag = 0
visit.SetAnnotationAttributes(anot)

viewit()
Ejemplo n.º 6
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.º 7
0
"""Script for saving the changed attribute files
"""

import visit as vi

view_attr_file = 'view_attr.xml'
annotation_attr_file = 'anno_attr.xml'
plasma_attr_file = 'plasma_attr.xml'
wave_attr_file = 'wave_attr.xml'

vi.SaveAttribute(view_attr_file, vi.GetView3D())
vi.SaveAttribute(annotation_attr_file, vi.GetAnnotationAttributes())
vi.SetActivePlots(0)
vi.SaveAttribute(plasma_attr_file, vi.GetPlotOptions())
vi.SetActivePlots(1)
vi.SaveAttribute(wave_attr_file, vi.GetPlotOptions())
Ejemplo n.º 8
0
pa.min = -0.7
pa.maxFlag = True
pa.max = 0.7
visit.SetPlotOptions(pa)

visit.AddOperator("Elevate")
ea = visit.ElevateAttributes()
ea.useXYLimits = 1
ea.minFlag = True
ea.min = -0.7
ea.maxFlag = True
ea.max = 0.7
visit.SetOperatorOptions(ea)

## Set global Annotations:
annot_attr = visit.GetAnnotationAttributes()
annot_attr.axes3D.triadFlag = False
annot_attr.axes3D.axesType = annot_attr.axes3D.StaticTriad

annot_attr.axes3D.xAxis.title.userTitle = True
annot_attr.axes3D.xAxis.title.title = "X"
annot_attr.axes3D.xAxis.title.font.scale = 1.5

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

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