Пример #1
0
  def read(self, filename):

    reader = VTKDataReader()
    data = reader.read(filename)

    cells = data['cells']
    vertices = data['vertices']

    (ncells, ncorners) = cells.shape
    (nvertices, spaceDim) = vertices.shape
    
    vtkData = tvtk.UnstructuredGrid()
    vtkData.points = vertices
    assert(spaceDim == 3)
    assert(ncorners == 3)
    cellType = tvtk.Triangle().cell_type

    vtkData.set_cells(cellType, cells)


    # Displacement vector
    displacement = data['vertex_fields']['displacement']
    array = tvtk.FloatArray()
    array.from_array(displacement.squeeze())
    array.name = "Displacement (m)"
    vtkData.point_data.vectors = array
    vtkData.point_data.vectors.name = "Displacement (m)"

    # Compute velocity magnitude
    velocity = data['vertex_fields']['velocity']
    velocityLog = ((velocity[:,0]**2 + 
                    velocity[:,1]**2 + 
                    velocity[:,2]**2)**0.5)
    array = tvtk.FloatArray()
    array.from_array(velocityLog.squeeze())
    array.name = "Velocity (m/s)"
    vtkData.point_data.scalars = array
    vtkData.point_data.scalars.name = "Velocity (m/s)"

    return vtkData
Пример #2
0
    def read(self, filename):

        reader = VTKDataReader()
        data = reader.read(filename)

        cells = data["cells"]
        vertices = data["vertices"]

        (ncells, ncorners) = cells.shape
        (nvertices, spaceDim) = vertices.shape

        vtkData = tvtk.UnstructuredGrid()
        vtkData.points = vertices
        assert spaceDim == 3
        assert ncorners == 3
        cellType = tvtk.Triangle().cell_type

        vtkData.set_cells(cellType, cells)

        # Displacement vector
        displacement = data["vertex_fields"]["displacement"]
        array = tvtk.FloatArray()
        array.from_array(displacement.squeeze())
        array.name = "Displacement (m)"
        vtkData.point_data.vectors = array
        vtkData.point_data.vectors.name = "Displacement (m)"

        # Compute velocity magnitude
        velocity = data["vertex_fields"]["velocity"]
        velocityLog = (velocity[:, 0] ** 2 + velocity[:, 1] ** 2 + velocity[:, 2] ** 2) ** 0.5
        array = tvtk.FloatArray()
        array.from_array(velocityLog.squeeze())
        array.name = "Velocity (m/s)"
        vtkData.point_data.scalars = array
        vtkData.point_data.scalars.name = "Velocity (m/s)"

        return vtkData
Пример #3
0
# ----------------------------------------------------------------------
def feq(a, b):
    if numpy.abs(a - b) < 0.0001:
        return 1
    else:
        return 0


# ----------------------------------------------------------------------
# Extract On Fault stations data ( Slip, Slip Rate, Tractions )
# ----------------------------------------------------------------------
nfileNames = numpy.arange(1, 1201, 5)
filename = "%s-fault_t%04d.vtk" % (outputRoot, nfileNames[0])
fieldNames = ["slip", "slip_rate", "traction"]
reader = VTKDataReader()
data = reader.read(filename)
values = numpy.array(data['vertices'])
(nvertices, spaceDim) = values.shape

x_OnFltStat = numpy.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
y_OnFltStat = numpy.array(
    [-12000.0, -7600.0, -4400.0, 0.0, 4400.0, 7600.0,
     12000.0])  # CHECK THESE VALUES
Index_OnFltStat = numpy.zeros(7)

# Find the indices of On Fault Stations
nFltStat = -1
for i in xrange(nvertices):
    if feq(values[i,1],y_OnFltStat[0]) or \
       feq(values[i,1],y_OnFltStat[1]) or \
Пример #4
0
from numpy import *

# ----------------------------------------------------------------------
def feq(a,b):
    if numpy.abs(a-b)<0.0001:
        return 1
    else:
        return 0

# ----------------------------------------------------------------------
# Extract On Fault stations data ( Slip, Slip Rate, Tractions )
# ----------------------------------------------------------------------
nfileNames = numpy.arange(1,1201,5)
filename = "%s-fault_t%04d.vtk" % (outputRoot,nfileNames[0])
fieldNames = ["slip","slip_rate","traction"]
reader = VTKDataReader()
data = reader.read(filename)
values = numpy.array(data['vertices'])
(nvertices, spaceDim) = values.shape

x_OnFltStat = numpy.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
y_OnFltStat = numpy.array([-12000.0, -7600.0, -4400.0, 0.0, 4400.0, 7600.0, 12000.0]) # CHECK THESE VALUES
Index_OnFltStat = numpy.zeros(7)

# Find the indices of On Fault Stations
nFltStat = -1
for i in xrange(nvertices):
    if feq(values[i,1],y_OnFltStat[0]) or \
       feq(values[i,1],y_OnFltStat[1]) or \
       feq(values[i,1],y_OnFltStat[2]) or \
       feq(values[i,1],y_OnFltStat[3]) or \