예제 #1
0
 def test_RenameSource(self):
     source = simple.Sphere(guiName='oldName')
     simple.SetActiveSource(source)
     simple.RenameSource('newName')
     # changing the source name should unregister the old name
     self.assertEqual(None, self.pxm.GetProxy('sources', 'oldName'))
     self.assertEqual(source, self.pxm.GetProxy('sources', 'newName'))
     # renaming as the current name should not unregister the source
     simple.RenameSource('newName')
     self.assertEqual(source, self.pxm.GetProxy('sources', 'newName'))
def plotTurbine(hubxy, basexy, turbR, NacYaw, name):
    # Some constants
    towerres = 100  # Resolution for tower
    nacellelength = 7.5

    # --- Plot the tower ---
    towerheight = hubxy[2] - basexy[2]
    plotTower(basexy, towerheight, name)
    # towerline = pvs.Line()
    # towerline.Point1 = basexy
    # towerline.Point2 = np.array(basexy) + towerheight*np.array([0,0,1])
    # towerline.Resolution = towerRes
    # pvs.RenameSource(name+'_tower', towerline)
    # --- Plot the nacelle ---
    plotNacelle(basexy, towerheight, NacYaw, name)
    # --- Plot the rotor disk ---
    plotRotorDisk(hubxy, turbR, NacYaw, name)
    # --- Group the datasets together ---
    turbine0_rotordisk = pvs.FindSource(name + '_rotordisk')
    turbine0_nacelle = pvs.FindSource(name + '_nacelle')
    turbine0_tower = pvs.FindSource(name + '_tower')
    groupDatasets1 = pvs.GroupDatasets(
        Input=[turbine0_rotordisk, turbine0_nacelle, turbine0_tower])
    pvs.RenameSource(name + '_allobjects', groupDatasets1)
    return
예제 #3
0
    def openRelativeFile(self, relativePath):
        fileToLoad = []
        if type(relativePath) == list:
            for file in relativePath:
                fileToLoad.append(os.path.join(self.baseDir, file))
        else:
            fileToLoad.append(os.path.join(self.baseDir, relativePath))

        reader = simple.OpenDataFile(fileToLoad)
        name = fileToLoad[0].split("/")[-1]
        if len(name) > 15:
            name = name[:15] + '*'
        simple.RenameSource(name, reader)
        simple.Show()
        simple.Render()
        simple.ResetCamera()

        # Add node to pipeline
        self.pipeline.addNode('0', reader.GetGlobalIDAsString())

        # Create LUT if need be
        self.lutManager.registerFieldData(reader.GetPointDataInformation())
        self.lutManager.registerFieldData(reader.GetCellDataInformation())

        return helper.getProxyAsPipelineNode(reader.GetGlobalIDAsString(),
                                             self.lutManager)
예제 #4
0
 def _rename(self, name):
     assert self._data is not None
     try:
         ps.RenameSource(name, self._data)
         self._name = name
     except Exception as e:
         print("Could not rename to {}".format(name))
         print(e)
예제 #5
0
    def load(self, path):
        vtk = ps.LegacyVTKReader(FileNames=[str(path)])
        ps.RenameSource(" ", vtk)
        name = self._get_postfix(path)
        data = self._threshold_vtk(vtk, name)

        self._data = data
        self._rename(name)
        self.show()
def makeLineOfSight(p1, p2, resolution, name=''):
    # create a new 'Line'
    line1 = pvs.Line()
    # Properties modified on line1
    line1.Point1 = p1
    line1.Point2 = p2
    line1.Resolution = resolution
    if (len(name) > 0):
        # rename source object
        pvs.RenameSource(name, line1)
    return line1
def setupCalculator(source, arrayName, color, fctString, renderView):
    calculator = smp.Calculator(Input=source)
    smp.RenameSource(getCalculatorName(arrayName), calculator)
    calculator.Function = ''
    calculator.ResultArrayName = arrayName
    calculator.Function = fctString
    calculatorDisplay = smp.GetDisplayProperties(calculator, view=renderView)
    calculatorDisplay.SetRepresentationType('3D Glyphs')
    calculatorDisplay.DiffuseColor = color
    calculatorDisplay.Orient = 1
    calculatorDisplay.SelectOrientationVectors = 'Orientation(AxisAngle)'
    calculatorDisplay.SelectOrientationVectors = arrayName
def makeSamplePlane(cornerpt, edge1, edge2, Nx, Ny, name=''):
    # create a new 'Plane'
    plane1 = pvs.Plane()

    # Properties modified on plane1
    plane1.Origin = cornerpt
    plane1.Point1 = cornerpt + edge1
    plane1.Point2 = cornerpt + edge2
    plane1.XResolution = Nx
    plane1.YResolution = Ny
    if (len(name) > 0):
        # rename source object
        pvs.RenameSource(name, plane1)
    return plane1
    def openFile(self, path):
        reader = simple.OpenDataFile(path)
        simple.RenameSource( path.split("/")[-1], reader)
        simple.Show()
        simple.Render()
        simple.ResetCamera()

        # Add node to pipeline
        self.pipeline.addNode('0', reader.GetGlobalIDAsString())

        # Create LUT if need be
        self.lutManager.registerFieldData(reader.GetPointDataInformation())
        self.lutManager.registerFieldData(reader.GetCellDataInformation())

        return helper.getProxyAsPipelineNode(reader.GetGlobalIDAsString(), self.lutManager)
def plotRotorDisk(hubxy, turbR, NacYaw, name):
    # Define some constants
    rotorres = 30
    rotorthick = 1
    # create a new 'Cylinder'
    rotordisk = pvs.Cylinder()
    rotordisk.Height = rotorthick
    rotordisk.Resolution = rotorres
    rotordisk.Radius = turbR
    #rotordisk.Center     = hubxy
    # create a new 'Transform'
    rotortrans = pvs.Transform(Input=rotordisk)
    rotortrans.Transform = 'Transform'
    rotortrans.Transform.Translate = hubxy
    rotortrans.Transform.Rotate = [0.0, 0.0, 90 + NacYaw]
    pvs.RenameSource(name + '_rotordisk', rotortrans)
    return
def plotNacelle(basexy, height, NacYaw, name):
    # Define some constants
    nacellewidth = 5
    nacellelength = 15
    # create a new nacelle
    nacellebox = pvs.Box()
    nacellebox.XLength = nacellelength
    nacellebox.YLength = nacellewidth
    nacellebox.ZLength = nacellewidth
    nacellebox.Center = [0.5 * nacellelength, 0,
                         0]  #[basexy[0], basexy[1], basexy[2]+height]
    transnacelle = pvs.Transform(Input=nacellebox)
    transnacelle.Transform.Translate = [
        basexy[0], basexy[1], basexy[2] + height
    ]  #[0.3*nacellelength, 0, 0]
    transnacelle.Transform.Rotate = [0.0, 0.0, NacYaw]
    pvs.RenameSource(name + '_nacelle', transnacelle)
    return
def plotTower(basexy, height, name):
    # Define some constants
    towerres = 30
    towerR = 1.5
    # create a new 'Cylinder'
    towercyl = pvs.Cylinder()
    # Properties modified on cylinder1
    towercyl.Height = height
    towercyl.Resolution = towerres
    towercyl.Radius = towerR
    towercyl.Center = [0, 0, 0]
    # create a new 'Transform'
    transcyl = pvs.Transform(Input=towercyl)
    transcyl.Transform = 'Transform'
    # Properties modified on transform1.Transform
    transcyl.Transform.Translate = [
        basexy[0], basexy[1], basexy[2] + 0.5 * height
    ]
    transcyl.Transform.Rotate = [90.0, 0.0, 0.0]
    #towercyl.RenameSource(name+'_tower_temp', towercyl)
    pvs.RenameSource(name + '_tower', transcyl)
    return
예제 #13
0
def main():
    import paraview.simple as para
    version_major = para.servermanager.vtkSMProxyManager.GetVersionMajor()
    source = para.GetActiveSource()
    renderView1 = para.GetRenderView()
    atoms = para.Glyph(
        Input=source,
        GlyphType='Sphere',
        Scalars='radii',
        ScaleMode='scalar',
    )
    para.RenameSource('Atoms', atoms)
    atomsDisplay = para.Show(atoms, renderView1)
    if version_major <= 4:
        atoms.SetScaleFactor = 0.8
        atomicnumbers_PVLookupTable = para.GetLookupTableForArray(
            'atomic numbers', 1)
        atomsDisplay.ColorArrayName = ('POINT_DATA', 'atomic numbers')
        atomsDisplay.LookupTable = atomicnumbers_PVLookupTable
    else:
        atoms.ScaleFactor = 0.8
        para.ColorBy(atomsDisplay, 'atomic numbers')
        atomsDisplay.SetScalarBarVisibility(renderView1, True)
    para.Render()
예제 #14
0
def RequestData():
    # V.2019.031
    import sys
    sys.path.insert(0, r'EMC_SRC_PATH')
    import paraview.simple as simple
    import numpy as np
    import csv
    import os
    import datetime
    from vtk.util import numpy_support as nps
    import IrisEMC_Paraview_Lib as Lib
    import IrisEMC_Paraview_Utils as Utils
    import urllib.parse

    pts = vtk.vtkPoints()
    Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End = Lib.get_area(
        Area, Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End)
    label2 = " - %s (lat:%0.1f,%0.1f, lon:%0.1f,%0.1f, depth:%0.1f-%0.1f)" % (
        Lib.areaValues[Area], Latitude_Begin, Latitude_End, Longitude_Begin,
        Longitude_End, Depth_Begin, Depth_End)

    # make sure we have input files
    if not Time_End.strip():
        Time_End = datetime.datetime.today().strftime('%Y-%m-%d')
    query = Lib.earthquakeQuery % (Time_Begin, Time_End, Magnitude_Begin,
                                   Magnitude_End, Depth_Begin, Depth_End,
                                   Latitude_Begin, Latitude_End,
                                   Longitude_Begin, Longitude_End)
    Alternate_FileName = Alternate_FileName.strip()
    if len(Alternate_FileName) <= 0:
        eqFile = Lib.query2filename(query, url=Lib.earthquakeKeys[Data_Source])
        query = '?'.join([Lib.earthquakeKeys[Data_Source], query])
        fileFound, address, source = Lib.find_file(eqFile,
                                                   loc=r'EMC_EARTHQUAKES_PATH',
                                                   query=query)
    else:
        fileFound, address, source = Lib.find_file(Alternate_FileName,
                                                   loc=r'EMC_EARTHQUAKES_PATH')
    if not fileFound:
        raise Exception(
            'earthquake catalog file "' + address +
            '" not found! Please provide the full path or UR for the file. Aborting.'
        )
    (params, lines) = Lib.read_geocsv(address)

    pdo = self.GetOutput()  # vtkPoints
    column_keys = Lib.columnKeys
    for key in list(Lib.columnKeys.keys()):
        if key in list(params.keys()):
            column_keys[key] = params[key]

    origin = None
    if 'source' in params:
        origin = params['source']
        this_label = urllib.parse.urlparse(origin).netloc
    else:
        try:
            this_label = urllib.parse.urlparse(Alternate_FileName).netloc
        except:
            this_label = Alternate_FileName

    header = params['header']
    lat_index = None
    lon_index = None
    depth_index = None
    mag_index = None
    time_index = None
    for index, value in enumerate(header):
        if value.strip().lower() == column_keys['longitude_column'].lower():
            lon_index = index
        elif value.strip().lower() == column_keys['latitude_column'].lower():
            lat_index = index
        elif value.strip().lower() == column_keys['depth_column'].lower():
            depth_index = index
        elif value.strip().lower() == column_keys['magnitude_column'].lower():
            mag_index = index
        elif value.strip().lower() == column_keys['time_column'].lower():
            time_index = index

    scalar_m = vtk.vtkFloatArray()
    scalar_m.SetNumberOfComponents(1)
    scalar_m.SetName("magnitude")
    scalar_d = vtk.vtkFloatArray()
    scalar_d.SetNumberOfComponents(1)
    scalar_d.SetName("depth")
    scalar_t = vtk.vtkLongArray()
    scalar_t.SetNumberOfComponents(1)
    scalar_t.SetName("year-month")
    lat = []
    lon = []
    depth = []
    mag = []
    time = []
    frame_tag = Frame_Tag.strip()
    frame = dict()
    frame_single = dict()
    frame_key = Frame_Length_sec

    for i in range(len(lines)):
        line = lines[i].strip()
        values = line.strip().split(params['delimiter'].strip())
        lat_value = float(values[lat_index])
        lat.append(lat_value)
        lon_value = float(values[lon_index])
        lon.append(lon_value)
        depth_value = float(values[depth_index])
        depth.append(depth_value)
        mag_value = float(values[mag_index])
        mag.append(mag_value)
        time_value = values[time_index]
        time.append(time_value)

        # check conditions again in case data came from a file
        if not (float(Latitude_Begin) <= lat_value <= float(Latitude_End)
                and float(Longitude_Begin) <= lon_value <= float(Longitude_End)
                and float(Depth_Begin) <= depth_value <= float(Depth_End) and
                float(Magnitude_Begin) <= mag_value <= float(Magnitude_End)):
            continue

        if Latitude_Begin <= lat[-1] <= Latitude_End and Longitude_Begin <= lon[
                -1] <= Longitude_End:
            x, y, z = Lib.llz2xyz(lat[-1], lon[-1], depth[-1])
            pts.InsertNextPoint(x, y, z)
            scalar_m.InsertNextValue(mag[-1])
            scalar_d.InsertNextValue(depth[-1])
            day_value = Utils.datetime_to_int(time[-1], level='day')
            scalar_t.InsertNextValue(day_value)
            if frame_tag:
                frame_time = int(
                    Utils.datetime_to_float(time_value) -
                    Utils.datetime_to_float(Time_Begin))
                if frame_time < frame_key:
                    frame[str(frame_key)] = '%s\n%f,%f,%f,%0.2f,%0.1f,%d' % (
                        frame[str(frame_key)], x, y, z, depth[-1], mag[-1],
                        day_value)
                    if frame_time >= frame_key - Frame_Length_sec:
                        frame_single[str(
                            frame_key)] = '%s\n%f,%f,%f,%0.2f,%0.1f,%d' % (
                                frame_single[str(frame_key)], x, y, z,
                                depth[-1], mag[-1], day_value)
                else:
                    frame_key += Frame_Length_sec
                    frame[str(frame_key)] = '%f,%f,%f,%0.2f,%0.1f,%d' % (
                        x, y, z, depth[-1], mag[-1], day_value)
                    frame_single[str(
                        frame_key)] = '%f,%f,%f,%0.2f,%0.1f,%d' % (
                            x, y, z, depth[-1], mag[-1], day_value)

    # save animation frames
    if frame_tag:
        Utils.remove_files(
            os.path.join('EMC_EQ_ANIMATION_PATH', '%s_*.txt') % frame_tag)
        key_list = [int(x) for x in list(frame.keys())]
        key_list.sort()
        key0 = key_list[0]
        eq_list = 'X,Y,Z,Depth,Mag,Year-Month'
        for i, key in enumerate(key_list):
            eq_list = '%s\n%s' % (eq_list, frame[str(key)])
            with open(
                    os.path.join('EMC_EQ_ANIMATION_PATH',
                                 '%s_%012d.txt' % (frame_tag, key - key0)),
                    'w') as fp:
                fp.write('%s' % eq_list)
            eq = 'X,Y,Z,Depth,Mag,Year-Month\n%s' % frame_single[str(key)]
            with open(
                    os.path.join(
                        'EMC_EQ_ANIMATION_PATH',
                        '%s_single_%012d.txt' % (frame_tag, key - key0)),
                    'w') as fp:
                fp.write('%s' % eq)
    pdo.SetPoints(pts)
    pdo.GetPointData().AddArray(scalar_m)
    pdo.GetPointData().AddArray(scalar_d)
    pdo.GetPointData().AddArray(scalar_t)

    if len(this_label.strip()) > 0:
        simple.RenameSource(' '.join([
            'Earthquake locations:', 'from',
            this_label.strip(),
            label2.strip()
        ]))

    # store metadata
    field_data = pdo.GetFieldData()
    field_data.AllocateArrays(3)  # number of fields

    data = vtk.vtkFloatArray()
    data.SetName('Latitude\nRange (deg)')
    data.InsertNextValue(min(lat))
    data.InsertNextValue(max(lat))
    field_data.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Longitude\nRange (deg)')
    data.InsertNextValue(min(lon))
    data.InsertNextValue(max(lon))
    field_data.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Depth\nRange (km)')
    data.InsertNextValue(min(depth))
    data.InsertNextValue(max(depth))
    field_data.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Magnitude\nRange')
    data.InsertNextValue(min(mag))
    data.InsertNextValue(max(mag))
    field_data.AddArray(data)

    data = vtk.vtkIntArray()
    data.SetName('Max. Event\nCount')
    data.InsertNextValue(len(mag))
    field_data.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('Start Date')
    data.InsertNextValue(Time_Begin)
    field_data.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('End Date')
    data.InsertNextValue(Time_End)
    field_data.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('Source')
    if origin is not None:
        data.InsertNextValue(origin)

    data.InsertNextValue(source)
    field_data.AddArray(data)

    pdo.SetFieldData(field_data)
예제 #15
0
def RequestData():
    # R.0.2018.080
    import sys
    import paraview.simple as simple
    import numpy as np
    import csv
    import os
    sys.path.insert(0, "EMC_SRC_PATH")
    import IrisEMC_Paraview_Lib as lib
    import urlparse

    if len(Alternate_FileName.strip()) > 0:
         FileName        = Alternate_FileName
         Label           = ' '.join(['Boundary',lib.fileName(Alternate_FileName).strip()])
    else:
         FileName        = lib.boundaryKeys[DataFile]
         Label           = lib.boundaryValues[DataFile]

    # make sure we have input files
    fileFound,address,source = lib.findFile(FileName,loc='EMC_BOUNDARIES_PATH')
    if not fileFound:
        raise Exception('boundary file "'+address+'" not found! Please provide the full path or UR for the file. Aborting.')
    (params,lines) = lib.readGcsv(address)
    
    pdo = self.GetOutput() # vtkPolyData
    
    Latitude_Begin,Latitude_End,Longitude_Begin,Longitude_End = lib.getArea(Area,Latitude_Begin,Latitude_End,Longitude_Begin,Longitude_End)
    Label2 = " - %s (lat:%0.1f,%0.1f, lon:%0.1f,%0.1f)"%(lib.areaValues[Area],Latitude_Begin,Latitude_End,Longitude_Begin,Longitude_End)

    x           = []
    y           = []
    z           = []
    segments    = []
    pointIndex  = -1
    thisSegment = []
    order       = 1

    # depth is positive down
    Boundary_Elevation *= -1

    column_keys = lib.columnKeys
    for key in lib.columnKeys.keys():
        if key in params.keys():
            column_keys[key] = params[key].strip()
    delimiter   = params['delimiter'].strip()
    gaps        = params['gaps'].strip()
    latIndex = 0
    lonIndex = 1
    if 'source' in params.keys():
        try:
           netloc = urlparse.urlparse(params['source']).netloc
        except:
           netloc = params['source']

        if len(netloc.strip()) <= 0:
           netloc = params['source']

        Label = ' '.join([Label.strip(),'from',netloc.strip()])
    
    header = lines[0].strip()
    fields = header.split(delimiter)
    if fields[0].strip() == column_keys['longitude_column']:
       latIndex = 1
       lonIndex = 0

    for l in range(1,len(lines)):
        line = lines[l].strip()
        # segment break
        if gaps in line:
            # file start
            if pointIndex <= 0:
               continue

            # finished one segment, store the number of points
            else:
                 segments.append(thisSegment)
                 thisSegment = []
                 pointIndex  = 0
        else:
             values = line.strip().split(delimiter)
             lat,lon = values[latIndex],values[lonIndex]
             if float(lat)< Latitude_Begin or float(lat)> Latitude_End or float(lon) < Longitude_Begin or float(lon) > Longitude_End:
                 continue
            
             # convert to spherical coordinates
             X,Y,Z =lib.llz2xyz(float(lat),float(lon),Boundary_Elevation)
             x.append(X)
             y.append(Y)
             z.append(Z)
             pointIndex += 1

             # store point index for this segment
             thisSegment.append(len(x)-1)

    # This vtk object will store all the points
    newPts = vtk.vtkPoints()
    nPoints = len(x)
    for i in range(nPoints):
       newPts.InsertPoint(i, x[i],y[i],z[i])

    # Add the points to the vtkPolyData object
    pdo.SetPoints(newPts)

    # storage for the line segments
    nSegments = len(segments)
    pdo.Allocate(nSegments, 1)

    # Make a vtkPolyLine object to hold each segment data
    for i in range(0,nSegments):
       aPolyLine = vtk.vtkPolyLine()

       # Indicate the number of points along the line
       aPolyLine.GetPointIds().SetNumberOfIds(len(segments[i]))
       for j in range(len(segments[i])):
           aPolyLine.GetPointIds().SetId(j, segments[i][j])
       pdo.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())

    simple.RenameSource(Label+Label2)

    # store boundary metadata
    fieldData = pdo.GetFieldData()
    fieldData.AllocateArrays(3) # number of fields

    data = vtk.vtkFloatArray()
    data.SetName('Latitude\nRange (deg)')
    data.InsertNextValue(Latitude_Begin)
    data.InsertNextValue(Latitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Longitude\nRange (deg)')
    data.InsertNextValue(Longitude_Begin)
    data.InsertNextValue(Longitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Boundary Elevation (km)')
    data.InsertNextValue(-1*Boundary_Elevation)
    fieldData.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('Source')
    data.InsertNextValue(source)
    fieldData.AddArray(data)

    pdo.SetFieldData(fieldData)
예제 #16
0
def manySlicesAlongAxis(dataNm, rng, axis=0, exportpath='', ext='.csv'):
    """
    Description
    -----------


    Parameters
    ----------
    `dataNm` : string
    - The string name of the data source to slice.
    - Make sure this data source is slice-able.

    `numSlices` : int, optional
    - The number of slices along the path.

    `exportpath` : string, optional
    - The absolute file path of where to save each slice

    `ext` : string, optional
    - The file extension for saving out the slices.
    - Default to '.csv'


    Notes
    -----
    - Make sure the input data source is slice-able.
    - The SciPy module is required for this macro.

    """

    # exportpath: Where to save data. Absolute path:
    if axis not in (0, 1, 2):
        raise Exception('Axis choice must be 0, 1, or 2 (x, y, or z)')

    # Specify data set to be sliced
    data = pvs.FindSource(dataNm)

    # get active view
    renderView = pvs.GetActiveViewOrCreate('RenderView')

    def getNorm():
        norm = [0, 0, 0]
        norm[axis] = 1
        return norm

    def updateOrigin(og, i):
        og[axis] = rng[i]
        return og

    norm = getNorm()

    num = 0
    inputs = []
    for i in range(len(rng)):
        # create slice
        slc = pvs.Slice(Input=data)
        slc.SliceType = 'Plane'

        # set origin at points
        og = slc.SliceType.Origin
        og = updateOrigin(og, i)
        # set normal as vector from current point to next point
        slc.SliceType.Normal = norm

        if exportpath != '':
            # save out slice with good metadata: TODO: change name
            # This will use a value from the point data to add to the name
            #num = wpdi.PointData['Advance LL (S-558)'][ptsi[i]]
            filename = path + 'Slice_%d%s' % (num, ext)
            print(filename)
            pvs.SaveData(filename, proxy=slc)

        num += 1
        inputs.append(slc)
        #pvs.Show(slc, renderView)

    # Now append all slices into once source for easy management
    app = pvs.AppendDatasets(Input=inputs)
    pvs.RenameSource('%s-Slices' % dataNm, app)
    pvs.Show(app, renderView)
    pvs.RenderAllViews()
    pvs.ResetCamera()
    return app
def RequestData():
    # R.0.2018.080
    import sys
    sys.path.insert(0, "EMC_SRC_PATH")
    from datetime import datetime
    import numpy as np
    from vtk.numpy_interface import dataset_adapter as dsa
    from vtk.util import numpy_support
    import IrisEMC_Paraview_Lib as lib
    import paraview.simple as simple

    views = simple.GetViews(viewtype="SpreadSheetView")
    if len(views) > 0:
       simple.Delete(views[0])
    else:
       view = simple.GetActiveView()
       layout = simple.GetLayout(view)
       locationId = layout.SplitViewVertical(view=view ,fraction=0.7)

    myId    = simple.GetActiveSource().Input.GetGlobalIDAsString()
    proxies = simple.GetSources()
    proxyList = []
    for key in proxies:
       listElt = {}
       listElt['name'] = key[0]
       listElt['id'] = key[1]
       proxy = proxies[key]
       parentId = '0'
       if hasattr(proxy, 'Input'):
           parentId = proxy.Input.GetGlobalIDAsString()
       listElt['parent'] = parentId
       proxyList.append(listElt)


    pdi = self.GetInput() # VTK PolyData Type
    np = pdi.GetNumberOfPoints()
    depthMin = 9999999999999.0
    depthMax = -9999999999999.0
    latitude  = {}
    longitude = {}

    pdo = self.GetOutput() # VTK Table Type
    polyData  = vtk.vtkPolyData()
    dataPoints = vtk.vtkPoints()

    if len(Label.strip()) <= 0:
         pid = simple.GetActiveSource().Input.GetGlobalIDAsString()
         proxies = simple.GetSources()
         for key in proxies:
             if key[1] == pid:
                 Label = " ".join(["Coordinates View:",key[0]])
                 break
    for i in range(np):
        point = pdi.GetPoints().GetPoint(i)
        (lat,lon,depth) = lib.xyz2llz(point[0],point[1],point[2])
        dataPoints.InsertNextPoint((lat,lon,depth))
        key = "%0.1f"%(depth)
        if depthMin >= float(key):
           depthMin = float(key)
           depthMinKey = key
        if depthMax <= float(key):
           depthMax = float(key)
           depthMaxKey = key
        if key not in latitude.keys():
            latitude[key] =[]
            longitude[key] = []
        latitude[key].append(float("%0.1f"%(lat)))
        longitude[key].append(float("%0.1f"%(lon)))

    # store boundary metadata

    fieldData = polyData.GetFieldData()
    fieldData.AllocateArrays(3) # number of fields

    depthData = vtk.vtkStringArray()
    depthData.SetName('Depth\n(km)')

    data = vtk.vtkStringArray()
    data.SetName('Corners (lat,lon)\n(degrees)')

    depthKeys = [depthMinKey,depthMaxKey]
    if depthMinKey == depthMaxKey:
        depthKeys = [depthMinKey]
    for i in range(len(depthKeys)):
       depthKey = depthKeys[i]
       borderLat = []
       borderLon = []
       oldMin = 999999999.0
       oldMax = -99999999.0
       lonList = list(set(sorted(longitude[depthKey])))
       for j in range(len(lonList)):
          lon = lonList[j]
          minVal = 999999999.0
          maxVal = -99999999.0
          for i in range(len(longitude[depthKey])):
             if longitude[depthKey][i] == lon:
                if latitude[depthKey][i] > maxVal:
                  maxVal = latitude[depthKey][i]
                if latitude[depthKey][i] < minVal:
                  minVal = latitude[depthKey][i]
          if oldMin != minVal or j==len(lonList)-1:
             if abs(oldMin) < 9999.0:
                borderLat.append(oldMin)
                borderLon.append(lon)
             borderLat.append(minVal)
             borderLon.append(lon)
             oldMin = minVal
          if oldMax != maxVal or j==len(lonList)-1:
             if abs(oldMax) < 9999.0:
                borderLat.append(oldMax)
                borderLon.append(lon)
             borderLat.append(maxVal)
             borderLon.append(lon)
             oldMax = maxVal
       borderList = zip(borderLat, borderLon)
       borderList.sort()
       borderList = list(set(borderList))
       min1 = borderList[0][0]
       max1 = borderList[0][0]
       for i in range(len(borderList)):
          if borderList[i][0] < min1:
             min1 = borderList[i][0]
          if borderList[i][0] > max1:
             max1 = borderList[i][0]
       minList = []
       maxList = []
       for i in range(len(borderList)):
          if borderList[i][0] ==  min1:
             minList.append(borderList[i][1])
          if borderList[i][0] ==  max1:
             maxList.append(borderList[i][1])
       depthData.InsertNextValue(depthKey)
       data.InsertNextValue("%0.1f, %0.1f"%(min1,min(minList)))
       if min(minList) != max(minList):
          depthData.InsertNextValue(" ")
          data.InsertNextValue("%0.1f, %0.1f"%(min1,max(minList)))
       depthData.InsertNextValue(" ")
       data.InsertNextValue("%0.1f, %0.1f"%(max1,max(maxList)))
       if min(maxList) != max(maxList):
         depthData.InsertNextValue(" ")
         data.InsertNextValue("%0.1f, %0.1f"%(max1,min(maxList)))
    fieldData.AddArray(data)
    fieldData.AddArray(depthData)

    if len(Label.strip()) > 0:
        simple.RenameSource(Label)

    pdo.SetFieldData(fieldData)
예제 #18
0
def RequestData():
    # R.0.2018.080
    import sys
    import numpy as np
    import os
    import paraview.simple as simple
    sys.path.insert(0, r'EMC_SRC_PATH')
    import IrisEMC_Paraview_Lib as lib

    grid_depth = float(Depth_Bias)
    spacing = float(Grid_Spacing)

    pdo = self.GetOutput()  # vtkPolyData

    Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End = lib.get_area(
        Area, Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End)
    Label2 = " - %s (lat:%0.1f,%0.1f, lon:%0.1f,%0.1f) with grid spacing of %0.1f degrees" % (
        lib.areaValues[Area], Latitude_Begin, Latitude_End, Longitude_Begin,
        Longitude_End, spacing)

    x = []
    y = []
    z = []
    segments = []

    # create grid points along latitudes
    nLat = int((Latitude_End - Latitude_Begin) / spacing) + 1
    mLat = int((Latitude_End - Latitude_Begin) / Grid_Resolution_degrees) + 1
    nLon = int((Longitude_End - Longitude_Begin) / spacing) + 1
    mLon = int((Longitude_End - Longitude_Begin) / Grid_Resolution_degrees) + 1

    lat = Latitude_Begin - spacing
    for i in range(nLat):
        lat += spacing
        this_segment = []
        point_index = 0
        lon = Longitude_Begin - Grid_Resolution_degrees
        for j in range(mLon):
            lon += Grid_Resolution_degrees
            X, Y, Z = lib.llz2xyz(lat, lon, grid_depth)
            x.append(X)
            y.append(Y)
            z.append(Z)
            point_index += 1

            # store point index for this segment
            this_segment.append(len(x) - 1)
        segments.append(this_segment)

    # create grid points along longitudes
    lon = Longitude_Begin - spacing
    for j in range(nLon):
        lon += spacing
        this_segment = []
        point_index = 0
        lat = Latitude_Begin - Grid_Resolution_degrees
        for i in range(mLat):
            lat += Grid_Resolution_degrees
            X, Y, Z = lib.llz2xyz(lat, lon, grid_depth)
            x.append(X)
            y.append(Y)
            z.append(Z)
            point_index += 1

            # store point index for this segment
            this_segment.append(len(x) - 1)
        segments.append(this_segment)

    # this vtk object will store all the points
    new_points = vtk.vtkPoints()
    npoints = len(x)
    for i in range(npoints):
        new_points.InsertPoint(i, x[i], y[i], z[i])

    # add the points to the vtkPolyData object
    pdo.SetPoints(new_points)

    # initialize storage for line segments
    nSegments = len(segments)
    pdo.Allocate(nSegments, 1)

    # make a vtkPolyLine object to hold each segment data
    for i in range(0, nSegments):
        a_polyLine = vtk.vtkPolyLine()

        # indicate the number of points along the line
        a_polyLine.GetPointIds().SetNumberOfIds(len(segments[i]))
        for j in range(len(segments[i])):
            a_polyLine.GetPointIds().SetId(j, segments[i][j])
        pdo.InsertNextCell(a_polyLine.GetCellType(), a_polyLine.GetPointIds())

    # store grid metadata
    fieldData = pdo.GetFieldData()
    fieldData.AllocateArrays(3)  # number of fields

    data = vtk.vtkFloatArray()
    data.SetName('Latitude\nRange (deg)')
    data.InsertNextValue(Latitude_Begin)
    data.InsertNextValue(Latitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Longitude\nRange (deg)')
    data.InsertNextValue(Longitude_Begin)
    data.InsertNextValue(Longitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Grid Elevation (km),\nResolution & Spacing (deg)')
    data.InsertNextValue(grid_depth)
    data.InsertNextValue(Grid_Resolution_degrees)
    data.InsertNextValue(spacing)
    fieldData.AddArray(data)

    pdo.SetFieldData(fieldData)
    simple.RenameSource(' '.join(['Grid', Label2.strip()]))
예제 #19
0
def RequestData():
    # V.2019.014
    import sys
    sys.path.insert(0, r'EMC_SRC_PATH')
    import paraview.simple as simple
    import numpy as np
    import csv
    import os
    from vtk.util import numpy_support as nps
    import IrisEMC_Paraview_Lib as lib
    import urllib.parse

    Label = ''

    pts = vtk.vtkPoints()

    # make sure we have input files
    if len(File_name.strip()) <= 0:
        fileFound = False
        address = ''
    else:
        fileFound, address, source = lib.find_file(File_name.strip(),
                                                   loc=r'EMC_VOLCANOES_PATH')

    if not fileFound:
        raise Exception(
            'volcano file "' + address +
            '" not found! Please provide the full path or UR for the file. Aborting.'
        )
    (params, lines) = lib.read_geocsv(address)

    Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End = lib.get_area(
        Area, Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End)
    Label2 = " - %s (lat:%0.1f,%0.1f, lon:%0.1f,%0.1f)" % (
        lib.areaValues[Area], Latitude_Begin, Latitude_End, Longitude_Begin,
        Longitude_End)

    pdo = self.GetOutput()  # vtkPoints
    lat_index = 0
    lon_index = 1

    column_keys = lib.columnKeys
    for key in list(lib.columnKeys.keys()):
        if key in list(params.keys()):
            column_keys[key] = params[key]

    delimiter = params['delimiter'].strip()

    origin = None
    if 'source' in params:
        origin = params['source']
        if len(Label.strip()) <= 0:
            Label = origin

    fields = params['header']
    for i in range(len(fields)):
        if fields[i].strip().lower() == column_keys['longitude_column'].lower(
        ):
            lon_index = i
        elif fields[i].strip().lower() == column_keys['latitude_column'].lower(
        ):
            lat_index = i
        elif fields[i].strip().lower(
        ) == column_keys['elevation_column'].lower():
            elev_index = i

    for i, line in enumerate(lines):
        line = line.strip()
        values = line.split(delimiter)
        try:
            lat = float(values[lat_index])
            lon = float(values[lon_index])
        except:
            continue
        if len(values[elev_index].strip()) <= 0:
            depth = 0.0
        else:
            try:
                depth = -1 * float(values[elev_index]) / 1000.0
            except:
                continue
        if Latitude_Begin <= lat <= Latitude_End and Longitude_Begin <= lon <= Longitude_End:
            x, y, z = lib.llz2xyz(lat, lon, depth)
            pts.InsertNextPoint(x, y, z)
    pdo.SetPoints(pts)

    simple.RenameSource(' '.join(
        ['Volcano locations:',
         Label.strip(), Label2.strip()]))

    view = simple.GetActiveView()

    # store metadata
    fieldData = pdo.GetFieldData()
    fieldData.AllocateArrays(3)  # number of fields

    data = vtk.vtkFloatArray()
    data.SetName('Latitude\nRange (deg)')
    data.InsertNextValue(Latitude_Begin)
    data.InsertNextValue(Latitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Longitude\nRange (deg)')
    data.InsertNextValue(Longitude_Begin)
    data.InsertNextValue(Longitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('Source')
    if origin is not None:
        data.InsertNextValue(origin)

    data.InsertNextValue(source)
    fieldData.AddArray(data)

    pdo.SetFieldData(fieldData)
예제 #20
0
def RequestData():
    # R.0.2018.120
    import sys
    sys.path.insert(0, "EMC_SRC_PATH")
    import paraview.simple as simple
    import numpy as np
    import csv
    import os
    from vtk.util import numpy_support as nps
    import IrisEMC_Paraview_Lib as lib
    import urlparse

    Label = ''

    pts = vtk.vtkPoints()
    Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End = lib.getArea(
        Area, Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End)
    Label2 = " - %s (lat:%0.1f,%0.1f, lon:%0.1f,%0.1f, depth:%0.1f-%0.1f)" % (
        lib.areaValues[Area], Latitude_Begin, Latitude_End, Longitude_Begin,
        Longitude_End, Depth_Begin, Depth_End)

    # make sure we have input files
    query = lib.earthquakeQuery % (Start_Time, Magnitude_Begin, Magnitude_End,
                                   Depth_Begin, Depth_End, Latitude_Begin,
                                   Latitude_End, Longitude_Begin,
                                   Longitude_End, Max_Count)
    if len(Alternate_FileName) <= 0:
        eqFile = lib.query2fileName(query, url=lib.earthquakeKeys[Data_Source])
        query = '?'.join([lib.earthquakeKeys[Data_Source], query])
        fileFound, address, source = lib.findFile(eqFile,
                                                  loc='EMC_EARTHQUAKES_PATH',
                                                  query=query)
    else:
        fileFound, address, source = lib.findFile(Alternate_FileName,
                                                  loc='EMC_EARTHQUAKES_PATH')
    if not fileFound:
        raise Exception(
            'earthquake catalog file "' + address +
            '" not found! Please provide the full path or UR for the file. Aborting.'
        )
    (params, lines) = lib.readGcsv(address)

    pdo = self.GetOutput()  # vtkPoints
    column_keys = lib.columnKeys
    for key in lib.columnKeys.keys():
        if key in params.keys():
            column_keys[key] = params[key]

    delimiter = params['delimiter'].strip()
    origin = None
    if 'source' in params:
        origin = params['source']
        Label = urlparse.urlparse(origin).netloc
    else:
        try:
            Label = urlparse.urlparse(Alternate_FileName).netloc
        except:
            Label = Alternate_FileName

    header = lines[0].strip()
    fields = header.split(delimiter)
    for i in range(len(fields)):
        if fields[i].strip().lower() == column_keys['longitude_column'].lower(
        ):
            lonIndex = i
        elif fields[i].strip().lower() == column_keys['latitude_column'].lower(
        ):
            latIndex = i
        elif fields[i].strip().lower() == column_keys['depth_column'].lower():
            depthIndex = i
        elif fields[i].strip().lower(
        ) == column_keys['magnitude_column'].lower():
            magIndex = i

    scalars = vtk.vtkFloatArray()
    scalars.SetNumberOfComponents(1)
    scalars.SetName("magnitude")
    lat = []
    lon = []
    depth = []
    mag = []

    for i in range(1, len(lines)):
        line = lines[i].strip()
        values = line.strip().split(params['delimiter'].strip())
        lat.append(float(values[latIndex]))
        lon.append(float(values[lonIndex]))
        depth.append(float(values[depthIndex]))
        mag.append(float(values[magIndex]))
        if lat[-1] >= Latitude_Begin and lat[-1] <= Latitude_End and lon[
                -1] >= Longitude_Begin and lon[-1] <= Longitude_End:
            x, y, z = lib.llz2xyz(lat[-1], lon[-1], depth[-1])
            pts.InsertNextPoint(x, y, z)
            scalars.InsertNextValue(mag[-1])
    pdo.SetPoints(pts)
    pdo.GetPointData().AddArray(scalars)

    if len(Label.strip()) > 0:
        simple.RenameSource(' '.join(
            ['Earthquake locations:', 'from',
             Label.strip(),
             Label2.strip()]))

    view = simple.GetActiveView()

    # store metadata
    fieldData = pdo.GetFieldData()
    fieldData.AllocateArrays(3)  # number of fields

    data = vtk.vtkFloatArray()
    data.SetName('Latitude\nRange (deg)')
    data.InsertNextValue(min(lat))
    data.InsertNextValue(max(lat))
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Longitude\nRange (deg)')
    data.InsertNextValue(min(lon))
    data.InsertNextValue(max(lon))
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Depth\nRange (km)')
    data.InsertNextValue(min(depth))
    data.InsertNextValue(max(depth))
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Magnitude\nRange')
    data.InsertNextValue(min(mag))
    data.InsertNextValue(max(mag))
    fieldData.AddArray(data)

    data = vtk.vtkIntArray()
    data.SetName('Max. Event\nCount')
    data.InsertNextValue(len(mag))
    fieldData.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('Start Date')
    data.InsertNextValue(Start_Time)
    fieldData.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('Source')
    if origin is not None:
        data.InsertNextValue(origin)

    data.InsertNextValue(source)
    fieldData.AddArray(data)

    pdo.SetFieldData(fieldData)
    # Double check and santize meshfilename
    root_ext = os.path.splitext(inputmeshfilename)
    if (len(root_ext) > 1):
        if ((root_ext[1] != '.exo') and (root_ext[1] != '.e')):
            print('Cannot load exo mesh from: %s' % inputmeshfilename,
                  file=sys.stderr)
            print('Possibly not an exodus file', file=sys.stderr)
            plotexomesh = False
    meshfilename = checkfilepath(fixslash(inputmeshfilename), basepath)
    if (not checkfileexists(meshfilename)):
        print('Cannot load exo mesh from: %s' % meshfilename, file=sys.stderr)
        plotexomesh = False
    if plotexomesh:
        print('Loading exo mesh from: %s' % meshfilename)
        meshexo = pvs.ExodusIIReader(FileName=[meshfilename])
        pvs.RenameSource(meshfilename, meshexo)

#plotdataprobes=True
if ((plotdataprobes) and ('data_probes' in data['realms'][0])):
    data_probe_specs = data['realms'][0]['data_probes']['specifications']
    # Stuff
    for spec in data_probe_specs:
        if 'plane_specifications' in spec:
            for plane in spec['plane_specifications']:
                name = plane['name']
                corner = np.array(plane['corner_coordinates'])
                edge1 = np.array(plane['edge1_vector'])
                edge2 = np.array(plane['edge2_vector'])
                Nx = plane['edge1_numPoints'] - 1
                Ny = plane['edge2_numPoints'] - 1
                offsetvec = np.array([0, 0, 0])
예제 #22
0
def RequestData():
    # R.0.2018.080
    import sys
    sys.path.insert(0, "EMC_SRC_PATH")
    import paraview.simple as simple
    import numpy as np
    import csv
    import os
    from vtk.util import numpy_support as nps
    import IrisEMC_Paraview_Lib as lib
    import urlparse

    Label = ''

    pts = vtk.vtkPoints()

    # make sure we have input files
    query = lib.volcanoLocationsQuery
    if len(Alternate_FileName) <= 0:
        volcanoFile = lib.query2fileName(query)
        query = '?'.join([lib.volcanoLocationsKeys[Data_Source], query])
        fileFound, address, source = lib.findFile(volcanoFile,
                                                  loc='EMC_VOLCANOES_PATH',
                                                  query=query)
        Label = ' '.join([
            lib.volcanoLocationsValues[Data_Source].strip(), 'from',
            urlparse.urlparse(
                lib.volcanoLocationsKeys[Data_Source]).netloc.strip()
        ])
    else:
        fileFound, address, source = lib.findFile(Alternate_FileName,
                                                  loc='EMC_VOLCANOES_PATH')

    if not fileFound:
        raise Exception(
            'volcano file "' + address +
            '" not found! Please provide the full path or UR for the file. Aborting.'
        )
    (params, lines) = lib.readGcsv(address)

    Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End = lib.getArea(
        Area, Latitude_Begin, Latitude_End, Longitude_Begin, Longitude_End)
    Label2 = " - %s (lat:%0.1f,%0.1f, lon:%0.1f,%0.1f)" % (
        lib.areaValues[Area], Latitude_Begin, Latitude_End, Longitude_Begin,
        Longitude_End)

    pdo = self.GetOutput()  # vtkPoints
    count = 0
    latIndex = 0
    lonIndex = 1

    column_keys = lib.columnKeys
    for key in lib.columnKeys.keys():
        if key in params.keys():
            column_keys[key] = params[key]

    delimiter = params['delimiter'].strip()

    origin = None
    if 'source' in params:
        origin = params['source']
        if len(Label.strip()) <= 0:
            Label = origin
    header = lines[0].strip()
    fields = header.split(delimiter)
    for i in range(len(fields)):
        if fields[i].strip().lower() == column_keys['longitude_column'].lower(
        ):
            lonIndex = i
        elif fields[i].strip().lower() == column_keys['latitude_column'].lower(
        ):
            latIndex = i
        elif fields[i].strip().lower(
        ) == column_keys['elevation_column'].lower():
            elevIndex = i
    for i in range(1, len(lines)):
        line = lines[i].strip()
        values = line.strip().split(params['delimiter'].strip())
        try:
            lat = float(values[latIndex])
            lon = float(values[lonIndex])
        except:
            continue
        if len(values[elevIndex].strip()) <= 0:
            depth = 0.0
        else:
            try:
                depth = -1 * float(values[elevIndex]) / 1000.0
            except:
                continue
        if lat >= Latitude_Begin and lat <= Latitude_End and lon >= Longitude_Begin and lon <= Longitude_End:
            x, y, z = lib.llz2xyz(lat, lon, depth)
            pts.InsertNextPoint(x, y, z)
    pdo.SetPoints(pts)

    done = False
    simple.RenameSource(' '.join(
        ['Volcano locations:',
         Label.strip(), Label2.strip()]))

    view = simple.GetActiveView()

    # store metadata
    fieldData = pdo.GetFieldData()
    fieldData.AllocateArrays(3)  # number of fields

    data = vtk.vtkFloatArray()
    data.SetName('Latitude\nRange (deg)')
    data.InsertNextValue(Latitude_Begin)
    data.InsertNextValue(Latitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkFloatArray()
    data.SetName('Longitude\nRange (deg)')
    data.InsertNextValue(Longitude_Begin)
    data.InsertNextValue(Longitude_End)
    fieldData.AddArray(data)

    data = vtk.vtkStringArray()
    data.SetName('Source')
    if origin is not None:
        data.InsertNextValue(origin)

    data.InsertNextValue(source)
    fieldData.AddArray(data)

    pdo.SetFieldData(fieldData)
def RequestData():
    # R.1.2018.354
    import sys
    sys.path.insert(0, "EMC_SRC_PATH")
    from operator import itemgetter
    from datetime import datetime
    import numpy as np
    from vtk.numpy_interface import dataset_adapter as dsa
    from vtk.util import numpy_support
    import IrisEMC_Paraview_Lib as lib
    import paraview.simple as simple

    views = simple.GetViews(viewtype="SpreadSheetView")
    if len(views) > 0:
        # set active view
        view = simple.SetActiveView(views[0])
    else:
        view = simple.GetActiveView()
        layout = simple.GetLayout(view)
        location_id = layout.SplitViewVertical(view=view, fraction=0.7)

    myId = simple.GetActiveSource().Input.GetGlobalIDAsString()

    proxies = simple.GetSources()
    proxyList = []
    for key in proxies:
        list_elt = dict()
        list_elt['name'] = key[0]
        list_elt['id'] = key[1]
        proxy = proxies[key]
        parent_id = '0'
        if hasattr(proxy, 'Input'):
            parent_id = proxy.Input.GetGlobalIDAsString()
        list_elt['parent'] = parent_id
        proxyList.append(list_elt)

    pdi = self.GetInput()  # VTK PolyData Type
    try:
        np = pdi.GetNumberOfPoints()
    except Exception:
        raise Exception('Invalid input!')

    na = pdi.GetPointData().GetNumberOfArrays()
    val_arrays = []
    for i in range(na):
        val_arrays.append(pdi.GetPointData().GetArray(i))

    latitude = {}
    longitude = {}
    value = {}
    depth = {}
    pdo = self.GetOutput()  # VTK Table Type
    poly_data = vtk.vtkPolyData()
    data_points = vtk.vtkPoints()

    if len(Label.strip()) <= 0:
        pid = simple.GetActiveSource().Input.GetGlobalIDAsString()
        proxies = simple.GetSources()
        for key in proxies:
            if key[1] == pid:
                Label = " ".join(["Coordinates:", key[0]])
                break
    for i in range(np):
        point = pdi.GetPoints().GetPoint(i)
        (lat, lon, this_depth) = lib.xyz2llz(point[0], point[1], point[2])
        data_points.InsertNextPoint((lat, lon, this_depth))
        key = "%0.2f" % this_depth
        if key not in list(latitude.keys()):
            latitude[key] = []
            longitude[key] = []
            value[key] = []

        # need to control precision to have a reasonable sort order
        # note that these coordinates are recomputed
        if key not in list(depth.keys()):
            depth[key] = float('%0.4f' % this_depth)
        latitude[key].append(float('%0.4f' % lat))
        longitude[key].append(float('%0.4f' % lon))
        value_array = []
        for j in range(na):
            value_array.append(float(val_arrays[j].GetTuple1(i)))
        value[key].append(value_array)

    # store boundary metadata
    field_data = poly_data.GetFieldData()
    field_data.AllocateArrays(5)  # number of fields

    depth_data = vtk.vtkFloatArray()
    depth_data.SetName('depth')

    lat_data = vtk.vtkFloatArray()
    lat_data.SetName('latitude')

    lon_data = vtk.vtkFloatArray()
    lon_data.SetName('longitude')

    val_data = []
    for j in range(na):
        val_data.append(vtk.vtkFloatArray())
        val_data[j].SetName('value(%s)' %
                            pdi.GetPointData().GetArray(j).GetName())

    depth_keys = list(latitude.keys())

    for i in range(len(depth_keys)):
        depth_key = depth_keys[i]
        lon_list = longitude[depth_key]
        lat_list = latitude[depth_key]
        val_list = value[depth_key]
        point_list = list(zip(lat_list, lon_list, val_list))
        point_list.sort(key=itemgetter(0, 1))

        for index, data in enumerate(point_list):
            depth_data.InsertNextValue(float(depth[depth_key]))
            lat_data.InsertNextValue(float(data[0]))
            lon_data.InsertNextValue(float(data[1]))
            for k in range(na):
                point_data = data[2]
                val_data[k].InsertNextValue(point_data[k])

    field_data.AddArray(lat_data)
    field_data.AddArray(lon_data)
    field_data.AddArray(depth_data)
    for j in range(na):
        field_data.AddArray(val_data[j])

    if len(Label.strip()) > 0:
        simple.RenameSource(Label)

    pdo.SetFieldData(field_data)