コード例 #1
0
 def _get_edge_set(self, tol=0.1):
     """
     Retrieve set of top edges from all of the individual surfaces,
     downsampling the upper edge based on the specified tolerance
     """
     edges = []
     for surface in self.surfaces:
         if isinstance(surface, GriddedSurface):
             return edges.append(surface.mesh)
         elif isinstance(surface, geo.surface.kite_fault.KiteSurface):
             # The downsample_trace function will be replaced by a more
             # appropriate function in a following PR
             lo, la = surface.get_tor()
             dep = numpy.tile(numpy.array([[0], [0.5]]), (1, len(lo)))
             mesh = RectangularMesh(numpy.tile(lo, (2, 1)),
                                    numpy.tile(la, (2, 1)), dep)
             edges.append(downsample_trace(mesh, tol))
         elif isinstance(surface, PlanarSurface):
             # Top edge determined from two end points
             edge = []
             for pnt in [surface.top_left, surface.top_right]:
                 edge.append([pnt.longitude, pnt.latitude, pnt.depth])
             edges.append(numpy.array(edge))
         elif isinstance(surface,
                         (ComplexFaultSurface, SimpleFaultSurface)):
             # Rectangular meshes are downsampled to reduce their
             # overall size
             edges.append(downsample_trace(surface.mesh, tol))
         else:
             raise ValueError(f"Surface {str(surface)} not recognised")
     return edges
コード例 #2
0
ファイル: multi.py プロジェクト: ARosemary/oq-engine
 def _get_edge_set(self, tol=0.1):
     """
     Retrieve set of top edges from all of the individual surfaces,
     downsampling the upper edge based on the specified tolerance
     """
     edges = []
     for surface in self.surfaces:
         if isinstance(
                 surface,
             (GriddedSurface, geo.surface.kite_fault.KiteSurface)):
             return edges.append(surface.mesh)
         elif isinstance(surface, PlanarSurface):
             # Top edge determined from two end points
             edge = []
             for pnt in [surface.top_left, surface.top_right]:
                 edge.append([pnt.longitude, pnt.latitude, pnt.depth])
             edges.append(numpy.array(edge))
         elif isinstance(surface,
                         (ComplexFaultSurface, SimpleFaultSurface)):
             # Rectangular meshes are downsampled to reduce their
             # overall size
             edges.append(downsample_trace(surface.mesh, tol))
         else:
             raise ValueError("Surface %s not recognised" % str(surface))
     return edges
コード例 #3
0
ファイル: gc2_test.py プロジェクト: maswiet/oq-engine
 def test_downsample_trace(self):
     # Use the simple fault case with a tolerance of 1.0 degree
     downsampled_trace = downsample_trace(SFLT1.mesh, 1.0)
     # Top edge of downsampled mesh should correspond to the five
     # points of the simple fault
     # Check longitudes
     numpy.testing.assert_array_almost_equal(downsampled_trace[:, 0],
                                             AS_ARRAY[:, 0], 5)
     # Check latitude
     numpy.testing.assert_array_almost_equal(downsampled_trace[:, 1],
                                             AS_ARRAY[:, 1], 5)
     # Check depths
     numpy.testing.assert_array_almost_equal(downsampled_trace[:, 2],
                                             AS_ARRAY[:, 2], 5)
コード例 #4
0
 def test_downsample_trace(self):
     # Use the simple fault case with a tolerance of 1.0 degree
     downsampled_trace = downsample_trace(SFLT1.mesh, 1.0)
     # Top edge of downsampled mesh should correspond to the five
     # points of the simple fault
     # Check longitudes
     numpy.testing.assert_array_almost_equal(downsampled_trace[:, 0],
                                             AS_ARRAY[:, 0],
                                             5)
     # Check latitude
     numpy.testing.assert_array_almost_equal(downsampled_trace[:, 1],
                                             AS_ARRAY[:, 1],
                                             5)
     # Check depths
     numpy.testing.assert_array_almost_equal(downsampled_trace[:, 2],
                                             AS_ARRAY[:, 2],
                                             5)
コード例 #5
0
 def _get_edge_set(self, tol=0.1):
     """
     Retrieve set of top edges from all of the individual surfaces,
     downsampling the upper edge based on the specified tolerance
     """
     edges = []
     for surface in self.surfaces:
         if isinstance(surface, GriddedSurface):
             return edges.append(surface.mesh)
         elif isinstance(surface, geo.surface.kite_fault.KiteSurface):
             edge = []
             mesh = surface.mesh
             lons = mesh.lons
             # We extract the top edge of the rupture from the
             # corresponding 2D mesh.
             # The calculation of indexes below is needed because we want
             # on each 'profile' of the mesh the uppermost node that is
             # finite (i.e. on the real grid)
             for icol in range(lons.shape[1]):
                 if numpy.all(numpy.isnan(lons[:, icol])):
                     continue
                 tmp = numpy.nonzero(numpy.isfinite(lons[:, icol]))[0]
                 irow = tmp.argmax(axis=0)
                 edge.append([
                     mesh.lons[irow, icol], mesh.lats[irow, icol],
                     mesh.depths[irow, icol]
                 ])
             edges.append(numpy.array(edge))
         elif isinstance(surface, PlanarSurface):
             # Top edge determined from two end points
             edge = []
             for pnt in [surface.top_left, surface.top_right]:
                 edge.append([pnt.longitude, pnt.latitude, pnt.depth])
             edges.append(numpy.array(edge))
         elif isinstance(surface,
                         (ComplexFaultSurface, SimpleFaultSurface)):
             # Rectangular meshes are downsampled to reduce their
             # overall size
             edges.append(downsample_trace(surface.mesh, tol))
         else:
             raise ValueError("Surface %s not recognised" % str(surface))
     return edges
コード例 #6
0
 def _get_edge_set(self, tol=0.1):
     """
     Retrieve set of top edges from all of the individual surfaces,
     downsampling the upper edge based on the specified tolerance
     """
     edges = []
     for surface in self.surfaces:
         if isinstance(surface, PlanarSurface):
             # Top edge determined from two end points
             edge = []
             for pnt in [surface.top_left, surface.top_right]:
                 edge.append([pnt.longitude, pnt.latitude, pnt.depth])
             edges.append(numpy.array(edge))
         elif isinstance(surface,
                         (ComplexFaultSurface, SimpleFaultSurface)):
             # Rectangular meshes are downsampled to reduce their
             # overall size
             edges.append(downsample_trace(surface.mesh, tol))
         else:
             raise ValueError("Surface %s not recognised" % str(surface))
     return edges