def __init__(self, file_name_generator, data_to_probe, point_series,
              fields, time_to_write):
     """
     file_name_generator: the file name generator to use. Need to have ['phi', 'theta'] as keys.
     data_to_probe: Input data proxy to probe.
     point_series: Data structure providing the location to probe.
         [ { name: "Origin", probe: [ 0.0, 0.0, 0.0 ] },
           { name: "Center", probe: [ 100.0, 100.0, 100.0 ]},
           { name: "Random", probe: [ 3.0, 2.0, 1.0 ] } ]
     fields: Array containing the name of the scalar value to extract.
         [ 'temperature', 'salinity' ]
     time_to_write: Give the time when the TimeSerieDataProber should dump the data to disk
                    at a given UpdatePipeline(time=2345) call.
     """
     self.file_name_generator = file_name_generator
     self.data_proxy = data_to_probe
     self.fields = fields
     self.probe = simple.ProbeLocation(
         Input=data_to_probe, ProbeType="Fixed Radius Point Source")
     self.probe.SMProxy.InvokeEvent('UserEvent', 'HideWidget')
     self.location = self.probe.ProbeType
     self.location.NumberOfPoints = 1
     self.location.Radius = 0.0
     self.data_arrays = {}
     self.time_to_write = time_to_write
     self.serie_names = ['time']
     self.points = []
     for serie in point_series:
         self.serie_names.append(serie['name'])
         self.points.append(serie['probe'])
     for field in self.fields:
         self.data_arrays[field] = [self.serie_names]
Example #2
0
    def probe(self, variable, point):
        """Return the value of a variable at a given point.

        Args:
            variable (str): Name of the variable.
                Probing a vector return its magnitude.
                Components of the vector are available by adding a suffix
                ' X', ' Y' or ' Z' to the vector name.
                Physical coordinates are available under the name 'X', 'Y' or 'Z'.
            point (tuple): x, y and z coordinates.

        Returns:
            float: Queried value or None.
                None is returned if the variable does not exist or the point is not
                defined at the given point.
        """

        pvs.SetActiveSource(self.reader)
        prob_loc = pvs.ProbeLocation(ProbeType="Fixed Radius Point Source")
        prob_loc.ProbeType.Center = point
        array = _get_variable_array(prob_loc, variable)

        pvs.Delete(prob_loc)

        if array is None or len(array) == 0:
            return None
        elif len(array) != 1:
            raise Exception("Unexpected length of the array.")
        else:
            return array[0]
Example #3
0
    def get_probe_value(self, position):
        """
		Returns the value on the probe location.
		"""
        # Apply ProbeLocation filter with configruation found by ParaView Trace function
        probeLocation = pv.ProbeLocation(Input=self.vtk_data,
                                         ProbeType='Fixed Radius Point Source')
        self._filters += [probeLocation]
        probeLocation.ProbeType.Center = position

        local = pv.servermanager.Fetch(probeLocation)
        return local.GetPointData().GetScalars(cfg.coloring_name).GetValue(0)
 def __init__(self, file_name_generator, data_to_probe, points_series,
              fields):
     """
     file_name_generator: the file name generator to use. Need to have ['phi', 'theta'] as keys.
     data_to_probe: Input data proxy to probe.
     points_series: Data structure providing the location to probe.
         [ { name: "X_axis", probes: [ [0.0, 0.0, 0.0], [1.0, 0.0, 0.0], ... [100.0, 0.0, 0.0] ] },
           { name: "Y_axis", probes: [ [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], ... [0.0, 100.0, 0.0] ] },
           { name: "Random", probes: [ [0.0, 0.0, 0.0], [0.0, 2.0, 1.0], ... [0.0, 50.0, 100.0] ] } ]
     fields: Array containing the name of the scalar value to extract.
         [ 'temperature', 'salinity' ]
     """
     self.file_name_generator = file_name_generator
     self.data_proxy = data_to_probe
     self.series = points_series
     self.fields = fields
     self.probe = simple.ProbeLocation(
         Input=data_to_probe, ProbeType="Fixed Radius Point Source")
     self.probe.SMProxy.InvokeEvent('UserEvent', 'HideWidget')
     self.location = self.probe.ProbeType
     self.location.NumberOfPoints = 1
     self.location.Radius = 0.0
Example #5
0
    def get_grid_values(self, grid):
        gridValues = {}
        for key in grid:
            gridValues[key] = []

        subset = pv.ExtractSubset(Input=self.data)

        # TODO: This is currently hardcoded for the small grid.  Must make it dynamic.
        subset.VOI = [390, 425, 185, 225, 185, 225]

        probe = pv.ProbeLocation(Input=subset, ProbeType='Fixed Radius Point Source')
        probe.ProbeType.Radius = 0.0

        for key in grid:
            for pts in grid[key]:
                probe.ProbeType.Center = pts
                try:
                    value = pv.servermanager.Fetch(probe).GetPointData().GetAbstractArray('B').GetTuple(0)
                    gridValues[key].append(value)
                except:
                    print "Value not found for point: ", pts
                    sys.exit()

        return gridValues
Example #6
0
fname = os.getcwd() + '/' + filename[0]

extension = os.path.splitext(filename[0])[1]
if extension == '.vtk':
    solution = s.LegacyVTKReader(guiName="solution", FileNames=[fname])
elif extension == '.vtu':
    solution = s.XMLUnstructuredGridReader(guiName="solution",
                                           FileName=[fname])
else:
    print "= - Unknown file format of type: ", extension

for i in range(np.size(x)):
    temp = []
    ProbeLocation1 = []
    ProbeLocation1 = s.ProbeLocation(guiName="ProbeLocation1",
                                     ProbeType="Fixed Radius Point Source",
                                     Input=solution)
    ProbeLocation1.ProbeType.Center = [x[i], y[i], z[i]]
    temp = s.servermanager.Fetch(ProbeLocation1)
    for name in refResponses.iterkeys():
        if name == 'velocity_X':
            simResponses[name].append(
                temp.GetPointData().GetArray('velocity').GetValue(0))
        elif name == 'velocity_Y':
            simResponses[name].append(
                temp.GetPointData().GetArray('velocity').GetValue(1))
        elif name == 'velocity_Z':
            simResponses[name].append(
                temp.GetPointData().GetArray('velocity').GetValue(2))
        else:
            simResponses[name].append(