Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ylyangtw committed Jun 5, 2024
1 parent 57cb035 commit 6b5f78a
Show file tree
Hide file tree
Showing 13 changed files with 1,002 additions and 419 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Update Non-structural Building Damage to support flood [#562](https://github.com/IN-CORE/pyincore/issues/562)
- Update flood input to non-structural building damage for combined wind-wave-surge building [#566](https://github.com/IN-CORE/pyincore/issues/566)
- Rename transportation recovery analysis to traffic flow recovery analysis [#558](https://github.com/IN-CORE/pyincore/issues/558)
- Rename building damage to building structural damage [#561](https://github.com/IN-CORE/pyincore/issues/561)

### Added
- Gas Facility Damage Analysis [#568](https://github.com/IN-CORE/pyincore/issues/568)
Expand Down
9 changes: 9 additions & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ analyses/buildingdamage
:members:
.. autoclass:: buildingdamage.buildingutil.BuildingUtil
:members:
.. deprecated:: 1.19.0
This class will be deprecated soon. Use :class:`buildingstructuraldamage.BuildingStructuralDamage` instead.

analyses/buildingstructuraldamage
=======================
.. autoclass:: buildingstructuraldamage.buildingstructuraldamage.BuildingStructuralDamage
:members:
.. autoclass:: buildingstructuraldamage.buildingutil.BuildingUtil
:members:

analyses/buildingeconloss
=========================
Expand Down
427 changes: 8 additions & 419 deletions pyincore/analyses/buildingdamage/buildingdamage.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions pyincore/analyses/buildingstructuraldamage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2019 University of Illinois and others. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/


from pyincore.analyses.buildingstructuraldamage.buildingutil import BuildingUtil
from pyincore.analyses.buildingstructuraldamage.buildingstructuraldamage import BuildingStructuralDamage
430 changes: 430 additions & 0 deletions pyincore/analyses/buildingstructuraldamage/buildingstructuraldamage.py

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions pyincore/analyses/buildingstructuraldamage/buildingutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2019 University of Illinois and others. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Mozilla Public License v2.0 which accompanies this distribution,
# and is available at https://www.mozilla.org/en-US/MPL/2.0/


class BuildingUtil:
"""Utility methods for the building damage analysis."""
DEFAULT_FRAGILITY_KEY = "Non-Retrofit Fragility ID Code"
DEFAULT_TSUNAMI_HMAX_FRAGILITY_KEY = "Non-Retrofit Inundation Fragility ID Code"
DEFAULT_TSUNAMI_MMAX_FRAGILITY_KEY = "Non-Retrofit MomentumFlux Fragility ID Code"
DEFAULT_REPAIR_KEY = "Repair ID Code"
BLDG_STORIES = "no_stories"
PROPERTIES = "properties"
BLDG_PERIOD = "period"
GROUND_FAILURE_PROB = "groundFailureProb"
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
from pyincore import IncoreClient, FragilityService, MappingSet, Earthquake, HazardService, Tsunami, Hurricane, \
Tornado
from pyincore.analyses.buildingstructuraldamage.buildingstructuraldamage import BuildingStructuralDamage
import pyincore.globals as pyglobals


def run_with_base_class():
client = IncoreClient(pyglobals.INCORE_API_DEV_URL)
hazardsvc = HazardService(client)

##########################################################
# Memphis Earthquake damage
# New madrid earthquake using Atkinson Boore 1995
eq = Earthquake.from_hazard_service("5b902cb273c3371e1236b36b", hazardsvc)

# Geology dataset
liq_geology_dataset_id = "5a284f53c7d30d13bc08249c"

# Building dataset
# 5a284f0bc7d30d13bc081a28 5kb
# 5bcf2fcbf242fe047ce79dad 300kb
# 5a284f37c7d30d13bc08219c 20mb
bldg_dataset_id = "5a284f0bc7d30d13bc081a28"

bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

# Earthquake mapping
mapping_id = "5b47b350337d4a3629076f2c"
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)

bldg_dmg.set_input_hazard("hazard", eq)

result_name = "memphis_eq_bldg_dmg_result"
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.set_parameter("use_liquefaction", True)
bldg_dmg.set_parameter("liquefaction_geology_dataset_id", liq_geology_dataset_id)

# Run Analysis
bldg_dmg.run_analysis()

##########################################################
# TSUNAMI
tsunami = Tsunami.from_hazard_service("5bc9e25ef7b08533c7e610dc", hazardsvc)

# Seaside building dataset
bldg_dataset_id = "5bcf2fcbf242fe047ce79dad"

# Run seaside tsunami building damage
bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

# Tsunami mapping
mapping_id = "5b48fb1f337d4a478e7bd54d"
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)
bldg_dmg.set_input_hazard("hazard", tsunami)
result_name = "seaside_tsunami_dmg_result"
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.run_analysis()

##########################################################
# Hurricane
hurricane = Hurricane.from_hazard_service("5f11e50cc6491311a814584c", hazardsvc)

# Galveston building dataset 602eba8bb1db9c28aef01358
bldg_dataset_id = "602eba8bb1db9c28aef01358" # 19k buildings with age_group
# bldg_dataset_id = "602d61d0b1db9c28aeedea03" # 40 buildings without age_group

bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

# Hurricane building mapping (with equation)
mapping_id = "602c381a1d85547cdc9f0675"
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)
bldg_dmg.set_parameter("fragility_key", "Hurricane SurgeLevel and WaveHeight Fragility ID Code")

bldg_dmg.set_input_hazard("hazard", hurricane)

result_name = "galveston_hurr_dmg_result"
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.run_analysis()

##########################################################
# joplin tornado without strategy
bldg_dataset_id = "5df7d0de425e0b00092d0082" # joplin building v6

bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

mapping_id = "5e8e3a21eaa8b80001f04f1c" # 19 archetype mapping
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)

tornado = Tornado.from_hazard_service("5dfa32bbc0601200080893fb", hazardsvc)
bldg_dmg.set_input_hazard("hazard", tornado)

result_name = "joplin_tornado_dmg_result"
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.set_parameter("seed", 1000)
bldg_dmg.run_analysis()


if __name__ == '__main__':
run_with_base_class()
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import os

from pyincore import IncoreClient, FragilityService, MappingSet
from pyincore.analyses.buildingstructuraldamage.buildingstructuraldamage import BuildingStructuralDamage
import pyincore.globals as pyglobals


def run_with_base_class():
result_folder = "legacy"
if not os.path.exists(result_folder):
os.mkdir(result_folder)

client = IncoreClient(pyglobals.INCORE_API_DEV_URL)

# Memphis Earthquake damage
# New madrid earthquake using Atkinson Boore 1995
hazard_type = "earthquake"
hazard_id = "5b902cb273c3371e1236b36b"

# Geology dataset
liq_geology_dataset_id = "5a284f53c7d30d13bc08249c"

# Building dataset
# 5a284f0bc7d30d13bc081a28 5kb
# 5bcf2fcbf242fe047ce79dad 300kb
# 5a284f37c7d30d13bc08219c 20mb
bldg_dataset_id = "5a284f0bc7d30d13bc081a28"

bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

# Earthquake mapping
mapping_id = "5b47b350337d4a3629076f2c"
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)

result_name = os.path.join(result_folder, "memphis_eq_bldg_dmg_result")
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("hazard_type", hazard_type)
bldg_dmg.set_parameter("hazard_id", hazard_id)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.set_parameter("use_liquefaction", True)
bldg_dmg.set_parameter("liquefaction_geology_dataset_id", liq_geology_dataset_id)

# Run Analysis
bldg_dmg.run_analysis()

# TSUNAMI

hazard_type = "tsunami"
hazard_id = "5bc9e25ef7b08533c7e610dc"

# Seaside building dataset
bldg_dataset_id = "5bcf2fcbf242fe047ce79dad"

# Run seaside tsunami building damage
bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

# Tsunami mapping
mapping_id = "5b48fb1f337d4a478e7bd54d"
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)

result_name = os.path.join(result_folder, "seaside_tsunami_dmg_result")
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("hazard_type", hazard_type)
bldg_dmg.set_parameter("hazard_id", hazard_id)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.run_analysis()

# Hurricane

hazard_type = "hurricane"
hazard_id = "5f11e50cc6491311a814584c"

# Galveston building dataset 602eba8bb1db9c28aef01358
bldg_dataset_id = "602eba8bb1db9c28aef01358" # 19k buildings with age_group
# bldg_dataset_id = "602d61d0b1db9c28aeedea03" # 40 buildings without age_group

bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

# Hurricane building mapping (with equation)
mapping_id = "602c381a1d85547cdc9f0675"
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)
bldg_dmg.set_parameter("fragility_key", "Hurricane SurgeLevel and WaveHeight Fragility ID Code")

result_name = os.path.join(result_folder, "galveston_hurr_dmg_result")
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("hazard_type", hazard_type)
bldg_dmg.set_parameter("hazard_id", hazard_id)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.run_analysis()

# joplin tornado with retrofit strategy
bldg_dataset_id = "5df7d0de425e0b00092d0082" # joplin building v6
retrofit_strategy_id = "660ab8f8ce705a7e54748557" # plan 1

bldg_dmg = BuildingStructuralDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)
bldg_dmg.load_remote_input_dataset("retrofit_strategy", retrofit_strategy_id)

mapping_id = "5e8e3a21eaa8b80001f04f1c" # 19 archetype with retrofit
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)

hazard_type = "tornado"
hazard_id = "5dfa32bbc0601200080893fb"
result_name = os.path.join(result_folder, "joplin_tornado_dmg_result_w_retrofit")
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("hazard_type", hazard_type)
bldg_dmg.set_parameter("hazard_id", hazard_id)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.set_parameter("seed", 1000)
bldg_dmg.run_analysis()


if __name__ == '__main__':
run_with_base_class()
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os

from pyincore import IncoreClient, FragilityService, MappingSet
from pyincore.analyses.buildingstructuraldamage.buildingstructuraldamage import BuildingStructuralDamage
import pyincore.globals as pyglobals


def run_with_base_class():
client = IncoreClient(pyglobals.INCORE_API_DEV_URL)

bldg_dmg = BuildingStructuralDamage(client)

# seaside multi-hazard
bldg_dmg.load_remote_input_dataset("buildings", "5bcf2fcbf242fe047ce79dad")

mapping_id = "648a3f88c687ae511a1814e2" # earthquake+tsunami mapping
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)
bldg_dmg.set_parameter("fragility_key", "Non-Retrofit Fragility ID Code")

hazard_type = "earthquake+tsunami"
hazard_id = "5ba8f127ec2309043520906c+5bc9eaf7f7b08533c7e610e1"

result_folder = "mutliple_hazards"
if not os.path.exists(result_folder):
os.mkdir(result_folder)
result_name = os.path.join(result_folder, "seaside_multihazard")
bldg_dmg.set_parameter("result_name", result_name)
bldg_dmg.set_parameter("hazard_type", hazard_type)
bldg_dmg.set_parameter("hazard_id", hazard_id)
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.set_parameter("seed", 1000)
bldg_dmg.run_analysis()


if __name__ == '__main__':
run_with_base_class()
Loading

0 comments on commit 6b5f78a

Please sign in to comment.