def run_example2(): # Create an instance of the Building Class bldg = Building() # Building object with default attributes # Add parcel data to the Building object: pid = '123-456-789' num_stories = 4 occupancy = 'commercial' yr_built = 2021 address = 'Number StreetName City State Zip Code' area = 4000 lon = 0 lat = 0 bldg.add_parcel_data(pid, num_stories, occupancy, yr_built, address, area, lon, lat) # The add_parcel_data function created new Story objects for the Building: print(bldg.hasStory) return bldg
def run_example3(): # Create an instance of the Building Class: bldg = Building() # Create a Roof object and add some component-level attributes: new_roof = Roof() new_roof.hasType = 'asphalt shingles' new_roof.hasShape['gable'] = True # Add the Roof to the building bldg.adjacentElement['Roof'].append( Roof()) # Roof bounds the building geometry # Create a Floor object and add some component-level attributes:: new_floor = Floor() new_floor.hasType = 'two-way concrete slab' new_floor.hasYearBuilt = 2021 bldg.containsElement['Floor'].append( new_floor) # Assume this is an interior floor # Update the building's hasElement attribute: bldg.update_elements() return bldg
def run_example1(): # Create an instance of the Site Class: site = Site() # Add three instances of the Building Class to the Site: for i in range(0, 3): site.hasBuilding.append(Building()) # Add four Story instances to the second building in the Site: for j in range(0, 4): site.hasBuilding[1].hasStory.append(Story()) # Add three Space instances to the second story of the second building in the Site: for k in range(0, 3): site.hasBuilding[1].hasStory[1].hasSpace.append(Space()) # Add relational attributes: site.hasBuilding[1].hasStory[1].update_zones() site.hasBuilding[1].update_zones() site.update_zones() return site
def run_hh_study( inventory='C:/Users/Karen/Desktop/HH_NSF_CMMI1759996_BuildingAssessments.csv', hazard_type='wind', hazard_file_path='C:/Users/Karen/PycharmProjects/DPBWE/Datasets/WindFields/ARA_Hurricane_Harvey_Windspeed_v26.csv', component_type='roof cover', parcel_id='12d068d3-5948-4d6f-9204-e04942773081', sfh_flag=True): # Irma case study: # Step 1: Create a Site Class that will hold all parcel-specific data models: site = Site() # Since building inventory is from StEER dataset, let's populate query column (if needed) to grab bldg attributes: steer_obj = STEER() # Make sure the StEER data is ready for querying: steer_obj.add_query_column(inventory) # Step 2: Populate building inventory data and create parcel-specific data models: df = pd.read_csv(inventory) inland_areas = ['NUECES', 'TIVOLI', 'TAFT', 'SINTON', 'REFUGIO'] for row in range(0, len(df.index)): use_code = df['assessment_type'][row] if sfh_flag: if 'Single' in use_code: if any([ i in df['address_locality'][row].upper() for i in inland_areas ]): pass else: try: roof_cover = df['roof_cover'][row].upper( ) # skip any empty roof cover entries # Create simple data model for each parcel and add roof and cover data: new_bldg = Building() new_bldg.add_parcel_data(df['fulcrum_id'][row], df['number_of_stories'][row], df['assessment_type'][row], df['year_built'][row], df['address_query'][row], 0, df['longitude'][row], df['latitude'][row], 'ft', loc_flag=False) new_bldg.hasLocation['State'] = 'TX' new_bldg.hasLocation[ 'Street Number'] = df['address_sub_thoroughfare'][ row] + ' ' + df['address_thoroughfare'][row] new_bldg.hasLocation['City'] = df['address_locality'][ row] new_bldg.hasLocation['County'] = df[ 'address_sub_admin_area'][row] new_bldg.hasLocation['Zip Code'] = df[ 'address_postal_code'][row] # Add roof element and data: new_roof = Roof() if 'ASPHALT' in roof_cover and 'SEAM' not in roof_cover: new_roof.hasCover = 'ASPHALT SHINGLES' new_roof.hasType = 'ASPHALT SHINGLES' else: new_roof.hasCover = roof_cover new_roof.hasType = roof_cover new_bldg.hasStory[-1].adjacentElement['Roof'] = [ new_roof ] new_bldg.hasStory[-1].update_elements() new_bldg.update_zones() new_bldg.update_elements() # Populate code-informed component-level information code_informed = TX(new_bldg, loading_flag=False) code_informed.roof_attributes(new_bldg) # Add height information: new_bldg.hasGeometry['Height'] = df[ 'number_of_stories'][row] * 4.0 * 3.28084 # ft # Step 3: Add new parcel-specific data model to the site description: site.hasBuilding.append(new_bldg) except AttributeError: pass else: pass # Step 4: Update the site's zone and element information (relational attributes): site.update_zones() site.update_elements() # Step 5: Extract the case study parcel's data model: for b in site.hasBuilding: if b.hasID == parcel_id: bldg = b else: pass # Step 6: Populate variables with list of post-disaster damage dataset types and file paths: data_types = [STEER(), FemaIahrld()] file_paths = [inventory, 'API'] # Step 7: Run the workflow: execute_fragility_workflow(bldg, site, component_type=component_type, hazard_type=hazard_type, event_year=2017, event_name='Hurricane Harvey', data_types=data_types, file_paths=file_paths, damage_scale_name='HAZUS-HM', analysis_date='09/16/2021', hazard_file_path=hazard_file_path, sfh_flag=True)
def run_hm_study( inventory='C:/Users/Karen/Desktop/MB_res.csv', hazard_type='wind', hazard_file_path='C:/Users/Karen/PycharmProjects/DPBWE/Datasets/WindFields/2018-Michael_windgrid_ver36.csv', component_type='roof cover', parcel_id='04973-808-000', sfh_flag=True, rpermit_flag=True): # Hurricane Michael case study: # Component type: Roof cover (built-up) # Hazard: Wind # Whole inventory: 'C:/Users/Karen/Desktop/MB_PCB.csv' # Commercial inventory: 'C:/Users/Karen/Desktop/MichaelBuildings.csv' # LR commercial case study: 18145-000-000 # Mexico Beach Inventory: 'C:/Users/Karen/Desktop/MB_res.csv' # residential, mexico beach: 04973-808-000 # Panama City Beach inventory: # 'C:/Users/Karen/Desktop/PCB_full_res.csv' # '38333-050-301' # Locality: Panama City Beach and Mexico Beach regions # '30569-100-000' original parcel number for 6 story guy # Step 1: Create a Site Class that will hold all parcel-specific data models: site = Site() # Step 2: Populate building inventory data and create parcel-specific data models: df = pd.read_csv(inventory) # We will also be tapping into the StEER dataset for additional building attributes: steer_obj = STEER() steer_file_path = 'C:/Users/Karen/PycharmProjects/DPBWE/Datasets/StEER/HM_D2D_Building.csv' # Make sure the StEER data is ready for querying: steer_obj.add_query_column(steer_file_path) for row in range(0, len(df.index)): if df['Stories'][row] >= 2: pass else: # Create simple data model for each parcel and add roof and cover data: new_bldg = Building() new_bldg.add_parcel_data(df['Parcel Id'][row], df['Stories'][row], df['Use Code'][row], df['Year Built'][row], df['Address'][row], df['Square Footage'][row], df['Longitude'][row], df['Latitude'][row], 'ft', loc_flag=True) # Add roof element and data: new_roof = Roof() new_roof.hasCover = df['Roof Cover'][row] new_roof.hasType = df['Roof Cover'][row] new_bldg.hasStory[-1].adjacentElement['Roof'] = [new_roof] new_bldg.hasStory[-1].update_elements() new_bldg.update_zones() new_bldg.update_elements() if rpermit_flag: try: if len(df['Permit Issued Date'][row]) > 0: pdesc = df['Permit Description'][row][2:-2].split("'") pyear = df['Permit Issued Date'][row][2:-2].split("'") year = df['Year Built'][row] for p in range(0, len(pdesc)): if 'REROOF' in pdesc[p] or 'RERF' in pdesc[ p] or 'ROOF' in pdesc[p]: new_year = int(pyear[p][:4]) if year < new_year < 2018: year = new_year else: pass new_bldg.adjacentElement['Roof'][0].hasYearBuilt = year new_bldg.hasYearBuilt = year except TypeError: new_bldg.adjacentElement['Roof'][ 0].hasYearBuilt = new_bldg.hasYearBuilt else: pass # Bring in additional attributes from StEER: parcel_identifier = steer_obj.get_parcel_identifer(new_bldg) steer_obj.add_steer_bldg_data(new_bldg, parcel_identifier, steer_file_path) # Populate code-informed component-level information code_informed = FBC(new_bldg, loading_flag=False) code_informed.roof_attributes(code_informed.hasEdition, new_bldg) # Add height information (if available): new_bldg.hasGeometry[ 'Height'] = df['Stories'][row] * 4.0 * 3.28084 # ft # Parcel data for this inventory includes some permit numbers. # Add when available and differentiate between disaster and regular permits. permit_data = df['Permit Number'][row] permit_description = df['Permit Type'][row] if isinstance(permit_data, str): permit_data = ast.literal_eval(permit_data) for item in permit_data: if 'DIS' in item: new_bldg.hasPermitData['disaster']['number'].append( item) else: new_bldg.hasPermitData['other']['number'].append(item) new_bldg.hasPermitData['other']['permit type'].append( permit_description) else: pass # Step 3: Add new parcel-specific data model to the site description: site.hasBuilding.append(new_bldg) # Step 4: Update the site's zone and element information (relational attributes): site.update_zones() site.update_elements() # Step 5: Extract the case study parcel's data model: for b in site.hasBuilding: if b.hasID == parcel_id: bldg = b else: pass # Step 6: Populate variables with list of post-disaster damage dataset types and file paths: data_types = [STEER(), BayCountyPermits()] file_paths = [ steer_file_path, 'C:/Users/Karen/PycharmProjects/DPBWE/BayCountyMichael_Permits.csv' ] # Step 7: Run the workflow: execute_fragility_workflow(bldg, site, component_type=component_type, hazard_type=hazard_type, event_year=2018, event_name='Hurricane Michael', data_types=data_types, file_paths=file_paths, damage_scale_name='HAZUS-HM', analysis_date='03/04/2021', hazard_file_path=hazard_file_path, sfh_flag=True)
def run_hi_study( inventory='C:/Users/Karen/Desktop/IrmaBuildings.csv', hazard_type='wind', hazard_file_path='C:/Users/Karen/PycharmProjects/DPBWE/Datasets/WindFields/ARA_Hurricane_Irma_Windspeed_v12.csv', component_type='roof cover', parcel_id='57360360006'): # Make sure StEER data is ready for parsing: steer_obj = STEER() steer_file_path = 'C:/Users/Karen/PycharmProjects/DPBWE/Datasets/StEER/HI-DA.csv' # Make sure the StEER data is ready for querying: steer_obj.add_query_column(steer_file_path) # Irma case study: # Step 1: Create a Site Class that will hold all parcel-specific data models: site = Site() # Step 2: Populate building inventory data and create parcel-specific data models: df = pd.read_csv(inventory) for row in range(0, len(df.index)): # Create simple data model for each parcel and add roof and cover data: new_bldg = Building() new_bldg.add_parcel_data(df['Parcel Id'][row], df['Stories'][row], df['Use Code'][row], df['Year Built'][row], df['Address'][row], df['Square Footage'][row], df['Longitude'][row], df['Latitude'][row], 'ft', loc_flag=True) # Add roof element and data: new_roof = Roof() new_roof.hasCover = df['Roof Cover'][row] new_roof.hasType = df['Roof Cover'][row] new_bldg.hasStory[-1].adjacentElement['Roof'] = [new_roof] new_bldg.hasStory[-1].update_elements() new_bldg.update_zones() new_bldg.update_elements() # Populate code-informed component-level information code_informed = FBC(new_bldg, loading_flag=False) code_informed.roof_attributes(code_informed.hasEdition, new_bldg) # Add height information (if available): if df['Height'][row] != 0: new_bldg.hasGeometry['Height'] = df['Height'][row] else: new_bldg.hasGeometry[ 'Height'] = df['Stories'][row] * 4.0 * 3.28084 # ft # Step 3: Add new parcel-specific data model to the site description: site.hasBuilding.append(new_bldg) # Step 4: Update the site's zone and element information (relational attributes): site.update_zones() site.update_elements() # Step 5: Extract the case study parcel's data model: for b in site.hasBuilding: if b.hasID == parcel_id: bldg = b else: pass # Step 6: Populate variables with list of post-disaster damage dataset types and file paths: data_types = [STEER(), FemaHma(), FemaIahrld()] file_paths = [ steer_file_path, 'C:/Users/Karen/Desktop/HMA_Irma.csv', 'C:/Users/Karen/Desktop/Irma_IAHR_LD_V1.csv' ] # Step 7: Run the workflow: execute_fragility_workflow(bldg, site, component_type=component_type, hazard_type=hazard_type, event_year=2017, event_name='Hurricane Irma', data_types=data_types, file_paths=file_paths, damage_scale_name='HAZUS-HM', analysis_date='05/20/2021', hazard_file_path=hazard_file_path, sfh_flag=False)
def __init__(self, pid, num_stories, occupancy, yr_built, address, area, lon, lat, length_unit, plot_flag): Building.__init__(self) # Bring in all of the attributes that are defined in the BIM class for the parcel model # Add parcel data: self.add_parcel_data(pid, num_stories, occupancy, yr_built, address, area, lon, lat, length_unit, loc_flag=True) # Define building-level attributes that are specific to parcel models # Building footprint: self.assign_footprint(self, num_stories) plt.rcParams["font.family"] = "Times New Roman" # Plot global and local CRS: if plot_flag: xfpt, yfpt = self.hasGeometry['Footprint']['local'].exterior.xy plt.plot(np.array(xfpt) / 3.281, np.array(yfpt) / 3.281, 'k') rx, ry = self.hasGeometry['Footprint']['rotated'].exterior.xy plt.plot(np.array(rx) / 3.281, np.array(ry) / 3.281, color='gray', linestyle='dashed') plt.legend(['local Cartesian', 'rotated Cartesian'], prop={"size":22}, loc='upper right') plt.xlabel('x [m]', fontsize=22) plt.ylabel('y [m]', fontsize=22) plt.xticks(fontsize=22) plt.yticks(fontsize=22) plt.show() # Pull building/story height information from DOE reference buildings: survey_data = SurveyData() # create an instance of the survey data class survey_data.run(self, ref_bldg_flag=True, parcel_flag=False) # Create an instance of the BldgCode class and populate building-level code-informed attributes for the parcel: #if self.hasLocation['State'] == 'FL': #code_informed = bldg_code.FBC(self, loading_flag=False) # Need building code for code-based descriptions #else: #pass # Now that we have the building and story heights, render the 3D geometries: # Extract points for the building footprint and add the base z coordinate: geo_keys = self.hasGeometry['Footprint'].keys() for key in geo_keys: if key == 'type': pass elif key == 'local': new_zpts = [] roof_zs = [] # Create z coordinates for each story: for story_num in range(0, len(self.hasStory)): zcoord = self.hasStory[story_num].hasElevation[0] zs = self.create_zcoords(self.hasGeometry['Footprint'][key], zcoord) if story_num == len(self.hasStory) - 1: zcoord_roof = self.hasStory[story_num].hasElevation[-1] roof_zs = self.create_zcoords(self.hasGeometry['Footprint'][key], zcoord_roof) else: pass # Save 3D coordinates: new_zpts.append(zs) new_zpts.append(roof_zs) # With new 3D coordinates for each horizontal plane, create surface geometry: # Set up plotting: if plot_flag: fig = plt.figure() ax = plt.axes(projection='3d') for plane in range(0, len(new_zpts) - 1): # Add the bottom and top planes for the Story: plane_poly1 = Polygon(new_zpts[plane]) plane_poly2 = Polygon(new_zpts[plane + 1]) self.hasStory[plane].hasGeometry['3D Geometry'][key].append(plane_poly1) self.hasStory[plane].hasGeometry['3D Geometry'][key].append(plane_poly2) for zpt in range(0, len(new_zpts[plane]) - 1): # Create the surface polygon: surf_poly = Polygon([new_zpts[plane][zpt], new_zpts[plane + 1][zpt], new_zpts[plane + 1][zpt + 1], new_zpts[plane][zpt + 1]]) # Save the polygon to the story's geometry: self.hasStory[plane].hasGeometry['3D Geometry'][key].append(surf_poly) self.hasStory[plane].hasGeometry['Facade'][key].append(surf_poly) # Extract xs, ys, and zs and plot surf_xs = [] surf_ys = [] surf_zs = [] for surf_points in list(surf_poly.exterior.coords): surf_xs.append(surf_points[0]) surf_ys.append(surf_points[1]) surf_zs.append(surf_points[2]) if plot_flag: # Plot the surfaces for the entire building to verify: ax.plot(np.array(surf_xs)/3.281, np.array(surf_ys)/3.281, np.array(surf_zs)/3.281, 'k') # Make the panes transparent: ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 1.0)) ax.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 1.0)) ax.w_zaxis.set_pane_color((1.0, 1.0, 1.0, 1.0)) # Make the grids transparent: ax.xaxis._axinfo["grid"]['color'] = (1, 1, 1, 0) ax.yaxis._axinfo["grid"]['color'] = (1, 1, 1, 0) ax.zaxis._axinfo["grid"]['color'] = (1, 1, 1, 0) # Plot labels ax.set_xlabel('x [m]', fontsize=16, labelpad=10) ax.set_ylabel('y [m]', fontsize=16, labelpad=10) ax.set_zlabel('z [m]', fontsize=16, labelpad=10) #ax.set_zlim(0, 16) ax.set_zlim3d(0, 16) # Show the surfaces for each story: #ax.set_xticks(np.arange(-20,20,5)) #ax.set_yticks(np.arange(-20, 20, 5)) if plot_flag: ax.set_zticks(np.arange(0, 20, 4)) ax.xaxis.set_tick_params(labelsize=16) ax.yaxis.set_tick_params(labelsize=16) ax.zaxis.set_tick_params(labelsize=16) plt.show() # Define full 3D surface renderings for the building using base plane and top plane: base_poly = Polygon(new_zpts[0]) top_poly = Polygon(new_zpts[-1]) self.hasGeometry['3D Geometry'][key].append(base_poly) self.hasGeometry['3D Geometry'][key].append(top_poly) for pt in range(0, len(new_zpts[0]) - 1): # Create the surface polygon: bsurf_poly = Polygon([new_zpts[0][pt], new_zpts[-1][pt], new_zpts[-1][pt + 1], new_zpts[0][pt + 1]]) # Save the polygon to the building geometry: self.hasGeometry['3D Geometry'][key].append(bsurf_poly) self.hasGeometry['Facade'][key].append(bsurf_poly) # # Generate a set of building elements (with default attributes) for the parcel: self.parcel_elements(self, zone_flag=True) # # Update the Building's Elements: self.update_elements()