def _complex_to_mtk(src, fault_mesh_spacing=1.0): """Convert a NRML complex fault source to the MTK equivalent. See :mod:`nrml.models` and :mod:`nhlib.source`. :param src: :class:`nrml.models.ComplexFaultSource` instance. :param float mesh_spacing: Rupture mesh spacing, in km. :returns: The NHLib representation of the input source. """ # Parse geometry - top edge input_geometry = [_line_wkt_to_array(src.geometry.top_edge_wkt)] if src.geometry.int_edges: # Source has intermediate edges for edge in src.geometry.int_edges: #int_edge = wkt.loads(edge) input_geometry.append( _line_wkt_to_array(edge)) # Parse bottom edge input_geometry.append( _line_wkt_to_array(src.geometry.bottom_edge_wkt)) #print input_geometry complex_fault = mtkComplexFaultSource( src.id, src.name, src.trt, src.rupt_aspect_ratio, input_geometry, mesh_spacing = fault_mesh_spacing) return complex_fault
def _complex_to_nhlib(src, mesh_spacing, bin_width): """Convert a NRML complex fault source to the NHLib equivalent. See :mod:`nrml.models` and :mod:`nhlib.source`. :param src: :class:`nrml.models.PointSource` instance. :param float mesh_spacing: Rupture mesh spacing, in km. :param float bin_width: Truncated Gutenberg-Richter MFD (Magnitude Frequency Distribution) bin width. :returns: The NHLib representation of the input source. """ edges_wkt = [] edges_wkt.append(src.geometry.top_edge_wkt) edges_wkt.extend(src.geometry.int_edges) edges_wkt.append(src.geometry.bottom_edge_wkt) edges = [] for edge in edges_wkt: shapely_line = wkt.loads(edge) line = geo.Line([geo.Point(*x) for x in shapely_line.coords]) edges.append(line) mf_dist = _mfd_to_nhlib(src.mfd, bin_width) cmplx = mtkComplexFaultSource( source_id=src.id, name=src.name, tectonic_region_type=src.trt, mfd=mf_dist, rupture_mesh_spacing=mesh_spacing, magnitude_scaling_relationship=_SCALE_REL_MAP[src.mag_scale_rel](), rupture_aspect_ratio=src.rupt_aspect_ratio, edges=edges, rake=src.rake ) return cmplx