示例#1
0
    def test_Multiple_ground_motion_calculatorI(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name2 = 'Youngs_97_interface'
        (distances, distance_types, magnitudes, test_mean, test_sigma, periods,
         depths, _, _, _, _, _, _) = data2atts(model_name2)

        model_names = [model_name2]
        model_weights = array([1.0])
        gm = Multiple_ground_motion_calculator(model_names, periods,
                                               model_weights)

        log_mean, log_sigma = gm._distribution_function(distances,
                                                        magnitudes,
                                                        depth=depths)

        mean_out = []
        for i in range(len(distances.distance(None))):
            mean_out.append([test_mean[i][0]])
        # print "exp(log_mean)", exp(log_mean).shape
        # print "exp(log_mean)", exp(log_mean)
        mean_out = asarray(mean_out).reshape(1, 3, 1, 12)
        # print "mean_out", mean_out.shape
        # print "mean_out", mean_out
        self.assert_(allclose(exp(log_mean), mean_out, rtol=0.05), "Fail")
示例#2
0
    def test_log_sigma_BA08(self):
        model_name = 'Boore_08'

        (distances, distance_types, magnitudes, test_mean, test_sigma, periods,
         depths, _, _, _, _, _, _) = data2atts('Toro_1997_midcontinent')
        event_activity = 0.5
        periods = array([0.015, 0.45, 4.5])

        gm = Ground_motion_calculator(model_name, periods=periods)
        # print "magnitudes", magnitudes
        Vs30 = 560 * ones(magnitudes['Mw'].shape)
        fault_type = zeros(magnitudes['Mw'].shape, dtype=int64)
        log_mean, log_sigma = gm.distribution_function(
            distances,
            distance_types,
            magnitudes,
            depth=depths,
            event_activity=event_activity,
            Vs30=560,
            fault_type=fault_type)
        test_log_sigma = array([0.569, 0.609, 0.716])
        # print "log_sigma", log_sigma
        # FIXME check the shape as well
        self.assert_(allclose(log_sigma, test_log_sigma, rtol=0.05),
                     "%s did not pass assert" % model_name)
    def test_Multiple_ground_motion_calculatorI(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name2 = 'Youngs_97_interface'
        (distances, distance_types, magnitudes, test_mean,
         test_sigma, periods, depths, _, _, _, _, _, _) = data2atts(
            model_name2)

        model_names = [model_name2]
        model_weights = array([1.0])
        gm = Multiple_ground_motion_calculator(model_names, periods,
                                               model_weights)

        log_mean, log_sigma = gm._distribution_function(distances,
                                                        magnitudes,
                                                        depth=depths)

        mean_out = []
        for i in range(len(distances.distance(None))):
            mean_out.append([test_mean[i][0]])
        # print "exp(log_mean)", exp(log_mean).shape
        # print "exp(log_mean)", exp(log_mean)
        mean_out = asarray(mean_out).reshape(1, 3, 1, 12)
        # print "mean_out", mean_out.shape
        # print "mean_out", mean_out
        self.assert_(allclose(exp(log_mean), mean_out, rtol=0.05), "Fail")
    def test_Multiple_ground_motion_calculatorII(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name = 'Combo_Sadigh_Youngs_M8_trimmed'
        (distances, distance_types, magnitudes, test_mean,
         test_sigma, periods, depths, _, _, _, _, _, _) = data2atts(model_name)

        model_name2 = 'Youngs_97_interface'
        (dist2, distance_types2, mag2, test_mean2,
         test_sigma2, periods2, depths2, _, _, _, _, _, _) = data2atts(
            model_name2)

        self.assert_(allclose(distances.distance(None), dist2.distance(None)))
        self.assert_(magnitudes == mag2)
        self.assert_(periods == periods2)
        self.assert_(depths == depths2)

        model_name = 'Combo_Sadigh_Youngs_M8'

        model_names = [model_name, model_name2]
        model_weights = array([0.1, 0.9])
        gm = Multiple_ground_motion_calculator(model_names, periods,
                                               model_weights)

        log_mean, log_sigma = gm._distribution_function(distances,
                                                        magnitudes,
                                                        depth=depths)

        mean_out = []
        for i in range(len(distances.distance(None))):
            mean_out.append([test_mean[i][0], test_mean2[i][0]])
        # print "exp(log_mean)", exp(log_mean).shape
        # print "exp(log_mean)", exp(log_mean)
        mean_out = asarray(mean_out).reshape(2, 3, 1, 12)
示例#5
0
    def test_Multiple_ground_motion_calculatorII(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name = 'Combo_Sadigh_Youngs_M8_trimmed'
        (distances, distance_types, magnitudes, test_mean, test_sigma, periods,
         depths, _, _, _, _, _, _) = data2atts(model_name)

        model_name2 = 'Youngs_97_interface'
        (dist2, distance_types2, mag2, test_mean2, test_sigma2, periods2,
         depths2, _, _, _, _, _, _) = data2atts(model_name2)

        self.assert_(allclose(distances.distance(None), dist2.distance(None)))
        self.assert_(magnitudes == mag2)
        self.assert_(periods == periods2)
        self.assert_(depths == depths2)

        model_name = 'Combo_Sadigh_Youngs_M8'

        model_names = [model_name, model_name2]
        model_weights = array([0.1, 0.9])
        gm = Multiple_ground_motion_calculator(model_names, periods,
                                               model_weights)

        log_mean, log_sigma = gm._distribution_function(distances,
                                                        magnitudes,
                                                        depth=depths)

        mean_out = []
        for i in range(len(distances.distance(None))):
            mean_out.append([test_mean[i][0], test_mean2[i][0]])
        # print "exp(log_mean)", exp(log_mean).shape
        # print "exp(log_mean)", exp(log_mean)
        mean_out = asarray(mean_out).reshape(2, 3, 1, 12)
    def test_log_sigma_Somerville09_Yilgarn(self):
        model_name = 'Somerville09_Yilgarn'

        (distances, distance_types, magnitudes, test_mean, test_sigma,
         periods, depths, _, _, _, _, _, _) = data2atts(
            'Toro_1997_midcontinent')
        event_activity = 1
        periods = array([0.010, 0.045, 1.0])

        gm = Ground_motion_calculator(model_name, periods=periods)

        log_mean, log_sigma = gm.distribution_function(
            distances, distance_types, magnitudes,
            depth=depths,
            event_activity=event_activity)
        test_log_sigma = array([0.5512, 0.55095, 0.6817])
        # FIXME check the shape as well
        self.assert_(allclose(log_sigma, test_log_sigma, rtol=0.0000005),
                     "%s did not pass assert" % model_name)
示例#7
0
    def test_log_sigma_Somerville09_Yilgarn(self):
        model_name = 'Somerville09_Yilgarn'

        (distances, distance_types, magnitudes, test_mean, test_sigma, periods,
         depths, _, _, _, _, _, _) = data2atts('Toro_1997_midcontinent')
        event_activity = 1
        periods = array([0.010, 0.045, 1.0])

        gm = Ground_motion_calculator(model_name, periods=periods)

        log_mean, log_sigma = gm.distribution_function(
            distances,
            distance_types,
            magnitudes,
            depth=depths,
            event_activity=event_activity)
        test_log_sigma = array([0.5512, 0.55095, 0.6817])
        # FIXME check the shape as well
        self.assert_(allclose(log_sigma, test_log_sigma, rtol=0.0000005),
                     "%s did not pass assert" % model_name)
示例#8
0
    def test_mult_gm(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name = 'Toro_1997_midcontinent'

        (distances, distance_types, magnitudes, test_mean, test_sigma, periods,
         depths, _, _, _, _, _, _) = data2atts(model_name)
        model_weights = [1]
        gm = Multiple_ground_motion_calculator([model_name], periods,
                                               model_weights)

        # ignoring event_activity
        log_mean, log_sigma = gm._distribution_function(distances,
                                                        magnitudes,
                                                        depth=depths)

        self.assert_(allclose(exp(log_mean), test_mean, rtol=0.05),
                     "%s did not pass assert" % model_name)
    def test_log_mean(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name = 'Toro_1997_midcontinent'
        (distances, distance_types, magnitudes, test_mean,
         test_sigma, periods, depths, _, _, _, _, _, _) = data2atts(model_name)

        event_activity = 0.5

        gm = Ground_motion_calculator(model_name, periods=periods)

        log_mean, log_sigma = gm.distribution_function(
            distances, distance_types, magnitudes,
            depth=depths,
            event_activity=event_activity)

        self.assert_(allclose(exp(log_mean), test_mean, rtol=0.05),
                     "%s did not pass assert" % model_name)
    def test_mult_gm(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name = 'Toro_1997_midcontinent'

        (distances, distance_types, magnitudes, test_mean,
         test_sigma, periods, depths, _, _, _, _, _, _) = data2atts(model_name)
        model_weights = [1]
        gm = Multiple_ground_motion_calculator([model_name], periods,
                                               model_weights)

        # ignoring event_activity
        log_mean, log_sigma = gm._distribution_function(distances,
                                                        magnitudes,
                                                        depth=depths)

        self.assert_(allclose(exp(log_mean), test_mean, rtol=0.05),
                     "%s did not pass assert" % model_name)
示例#11
0
    def test_log_mean(self):
        """
        This checks that for the given test_distance and test_magnitudes,
        the calculated ground motion is the same as the test_ground_motion
        """

        model_name = 'Toro_1997_midcontinent'
        (distances, distance_types, magnitudes, test_mean, test_sigma, periods,
         depths, _, _, _, _, _, _) = data2atts(model_name)

        event_activity = 0.5

        gm = Ground_motion_calculator(model_name, periods=periods)

        log_mean, log_sigma = gm.distribution_function(
            distances,
            distance_types,
            magnitudes,
            depth=depths,
            event_activity=event_activity)

        self.assert_(allclose(exp(log_mean), test_mean, rtol=0.05),
                     "%s did not pass assert" % model_name)
    def test_log_sigma_BA08(self):
        model_name = 'Boore_08'

        (distances, distance_types, magnitudes, test_mean, test_sigma,
         periods, depths, _, _, _, _, _, _) = data2atts('Toro_1997_midcontinent')
        event_activity = 0.5
        periods = array([0.015, 0.45, 4.5])

        gm = Ground_motion_calculator(model_name, periods=periods)
        # print "magnitudes", magnitudes
        Vs30 = 560 * ones(magnitudes['Mw'].shape)
        fault_type = zeros(magnitudes['Mw'].shape, dtype=int64)
        log_mean, log_sigma = gm.distribution_function(
            distances, distance_types, magnitudes,
            depth=depths,
            event_activity=event_activity,
            Vs30=560,
            fault_type=fault_type)
        test_log_sigma = array([0.569, 0.609, 0.716])
        # print "log_sigma", log_sigma
        # FIXME check the shape as well
        self.assert_(allclose(log_sigma, test_log_sigma, rtol=0.05),
                     "%s did not pass assert" % model_name)