def _point_to_nhlib(src, mesh_spacing, bin_width):
    """Convert a NRML point 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) binwidth.
    :returns: The NHLib representation of the input source.
    """
    shapely_pt = wkt.loads(src.geometry.wkt)

    mf_dist = _mfd_to_nhlib(src.mfd, bin_width)

    # nodal plane distribution:
    npd = pmf.PMF(
        [(x.probability,
          geo.NodalPlane(strike=x.strike, dip=x.dip, rake=x.rake))
         for x in src.nodal_plane_dist]
    )

    # hypocentral depth distribution:
    hd = pmf.PMF([(x.probability, x.depth) for x in src.hypo_depth_dist])

    point = mtkPointSource(
        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,
        upper_seismogenic_depth=src.geometry.upper_seismo_depth,
        lower_seismogenic_depth=src.geometry.lower_seismo_depth,
        location=geo.Point(shapely_pt.x, shapely_pt.y),
        nodal_plane_distribution=npd,
        hypocenter_distribution=hd
    )

    return point
def _point_to_mtk(src):
    """Convert a NRML point source to the MTK Source Equivalent.

    See :mod:`nrml.models` and :mod:`nhlib.source`.

    :param src:
    :class:`nrml.models.PointSource` instance.
    """
    # Loads point geometry
    shapely_pt = wkt.loads(src.geometry.wkt)
    geometry_input = np.array([shapely_pt.x, shapely_pt.y])
    point = mtkPointSource(
        src.id, 
        src.name, 
        src.trt, 
        src.rupt_aspect_ratio,
        geometry_input,
        upper_depth = src.geometry.upper_seismo_depth,
        lower_depth=src.geometry.lower_seismo_depth)
    return point
Esempio n. 3
0
def _point_to_nhlib(src)
    """Convert a NRML point source to the MTK Source Equivalent.

    See :mod:`nrml.models` and :mod:`nhlib.source`.

    :param src:
    :class:`nrml.models.PointSource` instance.
    """
    # Loads point geometry
    shapely_pt = wkt.loads(src.geometry.wkt)
    geometry_input = np.array([shapely_pt.x, shapely_pt.y])
    point = mtkPointSource(
        src.id, 
        src.name, 
        src.trt, 
        src.rupt_aspect_ratio,
        geometry_input,
        upper_depth = src.geometry.upper_seismo_depth,
        lower_depth=src.geometry.lower_seismo_depth)
    return point
    
def _area_to_nhlib


#~ def _point_to_nhlib(src, mesh_spacing, bin_width):
    #~ """Convert a NRML point source to the NHLib equivalent.

    #~ See :mod:`nrml.models` and :mod:`nhlib.source`.

    #~ :param src:
    #~ :class:`nrml.models.PointSource` instance.