def make_rupture(self): # Create the rupture surface. upper_seismogenic_depth = 3. lower_seismogenic_depth = 15. dip = 90. mesh_spacing = 1. fault_trace_start = Point(28.531397, 40.8790859336) fault_trace_end = Point(28.85, 40.9) fault_trace = Line([fault_trace_start, fault_trace_end]) default_arguments = { 'mag': 6.5, 'rake': 180., 'tectonic_region_type': const.TRT.STABLE_CONTINENTAL, 'hypocenter': Point(28.709146553353872, 40.890863701462457, 11.0), 'surface': SimpleFaultSurface.from_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip=dip, mesh_spacing=mesh_spacing), 'rupture_slip_direction': 0., 'occurrence_rate': 0.01, 'temporal_occurrence_model': PoissonTOM(50) } kwargs = default_arguments rupture = ParametricProbabilisticRupture(**kwargs) return rupture
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 make_rupture(self): # Create the rupture surface. upper_seismogenic_depth = 3. lower_seismogenic_depth = 15. dip = 90. mesh_spacing = 1. fault_trace_start = Point(28.531397, 40.8790859336) fault_trace_end = Point(28.85, 40.9) fault_trace = Line([fault_trace_start, fault_trace_end]) default_arguments = { 'mag': 6.5, 'rake': 180., 'tectonic_region_type': const.TRT.STABLE_CONTINENTAL, 'hypocenter': Point(28.709146553353872, 40.890863701462457, 11.0), 'surface': SimpleFaultSurface.from_fault_data( fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip=dip, mesh_spacing=mesh_spacing), 'rupture_slip_direction': 0., 'occurrence_rate': 0.01, 'temporal_occurrence_model': PoissonTOM(50) } kwargs = default_arguments rupture = ParametricProbabilisticRupture(**kwargs) return rupture
def setUp(self): # Create surface trc = Line([Point(0.0, 0.0), Point(0.5, 0.0)]) usd = 0.0 lsd = 20.0 dip = 90.0 spc = 2.5 self.srfc1 = SFS.from_fault_data(trc, usd, lsd, dip, spc) # Create surface trc = Line([Point(0.0, 0.0), Point(0.5, 0.0)]) usd = 0.0 lsd = 20.0 dip = 20.0 spc = 2.5 self.srfc2 = SFS.from_fault_data(trc, usd, lsd, dip, spc)
def get_surface(self): hyp = Line([Point(0, 0.5)]) trc = Line([Point(0, 0), Point(0, 1)]) sfc = SimpleFaultSurface.from_fault_data(fault_trace=trc, upper_seismogenic_depth=0, lower_seismogenic_depth=15, dip=90., mesh_spacing=10.) return sfc, hyp
def get_surface(self): """ """ hyp = Line([Point(0, 0.5)]) trc = Line([Point(0, 0), Point(0, 1)]) sfc = SimpleFaultSurface.from_fault_data(fault_trace=trc, upper_seismogenic_depth=0, lower_seismogenic_depth=15, dip=90., mesh_spacing=10.) return sfc, hyp
def _get_mesh_ch_from_simple_fs(fault, mesh_spacing): """ :parameter fault: An instance of the :class:`openquake.hazardlib.source.CharacteristicFaultSource` :parameter float mesh_spacing: The spacing [km] of the grid used to represent the fault surface """ srfa = SimpleFaultSurface.from_fault_data(fault.fault_trace, fault.upper_seismogenic_depth, fault.lower_seismogenic_depth, fault.dip, mesh_spacing) mesh = srfa.mesh chul = mesh.get_convex_hull() return mesh, chul
def test01(self): source_id = name = 'test-source' trt = self.TRT rake = self.RAKE rupture_mesh_spacing = 2.5 upper_seismogenic_depth = 0 lower_seismogenic_depth = 4.2426406871192848 magnitude_scaling_relationship = PeerMSR() rupture_aspect_ratio = 2.0 tom = self.TOM fault_trace = Line([ Point(0.0, 0.0), Point(0.0, 0.0359728811758), Point(0.0190775080917, 0.0550503815181), Point(0.03974514139, 0.0723925718855) ]) mfd = TruncatedGRMFD(a_val=0.5, b_val=1.0, min_mag=5.8, max_mag=6.2, bin_width=0.1) floating_x_step = 10.0 floating_y_step = 5.0 dip = 90.0 src = KiteFaultSource.as_simple_fault( source_id, name, trt, mfd, rupture_mesh_spacing, magnitude_scaling_relationship, rupture_aspect_ratio, tom, upper_seismogenic_depth, lower_seismogenic_depth, fault_trace, dip, rake, floating_x_step, floating_y_step) sfs = SimpleFaultSurface.from_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip, rupture_mesh_spacing) msh = Mesh(lons=numpy.array([0.02]), lats=numpy.array([0.03]), depths=numpy.array([0.0])) rrup_sf = sfs.get_min_distance(msh) rrup_kf = src.surface.get_min_distance(msh) numpy.testing.assert_almost_equal(rrup_sf, rrup_kf, decimal=1) if MAKE_PICTURES: ppp(src.profiles, src.surface)
def get_areas(model): """ Get maximum magnitudes from MFDs :parameter model: A list of hazardlib source instances :returns: A list with the areas of each fault """ msp = 2 areas = [] for src in model: if isinstance(src, SimpleFaultSource): fault_surface = SimpleFaultSurface.from_fault_data( src.fault_trace, src.upper_seismogenic_depth, src.lower_seismogenic_depth, src.dip, msp) area = fault_surface.get_area() areas.append(area) return areas
def get_profiles_from_simple_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip, rupture_mesh_spacing): """ Using the same information used for the construction of a simple fault surface, creates a set of profiles that can be used to instantiate a kite surface. :param fault_trace: A :class:`openquake.hazardlib.geo.line.Line` instance :param upper_seismogenic_depth: The upper seismmogenic depth [km] :param lower_seismogenic_depth: The lower seismmogenic depth [km] :param dip: The dip angle [degrees] :param rupture_mesh_spacing: The size of the mesh used to represent the fault surface. In our case the spacing between profiles [km] """ # Avoids singularity if (dip - 90.) < 1e-5: dip = 89.9 # Get simple fault surface srfc = SimpleFaultSurface.from_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip, rupture_mesh_spacing * 1.01) # Creating profiles profiles = [] for i in range(srfc.mesh.shape[1]): tmp = [ Point(lo, la, de) for lo, la, de in zip(srfc.mesh.lons[:, i], srfc.mesh.lats[:, i], srfc.mesh.depths[:, i]) ] profiles.append(Line(tmp)) return profiles
def get_fault_sources(filename, slip_rate_class, bin_width=0.1, m_low=6.5, b_gr=1.0, rupture_mesh_spacing=2.0, upper_seismogenic_depth=0.0, lower_seismogenic_depth=10.0, msr=WC1994(), rupture_aspect_ratio=2.0, temporal_occurrence_model=PoissonTOM(1.0), aseismic_coeff=0.9, oqsource=False): """ :parameter filename: The name of the .geojson file with fault data :parameter slip_rate_class: TODO: so far works only for slip_rate_class = "suggested/preferred" """ logging.info('Reading %s and slip_type = %s' % (filename, slip_rate_class)) with open(filename, 'r') as data_file: data = json.load(data_file) print('---------------------------------------' '---------------------------------------') # Configuration parameters to create the sources # TODO: # use b_gr values from the area_sources and not a generic value # to test the whole processing # LOOP over the faults/traces srcl = [] for idf, feature in enumerate(data['features']): source_id = '{0:d}'.format(idf) tectonic_region_type = TRT.ACTIVE_SHALLOW_CRUST fs_name = '' ns_name = '' # get fault name[s] - id if feature['properties']['fs_name'] is not None: fs_name = feature['properties']['fs_name'] if feature['properties']['fs_name'] is not None: ns_name = feature['properties']['fs_name'] name = '{0:s} | {1:s}'.format(fs_name, ns_name) if 'ogc_fid' in feature['properties']: id_fault = feature['properties']['ogc_fid'] else: id_fault = '%d' % (idf) # get fault slip type if feature['properties']['slip_type'] is not None: slipt = feature['properties']['slip_type'] msg = 'Slip type value is [%s] for fault with name' % slipt msg += '%s and id %s' % (name, id_fault) logging.info(msg) else: msg = 'Slip type value is missing for fault with name' msg += '%s and id %s' % (name, id_fault) logging.warning(msg) # get dip direction if feature['properties']['ns_dip_dir'] is not None: dip_dir = feature['properties']['ns_dip_dir'] print("'dip_dir'= ", dip_dir) else: msg = 'Dip direction value is missing for fault with name' msg += '%s and id %s' % (name, id_fault) logging.warning(msg) # JUST FOR TESTING REASONS dip_dir = "N" print("dip_dir fazzula= ", dip_dir) # continue # Get the tuples dipt = get_tples(feature['properties']['ns_average_dip']) print("dipt= ", dipt) raket = get_tples(feature['properties']['ns_average_rake']) print("raket= ", raket) sliprt = get_tples(feature['properties']['ns_net_slip_rate']) print("sliprt= ", sliprt) shor_rd = get_tples(feature['properties']['ns_shortening_rate']) print("shortening_rate= ", shor_rd) vert_rd = get_tples(feature['properties']['ns_vert_slip_rate']) print("vertical_slip_rate= ", vert_rd) stk_rd = get_tples(feature['properties']['ns_strike_slip_rate']) print("strike_slip_rate= ", stk_rd) # Set the value to be used [suggested, min, max] if slip_rate_class is 'suggested': valid_dip = False # Dip values dip = dipt[0] if dip is not None: valid_dip = _is_valid_dip(dip) if valid_dip: print("Dip value = ", dip) msg = 'Dip value is [%s] for fault with name' % (dip) msg += '%s and id %s' % (name, id_fault) logging.info(msg) # if dip is None, but slip_type is available elif (dip) is None and (slipt) is not None: dip = get_dip_from_slip_type(slipt) print('Dip value for id= %s is missing and was computed using ' 'slipt= %s, new dip= %s ' % (id_fault, slipt, dip)) # if dip is None, but slip_type is available elif (dip) is None and (slipt) is None: msg = ('Dip value is missing and could not be computed for' ' fault with name ') msg += '%s and id %s' % (name, id_fault) logging.warning(msg) continue valid_rake = False # Rake values rake = raket[0] if rake is not None: valid_rake = _is_valid_rake(rake) if valid_rake: print("Rake value = ", dip) msg = 'Rake value is [%s] for fault with name' % rake msg += '%s and id %s' % (name, id_fault) logging.info(msg) # if rake is None, but slip_type is available elif (rake) is None and (slipt) is not None: rake = get_rake_from_rup_type(RAKE_CLASS, slipt) print('Rake value for id= %s is missing and was computed using' ' slipt= %s, new rake= %s ' % (id_fault, slipt, rake)) msg = ('Rake value is [%s] for slip_type= %s for fault with' ' name' % (rake, slipt)) msg += '%s and id %s' % (name, id_fault) logging.info(msg) # if rake and slip_type are not available elif (rake) is None and (slipt) is None: msg = ('Rake value is missing or could not be computed for' ' fault with name ') msg += '%s and id %s' % (name, id_fault) logging.warning(msg) continue # Slip rate values [shortening, vertical, strike_slip, net_slip] # If net_slip value is not available, a value is computed when # other component are present in the database slipr = sliprt[0] shor_rv = shor_rd[0] stk_rv = stk_rd[0] vert_rv = vert_rd[0] msg = ('slipr= %s, shor_rv= %s , stk_rv= %s, vert_rv= %s for' ' fault with name ' % (slipr, shor_rv, stk_rv, vert_rv)) msg += '%s and id %s' % (name, id_fault) logging.info(msg) if (slipr) is None and (shor_rv, stk_rv, vert_rv): print('slipr= %s' % slipr) print('shor_rv= %s , stk_rv= %s, vert_rv= %s ' % (shor_rv, stk_rv, vert_rv)) slipr = get_net_slip(dip, rake, shor_rv, stk_rv, vert_rv) if slipr is None: msg = 'net_slip value is missing or can not be computed' msg += 'for fault with name %s and id %s' % (name, id_fault) logging.warning(msg) continue # Finally the net_slip is penalized using the aseismic_coeff net_slip = aseismic_coeff * float(slipr) print('net_slip value for id= %s is net_slip= %s [slipr = %s] ' % (id_fault, net_slip, slipt)) msg = ('net_slip value [%.2f] computed for fault with name ' % (net_slip)) msg += ' %s and id %s' % (name, id_fault) logging.info(msg) elif slip_rate_class is 'min': # Dip values dip = dipt[1] if (dip) is None and (slipt): # MN: get_dip_from_slip_dir UNDEFINED, probably the # method name is changed dip = get_dip_from_slip_dir(slipt) print('Dip value for id= %s is missing and was computed using' ' slipt= %s, new dip= %s ' % (id_fault, slipt, dip)) else: msg = 'Dip value is missing for fault with name ' msg += '%s and id %s' % (name, id_fault) logging.warning(msg) # continue # Rake values rake = raket[1] if (rake) is None and (slipt): rake = get_rake_from_rup_type(RAKE_CLASS, slipt) print('Rake value for id= %s is missing and was computed using' ' slipt= %s, new rake= %s ' % (id_fault, slipt, rake)) else: msg = 'Rake value is missing for fault with name ' msg += '%s and id %s' % (name, id_fault) logging.warning(msg) # continue # Slip rate values [shortening, vertical, strike_slip, net_slip] # If net_slip value is not available, a value is computed when # other component are present in the database slipr = sliprt[1] shor_rd = shor_rv[1] stk_rd = stk_rv[1] vert_rv = vert_rd[1] if (slipr) is None and (shor_rv, stk_rv, vert_rv): slipr = get_net_slip(shor_rv, stk_rv, vert_rv) else: msg = 'net_slip value is missing or not can be computed' msg += 'for fault with name %s and id %s' % (name, id_fault) logging.warning(msg) continue # Finally the net_slip is penalized using the aseismic_coeff net_slip = aseismic_coeff * float(slipr) elif slip_rate_class is 'max': # Dip values dip = dipt[2] if (dip) is None and (slipt): # MN: get_dip_from_slip_dir undefined dip = get_dip_from_slip_dir(slipt) print('Dip value for id= %s is missing and was computed using ' 'slipt= %s, new dip= %s ' % (id_fault, slipt, dip)) else: msg = 'Dip value is missing for fault with name ' msg += '%s and id %s' % (name, id_fault) logging.warning(msg) # continue # Rake values rake = raket[2] if (rake) is None and (slipt): rake = get_rake_from_rup_type(RAKE_CLASS, slipt) print('Rake value for id= %s is missing and was computed ' 'using slipt= %s, new rake= %s ' % (id_fault, slipt, rake)) else: msg = 'Rake value is missing for fault with name ' msg += '%s and id %s' % (name, id_fault) logging.warning(msg) # continue # Slip rate values [shortening, vertical, strike_slip, net_slip] # If net_slip value is not available, a value is computed when # other component are present in the database slipr = sliprt[2] shor_rd = shor_rv[2] stk_rd = stk_rv[2] vert_rv = vert_rd[0] if (slipr) is None and (shor_rv, stk_rv, vert_rv): slipr = get_net_slip(shor_rv, stk_rv, vert_rv) else: msg = 'net_slip value is missing or not can be computed' msg += 'for fault with name %s and id %s' % (name, id_fault) logging.warning(msg) continue # Finally the net_slip is penalized using the aseismic_coeff net_slip = aseismic_coeff * float(slipr) else: raise ValueError('Invalid slip_rate_class') # Get fault trace geometry fault_trace = get_line(numpy.array(feature['geometry']['coordinates'])) # Get dip direction angle from literal and strike from trace geometry mean_az_from_trace = _get_mean_az_from_trace(fault_trace) valid_az = False valid_az = _is_valid_strike(mean_az_from_trace) if valid_az: # print("Mean azimuth value from trace = ", mean_az_from_trace) msg = ('Mean azimuth value is [%s] for fault with name' % (mean_az_from_trace)) msg += '%s and id %s' % (name, id_fault) logging.info(msg) dip_dir_angle = _get_dip_dir_from_literal(dip_dir) # Check if it's necessary to revert the fault trace if (dip_dir_angle is not None and _need_to_revert(mean_az_from_trace, dip_dir_angle)): new_fault_trace = _revert_fault_trace(fault_trace) logging.info('The fault trace for id= %s was reverted' % id_fault) else: new_fault_trace = fault_trace if new_fault_trace: fault_trace = new_fault_trace # Get L from srl - See Table 5 of Leonard 2010 # SRL: surface rupture length [km] # RLD: Subsurface horizontal rupture length [km] # IF SRL/RLD < 5. km the fault will be exclused srl = fault_trace.get_length() rld = 10**((numpy.log10(srl) + 0.275) / 1.1) if rld < 5.0: msg = 'SRL/RLD value is < 5.0 km for fault with name ' msg += '%s and id %s' % (name, id_fault) logging.warning(msg) continue # Witdh width, cl = get_width_from_length(rld, slipt) # print("id=, %s, srl=, %.2f, rld=, %.2f, width=, %.2f, # slipt=, %s, cl=,%s "%(id_fault, srl, rld, width, slipt,cl)) msg = ("id=, %s, srl=, %.2f, rld=, %.2f, width=, %.2f, slipt=, %s," " cl=,%s " % (id_fault, srl, rld, width, slipt, cl)) logging.info(msg) # Get lower seismogenic depth from length lsd = width * numpy.sin(numpy.radians(float(dip))) lower_seismogenic_depth = lsd # create the surface from fault data sfce = SimpleFaultSurface.from_fault_data(fault_trace, upper_seismogenic_depth, lower_seismogenic_depth, dip, rupture_mesh_spacing) # compute the area of the surface area = sfce.get_area() # compute the Mmax m_upp = msr.get_median_mag(sfce.get_area(), rake) if m_upp < m_low: msg = 'Mx [%.2f] is lesser than Mmin [%.2f] for fault with name '\ % (m_upp, m_low) msg += '%s and id %s' % (name, id_fault) logging.warning(msg) tstr = '%3s - %-40s %5.2f' % (id_fault, name, m_upp) logging.info(tstr) if net_slip is not None: slip_rate = net_slip print("slip_rate= ", slip_rate) else: continue # constrainig the computation # Mx > Mmin=m_low # slip_rate >= 1e-10 if slip_rate is not None and slip_rate >= 1e-10 and m_upp > m_low: # compute rates rates = rates_for_double_truncated_mfd(area, slip_rate, m_low, m_upp, b_gr, bin_width) # MFD mfd = EvenlyDiscretizedMFD(m_low + bin_width / 2, bin_width, rates) # Source if oqsource: src = SimpleFaultSource( source_id, name, tectonic_region_type, mfd, rupture_mesh_spacing, msr, rupture_aspect_ratio, temporal_occurrence_model, upper_seismogenic_depth, lower_seismogenic_depth, fault_trace, dip, rake) else: src = OQtSource(source_id, source_type='SimpleFaultSource') src.name = name src.tectonic_region_type = tectonic_region_type src.mfd = mfd src.rupture_mesh_spacing = rupture_mesh_spacing src.slip_rate = slip_rate src.msr = msr src.rupture_aspect_ratio = rupture_aspect_ratio src.temporal_occurrence_model = temporal_occurrence_model src.upper_seismogenic_depth = upper_seismogenic_depth src.lower_seismogenic_depth = lower_seismogenic_depth src.trace = fault_trace src.dip = dip src.rake = rake print('right') srcl.append(src) return srcl