Ejemplo n.º 1
0
def create_nrml_source(rup, mag, sid, name, tectonic_region_type):
    """
    :param rup:
    :param mag:
    :param sid:
    :param name:
    :param tectonic_region_type:
    """
    data = []
    for key in rup.keys():
        d = rup[key][:]
        #
        # creating the surface
        llo = np.squeeze(d['lons'])
        lla = np.squeeze(d['lats'])
        lde = np.squeeze(d['deps'])
        #
        # find a node in the middle of the rupture
        if len(llo.shape):
            ihyp = (int(np.round(llo.shape[0] / 2)))
            if len(llo.shape) > 1:
                ihyp = (ihyp, int(np.round(llo.shape[1] / 2)))
            hlo = llo[ihyp]
            hla = lla[ihyp]
            hde = lde[ihyp]
            #
            #
            ppp = np.squeeze(d['prbs'])
            i = np.isfinite(llo)
            points = [
                Point(x, y, z) for x, y, z in zip(llo[i], lla[i], lde[i])
            ]
            srf = GriddedSurface.from_points_list(points)
            """
            br = BaseRupture(mag=mag,
                             rake=-90.,
                             tectonic_region_type=tectonic_region_type,
                             hypocenter=Point(hlo, hla, hde),
                             surface=srf,
                             source_typology=NonParametricSeismicSource)
            """
            br = BaseRupture(mag=mag,
                             rake=-90.,
                             tectonic_region_type=tectonic_region_type,
                             hypocenter=Point(hlo, hla, hde),
                             surface=srf)
            xxx = Decimal('{:.8f}'.format(ppp[1]))
            pmf = PMF(data=[((Decimal('1') - xxx), 0), (xxx, 1)])
            data.append((br, pmf))
    src = NonParametricSeismicSource(sid, name, tectonic_region_type, data)
    return src
Ejemplo n.º 2
0
def create_source(rup, mag, sid, name, tectonic_region_type):
    """
    :param rup:
        A h5py dataset with the rupture information
    :param mag:
        The magnitude of the ruptures
    :param sid:
        Source ID
    :param name:
        Name of the source
    :param tectonic_region_type:
        Tectonic region type
    """
    data = []
    for key in rup.keys():
        d = rup[key][:]

        # Creating the surface
        llo = np.squeeze(d['lons'])
        lla = np.squeeze(d['lats'])
        lde = np.squeeze(d['deps'])

        # Create the gridded surface
        if len(llo.shape) > 0:

            # Hypocenter computed in the 'rupture.py' module
            hypo = np.squeeze(d['hypo'][:])
            hlo = hypo[0]
            hla = hypo[1]
            hde = hypo[2]

            # Probabilities of occurrence
            ppp = np.squeeze(d['prbs'])
            i = np.isfinite(llo)
            points = [Point(x, y, z) for x, y, z in
                      zip(llo[i], lla[i], lde[i])]

            # Create the surface and the rupture
            srf = GriddedSurface.from_points_list(points)
            brup = BaseRupture(mag=mag, rake=-90.,
                               tectonic_region_type=tectonic_region_type,
                               hypocenter=Point(hlo, hla, hde),
                               surface=srf)
            xxx = Decimal('{:.8f}'.format(ppp[1]))
            pmf = PMF(data=[((Decimal('1')-xxx), 0), (xxx, 1)])
            data.append((brup, pmf))
    src = NonParametricSeismicSource(sid, name, tectonic_region_type, data)
    return src
Ejemplo n.º 3
0
 def setUp(self):
     self.surf = GriddedSurface.from_points_list(POINTSIDL)
     self.mesh = Mesh(np.array([-179.5]), np.array([2.]), np.array([3.]))
Ejemplo n.º 4
0
 def setUp(self):
     self.surf = GriddedSurface.from_points_list(POINTS)
     self.mesh = Mesh(np.array([1.]), np.array([2.]), np.array([3.]))
     self.surf2 = GriddedSurface.from_points_list(POINTS2)
Ejemplo n.º 5
0
 def setUp(self):
     self.surf = GriddedSurface.from_points_list(POINTS)
     self.mesh = Mesh(np.array([1.0]), np.array([2.0]), np.array([3.0]))