コード例 #1
0
    def test_load_site_class2Vs30_2(self):
        a = 60.0
        b = 2.0
        title_index_dic = {"site_class": 0, "vs30": 1}
        attribute_dic = {"site_class": ["A", "B"], "vs30": [a, b]}
        answer = {"A": 60.0, "B": 2.0}

        handle, file_name = tempfile.mkstemp(".csv", "test_regolith_")
        os.close(handle)
        dict2csv(file_name, title_index_dic, attribute_dic)
        file_handle = open(file_name, "rb")
        results = load_site_class2Vs30(file_handle)
        os.remove(file_name)
        self.failUnless(results == answer, "Failed!")
コード例 #2
0
    def test_load_site_class2Vs30_2(self):
        a = 60.0
        b = 2.0
        title_index_dic = {'site_class': 0, 'vs30': 1}
        attribute_dic = {'site_class': ['A', 'B'], 'vs30': [a, b]}
        answer = {'A': 60., 'B': 2.0}

        handle, file_name = tempfile.mkstemp('.csv', 'test_regolith_')
        os.close(handle)
        dict2csv(file_name, title_index_dic, attribute_dic)
        file_handle = open(file_name, "rb")
        results = load_site_class2Vs30(file_handle)
        os.remove(file_name)
        self.failUnless(results == answer, 'Failed!')
コード例 #3
0
    def test_load_site_class2Vs30_bad(self):
        a = 60.0
        b = 2.0
        title_index_dic = {"site_class": 0, "vs30yeah": 1}
        attribute_dic = {"site_class": ["A", "B"], "vs30yeah": [a, b]}
        answer = {"A": 60.0, "B": 2.0}

        handle, file_name = tempfile.mkstemp(".csv", "test_regolith_")
        os.close(handle)
        dict2csv(file_name, title_index_dic, attribute_dic)
        try:
            results = load_site_class2Vs30(file_name)
        except IOError:
            os.remove(file_name)
            pass
        else:
            os.remove(file_name)
            self.failUnless(False, "KeyError not raised")
コード例 #4
0
    def test_load_site_class2Vs30_bad(self):
        a = 60.0
        b = 2.0
        title_index_dic = {'site_class': 0, 'vs30yeah': 1}
        attribute_dic = {'site_class': ['A', 'B'], 'vs30yeah': [a, b]}
        answer = {'A': 60., 'B': 2.0}

        handle, file_name = tempfile.mkstemp('.csv', 'test_regolith_')
        os.close(handle)
        dict2csv(file_name, title_index_dic, attribute_dic)
        try:
            results = load_site_class2Vs30(file_name)
        except IOError:
            os.remove(file_name)
            pass
        else:
            os.remove(file_name)
            self.failUnless(False, "KeyError not raised")
コード例 #5
0
def write_test_file(file_name, attribute_dic=None):

    title_index_dic={
        'BID':0,
        'LATITUDE':1,
        'LONGITUDE':2,
        'STRUCTURE_CLASSIFICATION':3,
        'STRUCTURE_CATEGORY':4,
        'HAZUS_USAGE':5,
        'SUBURB':6,
        'POSTCODE':7,
        'PRE1989':8,
        'HAZUS_STRUCTURE_CLASSIFICATION':9,
        'CONTENTS_COST_DENSITY':10,
        'BUILDING_COST_DENSITY':11,
        'FLOOR_AREA':12,
        'SURVEY_FACTOR':13,
        'FCB_USAGE':14,
        'SITE_CLASS':15,
        'CD_CODE':16
        }    

    if attribute_dic is None:
        attribute_dic={
            'BID':[1,2],
            'LATITUDE':[-32.9,32.7],
            'LONGITUDE':[151.7,151.3],
            'STRUCTURE_CLASSIFICATION':['W1BVTILE','S3'],
            'STRUCTURE_CATEGORY':['BUILDING','BUILDING'],
            'HAZUS_USAGE':['RES1','COM8'],
            'SUBURB':['MEREWETHER','MEREWETHER'],
            'POSTCODE':[2291,2291],
            'PRE1989':[0,1],
            'HAZUS_STRUCTURE_CLASSIFICATION':['W1','URML'],
            'CONTENTS_COST_DENSITY':[300,10000],
            'BUILDING_COST_DENSITY':[600,1000],
            'FLOOR_AREA':[150,300],
            'SURVEY_FACTOR':[1,9.8],
            'FCB_USAGE':[111,451],
            'SITE_CLASS':['A','B'],
            'CD_CODE':['A','B']
            }
    dict2csv(file_name, title_index_dic, attribute_dic)
    return file_name, attribute_dic
コード例 #6
0
def write_test_file(file_name, attribute_dic=None):

    title_index_dic = {
        'BID': 0,
        'LATITUDE': 1,
        'LONGITUDE': 2,
        'STRUCTURE_CLASSIFICATION': 3,
        'STRUCTURE_CATEGORY': 4,
        'HAZUS_USAGE': 5,
        'SUBURB': 6,
        'POSTCODE': 7,
        'PRE1989': 8,
        'HAZUS_STRUCTURE_CLASSIFICATION': 9,
        'CONTENTS_COST_DENSITY': 10,
        'BUILDING_COST_DENSITY': 11,
        'FLOOR_AREA': 12,
        'SURVEY_FACTOR': 13,
        'FCB_USAGE': 14,
        'SITE_CLASS': 15
    }

    if attribute_dic is None:
        attribute_dic = {
            'BID': [1, 2, 3],
            'LATITUDE': [-32.9, -32.7, -33.],
            'LONGITUDE': [151.7, 151.3, 151.],
            'STRUCTURE_CLASSIFICATION': ['W1BVTILE', 'S3', 'S2'],
            'STRUCTURE_CATEGORY': ['BUILDING', 'BUILDING', 'BUILDING'],
            'HAZUS_USAGE': ['RES1', 'COM8', 'COM4'],
            'SUBURB': ['MEREWETHER', 'MEREWETHER', 'HUGHES'],
            'POSTCODE': [2291, 2291, 2289],
            'PRE1989': [0, 1, 1],
            'HAZUS_STRUCTURE_CLASSIFICATION': ['W1', 'URML', 'URML'],
            'CONTENTS_COST_DENSITY': [300, 10000, 200],
            'BUILDING_COST_DENSITY': [600, 1000, 700],
            'FLOOR_AREA': [150, 300, 100],
            'SURVEY_FACTOR': [1, 9.8, 2],
            'FCB_USAGE': [111, 451, 121],
            'SITE_CLASS': ['A', 'B', 'C']
        }
    dict2csv(file_name, title_index_dic, attribute_dic)
    return file_name, attribute_dic
コード例 #7
0
def write_test_file(file_name, attribute_dic=None):

    title_index_dic = {
        "BID": 0,
        "LATITUDE": 1,
        "LONGITUDE": 2,
        "STRUCTURE_CLASSIFICATION": 3,
        "STRUCTURE_CATEGORY": 4,
        "HAZUS_USAGE": 5,
        "SUBURB": 6,
        "POSTCODE": 7,
        "PRE1989": 8,
        "HAZUS_STRUCTURE_CLASSIFICATION": 9,
        "CONTENTS_COST_DENSITY": 10,
        "BUILDING_COST_DENSITY": 11,
        "FLOOR_AREA": 12,
        "SURVEY_FACTOR": 13,
        "FCB_USAGE": 14,
        "SITE_CLASS": 15,
    }

    if attribute_dic is None:
        attribute_dic = {
            "BID": [1, 2],
            "LATITUDE": [-32.9, 32.7],
            "LONGITUDE": [151.7, 151.3],
            "STRUCTURE_CLASSIFICATION": ["W1BVTILE", "S3"],
            "STRUCTURE_CATEGORY": ["BUILDING", "BUILDING"],
            "HAZUS_USAGE": ["RES1", "COM8"],
            "SUBURB": ["MEREWETHER", "MEREWETHER"],
            "POSTCODE": [2291, 2291],
            "PRE1989": [0, 1],
            "HAZUS_STRUCTURE_CLASSIFICATION": ["W1", "URML"],
            "CONTENTS_COST_DENSITY": [300, 10000],
            "BUILDING_COST_DENSITY": [600, 1000],
            "FLOOR_AREA": [150, 300],
            "SURVEY_FACTOR": [1, 9.8],
            "FCB_USAGE": [111, 451],
            "SITE_CLASS": ["A", "B"],
        }
    dict2csv(file_name, title_index_dic, attribute_dic)
    return file_name, attribute_dic