def RequestData(): from PVGPpy.filt import correlateArrays import PVGPpy.helpers as inputhelp # Get input/output of Proxy pdi = self.GetInput() pdo = self.GetOutput() # Grab input arrays to process from drop down menus # Simply grab the name and field association name0 = inputhelp.getSelectedArrayName(self, 0) field0 = inputhelp.getSelectedArrayField(self, 0) name1 = inputhelp.getSelectedArrayName(self, 1) field1 = inputhelp.getSelectedArrayField(self, 1) # Pass array names and associations on to process correlateArrays(pdi, (name0, field0), (name1, field1), multiplier=Multiplier, newName=New_Array_Name, pdo=pdo)
def RequestData(): from PVGPpy.filt import latLonTableToCartesian import PVGPpy.helpers as inputhelp # Get input/output of Proxy pdi = self.GetInput() pdo = self.GetOutput() # Grab input arrays to process from drop down menus # Simply grab the name and field association namelat = inputhelp.getSelectedArrayName(self, 0) fieldlat = inputhelp.getSelectedArrayField(self, 0) namelon = inputhelp.getSelectedArrayName(self, 1) fieldlon = inputhelp.getSelectedArrayField(self, 1) namealt = inputhelp.getSelectedArrayName(self, 2) fieldalt = inputhelp.getSelectedArrayField(self, 2) # Pass on to do conversion latLonTableToCartesian(pdi, (namelat, fieldlat), (namelon, fieldlon), (namealt, fieldalt), radius=Radius, pdo=pdo)
def RequestData(self): from vtk.util import numpy_support as nps import PVGPpy.helpers as inputhelp pdi = self.GetInput() # VTK Data Type pdo = self.GetOutput() # VTK Data Type # Get input array info (selection made in drop down menu) name = inputhelp.getSelectedArrayName(self, 0) field = inputhelp.getSelectedArrayField(self, 0) if test_bool: print(name) else: print(field)
def RequestData(): from PVGPpy.filt import normalizeArray import PVGPpy.helpers as inputhelp # Choose range to use: if Use_Range: rng = Range else: rng = None # Get input/output of Proxy pdi = self.GetInput() pdo = self.GetOutput() # Grab input arrays to process from drop down menus # Simply grab the name and field association name = inputhelp.getSelectedArrayName(self, 0) field = inputhelp.getSelectedArrayField(self, 0) # Perfrom normalization normalizeArray(pdi, (name,field), Normalization, multiplier=Multiplier, newName=New_Array_Name, pdo=pdo, abs=Absolute_Value, rng=rng)
def RequestData(): import numpy as np from vtk.numpy_interface import dataset_adapter as dsa import PVGPpy.helpers as inputhelp from PVGPpy.filt import pointsToTube # Get input/output of Proxy pdi = self.GetInput() pdo = self.GetOutput() # Grab input arrays to process from drop down menus #- Grab all fields for input arrays: fields = [] for i in range(3): fields.append(inputhelp.getSelectedArrayField(self, i)) #- Simply grab the names names = [] for i in range(9): names.append(inputhelp.getSelectedArrayName(self, i)) # Pass array names and associations on to process # Get the input arrays wpdi = dsa.WrapDataObject(pdi) arrs = [] for i in range(9): arrs.append(inputhelp.getArray(wpdi, fields[i], names[i])) # grab coordinates for each part of boring machine at time idx as row executive = self.GetExecutive() outInfo = executive.GetOutputInformation(0) idx = int(outInfo.Get(executive.UPDATE_TIME_STEP()) / dt) pts = [] for i in range(3): x = arrs[i * 3][idx] y = arrs[i * 3 + 1][idx] z = arrs[i * 3 + 2][idx] pts.append((x, y, z)) # now exectute a points to tube filter vtk_pts = vtk.vtkPoints() for i in range(len(pts)): vtk_pts.InsertNextPoint(pts[i][0], pts[i][1], pts[i][2]) poly = vtk.vtkPolyData() poly.SetPoints(vtk_pts) pointsToTube(poly, radius=Diameter / 2, numSides=20, nrNbr=False, pdo=pdo)
def RequestInformation(self): from vtk.numpy_interface import dataset_adapter as dsa import PVGPpy.helpers as inputhelp import numpy as np executive = self.GetExecutive() outInfo = executive.GetOutputInformation(0) pdi = self.GetInput() # Calculate list of timesteps here #- Get status array field = inputhelp.getSelectedArrayField(self, 3) name = inputhelp.getSelectedArrayName(self, 3) wpdi = dsa.WrapDataObject(pdi) statarr = inputhelp.getArray(wpdi, field, name) idcs = np.where(statarr == 2)[0] #- Get number of rows in table and use that for num time steps xtime = np.arange(0,len(idcs)*dt,dt, dtype=float) outInfo.Remove(executive.TIME_STEPS()) for i in range(len(xtime)): outInfo.Append(executive.TIME_STEPS(), xtime[i]) # Remove and set time range info outInfo.Remove(executive.TIME_RANGE()) outInfo.Append(executive.TIME_RANGE(), xtime[0]) outInfo.Append(executive.TIME_RANGE(), xtime[-1])
def RequestData(): import numpy as np from vtk.numpy_interface import dataset_adapter as dsa import PVGPpy.helpers as inputhelp from PVGPpy.filt import pointsToTube # Get input/output of Proxy pdi = self.GetInput() pdo = self.GetOutput() # Grab input arrays to process from drop down menus #- Grab all fields for input arrays: fields = [] for i in range(4): fields.append(inputhelp.getSelectedArrayField(self, i)) #- Simply grab the names names = [] for i in range(4): names.append(inputhelp.getSelectedArrayName(self, i)) # Pass array names and associations on to process # Get the input arrays wpdi = dsa.WrapDataObject(pdi) arrs = [] for i in range(4): arrs.append(inputhelp.getArray(wpdi, fields[i], names[i])) # Get indices for TimeSteps idcs = np.where(arrs[3] == 2)[0] # grab coordinates for each part of boring machine at time idx as row executive = self.GetExecutive() outInfo = executive.GetOutputInformation(0) idx = int(outInfo.Get(executive.UPDATE_TIME_STEP())/dt) index = idcs[idx] x = arrs[0][index] y = arrs[1][index] z = arrs[2][index] center = (x,y,z) pts = [] # now compute unit vector. def unitVec(s, g): # Direction Vector: Vector points from receiver to source vec = (s[0]-g[0], s[1]-g[1], s[2]-g[2]) # Total spatial distance: dist = np.sqrt(vec[0]**2 + vec[1]**2 + vec[2]**2) # Get unit vector for direction return (vec[0]/dist, vec[1]/dist, vec[2]/dist) if idx == (len(idcs) - 1): # use vect between current and last different points iii = 1 for i in range(1,idx): if arrs[0][idcs[idx-i]] != x or arrs[1][idcs[idx-i]] != y or arrs[2][idcs[idx-i]] != z: iii = i break index = idcs[idx-iii] vec = unitVec((arrs[0][index],arrs[1][index],arrs[2][index]), center) else: # get vector from current point to next different point. iii = 1 for i in range(1,len(idcs)-idx): if arrs[0][idcs[idx+i]] != x or arrs[1][idcs[idx+i]] != y or arrs[2][idcs[idx+i]] != z: iii = i break index = idcs[idx+iii] vec = unitVec(center, (arrs[0][index],arrs[1][index],arrs[2][index])) # Generate two more points Length/2 away in pos/neg unit vector direction def genPts(vec, c, l): """Generates two points l dist away from c in direction vec""" x1 = c[0] - (vec[0] * l) y1 = c[1] - (vec[1] * l) z1 = c[2] - (vec[2] * l) x2 = c[0] + (vec[0] * l) y2 = c[1] + (vec[1] * l) z2 = c[2] + (vec[2] * l) return ((x1,y1,z1), (x2,y2,z2)) # append the points and done. 3 points total add = genPts(vec, center, Length/2) #- append neg first pts.append(add[0]) #- append center pts.append(center) #- append pos last pts.append(add[1]) # Generate tube: vtk_pts = vtk.vtkPoints() for i in range(len(pts)): vtk_pts.InsertNextPoint(pts[i][0],pts[i][1],pts[i][2]) poly = vtk.vtkPolyData() poly.SetPoints(vtk_pts) pointsToTube(poly, radius=Diameter/2, numSides=20, nrNbr=False, pdo=pdo)