Exemplo n.º 1
0
    def test_Joyner_Boore(self):
        # define varying sites, at different positions, units is deg
        #                      1        2        3
        #                  (-0.1,.5)  (0,.5)  (0.1,.5)
        #                        .      .      .
        #                                
        #                                _______
        #                               |(0,.4) end    
        #                               |       |      
        #                               |       |       
        #                               |       |       
        #           4  (-0.1,.2) .      . 5     |       .  6 (0.2,0.2)
        #                               |       |
        #                               |       |
        #                               |       |
        #                               |_______|
        #                               (0,0) start
        #
        #                        .      .      .
        #                  (-0.1,-.1)  (0,-.1)  (0.1,-.1)
        #                       7         8         9
        #
        # Two events are defined:
        # dip = 90 (vertical)
        # dip = 45 (non-vertical)
        #
        # The projection of the rupture plane where dip-45 test is shown in the
        # diagram
        # Rjb is the closest distance to the projected rupture plane
        
        # y values, since long is y due to local co-ord system
        y_sites = asarray((-0.1, 0.0, 0.1, -0.1, 0.0, 0.2, -0.1,  0.0,  0.1))
        # x values, since lat is x due to local co-ord system
        x_sites = asarray(( 0.5, 0.5, 0.5,  0.2, 0.2, 0.2, -0.1, -0.1, -0.1))
        
        # define array of events, all at 0,0
        lat_events = asarray((0.0,0.0))
        lon_events = asarray((0.0,0.0))

        azimuths = asarray((0.0,0.0))
        
        widths = asarray((0.14142136,0.14142136))
        lengths = asarray((0.4,0.4))
        dips = asarray((90.0,45.0))
        depths_to_top = asarray((0.0,0.1))
        trace_start_lat = asarray((0.0,0.0))
        trace_start_lon = asarray((0.0,0.0))
        rupture_centroid_x = asarray((0.2,0.2))
        rupture_centroid_y = asarray((0.0,0.05))
        
        # Convert sites to lat/lon based on trace_start lat/lon
        lat_sites, lon_sites = xy2ll(x_sites, 
                                     y_sites, 
                                     trace_start_lat[0],
                                     trace_start_lon[0], 
                                     azimuths[0])
        
        projection = azimuthal_orthographic

        
        expected_Rjb = asarray(
            [[0.14142136, 0.14142136],
             [0.10000000, 0.10000000],
             [0.14142136, 0.10000000],
             [0.10000000, 0.10000000],
             [0.00000000, 0.00000000],
             [0.20000000, 0.10000000],
             [0.14142136, 0.14142136],
             [0.10000000, 0.10000000],
             [0.14142136, 0.10000000]])

        Rjb = Joyner_Boore(lat_sites, 
                           lon_sites, 
                           lat_events, 
                           lon_events, 
                           lengths,
                           azimuths, 
                           widths, 
                           dips, 
                           depths, 
                           depths_to_top,
                           projection,
                           trace_start_lat, 
                           trace_start_lon,
                           rupture_centroid_x, 
                           rupture_centroid_y)

        msg = ('Expected Rjb=\n%s\ngot\n%s' % (expected_Rjb, Rjb))
        self.failUnless(allclose(Rjb, expected_Rjb, atol=1e-06), msg)    
Exemplo n.º 2
0
    def test_Rupture_non_vertical(self):
        # define varying sites, at different positions, units is deg
        #                      1        2        3
        #                  (-0.1,.5)  (0,.5)  (0.1,.5)
        #                        .      .      .
        #                                
        #                                _______
        #                               |(0,.4) end    
        #                               |       |      
        #                               |       |       
        #                               |       |       
        #           4  (-0.1,.2) .      . 5     |       .  6 (0.2,0.2)
        #                               |       |
        #                               |       |
        #                               |       |
        #                               |_______|
        #                               (0,0) start
        #
        #                        .      .      .
        #                  (-0.1,-.1)  (0,-.1)  (0.1,-.1)
        #                       7         8         9
        #
        # The projection of the rupture plane in this test is also shown in the
        # diagram
        
        # y values, since long is y due to local co-ord system
        y_sites = asarray((-0.1, 0.0, 0.1, -0.1, 0.0, 0.2, -0.1,  0.0,  0.1))
        # x values, since lat is x due to local co-ord system
        x_sites = asarray(( 0.5, 0.5, 0.5,  0.2, 0.2, 0.2, -0.1, -0.1, -0.1))
        
        # define array of events, all at 0,0
        lat_events = asarray((0.0,0.0))
        lon_events = asarray((0.0,0.0))

        azimuths = asarray((0.0,0.0))
        
        widths = asarray((0.14142136,0.14142136))
        lengths = asarray((0.4,0.4))
        dips = asarray((45.0,45.0))
        depths_to_top = asarray((0.0,0.1))
        trace_start_lat = asarray((0.0,0.0))
        trace_start_lon = asarray((0.0,0.0))
        rupture_centroid_x = asarray((0.2,0.2))
        rupture_centroid_y = asarray((0.05,0.05))
        
        # Convert sites to lat/lon based on trace_start lat/lon
        lat_sites, lon_sites = xy2ll(x_sites, 
                                     y_sites, 
                                     trace_start_lat[0],
                                     trace_start_lon[0], 
                                     azimuths[0])
        
        projection = azimuthal_orthographic

        # define expected Rrup values
        # from kaklamanosDis
        expected_Rrup_deg = asarray(
            [[0.14142136, 0.17320508],
             [0.10000000, 0.14142136],
             [0.12247449, 0.17320508],
             [0.10000000, 0.14142136],
             [0.00000000, 0.10000000],
             [0.14142136, 0.21213203],
             [0.14142136, 0.17320508],
             [0.10000000, 0.14142136],
             [0.12247449, 0.17320508]])
        expected_Rrup = expected_Rrup_deg

        Rrup = Rupture(lat_sites, 
                       lon_sites, 
                       lat_events, 
                       lon_events, 
                       lengths,
                       azimuths, 
                       widths, 
                       dips, 
                       depths, 
                       depths_to_top,
                       projection,
                       trace_start_lat, 
                       trace_start_lon,
                       rupture_centroid_x, 
                       rupture_centroid_y)

        msg = ('Expected Rrup=\n%s\ngot\n%s' % (str(expected_Rrup), str(Rrup)))
        self.failUnless(allclose(Rrup, expected_Rrup, atol=1e-06), msg)
Exemplo n.º 3
0
    def test_Rupture_vertical(self):
        # define varying sites, at different positions, units is deg
        #                      1        2        3
        #                  (-0.1,.5)  (0,.5)  (0.1,.5)
        #                        .      .      .
        #
        #                               (0,.4) end
        #                               |
        #                               |
        #                               |
        #                               |
        #           4  (-0.1,.2) .      . 5     .  6 (0.1,.2)
        #                               |
        #                               |
        #                               |
        #                               |
        #                               (0,0) start
        #
        #                        .      .      .
        #                  (-0.1,-.1)  (0,-.1)  (0.1,-.1)
        #                       7         8         9
        #
        
        # y values, since long is y due to local co-ord system
        y_sites = asarray((-0.1, 0.0, 0.1, -0.1, 0.0, 0.1, -0.1,  0.0,  0.1))
        # x values, since lat is x due to local co-ord system
        x_sites = asarray(( 0.5, 0.5, 0.5,  0.2, 0.2, 0.2, -0.1, -0.1, -0.1))
        
        # define array of events, all at 0,0
        lat_events = asarray((0.0,))
        lon_events = asarray((0.0,))

        azimuths = asarray((0.0,))
        
        widths = asarray((10.0,)) # No used in test
        lengths = asarray((0.4,))
        dips = asarray((90.0,))
        depths_to_top = asarray((0.0,))
        trace_start_lat = asarray((0.0,))
        trace_start_lon = asarray((0.0,))
        rupture_centroid_x = asarray((0.2,))
        rupture_centroid_y = asarray((0.0,))
        
        # Convert sites to lat/lon based on trace_start lat/lon
        lat_sites, lon_sites = xy2ll(x_sites, 
                                     y_sites, 
                                     trace_start_lat,
                                     trace_start_lon, 
                                     azimuths)
        
        projection = azimuthal_orthographic

        # define expected Rrup values
        expected_Rrup_deg = asarray(
            [[2**0.5*0.1],
             [.1],
             [ 2**0.5*0.1],
             [.1],
             [0.0],
             [.1],
             [2**0.5*0.1],
             [.1],
             [2**0.5*0.1]])
        expected_Rrup = expected_Rrup_deg

        Rrup = Rupture(lat_sites, 
                       lon_sites, 
                       lat_events, 
                       lon_events, 
                       lengths,
                       azimuths, 
                       widths, 
                       dips, 
                       depths, 
                       depths_to_top,
                       projection,
                       trace_start_lat, 
                       trace_start_lon,
                       rupture_centroid_x, 
                       rupture_centroid_y)

        msg = ('Expected Rrup=\n%s\ngot\n%s' % (str(expected_Rrup), str(Rrup)))
        self.failUnless(allclose(Rrup, expected_Rrup, atol=1e-06), msg)
Exemplo n.º 4
0
    def test_Joyner_Boore(self):
        # define varying sites, at different positions, units is deg
        #                      1        2        3
        #                  (-0.1,.5)  (0,.5)  (0.1,.5)
        #                        .      .      .
        #
        #                                _______
        #                               |(0,.4) end
        #                               |       |
        #                               |       |
        #                               |       |
        #           4  (-0.1,.2) .      . 5     |       .  6 (0.2,0.2)
        #                               |       |
        #                               |       |
        #                               |       |
        #                               |_______|
        #                               (0,0) start
        #
        #                        .      .      .
        #                  (-0.1,-.1)  (0,-.1)  (0.1,-.1)
        #                       7         8         9
        #
        # Two events are defined:
        # dip = 90 (vertical)
        # dip = 45 (non-vertical)
        #
        # The projection of the rupture plane where dip-45 test is shown in the
        # diagram
        # Rjb is the closest distance to the projected rupture plane

        # y values, since long is y due to local co-ord system
        y_sites = asarray((-0.1, 0.0, 0.1, -0.1, 0.0, 0.2, -0.1, 0.0, 0.1))
        # x values, since lat is x due to local co-ord system
        x_sites = asarray((0.5, 0.5, 0.5, 0.2, 0.2, 0.2, -0.1, -0.1, -0.1))

        # define array of events, all at 0,0
        lat_events = asarray((0.0, 0.0))
        lon_events = asarray((0.0, 0.0))

        azimuths = asarray((0.0, 0.0))

        widths = asarray((0.14142136, 0.14142136))
        lengths = asarray((0.4, 0.4))
        dips = asarray((90.0, 45.0))
        depths_to_top = asarray((0.0, 0.1))
        trace_start_lat = asarray((0.0, 0.0))
        trace_start_lon = asarray((0.0, 0.0))
        rupture_centroid_x = asarray((0.2, 0.2))
        rupture_centroid_y = asarray((0.0, 0.05))

        # Convert sites to lat/lon based on trace_start lat/lon
        lat_sites, lon_sites = xy2ll(x_sites, y_sites, trace_start_lat[0],
                                     trace_start_lon[0], azimuths[0])

        projection = azimuthal_orthographic

        expected_Rjb = asarray([[0.14142136, 0.14142136],
                                [0.10000000, 0.10000000],
                                [0.14142136, 0.10000000],
                                [0.10000000, 0.10000000],
                                [0.00000000, 0.00000000],
                                [0.20000000, 0.10000000],
                                [0.14142136, 0.14142136],
                                [0.10000000, 0.10000000],
                                [0.14142136, 0.10000000]])

        Rjb = Joyner_Boore(lat_sites, lon_sites, lat_events, lon_events,
                           lengths, azimuths, widths, dips, depths,
                           depths_to_top, projection, trace_start_lat,
                           trace_start_lon, rupture_centroid_x,
                           rupture_centroid_y)

        msg = ('Expected Rjb=\n%s\ngot\n%s' % (expected_Rjb, Rjb))
        self.failUnless(allclose(Rjb, expected_Rjb, atol=1e-06), msg)
Exemplo n.º 5
0
    def test_Rupture_non_vertical(self):
        # define varying sites, at different positions, units is deg
        #                      1        2        3
        #                  (-0.1,.5)  (0,.5)  (0.1,.5)
        #                        .      .      .
        #
        #                                _______
        #                               |(0,.4) end
        #                               |       |
        #                               |       |
        #                               |       |
        #           4  (-0.1,.2) .      . 5     |       .  6 (0.2,0.2)
        #                               |       |
        #                               |       |
        #                               |       |
        #                               |_______|
        #                               (0,0) start
        #
        #                        .      .      .
        #                  (-0.1,-.1)  (0,-.1)  (0.1,-.1)
        #                       7         8         9
        #
        # The projection of the rupture plane in this test is also shown in the
        # diagram

        # y values, since long is y due to local co-ord system
        y_sites = asarray((-0.1, 0.0, 0.1, -0.1, 0.0, 0.2, -0.1, 0.0, 0.1))
        # x values, since lat is x due to local co-ord system
        x_sites = asarray((0.5, 0.5, 0.5, 0.2, 0.2, 0.2, -0.1, -0.1, -0.1))

        # define array of events, all at 0,0
        lat_events = asarray((0.0, 0.0))
        lon_events = asarray((0.0, 0.0))

        azimuths = asarray((0.0, 0.0))

        widths = asarray((0.14142136, 0.14142136))
        lengths = asarray((0.4, 0.4))
        dips = asarray((45.0, 45.0))
        depths_to_top = asarray((0.0, 0.1))
        trace_start_lat = asarray((0.0, 0.0))
        trace_start_lon = asarray((0.0, 0.0))
        rupture_centroid_x = asarray((0.2, 0.2))
        rupture_centroid_y = asarray((0.05, 0.05))

        # Convert sites to lat/lon based on trace_start lat/lon
        lat_sites, lon_sites = xy2ll(x_sites, y_sites, trace_start_lat[0],
                                     trace_start_lon[0], azimuths[0])

        projection = azimuthal_orthographic

        # define expected Rrup values
        # from kaklamanosDis
        expected_Rrup_deg = asarray([[0.14142136, 0.17320508],
                                     [0.10000000, 0.14142136],
                                     [0.12247449, 0.17320508],
                                     [0.10000000, 0.14142136],
                                     [0.00000000, 0.10000000],
                                     [0.14142136, 0.21213203],
                                     [0.14142136, 0.17320508],
                                     [0.10000000, 0.14142136],
                                     [0.12247449, 0.17320508]])
        expected_Rrup = expected_Rrup_deg

        Rrup = Rupture(lat_sites, lon_sites, lat_events, lon_events, lengths,
                       azimuths, widths, dips, depths, depths_to_top,
                       projection, trace_start_lat, trace_start_lon,
                       rupture_centroid_x, rupture_centroid_y)

        msg = ('Expected Rrup=\n%s\ngot\n%s' % (str(expected_Rrup), str(Rrup)))
        self.failUnless(allclose(Rrup, expected_Rrup, atol=1e-06), msg)
Exemplo n.º 6
0
    def test_Rupture_vertical(self):
        # define varying sites, at different positions, units is deg
        #                      1        2        3
        #                  (-0.1,.5)  (0,.5)  (0.1,.5)
        #                        .      .      .
        #
        #                               (0,.4) end
        #                               |
        #                               |
        #                               |
        #                               |
        #           4  (-0.1,.2) .      . 5     .  6 (0.1,.2)
        #                               |
        #                               |
        #                               |
        #                               |
        #                               (0,0) start
        #
        #                        .      .      .
        #                  (-0.1,-.1)  (0,-.1)  (0.1,-.1)
        #                       7         8         9
        #

        # y values, since long is y due to local co-ord system
        y_sites = asarray((-0.1, 0.0, 0.1, -0.1, 0.0, 0.1, -0.1, 0.0, 0.1))
        # x values, since lat is x due to local co-ord system
        x_sites = asarray((0.5, 0.5, 0.5, 0.2, 0.2, 0.2, -0.1, -0.1, -0.1))

        # define array of events, all at 0,0
        lat_events = asarray((0.0, ))
        lon_events = asarray((0.0, ))

        azimuths = asarray((0.0, ))

        widths = asarray((10.0, ))  # No used in test
        lengths = asarray((0.4, ))
        dips = asarray((90.0, ))
        depths_to_top = asarray((0.0, ))
        trace_start_lat = asarray((0.0, ))
        trace_start_lon = asarray((0.0, ))
        rupture_centroid_x = asarray((0.2, ))
        rupture_centroid_y = asarray((0.0, ))

        # Convert sites to lat/lon based on trace_start lat/lon
        lat_sites, lon_sites = xy2ll(x_sites, y_sites, trace_start_lat,
                                     trace_start_lon, azimuths)

        projection = azimuthal_orthographic

        # define expected Rrup values
        expected_Rrup_deg = asarray([[2**0.5 * 0.1], [.1], [2**0.5 * 0.1],
                                     [.1], [0.0], [.1], [2**0.5 * 0.1], [.1],
                                     [2**0.5 * 0.1]])
        expected_Rrup = expected_Rrup_deg

        Rrup = Rupture(lat_sites, lon_sites, lat_events, lon_events, lengths,
                       azimuths, widths, dips, depths, depths_to_top,
                       projection, trace_start_lat, trace_start_lon,
                       rupture_centroid_x, rupture_centroid_y)

        msg = ('Expected Rrup=\n%s\ngot\n%s' % (str(expected_Rrup), str(Rrup)))
        self.failUnless(allclose(Rrup, expected_Rrup, atol=1e-06), msg)