Example #1
0
    def test_get_directional_vulnerability2(self):
        # thresholds: 11.5, 28.75, 41.25, 90.0

        tower_dic = self.tower_dic.copy()
        tower_dic.update({'axisaz': 0})

        bearings = [
            0., 15., 30., 45., 60., 75., 90., 105., 120., 135., 150., 165.,
            180., 195., 210., 225., 240., 255., 270., 285., 300., 315., 330.,
            345.
        ]
        expected = [
            11.5, 28.75, 41.25, 90.0, 90.0, 90.0, 90.0, 90.0, 90.0, 90.0,
            41.25, 28.75
        ] * 2

        for bearing, value in zip(bearings, expected):

            tower = Tower(**tower_dic)
            result = tower.get_directional_vulnerability(bearing)
            try:
                self.assertAlmostEqual(result, value)
            except AssertionError:
                print(
                    f'Wrong: bearing:{bearing}, axisaz: {tower_dic["axisaz"]}, result:{result}, expected: {value}'
                )
Example #2
0
    def test_collapse_interaction(self):

        tower_dic = self.tower_dic.copy()
        tower_dic.update({
            'axisaz': 91,
            'no_sims': 5000,
            'cond_pc_interaction_no': [1, 3, 5, 7],
            'cond_pc_interaction_cprob': [0.2, 0.3, 0.31, 0.311],
            'cond_pc_interaction_prob': {
                1: 0.2,
                3: 0.1,
                5: 0.01,
                7: 0.001
            }
        })
        tower = Tower(**tower_dic)
        tower.init()
        tower._wind = create_wind_given_bearing(130.0, 1.072)

        #tower.collapse_interaction
        x = tower.collapse_interaction.groupby(['id_time', 'no_collapse'
                                                ]).apply(len).reset_index()
        for _, row in x.iterrows():
            expected = tower.dmg['collapse'].iloc[
                row['id_time']] * tower.cond_pc_interaction_prob[
                    row['no_collapse']]
            result = row[0] / tower.no_sims
            np.testing.assert_allclose(expected, result, atol=ATOL, rtol=RTOL)
Example #3
0
    def test_logger_collapse_interaction(self):

        with self.assertLogs('wistl.tower', level='INFO') as cm:
            tower_dic = self.tower_dic.copy()
            tower_dic.update({
                'axisaz':
                91,
                'no_sims':
                50,
                'cond_pc_interaction_no': [1, 3, 5, 7],
                'cond_pc_interaction_cprob': [0.2, 0.3, 0.31, 0.311],
                'cond_pc_interaction_prob': {
                    1: 0.2,
                    3: 0.1,
                    5: 0.01,
                    7: 0.001
                }
            })
            tower = Tower(**tower_dic)
            tower.init()
            prob_dic = {1: 0.2, 3: 0.1, 5: 0.01, 7: 0.001}
            tower._wind = create_wind_given_bearing(130.0, 1.072)
            tower.collapse_interaction

        msg = f'WARNING:wistl.tower:Pc_interaction({tower.name})'
        self.assertEqual(msg, ':'.join(cm.output[0].split(':')[:3]))
Example #4
0
    def test_collapse_adj_sim(self):

        # tower14 (idl: 13,
        tower_dic = self.tower_dic.copy()
        tower_dic.update({
            'axisaz': 90,
            'no_sims': 5000,
            'function': 'strainer'
        })

        tower = Tower(**tower_dic)
        tower.init()
        tower._wind = create_wind_given_bearing(130.0,
                                                1.2282)  # 1.18*np.exp(0.04)
        tower.collapse_adj_sim
Example #5
0
    def towers(self):

        if self._towers is None:

            self._towers = {}

            for idn in self.dic_towers:
                dic = h_tower(line=self, idn=idn)
                self._towers[dic['idl']] = Tower(**dic)

        return self._towers
Example #6
0
    def test_collapse_adj_sim(self):

        # tower14 (idl: 13,
        tower_dic = self.tower_dic.copy()
        tower_dic.update({'axisaz': 90, 'no_sims': 6000})

        tower = Tower(**tower_dic)
        tower.init()
        tower._wind = create_wind_given_bearing(
            [130, 130, 120, 130],
            [0.0712, 1.0712, 1.0712, 0.0712])  # 1.05*np.exp(0.02)
        df = tower.collapse_adj_sim.groupby(['id_time', 'id_adj'
                                             ]).apply(len).reset_index()
        for idl in tower.cond_pc_adj.keys():
            x = df.loc[df['id_adj'].apply(lambda x: idl in x)].groupby(
                'id_time').sum() / tower.no_sims
            np.testing.assert_allclose(x[0].values,
                                       tower.collapse_adj[idl],
                                       atol=ATOL,
                                       rtol=RTOL)
Example #7
0
    def test_get_directional_vulnerability1(self):
        # thresholds: 11.5, 28.75, 41.25, 90.0

        tower_dic = self.tower_dic.copy()
        tower_dic.update({'axisaz': 90})

        bearings = [
            10.0, 45.0, 60.0, 70.0, 80.0, 170.0, 135.0, 120.0, 110.0, 100.0,
            190.0, 225.0, 240.0, 250.0, 260.0, 350.0, 315.0, 300.0, 290.0,
            280.0
        ]
        expected = [180] * 20

        for bearing, value in zip(bearings, expected):

            tower = Tower(**tower_dic)
            result = tower.get_directional_vulnerability(bearing)
            try:
                self.assertAlmostEqual(result, value)
            except AssertionError:
                print(
                    f'Wrong: bearing:{bearing}, axisaz: {tower_dic["axisaz"]}, result:{result}, expected: {value}'
                )
Example #8
0
    def test_logger_collapse_adj_sim(self):

        with self.assertLogs('wistl.tower', level='INFO') as cm:
            # tower14 (idl: 13,
            tower_dic = self.tower_dic.copy()
            tower = Tower(**tower_dic)
            tower.init()
            tower.no_sims = 10
            tower._wind = create_wind_given_bearing(
                130.0, 1.0712)  # 1.05*np.exp(0.02)
            tower.collapse_adj_sim

        msg = 'WARNING:wistl.tower'
        self.assertEqual(msg, ':'.join(cm.output[0].split(':')[:2]))
Example #9
0
    def test_logger_dmg_sim(self):

        with self.assertLogs('wistl.tower', level='INFO') as cm:

            tower_dic = self.tower_dic.copy()
            tower = Tower(**tower_dic)
            tower.init()
            tower.no_sims = 10
            # 1. determine damage state of tower due to wind
            tower._wind = create_wind_given_bearing(
                130.0, 1.0712)  # 1.05*np.exp(0.02)
            tower.dmg_sim

        msg = 'WARNING:wistl.tower'
        self.assertEqual(msg, ':'.join(cm.output[0].split(':')[:2]))
Example #10
0
    def setUpClass(cls):
        # 23, T9
        cls.logger = logging.getLogger(__name__)

        frag_dic = {
            180: {
                'minor': ['lognorm', '1.143', '0.032'],
                'collapse': ['lognorm', '1.18', '0.04']
            }
        }

        cond_pc = {
            (-1, 0, 1): 0.05,
            (-2, -1, 0, 1, 2): 0.08,
            (-3, -2, -1, 0, 1, 2, 3): 0.10,
            (-4, -3, -2, -1, 0, 1, 2, 3, 4): 0.08,
            (-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5): 0.05,
            (-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6): 0.62,
        }

        cond_pc_adj = {
            2: 0.62,
            3: 0.67,
            4: 0.75,
            5: 0.85,
            6: 0.93,
            7: 0.98,
            9: 0.98,
            10: 0.93,
            11: 0.85,
            12: 0.75,
            13: 0.67,
            14: 0.62
        }

        cond_pc_adj_sim_idx = [(7, 9), (3, 4, 5, 6, 7, 9, 10, 11, 12, 13),
                               (6, 7, 9, 10), (4, 5, 6, 7, 9, 10, 11, 12),
                               (5, 6, 7, 9, 10, 11),
                               (2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14)]

        cond_pc_adj_sim_prob = np.array([0.05, 0.10, 0.18, 0.26, 0.36, 0.98])

        cls.tower_dic = {
            'type': 'Lattice Tower',
            'name': 'T9',
            'latitude': 0.0,
            'longitude': 149.0,
            'comment': 'Test',
            'function': 'Suspension',
            'devangle': 0,
            'axisaz': 134,
            'constcost': 0.0,
            'height': 17.0,
            'yrbuilt': 1980,
            'locsource': 'Fake',
            'lineroute': 'LineA',
            #'shapes': <shapefile.Shape object at 0x7ff06908ec50>,
            'coord': np.array([149.065, 0.]),
            'coord_lat_lon': np.array([0., 149.065]),
            #'point': <shapely.geometry.point.Point object at 0x7ff06908e320>,
            'design_span': 400.0,
            'design_level': 'low',
            'design_speed': 75.0,
            'terrain_cat': 2,
            'file_wind_base_name': 'ts.T9.csv',
            'height_z': 15.4,
            'ratio_z_to_10': 1.0524,
            'actual_span': 556.5974539658616,
            'u_factor': 1.0,
            'collapse_capacity': 75.0,
            'cond_pc': cond_pc,
            'max_no_adj_towers': 6,
            'id_adj': [2, 3, 4, 5, 6, 7, -1, 9, 10, 11, 12, 13, 14],
            'idl': 8,
            'idn': 0,
            'cond_pc_adj': cond_pc_adj,
            'cond_pc_adj_sim_idx': cond_pc_adj_sim_idx,
            'cond_pc_adj_sim_prob': cond_pc_adj_sim_prob,
            'no_sims': 10000,
            'damage_states': ['minor', 'collapse'],
            'non_collapse': ['minor'],
            'rnd_state': np.random.RandomState(1),
            'event_id': 0,
            'rtol': RTOL,
            'atol': ATOL,
            'dmg_threshold': PM_THRESHOLD,
            'scale': 1.0,
            'frag_dic': frag_dic,
            'path_event': os.path.join(BASE_DIR, 'wind_event/test1'),
        }

        cls.tower = Tower(**cls.tower_dic)
Example #11
0
    def setUpClass(cls):

        cls.logger = logging.getLogger(__name__)

        frag_dic = {
            11.5: {
                'minor': ['lognorm', '1.02', '0.02'],
                'collapse': ['lognorm', '1.05', '0.02']
            },
            28.75: {
                'minor': ['lognorm', '1.0', '0.02'],
                'collapse': ['lognorm', '1.02', '0.02']
            },
            41.25: {
                'minor': ['lognorm', '1.04', '0.02'],
                'collapse': ['lognorm', '1.07', '0.02']
            },
            90: {
                'minor': ['lognorm', '-1.05', '0.02'],
                'collapse': ['lognorm', '-1.05', '0.02']
            },
        }

        cond_pc = {
            (0, 1): 0.075,
            (-1, 0): 0.075,
            (-1, 0, 1): 0.35,
            (-1, 0, 1, 2): 0.025,
            (-2, -1, 0, 1): 0.025,
            (-2, -1, 0, 1, 2): 0.1
        }

        cond_pc_adj = {12: 0.575, 14: 0.575, 15: 0.125, 11: 0.125}

        cond_pc_adj_sim_idx = [(12, 14, 15), (11, 12, 14), (14, ), (12, ),
                               (11, 12, 14, 15), (12, 14)]

        cond_pc_adj_sim_prob = np.array([0.025, 0.05, 0.125, 0.2, 0.3, 0.65])

        cls.tower_dic = {
            'type': 'Lattice Tower',
            'name': 'T14',
            'latitude': 0.0,
            'longitude': 149.0,
            'comment': 'Test',
            'function': 'Suspension',
            'devangle': 0,
            'axisaz': 134,
            'constcost': 0.0,
            'height': 17.0,
            'yrbuilt': 1980,
            'locsource': 'Fake',
            'lineroute': 'LineA',
            #'shapes': <shapefile.Shape object at 0x7ff06908ec50>,
            'coord': np.array([149.065, 0.]),
            'coord_lat_lon': np.array([0., 149.065]),
            #'point': <shapely.geometry.point.Point object at 0x7ff06908e320>,
            'design_span': 400.0,
            'design_level': 'low',
            'design_speed': 75.0,
            'terrain_cat': 2,
            'file_wind_base_name': 'ts.T14.csv',
            'height_z': 15.4,
            'ratio_z_to_10': 1.0524,
            'actual_span': 556.5974539658616,
            'u_factor': 1.0,
            'collapse_capacity': 75.0,
            'cond_pc': cond_pc,
            'max_no_adj_towers': 2,
            'id_adj': [11, 12, 13, 14, 15],
            'idl': 13,
            'idn': 0,
            'cond_pc_adj': cond_pc_adj,
            'cond_pc_adj_sim_idx': cond_pc_adj_sim_idx,
            'cond_pc_adj_sim_prob': cond_pc_adj_sim_prob,
            'no_sims': 1000,
            'damage_states': ['minor', 'collapse'],
            'non_collapse': ['minor'],
            'rnd_state': np.random.RandomState(1),
            'event_id': 0,
            'scale': 1.0,
            'frag_dic': frag_dic,
            'rtol': RTOL,
            'atol': ATOL,
            'dmg_threshold': PM_THRESHOLD,
            'path_event': os.path.join(BASE_DIR, 'wind_event/test1'),
        }

        cls.tower = Tower(**cls.tower_dic)