Ejemplo n.º 1
0
 def __init__(self):
   self.center_of_rotation = [34.5, 32.45, 27.95]
   self.rotation_axis = [0.0, 0.0, 1.0]
   self.distance = 500.0
   self.exporters = []
   self.analysis = cinema.AnalysisManager( 'cinema', "Cinema", "Test various cinema exporter.")
   self.analysis.begin()
   min = 0.0
   max = 642.0
   self.lut = simple.GetColorTransferFunction(
     "velocity",
     RGBPoints=[min, 0.23, 0.299, 0.754, (min+max)*0.5, 0.865, 0.865, 0.865, max, 0.706, 0.016, 0.15])
   # ==
   self.createSliceExporter()
   self.createComposite()
   self.createImageResampler()
   self.simple360()
Ejemplo n.º 2
0
def doProcessing(outputDir, timesteps):
    # -----------------------------------------------------------------------------
    # Configuration
    # -----------------------------------------------------------------------------

    data_to_process = {
        "T": {
            "scalarRange": [178, 312],
            "contours": [265, 275, 285, 295]
        }
    }

    #resolution = 500
    resolution = 500
    #phis = [ 90, 180 ]
    #thetas = [ 0.0 ]
    phis = [float(r) for r in range(0, 360, 20)]
    thetas = [-80.0, -60.0, -30.0, 0.0, 30.0, 60.0, 80.0]
    distance = 450
    rotation_axis = [0.0, 0.0, 1.0]
    center_of_rotation = [0.0, 0.0, 0.0]

    # -----------------------------------------------------------------------------
    # Input data definition
    # -----------------------------------------------------------------------------

    #path_root = '/Volumes/OLeary'
    path_root = '/media/scott/CINEMA FAT'

    data_base_path = os.path.join(path_root, 'cam5')
    earth_core_path = os.path.join(data_base_path, 'earth-high.vtk')

    #output_working_dir = os.path.join(path_root, 'Output/MPAS/web-generated/mpas-composite')
    #output_working_dir = '/home/scott/Documents/cinemaDemo/simpleCinemaWebGL/cam5/contour-webgl-light'
    output_working_dir = os.path.join(outputDir, 'contour-webgl-light')

    earth_file = os.path.join(data_base_path, 'earth.vtk')
    file_pattern = os.path.join(data_base_path, 'cam5earth_%d.vtk')
    #file_times = range(0, 13, 1)
    #file_times = [ 6 ]
    file_times = timesteps
    cam5_filenames = [(file_pattern % int(time)) for time in file_times]

    # -----------------------------------------------------------------------------
    # Pipeline definition
    # -----------------------------------------------------------------------------

    cam5earth = LegacyVTKReader(FileNames=cam5_filenames)

    earthvtk = LegacyVTKReader(FileNames=[earth_file])
    extract_globe_surface = ExtractSurface(Input=earthvtk)
    surface_normals = GenerateSurfaceNormals(Input=extract_globe_surface)

    # Generate iso contours
    contours = {}
    for field in data_to_process:
        contours[field] = []
        for isoValue in data_to_process[field]['contours']:
            contours[field].append(
                Contour(Input=cam5earth,
                        PointMergeMethod="Uniform Binning",
                        ContourBy=field,
                        Isosurfaces=[isoValue],
                        ComputeScalars=1))

    # -----------------------------------------------------------------------------
    # Output configuration
    # -----------------------------------------------------------------------------

    title = "Visualizations from Cam5 Data"
    description = """
                  Atmospheric Simulations
                  """

    analysis = wx.AnalysisManager(output_working_dir,
                                  title,
                                  description,
                                  author="Patrick O'Leary",
                                  code_name="cam5",
                                  code_version="N/A",
                                  cores=1)

    # -----------------------------------------------------------------------------
    # Pre-calculate ranges
    # -----------------------------------------------------------------------------

    globalRanges = {
        'T': [10000000, -10000000],
        'U': [10000000, -10000000],
        'V': [10000000, -10000000],
        'magnitude': [10000000, -10000000]
    }

    print 'Calculating data array ranges over time'
    for time in file_times:
        t = int(time)
        print '  timestep ', t
        cam5earth.UpdatePipeline(t)
        pdi = cam5earth.GetPointDataInformation()

        for key in globalRanges.keys():
            globalRanges[key] = updateGlobalRange(
                pdi.GetArray(key).GetRange(), globalRanges[key])

    print 'Discovered global ranges:'
    print globalRanges

    # -----------------------------------------------------------------------------
    # Composite generator
    # -----------------------------------------------------------------------------

    id = 'contours-lit'
    title = 'Lit 3D contours composite'
    description = '3D contour of temperature'
    analysis.register_analysis(id, title, description,
                               '{time}/{theta}/{phi}/{filename}',
                               wx.CompositeImageExporter.get_data_type())
    fng = analysis.get_file_name_generator(id)

    camera_handler = wx.ThreeSixtyCameraHandler(fng, None, phis, thetas,
                                                center_of_rotation,
                                                rotation_axis, distance)

    iso_color_array = [('VALUE', 'T'), ('VALUE', 'U'), ('VALUE', 'V'),
                       ('VALUE', 'magnitude'), ('VALUE', 'nX'),
                       ('VALUE', 'nY'), ('VALUE', 'nZ')]

    luts = {
        "T": ["point", "T", 0, globalRanges['T']],
        "U": ["point", "U", 0, globalRanges['U']],
        "V": ["point", "V", 0, globalRanges['V']],
        "magnitude": ["point", "magnitude", 0, globalRanges['magnitude']],
        "bottomDepth": ["point", "bottomDepth", 0, [-10277.0, 7170.0]],
        'nX': ['point', 'Normals', 0, (-1, 1)],
        'nY': ['point', 'Normals', 1, (-1, 1)],
        'nZ': ['point', 'Normals', 2, (-1, 1)]
    }

    composite_list = [surface_normals]
    composite_description = [{'name': 'Earth core'}]
    colors = [[('VALUE', 'bottomDepth'), ('VALUE', 'nX'), ('VALUE', 'nY'),
               ('VALUE', 'nZ')]]

    for field in contours:
        for iso in contours[field]:
            composite_description.append({
                'name':
                field[0] + "=" + str(iso.Isosurfaces[0]),
                'parent':
                "Contour by %s" % field
            })
            composite_list.append(iso)
            colors.append(iso_color_array)

    exporter = wx.CompositeImageExporter(fng,
                                         composite_list,
                                         colors,
                                         luts,
                                         camera_handler,
                                         [resolution, resolution],
                                         composite_description,
                                         format='png')  #, 0, 0)

    # Customize some view properties
    exporter.view.Background = [1.0, 1.0, 1.0]
    exporter.view.OrientationAxesVisibility = 0
    exporter.view.CenterAxesVisibility = 0

    exporter.set_analysis(analysis)

    # -----------------------------------------------------------------------------
    # Perform analysis
    # -----------------------------------------------------------------------------
    analysis.begin()

    for t in file_times:
        time = int(t)
        GetAnimationScene().TimeKeeper.Time = float(time)
        fng.update_active_arguments(time=time)
        print 'Generating images for timestep ', time
        exporter.UpdatePipeline(time)

    analysis.end()
Ejemplo n.º 3
0
#globe_file_times = range(50, 351, 50)
#globe_file_times = [ 50 ]
globe_filenames = [ os.path.join(data_base_path, (globe_file_pattern % time)) for time in globe_file_times]

# -----------------------------------------------------------------------------
# Output configuration
# -----------------------------------------------------------------------------

title       = "MPAS - World Ocean - 120km"
description = """
              The following data anaylisis try to simulate the evolution
              of the ocean in term of temperature and salinity distribution accross
              20 years.
              """

analysis = wx.AnalysisManager(output_working_dir, title, description)

id = 'flat-time'
title = 'Earth slice'
description = '''
              Show the computational mesh with temperature and salinity
              iso-lines for the 40 layers and 120 time steps.
              '''

### The following line (in tandem with the line "fng.update_active_arguments(slice=layer)"),
### causes the UI not to show the layer/slice manipulation widget in the current
### version of Cinema.  It seems that if you use the word "layer" as an argument,
### the UI won't show it.   So I changed "layer" to "slice", and it allows the
### UI to be properly generated.  The same thing seems to go for "field", so I
### had to change that to something else, I chose "colorby".
###
Ejemplo n.º 4
0
angle_steps = (72, 60)
distance = 60
lut = simple.GetLookupTableForArray("RTData",
                                    1,
                                    RGBPoints=[
                                        min, 0.23, 0.299, 0.754,
                                        (min + max) * 0.5, 0.865, 0.865, 0.865,
                                        max, 0.706, 0.016, 0.15
                                    ],
                                    ColorSpace='Diverging',
                                    ScalarRangeInitialized=1.0)
iso_values = [((float(x) * (max - min) * 0.1) + min) for x in range(10)]

# === Create analysis =========================================================

analysis = cinema.AnalysisManager(work_directory, "Cinema Test",
                                  "Test various cinema explorers.")
analysis.begin()

# === SliceExplorer ===========================================================

analysis.register_analysis(
    "slice",  # id
    "Slice exploration",  # title
    "Perform 10 slice along X",  # description
    "{sliceColor}_{slicePosition}.jpg",  # data structure
    cinema.SliceExplorer.get_data_type())
nb_slices = 5
colorByArray = {"RTData": {"lut": lut, "type": 'POINT_DATA'}}
view = simple.CreateRenderView()

fng = analysis.get_file_name_generator("slice")
Ejemplo n.º 5
0
title = "499-2 - Probe the Cosmic Structure of the Dark Universe"
description = """
              In the standard model of cosmology, dark energy and dark matter
              together account for 95 percent of the mass energy of the universe;
              however, their ultimate origin remains a mystery. The Argonne
              Leadership Computing Facility (ALCF) will allocate significant
              supercomputing resources towards unraveling one of the key
              puzzles-the nature of the dark energy causing the universe to
              accelerate its current expansion rate.
              """

analysis = wx.AnalysisManager(output_working_dir,
                              title,
                              description,
                              author="Salman Habib and Katrin Heitmann",
                              code_name="HACC",
                              code_version="HACC 0.1",
                              cores=128)

# -----------------------------------------------------------------------------
# Image size, camera angles, and view information
# -----------------------------------------------------------------------------

resolution = 500
#phi_angles = [ float(r) for r in range(0, 360, 15)]
#theta_angles = [ -60.0, -45.0, -30.0, -15.0, 0, 15.0, 30.0, 45.0, 60.0 ]

# A small number of camera angles for when we're testing our pipeline and such
phi_angles = [180.0, 270.0]
theta_angles = [15.0, 45.0]
Ejemplo n.º 6
0
                                       Isosurfaces = [isoValue],
                                       ComputeScalars = 1))

# -----------------------------------------------------------------------------
# Output configuration
# -----------------------------------------------------------------------------

title       = "MPAS - World Ocean - 120km"
description = """
              The following data anaylisis tries to simulate the evolution
              of the ocean in terms of temperature and salinity distribution accross
              """

analysis = wx.AnalysisManager( output_working_dir, title, description,
                               author="Andy Bauer",
                               code_name="MPAS",
                               code_version="1.3 + Ben changes",
                               cores=1)

# -----------------------------------------------------------------------------
# Pre-calculate ranges
# -----------------------------------------------------------------------------

globalRanges = {
    'temperature': [ 10000000, -10000000 ],
    'salinity': [ 10000000, -10000000 ],
    'density': [ 10000000, -10000000 ],
    'pressure': [ 10000000, -10000000 ]
}

for t in range(0, len(globe_file_times), deltaTimeStep):
Ejemplo n.º 7
0
def generateData(datasetPath, outputDir) :

    if not os.path.exists(outputDir):
        os.makedirs(outputDir)

    resolution = 500
    center_of_rotation = [0.0, 0.0, 0.0]
    rotation_axis = [0.0, 0.0, 1.0]
    distance = 45.0

    disk_out_refex2 = simple.ExodusIIReader(FileName=[datasetPath])
    disk_out_refex2.PointVariables = ['Temp', 'V', 'Pres', 'AsH3', 'GaMe3', 'CH4', 'H2']
    disk_out_refex2.NodeSetArrayStatus = []
    disk_out_refex2.SideSetArrayStatus = []
    disk_out_refex2.ElementBlocks = ['Unnamed block ID: 1 Type: HEX8']

    filters = []
    filters_description = []

    calculator1 = simple.Calculator(Input=disk_out_refex2)
    calculator1.ResultArrayName = 'Velocity'
    calculator1.Function = 'mag(V)'

    simple.UpdatePipeline()

    color_by = []

    #
    # COMPLAINT
    #
    # As a user of this system, I'd like not to have to specify that I need
    # 'nX', 'nY', and 'nZ' when I add a colorby of type "VALUE".  Instead,
    # I'd like it to figure out that I'm going to need normals for that kind
    # of rendering and add them for me.
    #
    color_type = [
        ('VALUE', "Velocity"),
        ('VALUE', "Pres"),
        ('VALUE', "Temp"),
        ('VALUE', "nX"),
        ('VALUE', "nY"),
        ('VALUE', "nZ")
    ]

    pdi = calculator1.GetPointDataInformation()

    #
    # COMPLAINT
    #
    # Ditto the above complaint here.
    #
    luts = {
        "Velocity": ["point", "Velocity", 0, pdi.GetArray("Velocity").GetRange()],
        "Pres": ["point", "Pres", 0, pdi.GetArray("Pres").GetRange()],
        "Temp": ["point", "Temp", 0, pdi.GetArray("Temp").GetRange()],
        "nX": ["point", "Normals", 0, (-1,1)],
        "nY": ["point", "Normals", 1, (-1,1)],
        "nZ": ["point", "Normals", 2, (-1,1)]
    }

    contour_values = [ 300.0, 600.0, 900.0 ]

    for iso_value in contour_values:
        contour = simple.Contour(
            Input=calculator1,
            PointMergeMethod="Uniform Binning",
            ContourBy = ['POINTS', 'Temp'],
            Isosurfaces = [iso_value],
            ComputeScalars = 1)

        # Add this isocontour to my list of filters
        filters.append( contour )
        color_by.append( color_type )
        filters_description.append( {'name': 'iso=%s' % str(iso_value), 'parent': "Contour by temperature"} )

    # create a new 'Stream Tracer'
    streamTracer1 = StreamTracer(Input=calculator1,
        SeedType='High Resolution Line Source')
    streamTracer1.Vectors = ['POINTS', 'V']
    streamTracer1.MaximumStreamlineLength = 20.15999984741211

    # init the 'High Resolution Line Source' selected for 'SeedType'
    streamTracer1.SeedType.Point1 = [-5.75, -5.75, -10.0]
    streamTracer1.SeedType.Point2 = [5.75, 5.75, 10.15999984741211]

    # create a new 'Tube'
    tube1 = Tube(Input=streamTracer1)
    tube1.Scalars = ['POINTS', 'Velocity']
    tube1.Vectors = ['POINTS', 'Normals']
    tube1.Radius = 0.10474160957336426

    #
    # COMPLAINT
    #
    # Here, because the "Normals" field of the tube filter is all funky
    # (directions seem to change at the seed points, when integration
    # proceeded in both directions), I actually needed to play around
    # with ParaView until I found a filter that would get me nice
    # looking normals.  Then, that filter didn't have a "Normals" field,
    # so I had to use a calculator to create it.  Not super nice from a
    # users perspective.
    #
    surfaceVectors1 = SurfaceVectors(Input=tube1)
    surfaceVectors1.SelectInputVectors = ['POINTS', 'TubeNormals']
    calculator2 = simple.Calculator(Input=surfaceVectors1)
    calculator2.ResultArrayName = 'Normals'
    calculator2.Function = 'TubeNormals'

    # Now add the stream tubes to the filters list
    filters.append(calculator2);
    color_by.append(color_type);
    filters_description.append({'name': 'Stream Tubes'})

    # create a new 'Clip'
    clip1 = Clip(Input=calculator1)
    clip1.ClipType = 'Plane'
    clip1.Value = 11.209410083552676
    clip1.InsideOut = 1

    # init the 'Plane' selected for 'ClipType'
    clip1.ClipType.Origin = [0.0, 0.0, 0.07999992370605469]
    clip1.ClipType.Normal = [0.7, 0.0, -0.4]

    #
    # COMPLAINT
    #
    # Here again, the output of the clip filter doesn't have a "Normals"
    # field on points, so I have to do some funky stuff to get what I
    # need.  It would be nice if this could be figured out for me
    # somehow.
    #
    extractSurface1 = ExtractSurface(Input=clip1)
    generateSurfaceNormals1 = GenerateSurfaceNormals(Input=extractSurface1)

    # Now add the first clip to the filters list
    filters.append(generateSurfaceNormals1);
    color_by.append(color_type);
    filters_description.append({'name': 'Clip One'})

    # create a new 'Clip'
    clip2 = Clip(Input=calculator1)
    clip2.ClipType = 'Plane'
    clip2.Value = 11.209410083552676
    clip2.InsideOut = 0

    # init the 'Plane' selected for 'ClipType'
    clip2.ClipType.Origin = [0.0, 0.0, 0.07999992370605469]
    clip2.ClipType.Normal = [0.7, 0.0, -0.4]

    #
    # COMPLAINT
    #
    # Ditto the above complaint here.
    #
    extractSurface2 = ExtractSurface(Input=clip2)
    generateSurfaceNormals2 = GenerateSurfaceNormals(Input=extractSurface2)

    # Now add the second clip to the filters list
    filters.append(generateSurfaceNormals2);
    color_by.append(color_type);
    filters_description.append({'name': 'Clip Two'})

    title = "Composite Dynamic Rendering - Disk Out Ref"
    description = "A sample dataset for dynamic rendering"
    analysis = wx.AnalysisManager(outputDir, title, description)

    id = 'composite'
    title = '3D composite'
    description = "contour set"
    analysis.register_analysis(id, title, description, '{theta}/{phi}/{filename}', wx.CompositeImageExporter.get_data_type()+"-light")
    fng = analysis.get_file_name_generator(id)

    camera_handler = wx.ThreeSixtyCameraHandler(
        fng,
        None,
        [ float(r) for r in range(0, 360, 30) ],
        [ float(r) for r in range(-60, 61, 60) ],
        center_of_rotation,
        rotation_axis,
        distance)

    exporter = wx.CompositeImageExporter(
        fng,
        filters,
        color_by,
        luts,
        camera_handler,
        [resolution,resolution],
        filters_description,
        0, 0, 'png')
    exporter.set_analysis(analysis)

    analysis.begin()
    exporter.UpdatePipeline(0)
    analysis.end()