IN-CORE_resilience-logo.png

Wood Pole Damage#

Jupyter Notebook Created by:

1) Initialization#

import warnings
warnings.filterwarnings("ignore")
import os
import pandas as pd
import geopandas as gpd 
import numpy as np
import sys 
import os 
import glob
import matplotlib.pyplot as plt
import contextily as ctx
import copy
import math
from scipy.stats import norm
from pathlib import Path

from pyincore import IncoreClient, Dataset, DataService, HazardService, FragilityService, MappingSet, FragilityCurveSet
from pyincore_viz.geoutil import GeoUtil as geoviz
from pyincore_viz.plotutil import PlotUtil as plotviz

# importing pyIncone analyses:
from pyincore.analyses.buildingdamage import BuildingDamage
from pyincore.analyses.bridgedamage import BridgeDamage
from pyincore.analyses.roaddamage import RoadDamage
from pyincore.analyses.epfdamage import EpfDamage
from pyincore.analyses.buildingfunctionality import BuildingFunctionality
from pyincore.analyses.housingunitallocation import HousingUnitAllocation
from pyincore.analyses.populationdislocation import PopulationDislocation, PopulationDislocationUtil
from pyincore.analyses.housingrecoverysequential import HousingRecoverySequential
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], line 4
      2 warnings.filterwarnings("ignore")
      3 import os
----> 4 import pandas as pd
      5 import geopandas as gpd 
      6 import numpy as np

ModuleNotFoundError: No module named 'pandas'
# Check package versions - good practice for replication
print("Python Version ", sys.version)
print("pandas version: ", pd.__version__)
print("numpy version: ", np.__version__)
Python Version  3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:23:20) 
[Clang 12.0.1 ]
pandas version:  1.4.2
numpy version:  1.22.3
# Check working directory - good practice for relative path access
os.getcwd()
'/Users/mr77/Desktop/ProjectFiles/HybridResiliencePaper/Jupyter Notebooks/01_Damage_Electric Power_Wood poles'
client = IncoreClient()
# IN-CORE caches files on the local machine, it might be necessary to clear the memory
#client.clear_cache() 
data_service = DataService(client) # create data_service object for loading files
hazard_service = HazardService(client)
fragility_service = FragilityService(client)
Enter username: rmehrzad90
Enter password: ········
Connection successful to IN-CORE services. pyIncore version detected: 1.4.1

2) Setting up an alternative plotting function to plot spatially#

from mpl_toolkits.axes_grid1 import make_axes_locatable
def plot_gdf_map(gdf, column, category=False, basemap=True, source=ctx.providers.OpenStreetMap.Mapnik, **kwargs):
    """
    Taken from pyincore-viz. 
    Not using the pyincore-viz version b/c it's limited on plotting options
        - Added **kwargs for more control over the geopandas plotting function
    """
    fig, ax = plt.subplots(1,1, figsize=(10,15))
    gdf = gdf.to_crs(epsg=3857)

    if category == False: # adding a colorbar to side
        divider = make_axes_locatable(ax)
        cax = divider.append_axes("right", size="5%", pad=0.1)

        ax = gdf.plot(figsize=(10, 10), 
                      column=column,
                      categorical=category, 
                      legend=True,
                      ax=ax,
                      cax=cax,
                     **kwargs)

    elif category == True:
        ax = gdf.plot(figsize=(10, 10), 
                      column=column,
                      categorical=category, 
                      legend=True,
                      ax=ax,
                     **kwargs)

        
    if basemap:
        ctx.add_basemap(ax, source=source)

import matplotlib 
matplotlib.rc('xtick', labelsize=20) 
matplotlib.rc('ytick', labelsize=20) 

3) Hazard Model (Hurricane)#

hazard_type = "hurricane"

There are currently five hurricane hazard data for Galveston testbed. Four of them were created using the dynamically coupled versions of the Advanced Circulation (ADCIRC) and Simulating Waves Nearshore (SWAN) models. One of them is a surrogate model developed using USACE datasets.

No.

Simulation type

Name

GUID

More details

1

Coupled ADCIRC+SWAN

Hurricane Ike Hindcast

5fa5a228b6429615aeea4410

Darestani et al. (2021)

2

Coupled ADCIRC+SWAN

2% AEP Hurricane Simulation

5fa5a83c7e5cdf51ebf1adae

Darestani et al. (2021)

3

Coupled ADCIRC+SWAN

1% AEP Hurricane Simulation

5fa5a9497e5cdf51ebf1add2

Darestani et al. (2021)

4

Coupled ADCIRC+SWAN

0.2% AEP Hurricane Simulation

5fa5aa19b6429615aeea4476

Darestani et al. (2021)

5

Kriging-based surrogate model

Galveston Deterministic Hurricane - Kriging

5f15cd627db08c2ccc4e3bab

Fereshtehnejad et al. (2021)

Coupled ADCIRC+SWAN#

Galveston Island was struck by Hurricane Ike in September, 2008, with maximum windspeeds of 49 m/s (95 kts) and storm surge elevations reaching at least +3.5 m (NAVD88) on Galveston Island. A full hindcast of Hurricane Ike’s water levels, and wave conditions along with 2% (50-yr return period), 1% (100-yr return period), and 0.2% (500-yr return period) Annual Exceedance Probabilities (AEP) hurricane simulations were created using ADCIRC+SWAN models. These hurricane hazard events contain eight hazardDatasets, which is five more than the current pyincore hurricane schema. Please be sure to adjust your codes accordingly if you need to incorporate the five new intensity measures (IMs). The existing schema includes the peak significant wave height, peak surge level, and inundation duration. These new events include those as well as maximum inundation depth, peak wave period, wave direction, maximum current speed, and maximum wind speed.

Kriging-based surrogate model#

Three hazardDatasets of kriging-based surrogate models are developed for peak significant wave height, peak surge level, and inundation duration. Training datasets for developing the Kriging surorgate models were collected through USACE. For the peak significant wave height, peak surge level, and inundation duration the training datasets included 61, 251, and 254 synthetic storms, respectively.

What is the your desired hurricane simulation?#

hur_hazard_dict = {1: "Galv_EPNNodes_DataandHazard_Ike.csv", 
                   2: "Galv_EPNNodes_DataandHazard_50yr.csv",
                   3: "Galv_EPNNodes_DataandHazard_100yr.csv",
                   4: "Galv_EPNNodes_DataandHazard_500yr.csv",
                   5: "Galv_EPNNodes_DataandHazard_kriging.csv"}
hur_no = int(input('The No. of your desired hurricane simulation: '))
The No. of your desired hurricane simulation: 1
EPN_inv_csv = hur_hazard_dict[hur_no]
EPN_inv_csv
'Galv_EPNNodes_DataandHazard_Ike.csv'
path_to_output = os.path.join(os.getcwd(), 'output', 'Results for Hurricane No{}' .format(hur_no))
if not os.path.exists(path_to_output):
    os.makedirs(path_to_output)

4) Wood poles inventory, fragility, and damage#

INVENTORY#

Num_of_Conductors = 4
Dia_of_Conductors = 0.025 #m
# Wood Poles Inventory Dataset
EPN_inv_df  = pd.read_csv(EPN_inv_csv)

Lon_EPNnodes = pd.read_csv(EPN_inv_csv, usecols=['LON'])
Lat_EPNnodes = pd.read_csv(EPN_inv_csv, usecols=['LAT'])

WindVel = pd.read_csv(EPN_inv_csv, usecols=['MaxWindVel']) 
WaterVel = pd.read_csv(EPN_inv_csv, usecols=['MaxWaterVel']) 
SurgeHeight = pd.read_csv(EPN_inv_csv, usecols=['MaxWSE']) 
WaveHeight = pd.read_csv(EPN_inv_csv, usecols=['MaxSigWaveHt']) 
WindDir = pd.read_csv(EPN_inv_csv, usecols=['MaxWaveDir']) 

Class = pd.read_csv(EPN_inv_csv, usecols=['CLASS']) 
Height = pd.read_csv(EPN_inv_csv, usecols=['HEIGHT']) 
Type = pd.read_csv(EPN_inv_csv, usecols=['TYPE']) 
Soil = pd.read_csv(EPN_inv_csv, usecols=['SOIL']) 
Age = pd.read_csv(EPN_inv_csv, usecols=['AGE']) 
SpanLength = pd.read_csv(EPN_inv_csv, usecols=['SpanLength']) 
ConSurArea = SpanLength*Num_of_Conductors*Dia_of_Conductors
Class=np.array(Class) # <class 'numpy.float64'>
Type=np.array(Type)   # <class 'numpy.int64'> 
Soil=np.array(Soil)   # <class 'str'>

Soil
array([['Very Stiff'],
       ['Very Stiff'],
       ['Very Stiff'],
       ...,
       ['Very Stiff'],
       ['Very Stiff'],
       ['Very Stiff']], dtype=object)
def EPN_fail_prob(WindVel,WaterVel,SurgeHeight,WaveHeight,WindDir,Age,ConSurArea,Height,Class,Type,Soil):

    WindVel=np.array(WindVel)
    WaterVel=np.array(WaterVel)
    SurgeHeight=np.array(SurgeHeight)
    WaveHeight=np.array(WaveHeight)
    WindDir=np.array(WindDir)
    Age=np.array(Age)
    ConSurArea=np.array(ConSurArea)
    Height=np.array(Height)
    Class=np.array(Class)
    Type=np.array(Type)
    Soil=np.array(Soil)
    
    pf_woodpole_polerupture=[];
    for i in range(0, np.size(WindVel,0)):
        if Soil[i,0]  == 'Stiff': 
            a0 = -7.1325;
        elif Soil[i,0]  == 'Very Stiff': 
            a0 = -6.798
            a1 = 0.021067
            a2 = 0.040692
            a3 = 0.33019
            a4 = 0.033158 
            a5 = 0.002863
            a6 = 0.026811
            a7 = 0.56842
        pf_woodpole_polerupture.append(1/(1+math.exp(-(a0+a1*WindVel[i,0]+a2*(Height[i,0]/3.281-SurgeHeight[i,0]-WaveHeight[i,0])
                                           +a3*WaterVel[i,0]*SurgeHeight[i,0]+a4*WindVel[i,0]*math.sin(WindDir[i,0]*math.pi/180)
                                           +a5*WindVel[i,0]*ConSurArea[i,0]+a6*max(Age[i,0],25)+a7*WaveHeight[i,0]))))
        

    return pf_woodpole_polerupture
PF_woodpole = EPN_fail_prob(WindVel,WaterVel,SurgeHeight,WaveHeight,WindDir,Age,ConSurArea,Height,Class,Type,Soil)
np.size(PF_woodpole)
PF_woodpole
[nan,
 nan,
 nan,
 nan,
 nan,
 nan,
 nan,
 nan,
 nan,
 0.010639763138594051,
 0.04168102943108706,
 0.03307495137137483,
 0.035460514380348536,
 0.04222803912692982,
 0.03344727862395931,
 0.03698494993542245,
 0.03393826981529394,
 0.022802258966722107,
 0.029432907145305214,
 0.02813163748991182,
 0.04070515744047973,
 0.040722642736861187,
 0.0388879347339218,
 0.028518797161995714,
 0.04209361342314816,
 0.03264789082473314,
 0.03131007659665255,
 0.02991454039459203,
 0.0336952275754712,
 0.029609868273096293,
 0.02687675327912172,
 0.03070062704821486,
 0.03421660264224059,
 0.02598948440872228,
 0.03248024479145282,
 0.04387628614688654,
 0.03267267286402243,
 0.041795433063944884,
 0.03331268302434379,
 0.03010578877567625,
 0.024724349251594325,
 0.03251154048357941,
 0.02649748746876436,
 0.03716518736240776,
 0.02684739981941228,
 0.03508194965410416,
 0.029930287491684318,
 0.03871174809949811,
 0.02885190302538584,
 0.03321886969438518,
 0.022891597321931936,
 0.029103500336557984,
 0.024538327486956116,
 0.023507375411515874,
 0.02440369448182992,
 0.029879216777062848,
 0.029805147175020606,
 0.04098117914362335,
 0.03437891007418965,
 0.03553648263739567,
 0.027755130973541042,
 0.02787264816422525,
 0.03668784766475649,
 0.02776812379152776,
 0.034362322090346786,
 0.029097963111694377,
 0.025156155146775296,
 0.026873136271444924,
 0.026719588421918097,
 0.02740760977380723,
 0.03365783553500679,
 0.04206736629526353,
 0.031628501487355694,
 0.0354905475989429,
 0.022940785958397974,
 0.01104842999997139,
 0.011578204053115009,
 0.00937474897317517,
 0.013077915077534486,
 0.013361136515374124,
 0.021737604372188572,
 0.019635884213248744,
 0.017064515278389366,
 0.01754698027628104,
 0.017301171987847957,
 0.01643998184678067,
 0.008768294969115633,
 0.005567617242267188,
 0.00940755579702286,
 0.009322103853655632,
 0.007902277234139282,
 0.005324890180706282,
 0.006276496487331696,
 0.009888340428021523,
 0.0043911967113783885,
 0.018834858934499404,
 0.03165080262935859,
 0.031530141702152514,
 0.026864900202378472,
 0.028385575004256876,
 0.0042116961176969555,
 0.004244671287501222,
 0.004071602269601242,
 0.0047728722292602575,
 0.007872456069096936,
 0.00846571624090529,
 0.007956624536053116,
 0.012372605612507763,
 0.03195993559211938,
 0.03807202646658423,
 0.017533219587463927,
 0.021508848988308744,
 0.018102424665689516,
 0.01570441399442152,
 0.016442491198550808,
 0.012910229455118502,
 0.01669955187344173,
 0.016846499675440246,
 0.01755976857802084,
 0.017291020391002988,
 0.017749155643274662,
 0.017815757835437165,
 0.017047359045622407,
 0.016591365093935814,
 0.012352081179879987,
 0.01337628995866462,
 0.01350353472146965,
 0.02361389705556431,
 0.023423915438571828,
 0.026032982871860556,
 0.023987660923416882,
 0.00432100354714203,
 0.008075020762870096,
 0.036927835741776785,
 0.038220378475790316,
 0.03285721701330706,
 0.030645254279455143,
 0.030232300060229998,
 0.0457189916815625,
 0.033673246795363605,
 0.03495279562999708,
 0.028147638070448715,
 0.03273631322419287,
 0.03666458027217674,
 0.026584819952711815,
 0.027299845714889144,
 0.03518257146495951,
 0.03369104574411939,
 0.031640479889074334,
 0.03557428032455415,
 0.021915002526157416,
 0.015901411139296075,
 0.014988415326126058,
 0.01422390176331711,
 0.014628213488948707,
 0.01430309103634135,
 0.01476414398557275,
 0.014256447034367802,
 0.019172895120361893,
 0.018302060978260672,
 0.020913254269156585,
 0.021947584363739024,
 0.018302060978260672,
 0.025416522251339464,
 0.019675566098273867,
 0.02815112311234367,
 0.02910342302700984,
 0.028740145165957163,
 0.03285916902894605,
 0.03752235876046546,
 0.03429036356462114,
 0.04245332564460683,
 0.03283665977942509,
 0.028737893537641307,
 0.04091760896314749,
 0.03846750324743736,
 0.03472466774229423,
 0.023747359715927886,
 0.027553818173627658,
 0.01896501902524277,
 0.01896501902524277,
 0.02322322376001374,
 0.033754993719696154,
 0.027786220211710018,
 0.023786650951971473,
 0.02729295602851616,
 0.019039908894708354,
 0.02424500550830086,
 0.021923991764247988,
 0.027544842663751807,
 0.02903415888857881,
 0.028435641886435447,
 0.0350194053185639,
 0.035151742056300485,
 0.017670037263984237,
 0.02369343466478453,
 0.02544222996093388,
 0.02880473899494446,
 0.029999500505144924,
 0.00936748438749851,
 0.013770262378786815,
 0.013866287755045602,
 0.014610483349494519,
 0.020355397206078853,
 0.010535589113213858,
 0.0141222834037591,
 0.03622801665217573,
 0.017484780925554208,
 0.015929571172854033,
 0.016041931203809454,
 0.007211369410487675,
 0.02135715019464271,
 0.028977420557967398,
 0.03666451349508241,
 0.027003629953213433,
 0.029737286045936718,
 0.027647429850535962,
 0.03403233493279114,
 0.02727770648478426,
 0.027937933139560583,
 0.026934875623341115,
 0.02714154120955818,
 0.022777908927294824,
 0.03347979428619102,
 0.04131352128236581,
 0.027673174366562442,
 0.04642691832330632,
 0.033343403854330676,
 0.0439849034582271,
 0.038667337283887715,
 0.006925809569104557,
 0.009443607431626195,
 0.03489969565062447,
 0.033338851561591394,
 0.02725127659333709,
 0.037374494312054134,
 0.024402237194666845,
 0.02505351426439262,
 0.0246898046660968,
 0.01911717783664263,
 0.0393629956836387,
 0.03195978185850608,
 0.022304942360598868,
 0.02210315896623653,
 0.019428569852199158,
 0.03379206259462501,
 0.023815339765724745,
 0.02202491011141731,
 0.02119223792047427,
 0.01711026326771148,
 0.007255167913189811,
 0.014325420588286793,
 0.02618972909673108,
 0.029885062320819413,
 0.02775370578471937,
 0.027791489189780666,
 0.03024414943794746,
 0.03282871926444604,
 0.03232592981836825,
 0.02787085638750687,
 0.028153449017525388,
 0.028619881380817946,
 0.020640430753554043,
 0.026498299793229724,
 0.03291375988103786,
 0.04228571791557555,
 0.037299900344351496,
 0.039668677823842646,
 0.030448850818854904,
 0.025431084995328382,
 0.03916938501248641,
 0.03585264709507416,
 0.03719868727792115,
 0.03677617584022771,
 0.03421722149314038,
 0.03630379245786057,
 0.03107302140746965,
 0.035047786769588515,
 0.03777187109460218,
 0.035765675381157234,
 0.023738207125625424,
 0.022508469004016103,
 0.024273466563277613,
 0.024693948619217677,
 0.03625101902566021,
 0.033197287179754884,
 0.029701190971829015,
 0.04209815646911605,
 0.03237464474673311,
 0.024286262850863178,
 0.024926577765278114,
 0.0228835583138827,
 0.0222239283087941,
 0.03643825283254721,
 0.02415839690741218,
 0.0178215025366135,
 0.020553502085580176,
 0.018543630190218322,
 0.015578285646317141,
 0.019711538291152724,
 0.016707770401205826,
 0.02499089165091702,
 0.025673432804650845,
 0.022526079646179063,
 0.017585845182831614,
 0.01920075258413361,
 0.01637358807363322,
 0.014889913446787672,
 0.01536524760029615,
 0.01519583363022978,
 0.022502353210113533,
 0.01785919941627995,
 0.015189110368370532,
 0.016051569344831818,
 0.014828442600623912,
 0.01646917186561983,
 0.018677147710788586,
 0.023278900372349604,
 0.0214778353295754,
 0.02594722131985941,
 0.01640437225895917,
 0.024886940531544013,
 0.023288257554243026,
 0.026354902394941263,
 0.020216618408281827,
 0.02165890093296005,
 0.025585426507140855,
 0.026064788743858022,
 0.02194676881574138,
 0.02172294247442146,
 0.022358051223373407,
 0.03040440934860509,
 0.032548666104031704,
 0.022357899035721985,
 0.03557932957568286,
 0.043686997294945386,
 0.03290375424813964,
 0.027111331217411272,
 0.04769175059410367,
 0.02344241703068727,
 0.021964859821134674,
 0.05318695923797893,
 0.050752820122392864,
 0.047050056449334104,
 0.03303154902438036,
 0.0347404322582279,
 0.034881636737885933,
 0.030540294488370905,
 0.031149846626278132,
 0.00895355445811038,
 0.009407578117252131,
 0.03604953276686061,
 0.008382272530749517,
 0.01647650633899867,
 0.016499348969743137,
 0.016329128946326227,
 0.018446101160806937,
 0.018291684731111934,
 0.016746957098544644,
 0.023972968269352912,
 0.023744439913898782,
 0.02248624905471135,
 0.019474693236341063,
 0.02111973150239891,
 0.027060027221893608,
 0.022773514925255957,
 0.02596757592288216,
 0.023699809817744732,
 0.022330083635855473,
 0.01981140928905958,
 0.029590579333042866,
 0.02387148544813112,
 0.023107165381357594,
 0.025215572536126937,
 0.02454628403659529,
 0.022416698024337534,
 0.02316268005066543,
 0.026392383846563144,
 0.028802055528566576,
 0.022855970736111612,
 0.02008944692145914,
 0.021634471663057785,
 0.036530730481608514,
 0.035664487425605476,
 0.03560197090645508,
 0.03552678513352095,
 0.04357901207615583,
 0.034545833218536076,
 0.0346343117743872,
 0.010728409191835906,
 0.007402525671776122,
 0.007152683416267134,
 0.007367620127122401,
 0.00704310034732097,
 0.006016181812717266,
 0.007248493061321947,
 0.005747939386253116,
 0.005953334029358345,
 0.020575326810448522,
 0.02059450302955032,
 0.016404944137238562,
 0.01821641741788894,
 0.017024912924614014,
 0.019259566432124016,
 0.016775854705999828,
 0.01217735276803573,
 0.012794264311427009,
 0.013468020604291643,
 0.015369013686128044,
 0.015006175269605123,
 0.016313419424418087,
 0.014062492347873337,
 0.0172252588269658,
 0.014411151342488103,
 0.014067714009814204,
 0.013024760445853994,
 0.015146045489059916,
 0.0132098365341225,
 0.013207372858289327,
 0.016810816747688632,
 0.013344374373709476,
 0.014696735241556161,
 0.01358457543114723,
 0.02051470416031971,
 0.013039167986769786,
 0.015811239309584925,
 0.013443931928626971,
 0.016943701071394913,
 0.018389310037624687,
 0.013373817688238676,
 0.013824722206816412,
 0.016730766520588154,
 0.013342425513028717,
 0.01821784981957814,
 0.01384832886252291,
 0.013427142356656792,
 0.015057214278988509,
 0.014705355632816847,
 0.01436487947978049,
 0.01841609434423663,
 0.01801895230612821,
 0.018715223284438465,
 0.019719384442226713,
 0.018012802683370275,
 0.020718921607772126,
 0.02374870640619422,
 0.020540568981165783,
 0.02070430116740655,
 0.02082106650188283,
 0.020918398021461202,
 0.020895505616254653,
 0.019344662986443044,
 0.005081821386570329,
 0.005138268748853501,
 0.004219348651325103,
 0.005442335647975442,
 0.004070399942959833,
 0.004765476495715948,
 0.00399953398173114,
 0.004092171196744845,
 0.003702299919311092,
 0.0036425885650979354,
 0.0037447103597813953,
 0.0038705654162658164,
 0.0045306326377650575,
 0.004494045274909457,
 0.005713343186017525,
 0.004563521829179393,
 0.003925971088599346,
 0.00392196938742766,
 0.004868808416685145,
 0.0037205912548436406,
 0.0036595074510806904,
 0.0035971910736710016,
 0.0038955482946557178,
 0.015465492519724297,
 0.02107143982225587,
 0.015974947141831897,
 0.019325312017897976,
 0.0142936055855415,
 0.01949810395352382,
 0.011429889039877348,
 0.012229703145485443,
 0.013707172681234125,
 0.016727746282505212,
 0.0032690741158814852,
 0.0035251740076887796,
 0.0032940522689748303,
 0.0034653637625472974,
 0.0034891656544282627,
 0.0030845438625065327,
 0.0031612667887748872,
 0.05195473371876443,
 0.016532269483587166,
 0.01501779521893445,
 0.005216989556008815,
 0.004004796549574726,
 0.004061490882502173,
 0.004158342315138649,
 0.005360673977767856,
 0.009936370978288457,
 0.008246377768716904,
 0.008504175234013844,
 0.0047051730343579574,
 0.00662079694239389,
 0.009160350729135803,
 0.005945714845710865,
 0.006168715529969619,
 0.006573987411867289,
 0.006364615611671309,
 0.006528848839529644,
 0.009603203872912582,
 0.008971834519904808,
 0.018160491195739255,
 0.014468292914094412,
 0.014078381967701031,
 0.014110596162300836,
 0.01382598386798295,
 0.01646198155739277,
 0.011911322286376301,
 0.01161911832120765,
 0.011815397490366844,
 0.013530849004634403,
 0.014064702029384117,
 0.014780033658066299,
 0.007215828782809598,
 0.006576313807604452,
 0.007346853576562119,
 0.047007847999940504,
 0.027682964322091302,
 0.02705886145587612,
 0.02598405912468029,
 0.013167798844599744,
 0.013435150870117388,
 0.01759195162599088,
 0.013298874800872237,
 0.012939563795402259,
 0.009949150594716016,
 0.01690231497116959,
 0.010562437798590047,
 0.016677561022673672,
 0.014925436226163736,
 0.014578723940200908,
 0.014976190821231033,
 0.015003388695297814,
 0.012782412321639203,
 0.007036114068677797,
 0.006867198321950371,
 0.006793739289359668,
 0.047862525886760265,
 0.004512610062165788,
 0.004262439199697585,
 0.004079105021737422,
 0.005012180871155787,
 0.004120656685607873,
 0.0041713895661069054,
 0.004002998429643426,
 0.010719584497916726,
 0.010443537963172048,
 0.011536214238391337,
 0.006003534348517349,
 0.014798709952464666,
 0.017622070479327408,
 0.016143969214815524,
 0.015678434710275784,
 0.018625284694554756,
 0.007054460486317844,
 0.006854123621759979,
 0.007350577916563939,
 0.007163286468208048,
 0.007274023864421894,
 0.00697568085503572,
 0.02773632733840294,
 0.029523938876470476,
 0.025585481115917838,
 0.020050128253437653,
 0.019627933201398946,
 0.019515982027544374,
 0.02335977578723291,
 0.021803965795486706,
 0.029709754052567927,
 0.02336721201616001,
 0.022881292959925695,
 0.02216632631633673,
 0.021720327847505796,
 0.022083934086720977,
 0.02263791952782158,
 0.022896288912847746,
 0.004790937280843856,
 0.00449635953857827,
 0.004375005449250964,
 0.004149735316343365,
 0.005134374628946625,
 0.004180081738102629,
 0.004229298692002347,
 0.004244703207444916,
 0.004253354854393118,
 0.004287363341902283,
 0.005779949011886359,
 0.004174025633540958,
 0.00406697923403337,
 0.004077827989942964,
 0.004187507518000694,
 0.0041561315654080845,
 0.004114469554709275,
 0.008146143925855522,
 0.011328686181638651,
 0.011375518161630429,
 0.012288718984372605,
 0.011312181019209274,
 0.013590587596749906,
 0.011583820083070365,
 0.01238453708260651,
 0.01151304441727919,
 0.011914663793803118,
 0.014057276749543208,
 0.015341412730648912,
 0.006448471870515557,
 0.006450254622125605,
 0.0063382014970547115,
 0.009835707280031096,
 0.010039590302347433,
 0.01148393492067648,
 0.010030594072717523,
 0.01422888786119012,
 0.015344254873989865,
 0.015255652642474325,
 0.012505255985490996,
 0.012377718411219575,
 0.011918543823630097,
 0.011989021654449296,
 0.012322916475420368,
 0.014103627063019923,
 0.013987016731444568,
 0.0032125998460907066,
 0.004450668196232245,
 0.015490011990664592,
 0.01631382417344113,
 0.015277779925377157,
 0.009484352459497922,
 0.007217217704609061,
 0.007429136154057479,
 0.008288706101561885,
 0.007411087101522574,
 0.007052782985505027,
 0.007281390091335476,
 0.007893518999992301,
 0.0071903737916923635,
 0.006990167326915118,
 0.006785489441125511,
 0.007622852598353494,
 0.00689914307020678,
 0.032078358001154106,
 0.020356715640935767,
 0.024884996002914165,
 0.029283491365133914,
 0.024001559642087153,
 0.005359185016417737,
 0.00553643691630827,
 0.004669583394144213,
 0.004362383178050909,
 0.004035578899340473,
 0.005459380258953023,
 0.005659091795916011,
 0.0055666304845359066,
 0.005220216248486894,
 0.004725652517803617,
 0.004596427572599548,
 0.004551749024487837,
 0.004301972520783822,
 0.011892385378981296,
 0.011276403248255554,
 0.009613289072419666,
 0.006583122789095522,
 0.00560367593023458,
 0.006178761401043989,
 0.006109389806567901,
 0.005342921251549256,
 0.004783124996689764,
 0.005140850558584769,
 0.005197737365548871,
 0.00522872184432129,
 0.02225950860924403,
 0.020775461706461006,
 0.022133019348591885,
 0.010262727816802798,
 0.016133035613217904,
 0.017696895363744233,
 0.020971881588717056,
 0.013967069770090126,
 0.02941345528100609,
 0.02988539100688182,
 0.023156961542555952,
 0.022006200448261914,
 0.025084561763289867,
 0.004625278056934705,
 0.004216530428767742,
 0.004636793892681324,
 0.0045446561246054624,
 0.010035435633511808,
 0.008687295655155646,
 0.00419688102199142,
 0.005339362050805419,
 0.00492676731235655,
 0.022148735683352398,
 0.024234964647408843,
 0.02209715048766216,
 0.022822787687069843,
 nan,
 0.016878645245049256,
 0.016303948195256195,
 0.020962285042663002,
 0.019831032442363797,
 0.021897627660060082,
 0.021917087610444592,
 0.0207455448076851,
 0.019017677455172098,
 0.015527945199735394,
 0.019799201916913915,
 0.018004008421473816,
 0.01631130251101496,
 0.020133769852098297,
 0.01855056901351069,
 nan,
 nan,
 0.020071521997586262,
 0.005242928900283729,
 0.005458732350751412,
 0.00414921986681744,
 0.004932678017442898,
 0.0054307396137694445,
 0.004972344165034489,
 0.0056805241532867515,
 0.003766644673068936,
 0.005169574362630279,
 0.005126246889480272,
 0.004493784024770075,
 0.0042448455021475056,
 0.00528579957871733,
 0.0051738955623196305,
 0.0054896606434721214,
 0.00559229217130269,
 0.005427315193596676,
 0.00595613228914167,
 0.004458684846763622,
 0.0038560560552843757,
 0.014498711221863279,
 0.0061648836714536534,
 0.007217535916247704,
 0.007559241453491457,
 0.007815187879361571,
 0.0072119433882846615,
 0.015743767943821537,
 0.0168444349240333,
 0.016029141295869912,
 0.013803382687161601,
 0.014688754055392257,
 0.009472072332682137,
 0.008951215132574495,
 0.007108488186177762,
 0.006924751214425359,
 0.007213062685356287,
 0.021149871810558475,
 0.023652025239213552,
 0.02524476043929237,
 0.040971939837474894,
 0.036025475402734014,
 0.03430913613005068,
 0.039681200002277185,
 0.046197964118055164,
 0.06020205819112961,
 0.043330768353755864,
 0.05709195194932099,
 0.04925067576778358,
 0.00495622266898934,
 0.004599544837233378,
 0.004336991598347604,
 0.0038983021999906245,
 0.0035733661151049682,
 0.0032460453630930113,
 0.0032609439785145577,
 0.011659042727913706,
 0.010651433309676016,
 0.010418346992959151,
 0.010772522908951669,
 0.0034954204410242973,
 0.0034694559392930376,
 0.01740113515677317,
 0.0036715687825646065,
 0.003757128563582152,
 0.0037379340157107422,
 0.003370589797606517,
 0.0035254633353385264,
 0.0030984095173633196,
 0.0031553695608433747,
 0.0031115148213351263,
 0.003394356544865483,
 0.0031207490194678305,
 0.0033653704513620336,
 0.003859877883308834,
 0.0033589142789980327,
 0.0062337990223502665,
 0.003140495183431779,
 0.004962200077346369,
 0.005335875244556062,
 0.004414273878316473,
 0.010965333301984686,
 0.02413921224707044,
 0.025211951250489112,
 0.024860083654469088,
 0.024715742906564676,
 0.028548578281704935,
 0.005951898386988911,
 0.0058068459204337515,
 0.006026784537293539,
 0.006006259459749228,
 0.01656847072151133,
 0.01993712714046174,
 0.016460091770156244,
 0.015464145515998569,
 0.01599909845924049,
 0.016152006911794622,
 0.00953170501500447,
 0.007831441269178428,
 0.008758906697897459,
 0.004193989192074203,
 0.005362876920276145,
 0.003927493849849327,
 0.003886220122432584,
 0.0038947816613174586,
 0.004095151963380486,
 0.003950594072879226,
 0.005166277322336922,
 0.0040522239128971994,
 0.0043220962757662545,
 0.003938342939869147,
 0.0034796173338098218,
 0.0034855679792112184,
 0.003738967727168156,
 0.013805996114520573,
 0.014589413177306953,
 0.01455063737746261,
 0.014935548101062894,
 0.013582319313255313,
 0.0162193865884875,
 0.013598030905719283,
 0.014423183176082818,
 0.014362605704771578,
 0.015695068753359853,
 0.014226785713869724,
 0.013934107532858252,
 0.01384654904703407,
 0.013456544273697411,
 0.013405187277425708,
 0.012625400314031612,
 0.012243482970073835,
 0.012292421813150359,
 0.012317394084848643,
 0.013639845177899991,
 0.012322515652829222,
 0.00798496898001694,
 0.00815147082184333,
 0.006306086776123366,
 0.0060288769524295995,
 0.006781064813823805,
 0.006733216365487666,
 0.00798522432276271,
 0.007500862264344992,
 0.006215586780665125,
 0.0074651756827366425,
 0.0063880037617475224,
 0.012272837283919999,
 0.012146619590071774,
 0.012551084917584644,
 0.008554938846461536,
 0.008060678582086561,
 0.010191911585796826,
 0.010827349187354802,
 0.010063227545852987,
 0.012408429424028405,
 0.008880542078382795,
 0.011125297644010265,
 0.010041441464212039,
 0.00987961161795744,
 0.012203549068051978,
 0.012638204526684004,
 0.015918378721179818,
 0.0139112524552858,
 0.012995864887578324,
 0.015054771743354713,
 0.014850847207172668,
 0.014832334558669766,
 0.022770724384278164,
 0.006808024279365031,
 0.009484180073535362,
 0.007288480726290457,
 0.0071021964478771545,
 0.007119050007731206,
 0.0071726826109300545,
 0.00959574667076408,
 0.007081453064315501,
 0.006425547919357524,
 0.007564024303820321,
 0.003847492731556391,
 0.006080210924889607,
 0.006180880277882301,
 0.004440627549474574,
 0.004091363523744042,
 0.004888585822983616,
 0.004118828650918551,
 0.00418401510196968,
 0.005058285169597546,
 0.004295685164894297,
 0.007900404567675566,
 0.007868304236543857,
 0.009312733690786723,
 0.007870688800847545,
 0.007762331288487047,
 0.015032252570287067,
 0.015450654526075894,
 0.027176428865483115,
 0.01602331232402593,
 0.01543921015799678,
 0.017648316794135047,
 0.016383285817747287,
 0.017080902866768062,
 0.016312742208403695,
 0.016327905911669594,
 0.016396104962904192,
 0.016302086126993878,
 0.016569544311108516,
 0.01909961964509641,
 0.017380031809132886,
 0.01718609980854224,
 0.01611805331321097,
 0.016393644789717266,
 0.020874137494538036,
 0.01802006757960558,
 0.017601404765925314,
 0.020083398132728095,
 0.02132936981312572,
 0.02056389371851528,
 0.026025889020760987,
 0.026023226822610625,
 0.019216002418916876,
 0.025264258165394286,
 0.02495115909530368,
 0.03405062688864236,
 0.025943053921049914,
 0.013075202102717606,
 0.015235080881720584,
 0.009615075280538524,
 0.009930526053365224,
 0.01030364689152672,
 0.010162049492398836,
 0.030212654529788635,
 0.03287962773073943,
 0.02996182927791988,
 0.030028376099612158,
 0.029596302658936254,
 0.015825193422792077,
 0.01971541780456155,
 0.016787984713908802,
 0.016112500623783107,
 0.016056151760402995,
 0.019950408554916574,
 0.01787013317250037,
 0.027278556083016964,
 0.019300084309113192,
 0.019220686933332346,
 0.019199393889195844,
 0.019493880261170927,
 0.01991360729163236,
 0.004117494326822312,
 0.004178934294521448,
 0.0042855187953305006,
 0.003952813968509528,
 0.005802827982979353,
 0.004054712034428507,
 0.00475158633183075,
 0.0038128240557735458,
 0.0038837028454647266,
 0.003998804348599377,
 0.005675326856907114,
 0.005169184811196825,
 0.0051014413202266065,
 0.005561234625769061,
 0.005067865006270919,
 0.018263112899888308,
 0.01924625379841404,
 0.01808524432685846,
 0.0321163577018075,
 0.010103186740205826,
 0.010887560286686691,
 0.011175373164137602,
 0.010235625451650002,
 0.010408055531157805,
 0.010404477819337406,
 0.004233630048132852,
 0.009411879792295685,
 ...]
        pf_woodpole_polerupture.append(a0+a1*WindVel[i,0]+a2*(Height[i,0]-SurgeHeight[i,0]-WaveHeight[i,0])
                                           +a3*WaterVel[i,0]*SurgeHeight[i,0]+a4*WindVel[i,0]*sin(WindDir[i,0]*3.14/180)
                                           +a5*WindVel[i,0]*ConSurArea[i,0]+a6*max(Age[i,0],25)+a7*WaveHeight[i,0])
def bridge_fail_prob(Clear,Mass,Elev,Surge,Wave):

    Clear=np.array(Clear)
    Mass=np.array(Mass)
    Elev=np.array(Elev)
    Surge=np.array(Surge)
    Wave=np.array(Wave)
    

    pf_bridge=[];
    for i in range(0, np.size(Clear,0)):
        if Mass[i,0]<5 :
            a = 0.6468
            b = 0.0406
            c =-0.1376; 
        elif Mass[i,0]>=5 and Mass[i,0]<10:
            a = 0.4166
            b = 0.0456
            c =-0.2343
        elif Mass[i,0]>=10 and Mass[i,0]<15:
            a = 0.3291
            b = 0.0546
            c =-0.2464
        elif Mass[i,0]>=15 and Mass[i,0]<20:
            a = 0.33
            b = 0.0576
            c =-0.2444
        elif Mass[i,0]>=20 and Mass[i,0]<25:
            a = 0.2843
            b = 0.0512
            c =-0.2421
        elif Mass[i,0]>=25 and Mass[i,0]<30:
            a = 0.2865
            b = 0.0881
            c =-0.2391
        elif Mass[i,0]>=30 and Mass[i,0]<35:
            a = 0.1870
            b = 0.0782
            c =-0.2618
                 
        pf_bridge.append(min(1,max(0,a+b*Wave[i,0]+c*(Clear[i,0]-Surge[i,0]+Elev[i,0]))))
    return pf_bridge
# Bridge Inventory Dataset (Also available in INCORE)
Bridge_inv_csv = "Galv_bridge_dataandHazards.csv"
Building_inv_df  = pd.read_csv(Bridge_inv_csv)

Lon_Build = pd.read_csv("Galv_bridge_dataandHazards.csv", usecols=['LON'])
Lat_Build = pd.read_csv("Galv_bridge_dataandHazards.csv", usecols=['LAT'])
Surge= pd.read_csv("Galv_bridge_dataandHazards.csv", usecols=['Surge'])
Wave= pd.read_csv("Galv_bridge_dataandHazards.csv", usecols=['Wave'])
Mass= pd.read_csv("Galv_bridge_dataandHazards.csv", usecols=['Mass'])
Clear= pd.read_csv("Galv_bridge_dataandHazards.csv", usecols=['Clear'])
Elev= pd.read_csv("Galv_bridge_dataandHazards.csv", usecols=['Elev'])
def bridge_fail_prob(Clear,Mass,Elev,Surge,Wave):

    Clear=np.array(Clear)
    Mass=np.array(Mass)
    Elev=np.array(Elev)
    Surge=np.array(Surge)
    Wave=np.array(Wave)
    

    pf_bridge=[];
    for i in range(0, np.size(Clear,0)):
        if Mass[i,0]<5 :
            a0 = -7.1325
            a1 = 0.021686
            a2 = 0.048014
            a3 = 0.2974
            a4 = 0.026337
            a5 = 0.002212
            a6 = 0.028545
            a7 = 0.52904;
        elif Mass[i,0]>=5 and Mass[i,0]<10:
            a0 = 0.4166
            b = 0.0456
            c =-0.2343
        elif Mass[i,0]>=10 and Mass[i,0]<15:
            a0 = 0.3291
            b = 0.0546
            c =-0.2464
        elif Mass[i,0]>=15 and Mass[i,0]<20:
            a0 = 0.33
            b = 0.0576
            c =-0.2444
        elif Mass[i,0]>=20 and Mass[i,0]<25:
            a0 = 0.2843
            b = 0.0512
            c =-0.2421
        elif Mass[i,0]>=25 and Mass[i,0]<30:
            a0 = 0.2865
            b = 0.0881
            c =-0.2391
        elif Mass[i,0]>=30 and Mass[i,0]<35:
            a0 = 0.1870
            b = 0.0782
            c =-0.2618
                 
        pf_bridge.append(min(1,max(0,a0+b*Wave[i,0]+c*(Clear[i,0]-Surge[i,0]+Elev[i,0]))))
    return pf_bridge
PF_bridge = bridge_fail_prob(Clear,Mass,Elev,Surge,Wave)
Mass=np.array(Mass)
print(type(Mass[1,0]))
<class 'numpy.float64'>
def EPN_fail_prob(WindVel,WaterVel,SurgeHeight,WaveHeight,WindDir,Age,ConSurArea,Height,Class,Type,Soil):

    WindVel=np.array(WindVel)
    WaterVel=np.array(WaterVel)
    SurgeHeight=np.array(SurgeHeight)
    WaveHeight=np.array(WaveHeight)
    WindDir=np.array(WindDir)
    Age=np.array(Age)
    ConSurArea=np.array(ConSurArea)
    Height=np.array(Height)
    Class=np.array(Class)
    Type=np.array(Type)
    Soil=np.array(Soil)
    
    pf_woodpole_polerupture=[];
    for i in range(0, np.size(WindVel,0)):
        
        
        
        print(f"Running Analysis: {i}")
        if Type[i,0]  == 1 and Class[i,0] == 3 and Soil[i,0]  == 'Stiff': 
            a0 = -7.1325
            a1 = 0.021686
            a2 = 0.048014
            a3 = 0.2974
            a4 = 0.026337
            a5 = 0.002212
            a6 = 0.028545
            a7 = 0.52904;
        elif Type[i,0]  == 1 and Class[i,0] == 3 and Soil[i,0]  == 'Very Stiff': 
            a0 = -7.2476
            a1 = 0.02157
            a2 = 0.051976
            a3 = 0.29907
            a4 = 0.027067
            a5 = 0.002424
            a6 = 0.027865
            a7 = 0.51853
        elif Type[i,0]  == 1 and Class[i,0] == 4 and Soil[i,0]  == 'Medium': 
            a0 = -6.8655
            a1 = 0.022127
            a2 = 0.038238
            a3 = 0.30961
            a4 = 0.028689
            a5 = 0.002461
            a6 = 0.027454
            a7 = 0.53341
        elif Type[i,0]  == 1 and Class[i,0] == 4 and Soil[i,0]  == 'Stiff': 
            a0 = -6.8655
            a1 = 0.022127
            a2 = 0.038238
            a3 = 0.30961
            a4 = 0.028689
            a5 = 0.002461
            a6 = 0.027454
            a7 = 0.53341
        elif Type[i,0]  == 1 and Class[i,0] == 4 and Soil[i,0]  == 'Very Stiff': 
            a0 = -6.9997
            a1 = 0.020323 
            a2 = 0.042443
            a3 = 0.30771
            a4 = 0.030009
            a5 = 0.00284
            a6 = 0.02892
            a7 = 0.53529
        elif Type[i,0]  == 1 and Class[i,0] == 5 and Soil[i,0]  == 'Medium': 
            a0 = -6.8029
            a1 = 0.019763
            a2 = 0.041838
            a3 = 0.33543
            a4 = 0.032922
            a5 = 0.002892
            a6 = 0.026793
            a7 = 0.57772
        elif Type[i,0]  == 1 and Class[i,0] == 5 and Soil[i,0]  == 'Stiff': 
            a0 = -6.8029
            a1 = 0.019763
            a2 = 0.041838
            a3 = 0.33543
            a4 = 0.032922
            a5 = 0.002892
            a6 = 0.026793
            a7 = 0.57772;
        elif Type[i,0]  == 1 and Class[i,0] == 5 and Soil[i,0]  == 'Very Stiff': 
            a0 = -6.798
            a1 = 0.021067
            a2 = 0.040692
            a3 = 0.33019
            a4 = 0.033158 
            a5 = 0.002863
            a6 = 0.026811
            a7 = 0.56842

        pf_woodpole_polerupture.append(a0+a1*WindVel[i,0]+a2*(Height[i,0]-SurgeHeight[i,0]-WaveHeight[i,0])
                                           +a3*WaterVel[i,0]*SurgeHeight[i,0]+a4*WindVel[i,0]*sin(WindDir[i,0]*3.14/180)
                                           +a5*WindVel[i,0]*ConSurArea[i,0]+a6*max(Age[i,0],25)+a7*WaveHeight[i,0])

    return pf_woodpole_polerupture