Exemplo n.º 1
0
 def setUp(self):
     reset_seed(True)
Exemplo n.º 2
0
    def test_calc_total_loss_OS_bug_search(self):
        blocking_block_comments = True
        """plugging in results from TS_risk57.par"""
        
        SA =array([[[0.14210731, 0.29123634, 0.23670422, 0.13234554,
                     0.08648546, 0.06338455, 0.04945741, 0.04140068,
                     0.03497466, 0.02969136, 0.02525473, 0.02151188,
                     0.018371, 0.01571802, 0.01344816, 0.01148438,
                     0.00980236, 0.00836594, 0.00714065, 0.00609482],
                    [0.2093217, 0.30976405, 0.16232743, 0.06989206,
                     0.03216174, 0.01945677, 0.01347719, 0.00987403,
                     0.00799221, 0.00660128, 0.00547129, 0.0045463,
                     0.0042072, 0.00418348, 0.0041599, 0.00413222,
                     0.00410333, 0.00407463, 0.00404614, 0.00401785],
                    [0.01450217, 0.02750284, 0.02231209, 0.01127933,
                     0.00793098, 0.00621618, 0.0051103, 0.00430777,
                     0.00364714, 0.0031542, 0.00279411, 0.00247654,
                     0.0022153, 0.001994, 0.0017948, 0.00161223,
                     0.00144737, 0.00129929, 0.00117312, 0.00105988]]])
        event_set = array([6.0201519, 6.0201519, 6.0201519])

        eqrm_flags = Dummy()
        eqrm_flags.csm_variability_method = 3
        eqrm_flags.atten_periods = array([0., 0.17544,0.35088, 0.52632,
                                           0.70175, 0.87719, 1.0526, 1.2281,
                                           1.4035, 1.5789, 1.7544, 1.9298,
                                           2.1053, 2.2807, 2.4561, 2.6316,
                                           2.807,  2.9825, 3.1579, 3.3333 ])
        eqrm_flags.csm_use_variability = True
        eqrm_flags.csm_standard_deviation = 0.3
        eqrm_flags.csm_damping_regimes = CSM_DAMPING_REGIMES_USE_ALL
        eqrm_flags.csm_damping_modify_Tav = CSM_DAMPING_MODIFY_TAV
        eqrm_flags.csm_damping_use_smoothing = CSM_DAMPING_USE_SMOOTHING
        eqrm_flags.csm_SDcr_tolerance_percentage = 1
        eqrm_flags.csm_damping_max_iterations = 7
        eqrm_flags.csm_hysteretic_damping = 'trapezoidal'
        eqrm_flags.bridges_functional_percentages = None
        eqrm_flags.atten_override_RSA_shape = None
        eqrm_flags.atten_pga_scaling_cutoff = False
        eqrm_flags.atten_cutoff_max_spectral_displacement = False
        eqrm_flags.loss_min_pga = 0.05
        eqrm_flags.loss_regional_cost_index_multiplier = 1.4516
        eqrm_flags.loss_aus_contents = 0

        building_parameters = {'residential_drift_threshold':
                                   array([[21.9456, 43.8912,
                                           109.728 ,164.592]]),
                               'structure_class':
                                   array(['BUILDING'], dtype='|S8'),
                               'height': array([7315.2]),
                               'nsd_a_ratio': array([0.7254902]),
                               'design_strength': array([0.033]),
                               'non_residential_drift_threshold':
                                   array([[5.4864, 43.8912, 82.296, 137.16]]),
                               'damping_Be': array([0.1]),
                               'fraction_in_first_mode': array([0.8]),
                               'ultimate_to_yield': array([3.]),
                               'acceleration_threshold':
                                   array([[0.2, 0.4, 0.8, 1.6]]),
                               'nsd_d_ratio': array([0.11764706]),
                               'structure_ratio': array([0.15686275]),
                               'structural_damage_threshold':
                                   array([[26.33472, 41.69664,
                                           88.87968, 219.456]]),
                               'natural_elastic_period': array([0.5]),
                               'damping_s': array([0.4]),
                               'drift_threshold':
                                   array([[5.4864, 43.8912, 82.296, 137.16]]),
                               'yield_to_design': array([1.5]),
                               'structure_classification':
                                   array(['S1L'], dtype='|S13'),
                               'height_to_displacement': array([0.75]),
                               'ductility': array([5.]),
                               'damping_l': array([0.]),
                               'damping_m': array([0.2])}

        # Note, this lats and longs are wrong
        sites = Structures(latitude=[-31],longitude=[150],
                           building_parameters=building_parameters)
        sites.attributes = {'FCB_USAGE': array([311]),
                            'SURVEY_FACTOR': array([1.]),
                            'HAZUS_STRUCTURE_CLASSIFICATION':
                                array(['S1L'], dtype='|S4'),
                            'SITE_CLASS': array(['D'], dtype='|S1'),
                            'FLOOR_AREA': array([3000.]),
                            'CONTENTS_COST_DENSITY': array([823.4392]),
                            'STRUCTURE_CATEGORY':
                                array(['BUILDING'], dtype='|S8'),
                            'STRUCTURE_CLASSIFICATION':
                                array(['S1L'], dtype='|S13'),
                            'SUBURB': array(['LAMBTON'], dtype='|S19'),
                            'HAZUS_USAGE': array(['IND3'], dtype='|S4'),
                            'POSTCODE': array([2299]),
                            'BUILDING_COST_DENSITY': array([548.9594]),
                            'BID': array([3562]),
                            'PRE1989': array([0])}

        reset_seed(True)
        total_loss, _ = sites.calc_total_loss(SA, 
                                              eqrm_flags, 
                                              event_set)

        total_loss_windows = (array([[5.56013748, 0.00899564, 0.]]),
                              array([[4059.31954558, 1473.71938878, 0.]]),
                              array([[9423.06584855, 1181.40856505, 0.]]),
                              array([[9978.48421213, 1226.05473008, 0.]]))
        assert allclose(asarray(total_loss), asarray(total_loss_windows))
Exemplo n.º 3
0
    def test_calc_total_loss_OS_bug_search(self):
        blocking_block_comments = True
        """plugging in results from TS_risk57.par"""
        
        SA =array([[[0.14210731, 0.29123634, 0.23670422, 0.13234554,
                     0.08648546, 0.06338455, 0.04945741, 0.04140068,
                     0.03497466, 0.02969136, 0.02525473, 0.02151188,
                     0.018371, 0.01571802, 0.01344816, 0.01148438,
                     0.00980236, 0.00836594, 0.00714065, 0.00609482],
                    [0.2093217, 0.30976405, 0.16232743, 0.06989206,
                     0.03216174, 0.01945677, 0.01347719, 0.00987403,
                     0.00799221, 0.00660128, 0.00547129, 0.0045463,
                     0.0042072, 0.00418348, 0.0041599, 0.00413222,
                     0.00410333, 0.00407463, 0.00404614, 0.00401785],
                    [0.01450217, 0.02750284, 0.02231209, 0.01127933,
                     0.00793098, 0.00621618, 0.0051103, 0.00430777,
                     0.00364714, 0.0031542, 0.00279411, 0.00247654,
                     0.0022153, 0.001994, 0.0017948, 0.00161223,
                     0.00144737, 0.00129929, 0.00117312, 0.00105988]]])
        event_set = array([6.0201519, 6.0201519, 6.0201519])

        eqrm_flags = Dummy()
        eqrm_flags.csm_variability_method = 3
        eqrm_flags.atten_periods = array([0., 0.17544,0.35088, 0.52632,
                                           0.70175, 0.87719, 1.0526, 1.2281,
                                           1.4035, 1.5789, 1.7544, 1.9298,
                                           2.1053, 2.2807, 2.4561, 2.6316,
                                           2.807,  2.9825, 3.1579, 3.3333 ])
        eqrm_flags.csm_use_variability = True
        eqrm_flags.csm_standard_deviation = 0.3
        eqrm_flags.csm_damping_regimes = CSM_DAMPING_REGIMES_USE_ALL
        eqrm_flags.csm_damping_modify_Tav = CSM_DAMPING_MODIFY_TAV
        eqrm_flags.csm_damping_use_smoothing = CSM_DAMPING_USE_SMOOTHING
        eqrm_flags.csm_SDcr_tolerance_percentage = 1
        eqrm_flags.csm_damping_max_iterations = 7
        eqrm_flags.csm_hysteretic_damping = 'trapezoidal'
        eqrm_flags.bridges_functional_percentages = None
        eqrm_flags.atten_override_RSA_shape = None
        eqrm_flags.atten_pga_scaling_cutoff = False
        eqrm_flags.atten_cutoff_max_spectral_displacement = False
        eqrm_flags.loss_min_pga = 0.05
        eqrm_flags.loss_regional_cost_index_multiplier = 1.4516
        eqrm_flags.loss_aus_contents = 0

        building_parameters = {'residential_drift_threshold':
                                   array([[21.9456, 43.8912,
                                           109.728 ,164.592]]),
                               'structure_class':
                                   array(['BUILDING'], dtype='|S8'),
                               'height': array([7315.2]),
                               'nsd_a_ratio': array([0.7254902]),
                               'design_strength': array([0.033]),
                               'non_residential_drift_threshold':
                                   array([[5.4864, 43.8912, 82.296, 137.16]]),
                               'damping_Be': array([0.1]),
                               'fraction_in_first_mode': array([0.8]),
                               'ultimate_to_yield': array([3.]),
                               'acceleration_threshold':
                                   array([[0.2, 0.4, 0.8, 1.6]]),
                               'nsd_d_ratio': array([0.11764706]),
                               'structure_ratio': array([0.15686275]),
                               'structural_damage_threshold':
                                   array([[26.33472, 41.69664,
                                           88.87968, 219.456]]),
                               'natural_elastic_period': array([0.5]),
                               'damping_s': array([0.4]),
                               'drift_threshold':
                                   array([[5.4864, 43.8912, 82.296, 137.16]]),
                               'yield_to_design': array([1.5]),
                               'structure_classification':
                                   array(['S1L'], dtype='|S13'),
                               'height_to_displacement': array([0.75]),
                               'ductility': array([5.]),
                               'damping_l': array([0.]),
                               'damping_m': array([0.2])}

        # Note, this lats and longs are wrong
        sites = Structures(latitude=[-31],longitude=[150],
                           building_parameters=building_parameters)
        sites.attributes = {'FCB_USAGE': array([311]),
                            'SURVEY_FACTOR': array([1.]),
                            'HAZUS_STRUCTURE_CLASSIFICATION':
                                array(['S1L'], dtype='|S4'),
                            'SITE_CLASS': array(['D'], dtype='|S1'),
                            'FLOOR_AREA': array([3000.]),
                            'CONTENTS_COST_DENSITY': array([823.4392]),
                            'STRUCTURE_CATEGORY':
                                array(['BUILDING'], dtype='|S8'),
                            'STRUCTURE_CLASSIFICATION':
                                array(['S1L'], dtype='|S13'),
                            'SUBURB': array(['LAMBTON'], dtype='|S19'),
                            'HAZUS_USAGE': array(['IND3'], dtype='|S4'),
                            'POSTCODE': array([2299]),
                            'BUILDING_COST_DENSITY': array([548.9594]),
                            'BID': array([3562]),
                            'PRE1989': array([0])}

        reset_seed(True)
        total_loss, _ = sites.calc_total_loss(SA, 
                                              eqrm_flags, 
                                              event_set)

        total_loss_windows = (array([[5.56013748, 0.00899564, 0.]]),
                              array([[4059.31954558, 1473.71938878, 0.]]),
                              array([[9423.06584855, 1181.40856505, 0.]]),
                              array([[9978.48421213, 1226.05473008, 0.]]))
        assert allclose(asarray(total_loss), asarray(total_loss_windows))