Example #1
0
    def test02(self):
        """ Simplest test """

        profiles = [
            Line([Point(0.0, 0.0, 0.0),
                  Point(0.0, 0.001, 15.0)]),
            Line([Point(0.1, 0.0, 0.0),
                  Point(0.1, 0.010, 12.0)]),
            Line([Point(0.2, 0.0, 0.0),
                  Point(0.2, 0.020, 9.0)]),
            Line([Point(0.3, 0.0, 0.0),
                  Point(0.3, 0.030, 6.0)])
        ]

        mfd = TruncatedGRMFD(a_val=0.5,
                             b_val=1.0,
                             min_mag=5.8,
                             max_mag=6.2,
                             bin_width=0.1)

        source = self._make_source(mfd=mfd,
                                   aspect_ratio=1.5,
                                   profiles=profiles)

        msg = 'Wrong number of ruptures'
        self.assertEqual(source.count_ruptures(), 28, msg)

        if MAKE_MOVIES:
            self._ruptures_animation('test02', source.surface, self.ruptures,
                                     source.profiles)
 def test_modify_geometry(self):
     fault = self._make_source(self.edges)
     # Modify the edges
     top_edge_2 = Line([Point(29.9, 30.0, 2.0), Point(31.1, 30.0, 2.1)])
     bottom_edge_2 = Line(
         [Point(29.6, 29.9, 29.0),
          Point(31.4, 29.9, 33.0)])
     fault.modify_set_geometry([top_edge_2, bottom_edge_2], self.spacing)
     exp_lons_top = [29.9, 31.1]
     exp_lats_top = [30.0, 30.0]
     exp_depths_top = [2.0, 2.1]
     exp_lons_bot = [29.6, 31.4]
     exp_lats_bot = [29.9, 29.9]
     exp_depths_bot = [29.0, 33.0]
     for iloc in range(len(fault.edges[0])):
         self.assertAlmostEqual(fault.edges[0].points[iloc].longitude,
                                exp_lons_top[iloc])
         self.assertAlmostEqual(fault.edges[0].points[iloc].latitude,
                                exp_lats_top[iloc])
         self.assertAlmostEqual(fault.edges[0].points[iloc].depth,
                                exp_depths_top[iloc])
     for iloc in range(len(fault.edges[1])):
         self.assertAlmostEqual(fault.edges[1].points[iloc].longitude,
                                exp_lons_bot[iloc])
         self.assertAlmostEqual(fault.edges[1].points[iloc].latitude,
                                exp_lats_bot[iloc])
         self.assertAlmostEqual(fault.edges[1].points[iloc].depth,
                                exp_depths_bot[iloc])
    def _make_source(self, mfd, aspect_ratio, fault_trace, dip):
        sf = super(ComplexFaultSourceRupEnclPolyTestCase,
                   self)._make_source(mfd, aspect_ratio, fault_trace, dip)
        # create an equivalent top and bottom edges
        vdist_top = sf.upper_seismogenic_depth
        vdist_bottom = sf.lower_seismogenic_depth

        hdist_top = vdist_top / numpy.tan(numpy.radians(dip))
        hdist_bottom = vdist_bottom / numpy.tan(numpy.radians(dip))

        strike = fault_trace[0].azimuth(fault_trace[-1])
        azimuth = (strike + 90.0) % 360

        top_edge = []
        bottom_edge = []
        for point in fault_trace.points:
            top_edge.append(point.point_at(hdist_top, vdist_top, azimuth))
            bottom_edge.append(
                point.point_at(hdist_bottom, vdist_bottom, azimuth))
        edges = [Line(top_edge), Line(bottom_edge)]

        return ComplexFaultSource(sf.source_id, sf.name,
                                  sf.tectonic_region_type, sf.mfd,
                                  sf.rupture_mesh_spacing,
                                  sf.magnitude_scaling_relationship,
                                  sf.rupture_aspect_ratio,
                                  sf.temporal_occurrence_model, edges, sf.rake)
Example #4
0
 def setUp(self):
     self.pro1 = Line([
         Point(10.0, 45.0, 5.0),
         Point(10.1, 45.1, 10.0),
         Point(10.2, 45.2, 15.0),
         Point(10.0, 45.3, 20.0)
     ])
     self.pro2 = Line([
         Point(10.0, 45.0, 2.0),
         Point(10.1, 45.1, 8.0),
         Point(10.2, 45.2, 11.0),
         Point(10.0, 45.3, 19.0)
     ])
     self.pro3 = Line([
         Point(10.0, 45.0, 2.0),
         Point(10.1, 45.1, 8.0),
         Point(10.2, 45.2, 11.0),
         Point(10.0, 45.3, 17.0)
     ])
     self.pro4 = Line([
         Point(10.0, 45.0, 8.0),
         Point(10.1, 45.1, 13.0),
         Point(10.2, 45.2, 17.0),
         Point(10.0, 45.3, 23.0)
     ])
     self.pro5 = Line([
         Point(10.0, 45.0, 3.0),
         Point(10.1, 45.1, 8.0),
         Point(10.2, 45.2, 12.0)
     ])
    def _make_source(self, mfd, aspect_ratio, profiles=None,
                     floating_x_step=0.5, floating_y_step=0.5):
        """
        Utility method for creating quickly fault instances
        :param mfd:
            An instance of :class:`openquake.hazardlib.scalerel.base.`
        :param aspect_ratio:
            The rupture aspect ratio
        :param profiles:
            A list of profiles used to build the fault surface
        """

        # Set the fault source parameter
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 2.5
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = aspect_ratio
        tom = self.TOM
        if profiles is None:
            profiles = [Line([Point(0.0, 0.0, 0.0), Point(0.0, 0.01, 15.0)]),
                        Line([Point(0.3, 0.0, 0.0), Point(0.3, 0.01, 15.0)])]

        # Create the source instance
        kfs = KiteFaultSource(source_id, name, trt, mfd, rupture_mesh_spacing,
                              magnitude_scaling_relationship,
                              rupture_aspect_ratio, tom, profiles, rake,
                              floating_x_step=floating_x_step,
                              floating_y_step=floating_y_step)

        # Check we can create a pickled version of this object
        assert_pickleable(kfs)
        return kfs
Example #6
0
    def setUp(self):
        """ This creates a fault dipping to north """

        self.profiles1 = []
        tmp = [
            Point(0.0, 0.00, 0.0),
            Point(0.0, 0.05, 5.0),
            Point(0.0, 0.10, 10.0),
            Point(0.0, 0.20, 20.0)
        ]
        self.profiles1.append(Line(tmp))

        tmp = [
            Point(0.17, 0.00, 0.0),
            Point(0.17, 0.05, 5.0),
            Point(0.17, 0.10, 10.0),
            Point(0.17, 0.15, 15.0)
        ]
        self.profiles1.append(Line(tmp))

        tmp = [
            Point(0.20, 0.00, 0.0),
            Point(0.20, 0.05, 5.0),
            Point(0.20, 0.10, 10.0),
            Point(0.20, 0.15, 15.0)
        ]

        tmp = [
            Point(0.23, 0.13, 0.0),
            Point(0.23, 0.18, 5.0),
            Point(0.23, 0.23, 10.0),
            Point(0.23, 0.28, 15.0)
        ]
        self.profiles1.append(Line(tmp))
Example #7
0
 def setUp(self):
     # First surface - Almost vertical dipping to south
     prf1 = Line([Point(0, 0, 0), Point(0, -0.00001, 20.)])
     prf2 = Line([Point(0.15, 0, 0), Point(0.15, -0.00001, 20.)])
     prf3 = Line([Point(0.3, 0, 0), Point(0.3, -0.00001, 20.)])
     sfca = KiteSurface.from_profiles([prf1, prf2, prf3], 1., 1.)
     self.msrf = MultiSurface([sfca])
Example #8
0
    def setUp(self):
        """ This creates a fault dipping to north """

        self.profiles1 = []
        tmp = [
            Point(0.0, 0.00, 0.0),
            Point(0.0, 0.05, 5.0),
            Point(0.0, 0.10, 10.0),
            Point(0.0, 0.15, 15.0)
        ]
        self.profiles1.append(Line(tmp))

        tmp = [
            Point(0.3, 0.00, 0.0),
            Point(0.3, 0.05, 5.0),
            Point(0.3, 0.10, 10.0),
            Point(0.3, 0.15, 15.0)
        ]
        self.profiles1.append(Line(tmp))

        tmp = [
            Point(0.5, 0.00, 0.0),
            Point(0.5, 0.05, 5.0),
            Point(0.5, 0.10, 10.0),
            Point(0.5, 0.15, 15.0)
        ]
        self.profiles1.append(Line(tmp))

        self.profiles2 = []
        tmp = [Point(0.0, 0.000, 0.0), Point(0.0, 0.001, 15.0)]
        self.profiles2.append(Line(tmp))
        tmp = [Point(0.5, 0.000, 0.0), Point(0.5, 0.001, 15.0)]
        self.profiles2.append(Line(tmp))
Example #9
0
    def test_get_area1(self):
        pntsa = npoints_towards(lon=0.32,
                                lat=0.0,
                                depth=0.0,
                                azimuth=45,
                                hdist=10.0,
                                vdist=0.0,
                                npoints=2)
        pntsb = npoints_towards(lon=pntsa[0][1],
                                lat=pntsa[1][1],
                                depth=pntsa[2][1],
                                azimuth=45 + 90,
                                hdist=10.0,
                                vdist=10.0,
                                npoints=2)
        pntsc = npoints_towards(lon=0.32,
                                lat=0.0,
                                depth=0.0,
                                azimuth=45 + 90,
                                hdist=10.0,
                                vdist=10.0,
                                npoints=2)
        tmp = Point(pntsc[0][1], pntsc[1][1], pntsc[2][1])
        prf3 = Line([Point(0.32, 0, 0), tmp])
        tmp1 = Point(pntsa[0][1], pntsa[1][1], pntsa[2][1])
        tmp2 = Point(pntsb[0][1], pntsb[1][1], pntsb[2][1])
        prf4 = Line([tmp1, tmp2])
        sfcb = KiteSurface.from_profiles([prf3, prf4], 0.2, 0.2)

        computed = sfcb.get_area()
        expected = 10.0 * 14.14
        msg = 'Multi fault surface: area is wrong'
        aae(expected, computed, decimal=-1, err_msg=msg)
Example #10
0
    def setUp(self):
        edges = []
        edge1 = Line([
            Point(10.0, 45.0, 0.0),
            Point(10., 45.1, 0.0),
            Point(10.0, 45.2, 0.0)
        ])
        edge2 = Line([
            Point(10.1, 45.0, 10.0),
            Point(10.1, 45.1, 10.0),
            Point(10.1, 45.2, 10.0)
        ])
        edges.append(edge1)
        edges.append(edge2)
        self.edgesA = edges

        edges = []
        edge1 = Line([
            Point(10.0, 45.0, 0.0),
            Point(10., 45.1, 0.0),
            Point(10.0, 45.2, 0.0)
        ])
        edge2 = Line([
            Point(10.1, 45.2, 10.0),
            Point(10.1, 45.1, 10.0),
            Point(10.1, 45.0, 10.0)
        ])
        edges.append(edge1)
        edges.append(edge2)
        self.edgesB = edges
Example #11
0
 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
Example #12
0
 def setUp(self):
     top_edge_1 = Line([Point(30.0, 30.0, 1.0), Point(31.0, 30.0, 1.0)])
     bottom_edge_1 = Line([Point(29.7, 29.9, 30.0),
                           Point(31.3, 29.9, 32.0)])
     self.edges = [top_edge_1, bottom_edge_1]
     self.mfd = EvenlyDiscretizedMFD(7.0, 0.1, [1.0])
     self.aspect = 1.0
     self.spacing = 5.0
     self.rake = 90.
Example #13
0
    def get_target_sites_mesh(self, maximum_distance, spacing, vs30,
                              vs30measured=True, z1pt0=None, z2pt5=None,
                              backarc=False):
        """
        Renders a two dimensional mesh of points over the rupture surface
        """
        # Get bounding box of dilated rupture
        lowx, highx, lowy, highy = self._get_limits_maximum_rjb(
            maximum_distance)
        # Create bounding box lines and then resample at spacing
        ewline = Line([Point(lowx, highy, 0.), Point(highx, highy, 0.)])
        nsline = Line([Point(lowx, highy, 0.), Point(lowx, lowy, 0.)])
        ewline = ewline.resample(spacing)
        nsline = nsline.resample(spacing)
        xvals = np.array([pnt.longitude for pnt in ewline.points])
        yvals = np.array([pnt.latitude for pnt in nsline.points])

        gridx, gridy = np.meshgrid(xvals, yvals)

        numx, numy = np.shape(gridx)
        npts = numx * numy
        gridx = (np.reshape(gridx, npts, 1)).flatten()
        gridy = (np.reshape(gridy, npts, 1)).flatten()
        site_list = []

        if not z1pt0:
            # z1pt0 = vs30_to_z1pt0_as08(vs30)
            z1pt0 = vs30_to_z1pt0_cy14(vs30)

        if not z2pt5:
            # z2pt5 = z1pt0_to_z2pt5(z1pt0)
            z2pt5 = vs30_to_z2pt5_cb14(vs30)

        for iloc in range(0, npts):
            site_list.append(Site(Point(gridx[iloc], gridy[iloc], 0.),
                                  vs30,
                                  z1pt0,
                                  z2pt5,
                                  vs30measured=vs30measured,
                                  backarc=backarc))
        self.target_sites = SiteCollection(site_list)
        self.target_sites_config = {
            "TYPE": "Mesh",
            "RMAX": maximum_distance,
            "SPACING": spacing,
            "VS30": vs30,
            "VS30MEASURED": vs30measured,
            "Z1.0": z1pt0,
            "Z2.5": z2pt5,
            "BACKARC": backarc}
        return self.target_sites
Example #14
0
def _3d_line_from_list(vals):
    """
    """
    vertices = []
    for lon, lat, depth in vals:
        vertices.append(Point(lon, lat, depth))
    return Line(vertices)
Example #15
0
 def test(self):
     sitecol = SiteCollection([Site(Point(-65.13490, 0.0),
                               vs30=760., z1pt0=48.0, z2pt5=0.607,
                               vs30measured=True)])
     mfd = ArbitraryMFD([6.0], [0.01604252])
     trace = Line([Point(-65.0000, -0.11240), Point(-65.000, 0.11240)])
     # 1.0 km Mesh Spacing
     mesh_spacing = 1.0
     msr = PeerMSR()
     sources = [SimpleFaultSource("001", "PEER Fault Set 2.5",
                                  "Active Shallow Crust", mfd,
                                  mesh_spacing,  msr, 2.0, PoissonTOM(1.0),
                                  0.0, 12., trace, 90., 0.)]
     imtls = {"PGA": [0.001, 0.01, 0.05, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0,
                      1.25, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0, 7.0]}
     gmpe = ChiouYoungs2014PEER()
     gmpe.mixture_model = {"factors": [0.8, 1.2], "weights": [0.5, 0.5]}
     hcm = calc_hazard_curves(sources, sitecol, imtls,
                              {"Active Shallow Crust": gmpe})
     # Match against the benchmark is not exact - but differences in the
     # log space should be on the order of less than 0.04%
     expected = numpy.array([-4.140470001, -4.140913368, -4.259457496,
                             -4.724733842, -5.900747959, -7.734816415,
                             -9.019329629, -10.03864778, -10.90333404,
                             -11.83885783, -12.65826442, -14.05429951,
                             -15.22535996, -16.23988897, -17.94685518,
                             -19.36079032, -20.57460101, -21.64201335])
     expected = numpy.around(expected, 5)
     hcm_lnpga = numpy.around(numpy.log(hcm["PGA"].flatten()), 5)
     perc_diff = 100.0 * ((hcm_lnpga / expected) - 1.0)
     numpy.testing.assert_allclose(perc_diff, numpy.zeros(len(perc_diff)),
                                   atol=0.04)
    def test_Pago_VeianoMontaguto(self):
        # regression test
        fault_trace = Line([
            Point(15.2368, 41.1594),
            Point(15.1848, 41.1644),
            Point(15.1327, 41.1694),
            Point(15.0807, 41.1745),
            Point(15.0286, 41.1795),
            Point(14.9765, 41.1846),
            Point(14.9245, 41.1896),
            Point(14.8724, 41.1946),
            Point(14.8204, 41.1997)
        ])
        mfd = EvenlyDiscretizedMFD(min_mag=6.9,
                                   bin_width=0.2,
                                   occurrence_rates=[1.0])
        dip = 70.0
        upper_seismogenic_depth = 11.0
        lower_seismogenic_depth = 25.0
        rake = -130
        scalerel = WC1994()
        rupture_mesh_spacing = 5
        rupture_aspect_ratio = 1
        tom = PoissonTOM(10)

        fault = SimpleFaultSource(
            'ITCS057', 'Pago Veiano-Montaguto', TRT.ACTIVE_SHALLOW_CRUST, mfd,
            rupture_mesh_spacing, scalerel, rupture_aspect_ratio, tom,
            upper_seismogenic_depth, lower_seismogenic_depth, fault_trace, dip,
            rake)

        self.assertEqual(len(list(fault.iter_ruptures())), 1)
    def _make_source(self, mfd, aspect_ratio, fault_trace=None, dip=45):
        source_id = name = 'test-source'
        trt = self.TRT
        rake = self.RAKE
        rupture_mesh_spacing = 1
        upper_seismogenic_depth = 0
        lower_seismogenic_depth = 4.2426406871192848
        magnitude_scaling_relationship = PeerMSR()
        rupture_aspect_ratio = aspect_ratio
        tom = self.TOM
        if fault_trace is None:
            fault_trace = Line([
                Point(0.0, 0.0),
                Point(0.0, 0.0359728811758),
                Point(0.0190775080917, 0.0550503815181),
                Point(0.03974514139, 0.0723925718855)
            ])

        sfs = SimpleFaultSource(
            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)
        assert_pickleable(sfs)
        return sfs
Example #18
0
    def get_resampled_top_edge(self, angle_var=0.1):
        """
        This methods computes a simplified representation of a fault top edge
        by removing the points that are not describing a change of direction,
        provided a certain tolerance angle.

        :param float angle_var:
            Number representing the maximum deviation (in degrees) admitted
            without the creation of a new segment
        :returns:
            A :class:`~openquake.hazardlib.geo.line.Line` representing the
            rupture surface's top edge.
        """
        mesh = self.mesh
        top_edge = [Point(mesh.lons[0][0], mesh.lats[0][0], mesh.depths[0][0])]

        for i in range(len(mesh.triangulate()[1][0]) - 1):
            v1 = numpy.asarray(mesh.triangulate()[1][0][i])
            v2 = numpy.asarray(mesh.triangulate()[1][0][i + 1])
            cosang = numpy.dot(v1, v2)
            sinang = numpy.linalg.norm(numpy.cross(v1, v2))
            angle = math.degrees(numpy.arctan2(sinang, cosang))

            if abs(angle) > angle_var:

                top_edge.append(
                    Point(mesh.lons[0][i + 1], mesh.lats[0][i + 1],
                          mesh.depths[0][i + 1]))

        top_edge.append(
            Point(mesh.lons[0][-1], mesh.lats[0][-1], mesh.depths[0][-1]))
        line_top_edge = Line(top_edge)

        return line_top_edge
Example #19
0
def _setup_fault_source():
    """
    Builds a fault source using the PEER Bending Fault case.
    """
    point_order_dipping_east = [
        Point(-64.78365, -0.45236),
        Point(-64.80164, -0.45236),
        Point(-64.90498, -0.36564),
        Point(-65.0000, -0.16188),
        Point(-65.0000, 0.0000)
    ]
    trace_dip_east = Line(point_order_dipping_east)
    fault_surface1 = SimpleFaultSurface.from_fault_data(
        trace_dip_east, 0.0, 12.0, 60., 1.0)
    # Activity Rates
    # cm per km2
    area = 60. * 12.0 / np.sin(np.radians(60.))
    cm2perkm2 = (100. * 1000.)**2.
    mo1 = 3.0E11 * 0.2 * (area * cm2perkm2)
    mo_m6p75 = 10.0**(16.05 + 1.5 * 6.75)
    rate1 = mo1 / mo_m6p75
    mfd1 = EvenlyDiscretizedMFD(6.75, 0.01, [rate1])
    tom = PoissonTOM(1.0)
    aspect = 2.0
    rake = 90.0
    src = SimpleFaultSource("PEER_FLT_EAST", "PEER Bending Fault Dipping East",
                            "Active Shallow Crust", mfd1, 1.0, PeerMSR(), 2.0,
                            tom, 0.0, 12.0, trace_dip_east, 60.0, rake)
    src.num_ruptures = src.count_ruptures()
    return src
Example #20
0
 def make_rupture_fordpp(self, rupture_class, **kwargs):
     # Create the rupture surface.
     upper_seismogenic_depth = 0.
     lower_seismogenic_depth = 15.
     dip = 90.
     mesh_spacing = 1.
     fault_trace_start = Point(10., 45.2)
     fault_trace_end = Point(10., 45.919457)
     fault_trace = Line([fault_trace_start, fault_trace_end])
     default_arguments = {
         'mag': 7.2,
         'rake': 0.,
         'tectonic_region_type': const.TRT.STABLE_CONTINENTAL,
         'hypocenter': Point(10.0, 45.334898, 10),
         'surface': SimpleFaultSurface.from_fault_data(
             fault_trace, upper_seismogenic_depth, lower_seismogenic_depth,
             dip=dip, mesh_spacing=mesh_spacing),
         'rupture_slip_direction': 0.
     }
     default_arguments.update(kwargs)
     kwargs = default_arguments
     rupture = rupture_class(**kwargs)
     for key in kwargs:
         assert getattr(rupture, key) is kwargs[key]
     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)
Example #22
0
 def test_fault_trace_intersects_itself(self):
     mfd = TruncatedGRMFD(a_val=0.5, b_val=1.0, min_mag=10, max_mag=20,
                          bin_width=1.0)
     fault_trace = Line([Point(0, 0), Point(0, 1),
                         Point(1, 1), Point(0, 0.5)])
     with self.assertRaises(ValueError) as ar:
         self._make_source(mfd=mfd, aspect_ratio=1, fault_trace=fault_trace)
     self.assertEqual(str(ar.exception), 'fault trace intersects itself')
 def setUp(self):
     self.basic_trace = Line([Point(30.0, 30.0), Point(30.0, 32.0)])
     self.mfd = EvenlyDiscretizedMFD(7.0, 0.1, [1.0])
     self.aspect = 1.0
     self.dip = 45.0
     self.fault = self._make_source(self.mfd, self.aspect, self.basic_trace,
                                    self.dip)
     self.fault.lower_seismogenic_depth = 10.0
Example #24
0
    def setUp(self):

        # First surface
        prf1 = Line([Point(0, 0, 0), Point(0, -0.001, 20.)])
        prf2 = Line([Point(0.15, 0, 0), Point(0.15, -0.001, 20.)])
        prf3 = Line([Point(0.3, 0, 0), Point(0.3, -0.001, 20.)])
        sfcA = KiteSurface.from_profiles([prf1, prf2, prf3], 5., 5.)

        # Second surface
        prf3 = Line([Point(0.32, 0, 0), Point(0.32, 0.001, 20.)])
        prf4 = Line([Point(0.45, 0.15, 0), Point(0.45, 0.1501, 20.)])
        sfcB = KiteSurface.from_profiles([prf3, prf4], 5., 5.)

        self.msrf = MultiSurface([sfcA, sfcB])

        coo = np.array([[-0.1, 0.0], [0.0, 0.1]])
        self.mesh = Mesh(coo[:, 0], coo[:, 1])
Example #25
0
    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)
Example #26
0
 def test_dip_90_no_dilation(self):
     trace = Line([Point(0.0, 0.0), Point(0.0, 0.04),
                   Point(0.03, 0.05), Point(0.04, 0.06)])
     source = self._make_source(self.mfd, 1, dip=90, fault_trace=trace)
     polygon = source.get_rupture_enclosing_polygon()
     elons = [0, 0, 0.04]
     elats = [0, 0.04, 0.06]
     numpy.testing.assert_allclose(polygon.lons, elons, rtol=0, atol=1e-5)
     numpy.testing.assert_allclose(polygon.lats, elats)
Example #27
0
 def test_dip_30_no_dilation(self):
     trace = Line([Point(0.0, 0.0), Point(0.0, 0.04),
                   Point(0.03, 0.05), Point(0.04, 0.06)])
     source = self._make_source(self.mfd, 1, dip=30, fault_trace=trace)
     polygon = source.get_rupture_enclosing_polygon()
     elons = [0.0549872, 0., 0., 0.04, 0.09498719]
     elats = [-0.0366581, 0, 0.04, 0.06, 0.02334187]
     numpy.testing.assert_allclose(polygon.lons, elons, rtol=0, atol=1e-5)
     numpy.testing.assert_allclose(polygon.lats, elats, rtol=0, atol=1e-5)
Example #28
0
 def test_rx_kite(self):
     spc = 2.0
     pro1 = Line([Point(0.2, 0.0, 0.0), Point(0.2, 0.05, 15.0)])
     pro2 = Line([Point(0.0, 0.0, 0.0), Point(0.0, 0.05, 15.0)])
     sfc1 = KiteSurface.from_profiles([pro1, pro2], spc, spc)
     msurf = MultiSurface([sfc1])
     pcoo = numpy.array([[0.2, 0.1], [0.0, -0.1]])
     mesh = Mesh(pcoo[:, 0], pcoo[:, 1])
     # Compute expected distances
     lo = pro1.points[0].longitude
     la = pro1.points[0].longitude
     tmp0 = geodetic_distance(lo, la, pcoo[0, 0], pcoo[0, 1])
     lo = pro2.points[0].longitude
     la = pro2.points[0].longitude
     tmp1 = geodetic_distance(lo, la, pcoo[1, 0], pcoo[1, 1])
     # Checking
     rx = msurf.get_rx_distance(mesh)
     expected = numpy.array([tmp0, -tmp1])
     numpy.testing.assert_almost_equal(expected, rx, decimal=5)
Example #29
0
    def _make_source(self, *args, **kwargs):
        source = super()._make_source(*args, **kwargs)
        surface = SimpleFaultSurface.from_fault_data(
            source.fault_trace, source.upper_seismogenic_depth,
            source.lower_seismogenic_depth, source.dip,
            source.rupture_mesh_spacing)
        mesh = surface.mesh
        top_edge = Line(list(mesh[0:1]))
        bottom_edge = Line(list(mesh[-1:]))

        cfs = ComplexFaultSource(source.source_id, source.name,
                                 source.tectonic_region_type, source.mfd,
                                 source.rupture_mesh_spacing,
                                 source.magnitude_scaling_relationship,
                                 source.rupture_aspect_ratio,
                                 source.temporal_occurrence_model,
                                 [top_edge, bottom_edge], source.rake)
        assert_pickleable(cfs)
        return cfs
Example #30
0
 def from_files(cls, fname):
     """
     """
     lines = []
     for filename in sorted(glob.glob(os.path.join(fname, 'edge*.csv'))):
         tmp = numpy.loadtxt(filename)
         pnts = []
         for i in range(tmp.shape[0]):
             pnts.append(Point(tmp[i, 0], tmp[i, 1], tmp[i, 2]))
         lines.append(Line(pnts))
     return cls(lines)
Example #31
0
    def setUp(self):

        # First surface - Almost vertical dipping to south
        prf1 = Line([Point(0, 0, 0), Point(0, -0.00001, 20.)])
        prf2 = Line([Point(0.15, 0, 0), Point(0.15, -0.00001, 20.)])
        prf3 = Line([Point(0.3, 0, 0), Point(0.3, -0.00001, 20.)])
        sfca = KiteSurface.from_profiles([prf1, prf2, prf3], 1., 1.)

        # Second surface - Strike to NE and dip to SE
        pntsa = npoints_towards(lon=0.32,
                                lat=0.0,
                                depth=0.0,
                                azimuth=45,
                                hdist=10.0,
                                vdist=0.0,
                                npoints=2)
        pntsb = npoints_towards(lon=pntsa[0][1],
                                lat=pntsa[1][1],
                                depth=pntsa[2][1],
                                azimuth=45 + 90,
                                hdist=10.0,
                                vdist=10.0,
                                npoints=2)
        pntsc = npoints_towards(lon=0.32,
                                lat=0.0,
                                depth=0.0,
                                azimuth=45 + 90,
                                hdist=10.0,
                                vdist=10.0,
                                npoints=2)
        tmp = Point(pntsc[0][1], pntsc[1][1], pntsc[2][1])
        prf3 = Line([Point(0.32, 0, 0), tmp])
        tmp1 = Point(pntsa[0][1], pntsa[1][1], pntsa[2][1])
        tmp2 = Point(pntsb[0][1], pntsb[1][1], pntsb[2][1])
        prf4 = Line([tmp1, tmp2])
        sfcb = KiteSurface.from_profiles([prf3, prf4], 0.2, 0.2)

        # Create surface and mesh needed for the test
        self.msrf = MultiSurface([sfca, sfcb])
        self.coo = np.array([[-0.1, 0.0], [0.0, 0.1]])
        self.mesh = Mesh(self.coo[:, 0], self.coo[:, 1])