예제 #1
0
    def test_write_gmm_data_file_TOTAL_STDDEV(self):
        (handle, file_name) = tempfile.mkstemp('.csv', 
                                               'test_create_gmm_data_4_nhlibt')
        os.close(handle)

        gmm = 'mean_10_sigma_1' #'Somerville09_Yilgarn'
        mag = ['rup_mag', [5, 7]]
        dist = ['Rupture', [1.,10.]]
        result_type = 'TOTAL_STDDEV'
        periods = [0.0, 0.3, 0.7, 1.0]
        cgd.write_gmm_data_file(gmm, mag, dist, result_type,
                        periods, file_name)
        handle = open(file_name, 'rb')
        reader = csv.reader(handle,  delimiter=',', quoting=csv.QUOTE_NONE)
        row = reader.next()
        string_periods = [str(x) for x in periods[1:]]
        actual = [mag[0], dist[0], 'result_type', 'component_type'] + \
                 string_periods + ['pga'] 
        
        self.assertEqual(row, actual)
        
        # this isn't such a good ground model to use
        # since the coeffiecents/dist/mag values aren't tested
        # This isn't testing how pga is at the end.
        sa = ['1.0'] * len(periods)
        
        for magi in mag[1]:
            for disti in dist[1]:
                row = reader.next()
                actual = [str(magi), str(disti), 'TOTAL_STDDEV', 
                          'AVERAGE_HORIZONTAL'] + sa
                self.assertEqual(row, actual)

        handle.close()
        os.remove(file_name)
예제 #2
0
        2.0,
        3.003,
        4.0,
        5.0,
        7.5019,
        10.0,
    ]

    gmm = None
    gmm = "Somerville09_Yilgarn"
    gmm = "Somerville09_Non_Cratonic"

    if gmm == "Somerville09_Non_Cratonic":
        file_name = "SOMMERVILLE_Non_Cratonic2009_MEAN.csv"
        result_type = "MEAN"
        cgd.write_gmm_data_file(gmm, mag, dist, result_type, periods, file_name)
        result_type = "TOTAL_STDDEV"
        file_name = "SOMMERVILLE_Non_Cratonic2009_STD_TOTAL.csv"
        cgd.write_gmm_data_file(gmm, mag, dist, result_type, periods, file_name)

    if gmm == "Somerville09_Yilgarn":
        file_name = "SOMMERVILLE_YILGARN2009_MEAN.csv"
        result_type = "MEAN"
        cgd.write_gmm_data_file(gmm, mag, dist, result_type, periods, file_name)
        result_type = "TOTAL_STDDEV"
        file_name = "SOMMERVILLE_YILGARN2009_STD_TOTAL.csv"
        cgd.write_gmm_data_file(gmm, mag, dist, result_type, periods, file_name)

    gmm = "Allen_2012"
    depth = ["depth", [5, 15]]
    dist = ["Rupture", [0.0002, 5.0, 20.0, 50.0, 100.0, 400.0]]
    dist = ['Joyner_Boore', [0.0002, 5.0, 20.0, 50.0, 100.0, 400.0]]

    result_type = 'MEAN'
    periods = [
        0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.075,
        0.1, 0.15, 0.2, 0.25, 0.3003,
        0.4, 0.5, 0.75, 1., 1.4993, 2., 3.003, 4., 5., 7.5019, 10., ]

    gmm = None
    gmm = 'Somerville09_Yilgarn'
    gmm = 'Somerville09_Non_Cratonic'

    if gmm == 'Somerville09_Non_Cratonic':
        file_name = "SOMMERVILLE_Non_Cratonic2009_MEAN.csv"
        result_type = 'MEAN'
        cgd.write_gmm_data_file(gmm, mag, dist, result_type,
                                periods, file_name)
        result_type = 'TOTAL_STDDEV'
        file_name = "SOMMERVILLE_Non_Cratonic2009_STD_TOTAL.csv"
        cgd.write_gmm_data_file(gmm, mag, dist, result_type,
                                periods, file_name)

    if gmm == 'Somerville09_Yilgarn':
        file_name = "SOMMERVILLE_YILGARN2009_MEAN.csv"
        result_type = 'MEAN'
        cgd.write_gmm_data_file(gmm, mag, dist, result_type,
                                periods, file_name)
        result_type = 'TOTAL_STDDEV'
        file_name = "SOMMERVILLE_YILGARN2009_STD_TOTAL.csv"
        cgd.write_gmm_data_file(gmm, mag, dist, result_type,
                                periods, file_name)