예제 #1
0
 def _expected_char_multi(self):
     tgr_mfd = mfd.TruncatedGRMFD(
         a_val=-3.6, b_val=1.0, min_mag=5.2, max_mag=6.4, bin_width=1.0)
     surfaces = [
         geo.PlanarSurface(
             strike=89.98254582,
             dip=9.696547068,
             top_left=geo.Point(-1, 1, 21),
             top_right=geo.Point(1, 1, 21),
             bottom_left=geo.Point(-1, -1, 59),
             bottom_right=geo.Point(1, -1, 59)
         ),
         geo.PlanarSurface(
             strike=89.98254582,
             dip=15.0987061388,
             top_left=geo.Point(1, 1, 20),
             top_right=geo.Point(3, 1, 20),
             bottom_left=geo.Point(1, -1, 80),
             bottom_right=geo.Point(3, -1, 80))]
     multi_surface = geo.MultiSurface(surfaces)
     char = source.CharacteristicFaultSource(
         source_id="7",
         name="characteristic source, multi surface",
         tectonic_region_type="Volcanic",
         mfd=tgr_mfd,
         surface=multi_surface,
         rake=90.0,
         temporal_occurrence_model=PoissonTOM(50.0))
     char.num_ruptures = char.count_ruptures()
     return char
예제 #2
0
    def _expected_char_multi(self):
        tgr_mfd = mfd.TruncatedGRMFD(a_val=-3.6,
                                     b_val=1.0,
                                     min_mag=5.2,
                                     max_mag=6.4,
                                     bin_width=1.0)

        surfaces = [
            geo.PlanarSurface(mesh_spacing=MESH_SPACING,
                              strike=0.0,
                              dip=90.0,
                              top_left=geo.Point(-1, 1, 21),
                              top_right=geo.Point(1, 1, 21),
                              bottom_left=geo.Point(-1, -1, 59),
                              bottom_right=geo.Point(1, -1, 59)),
            geo.PlanarSurface(mesh_spacing=MESH_SPACING,
                              strike=20.0,
                              dip=45.0,
                              top_left=geo.Point(1, 1, 20),
                              top_right=geo.Point(3, 1, 20),
                              bottom_left=geo.Point(1, -1, 80),
                              bottom_right=geo.Point(3, -1, 80))
        ]
        multi_surface = geo.MultiSurface(surfaces)

        char = source.CharacteristicFaultSource(
            source_id="7",
            name="characteristic source, multi surface",
            tectonic_region_type="Volcanic",
            mfd=tgr_mfd,
            surface=multi_surface,
            rake=90.0)
        return char
예제 #3
0
def _characteristic_to_hazardlib(src, mesh_spacing, bin_width):
    """
    Convert a NRML characteristic fault source to the HazardLib equivalent.

    The surface of a characteristic fault source can be one of the following:
        * simple fault
        * complex fault
        * one or more planar surfaces

    See :mod:`openquake.nrmllib.models` and :mod:`openquake.hazardlib.source`.

    :param src:
        :class:`openquake.nrmllib.models.CharacteristicSource` 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 HazardLib representation of the input source.
    """
    mf_dist = _mfd_to_hazardlib(src.mfd, bin_width)

    if isinstance(src.surface, nrml_models.SimpleFaultGeometry):
        shapely_line = wkt.loads(src.surface.wkt)
        fault_trace = geo.Line([geo.Point(*x) for x in shapely_line.coords])

        surface = geo.SimpleFaultSurface.from_fault_data(
            fault_trace, src.surface.upper_seismo_depth,
            src.surface.lower_seismo_depth, src.surface.dip, mesh_spacing)
    elif isinstance(src.surface, nrml_models.ComplexFaultGeometry):
        edges_wkt = []
        edges_wkt.append(src.surface.top_edge_wkt)
        edges_wkt.extend(src.surface.int_edges)
        edges_wkt.append(src.surface.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)

        surface = geo.ComplexFaultSurface.from_fault_data(edges, mesh_spacing)
    else:
        # A collection of planar surfaces
        planar_surfaces = []
        for planar_surface in src.surface:
            kwargs = planar_surface.__dict__
            kwargs.update(dict(mesh_spacing=mesh_spacing))

            planar_surfaces.append(geo.PlanarSurface(**kwargs))

        surface = geo.MultiSurface(planar_surfaces)

    char = source.CharacteristicFaultSource(source_id=src.id,
                                            name=src.name,
                                            tectonic_region_type=src.trt,
                                            mfd=mf_dist,
                                            surface=surface,
                                            rake=src.rake)
    return char