def _create_rupture(distance, magnitude, tectonic_region_type=TRT.ACTIVE_SHALLOW_CRUST): # Return a rupture with a fixed geometry located at a given r_jb distance # from a site located at (0.0, 0.0). # parameter float distance: # Joyner and Boore rupture-site distance # parameter float magnitude: # Rupture magnitude # Find the point at a given distance lonp, latp = point_at(0.0, 0.0, 90., distance) mag = magnitude rake = 0.0 tectonic_region_type = tectonic_region_type hypocenter = Point(lonp, latp, 2.5) surface = PlanarSurface.from_corner_points( Point(lonp, -1, 0.), Point(lonp, +1, 0.), Point(lonp, +1, 5.), Point(lonp, -1, 5.)) surface = SimpleFaultSurface.from_fault_data( fault_trace=Line([Point(lonp, -1), Point(lonp, 1)]), upper_seismogenic_depth=0.0, lower_seismogenic_depth=5.0, dip=90.0, mesh_spacing=1.0) # check effective rupture-site distance from openquake.hazardlib.geo.mesh import Mesh mesh = Mesh(numpy.array([0.0]), numpy.array([0.0])) assert abs(surface.get_joyner_boore_distance(mesh)-distance) < 1e-2 return BaseRupture(mag, rake, tectonic_region_type, hypocenter, surface, NonParametricSeismicSource)
def build_planar_surface(geometry): """ Builds the planar rupture surface from the openquake.nrmllib.models instance """ # Read geometry from wkt geom = wkt.loads(geometry.wkt) top_left = Point(geom.xy[0][0], geom.xy[1][0], geometry.upper_seismo_depth) top_right = Point(geom.xy[0][1], geom.xy[1][1], geometry.upper_seismo_depth) strike = top_left.azimuth(top_right) dip_dir = (strike + 90.) % 360. depth_diff = geometry.lower_seismo_depth - geometry.upper_seismo_depth bottom_right = top_right.point_at( depth_diff / np.tan(geometry.dip * (np.pi / 180.)), depth_diff, dip_dir) bottom_left = top_left.point_at( depth_diff / np.tan(geometry.dip * (np.pi / 180.)), depth_diff, dip_dir) return PlanarSurface(1.0, strike, geometry.dip, top_left, top_right, bottom_right, bottom_left)
def _create_rupture(distance, magnitude, tectonic_region_type=TRT.ACTIVE_SHALLOW_CRUST): # Return a rupture with a fixed geometry located at a given r_jb distance # from a site located at (0.0, 0.0). # parameter float distance: # Joyner and Boore rupture-site distance # parameter float magnitude: # Rupture magnitude # Find the point at a given distance lonp, latp = point_at(0.0, 0.0, 90., distance) mag = magnitude rake = 0.0 tectonic_region_type = tectonic_region_type hypocenter = Point(lonp, latp, 2.5) surface = PlanarSurface.from_corner_points( Point(lonp, -1, 0.), Point(lonp, +1, 0.), Point(lonp, +1, 5.), Point(lonp, -1, 5.)) surface = SimpleFaultSurface.from_fault_data( fault_trace=Line([Point(lonp, -1), Point(lonp, 1)]), upper_seismogenic_depth=0.0, lower_seismogenic_depth=5.0, dip=90.0, mesh_spacing=1.0) # check effective rupture-site distance from openquake.hazardlib.geo.mesh import Mesh mesh = Mesh(numpy.array([0.0]), numpy.array([0.0])) assert abs(surface.get_joyner_boore_distance(mesh)-distance) < 1e-2 return BaseRupture(mag, rake, tectonic_region_type, hypocenter, surface, NonParametricSeismicSource)
def from_csv(cls, fname): """ :param fname: path to a CSV file with header (lon, lat, dep) and 4 x P rows describing planes in terms of corner points in the order topleft, topright, bottomright, bottomleft :returns: a MultiSurface made of P planar surfaces """ surfaces = [] array = read_csv(fname).array.reshape(4, -1) # shape (4, P) for plane in array.T: arr = plane.view((float, 3)) # shape (4, 3) surfaces.append(PlanarSurface.from_ucerf(arr)) return cls(surfaces)
def _make_source(self): points = [Point(lon, lat, depth) for lon, lat, depth in zip(self.CORNER_LONS, self.CORNER_LATS, self.CORNER_DEPTHS)] source = CharacteristicFaultSource( source_id=self.SOURCE_ID, name=self.NAME, tectonic_region_type=self.TRT, mfd=EvenlyDiscretizedMFD(self.MIN_MAG, self.BIN_WIDTH, self.RATES), temporal_occurrence_model=self.TOM, surface=PlanarSurface(self.STRIKE, self.DIP, points[0], points[1], points[3], points[2]), rake=self.RAKE ) assert_pickleable(source) return source
def test_modify_set_geometry(self): new_corner_lons = numpy.array([-1.1, 1.1, -1.1, 1.1]) new_corner_lats = numpy.array([0., 0., 0., 0.]) new_corner_depths = numpy.array([0., 0., 15., 15.]) points = [Point(lon, lat, depth) for lon, lat, depth in zip(new_corner_lons, new_corner_lats, new_corner_depths)] new_surface = PlanarSurface(self.STRIKE, self.DIP, points[0], points[1], points[3], points[2]) self.fault.modify_set_geometry(new_surface, "XYZ") self.assertEqual(self.fault.surface_node, "XYZ") numpy.testing.assert_array_almost_equal(self.fault.surface.corner_lons, new_corner_lons) numpy.testing.assert_array_almost_equal(self.fault.surface.corner_lats, new_corner_lats) numpy.testing.assert_array_almost_equal( self.fault.surface.corner_depths, new_corner_depths)
def make_aftershock_surface(aft_d, scale_relationship=WC1994, mesh_spacing=2.): rupture_area = scale_relationship().get_median_area( aft_d['Mw'], aft_d['rake']) length = (rupture_area * aft_d['aspect_ratio'])**0.5 width = length / aft_d['aspect_ratio'] mid_upper_lon, mid_upper_lat = point_at( aft_d['lon'], aft_d['lat'], aft_d['strike'] - 90, width * np.sin(np.radians(aft_d['dip']))) mid_lower_lon, mid_lower_lat = point_at( aft_d['lon'], aft_d['lat'], aft_d['strike'] + 90, width * np.sin(np.radians(aft_d['dip']))) ul_lon, ul_lat = point_at(mid_upper_lon, mid_upper_lat, aft_d['strike'] - 180, length / 2) ur_lon, ur_lat = point_at(mid_upper_lon, mid_upper_lat, aft_d['strike'], length / 2) ll_lon, ll_lat = point_at(mid_upper_lon, mid_upper_lat, aft_d['strike'] - 180, length / 2) lr_lon, lr_lat = point_at(mid_upper_lon, mid_upper_lat, aft_d['strike'], length / 2) upper_surface_depth = (aft_d['depth'] - width * np.cos(np.radians(aft_d['dip']))) if upper_surface_depth < 0: upper_surface_depth = 0. lower_surface_depth = (aft_d['depth'] + width * np.cos(np.radians(aft_d['dip']))) ul_corner = Point(ul_lon, ul_lat, upper_surface_depth) ll_corner = Point(ll_lon, ll_lat, lower_surface_depth) ur_corner = Point(ur_lon, ur_lat, upper_surface_depth) lr_corner = Point(lr_lon, lr_lat, lower_surface_depth) return PlanarSurface.from_corner_points(mesh_spacing, ul_corner, ur_corner, lr_corner, ll_corner)