Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

562 update building nonstructural damage to support flood #571

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed
- Rename Social Vulnerability Analysis to Social Vulnerability Index Analysis [#556](https://github.com/IN-CORE/pyincore/issues/556)
- Join dataset has an option for only keeping the table dataset fields [#299](https://github.com/IN-CORE/pyincore/issues/299)
- 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)

### Added
- Gas Facility Damage Analysis [#568](https://github.com/IN-CORE/pyincore/issues/568)
- Copyrights to transportation recovery analysis [#579](https://github.com/IN-CORE/pyincore/issues/579)

### Changed
- Join dataset has an option for only keeping the table dataset fields [#299](https://github.com/IN-CORE/pyincore/issues/299)

### Fixed
- Permission error in clearing cache process [#563](https://github.com/IN-CORE/pyincore/issues/563)

## [Unreleased]

### Changed
- Rename Social Vulnerability Analysis to Social Vulnerability Index Analysis [#556](https://github.com/IN-CORE/pyincore/issues/556)

## [Unreleased]

### Changed
- Rename transportation recovery analysis to traffic flow recovery analysis [#558](https://github.com/IN-CORE/pyincore/issues/558)

## [1.18.1] - 2024-04-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def get_spec(self):
'id': 'flood_damage',
'required': True,
'description': 'Flood damage result that has damage intervals in it',
'type': ['ergo:buildingDamageVer6']
'type': ['ergo:nsBuildingInventoryDamageVer4']
},

],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def get_spec(self):
'id': 'flood_damage',
'required': True,
'description': 'Flood damage result that has damage intervals in it',
'type': ['ergo:buildingDamageVer6']
'type': ['ergo:nsBuildingInventoryDamageVer4']
},
{
'id': 'structural_cost',
Expand Down
230 changes: 86 additions & 144 deletions pyincore/analyses/nonstructbuildingdamage/nonstructbuildingdamage.py

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions pyincore/analyses/nonstructbuildingdamage/nonstructbuildingutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,3 @@ def adjust_damage_for_liquefaction(limit_state_probabilities, ground_failure_pro
+ prob_ground_failure - limit_state_probabilities[keys[j]] * prob_ground_failure

return adjusted_limit_state_probabilities

@staticmethod
def determine_haz_exposure(hazard_exposure_as, hazard_exposure_ds):
"""
Determine the hazard exposure of the building based on the
Args:
hazard_exposure_as:
hazard_exposure_ds:

Returns:

"""
if hazard_exposure_as == "yes" and hazard_exposure_ds == "yes":
haz_expose = "yes"
elif hazard_exposure_as == "error" or hazard_exposure_ds == "error":
haz_expose = "error"
elif hazard_exposure_as == "no" and hazard_exposure_ds == "no":
haz_expose = "no"
else:
haz_expose = "partial"

return haz_expose
31 changes: 2 additions & 29 deletions tests/pyincore/analyses/buildingdamage/test_buildingdamage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyincore import IncoreClient, FragilityService, MappingSet, Earthquake, HazardService, Tsunami, Hurricane, Flood, \
from pyincore import IncoreClient, FragilityService, MappingSet, Earthquake, HazardService, Tsunami, Hurricane, \
Tornado
from pyincore.analyses.buildingdamage import BuildingDamage
import pyincore.globals as pyglobals
Expand Down Expand Up @@ -89,44 +89,17 @@ def run_with_base_class():
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.run_analysis()

##########################################################
# lumberton flood
flood = Flood.from_hazard_service("5f4d02e99f43ee0dde768406", hazardsvc)

# lumberton building inventory v7
# bldg_dataset_id = "603010f7b1db9c28aef53214" # 40 building subset
bldg_dataset_id = "603010a4b1db9c28aef5319f" # 21k full building

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

# lumberton building mapping (with equation)
mapping_id = "602f3cf981bd2c09ad8f4f9d"
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", "Lumberton Flood Building Fragility ID Code")

bldg_dmg.set_input_hazard("hazard", flood)

result_name = "lumberton_flood_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 = BuildingDamage(client)
bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

mapping_id = "6091d9fbb53ed4646fd276ca" # 19 archetype with retrofit
# mapping_id = "60994a1906d63d5ded1d6dcc" # 19 archetype with retrofit new format mapping
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)
bldg_dmg.set_parameter("fragility_key", "Fragility ID Code")

tornado = Tornado.from_hazard_service("5dfa32bbc0601200080893fb", hazardsvc)
bldg_dmg.set_input_hazard("hazard", tornado)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,47 +97,18 @@ def run_with_base_class():
bldg_dmg.set_parameter("num_cpu", 4)
bldg_dmg.run_analysis()

# lumberton flood
hazard_type = "flood"
hazard_id = "5f4d02e99f43ee0dde768406"

# lumberton building inventory v7
# bldg_dataset_id = "603010f7b1db9c28aef53214" # 40 building subset
bldg_dataset_id = "603010a4b1db9c28aef5319f" # 21k full building

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

# lumberton building mapping (with equation)
mapping_id = "602f3cf981bd2c09ad8f4f9d"
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", "Lumberton Flood Building Fragility ID Code")

result_name = os.path.join(result_folder, "lumberton_flood_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 = "6091d5a8daa06e14ee96d502" # plan 1
# retrofit_strategy_id = "6091d5ffdaa06e14ee96d5ef" # plan 2
retrofit_strategy_id = "660ab8f8ce705a7e54748557" # plan 1

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

# lumberton building mapping (with equation)
mapping_id = "6091d9fbb53ed4646fd276ca" # 19 archetype with retrofit
# mapping_id = "60994a1906d63d5ded1d6dcc" # 19 archetype with retrofit new format mapping
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)
bldg_dmg.set_parameter("fragility_key", "Fragility ID Code")

hazard_type = "tornado"
hazard_id = "5dfa32bbc0601200080893fb"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from pyincore import IncoreClient, MappingSet, Tornado, Dataset, HazardService, Flood
from pyincore import IncoreClient, MappingSet, Tornado, Dataset, HazardService
from pyincore.analyses.buildingdamage import BuildingDamage
import pyincore.globals as pyglobals
import time
Expand Down Expand Up @@ -53,37 +53,6 @@ def run_with_base_class():
end_time_1 = time.time()
print(f"Joplin Tornado Retrofit execution time: {end_time_1 - start_time:.5f} seconds")

##############################
# lumberton flood
flood = Flood.from_hazard_service("5f4d02e99f43ee0dde768406", dev_hazardsvc)

flood_fragility_mapping_set = MappingSet.from_json_file(os.path.join(pyglobals.TEST_DATA_DIR,
"retrofit/flood_retrofit_mapping.json"))
# lumberton building inventory v7
bldg_dataset_id = "603010a4b1db9c28aef5319f" # 21k full building

flood_bldg_dmg = BuildingDamage(dev_client)
flood_bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)

# lumberton building mapping (with equation)
flood_bldg_dmg.set_input_dataset("dfr3_mapping_set", flood_fragility_mapping_set)
flood_bldg_dmg.set_parameter("fragility_key", "Lumberton Flood Building Fragility ID Code")

flood_bldg_dmg.set_input_hazard("hazard", flood)

retrofit_strategy_plan = Dataset.from_file(os.path.join(pyglobals.TEST_DATA_DIR,
"retrofit/flood_retrofit_plan.csv"),
data_type="incore:retrofitStrategy")
flood_bldg_dmg.set_input_dataset("retrofit_strategy", retrofit_strategy_plan)

result_name = "lumberton_flood_dmg_result_w_retrofit"
flood_bldg_dmg.set_parameter("result_name", os.path.join(result_folder, result_name))
flood_bldg_dmg.set_parameter("num_cpu", 8)
flood_bldg_dmg.run_analysis()

end_time_2 = time.time()
print(f"Lumberton Flood Retrofit execution time: {end_time_2 - end_time_1:.5f} seconds")


if __name__ == '__main__':
run_with_base_class()
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pyincore import IncoreClient, FragilityService, MappingSet
from pyincore.analyses.combinedwindwavesurgebuildingdamage import CombinedWindWaveSurgeBuildingDamage
from pyincore.analyses.buildingdamage import BuildingDamage
from pyincore.analyses.nonstructbuildingdamage import NonStructBuildingDamage
import pyincore.globals as pyglobals


Expand Down Expand Up @@ -50,10 +51,11 @@ def run_with_base_class():
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))

# flood building damage
f_bldg_dmg = BuildingDamage(client)
f_bldg_dmg = NonStructBuildingDamage(client)
f_bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)
f_bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)
f_bldg_dmg.set_parameter("result_name", "Galveston-flood-dmg")
f_bldg_dmg.set_parameter("fragility_key", "Non-Retrofit Fragility ID Code")
f_bldg_dmg.set_parameter("hazard_type", hazard_type)
f_bldg_dmg.set_parameter("hazard_id", hazard_id)
f_bldg_dmg.set_parameter("num_cpu", 4)
Expand All @@ -62,7 +64,7 @@ def run_with_base_class():
# Get damage outputs from different hazards
surge_wave_damage = sw_bldg_dmg.get_output_dataset("ds_result")
wind_damage = w_bldg_dmg.get_output_dataset("ds_result")
flood_damage = f_bldg_dmg.get_output_dataset("ds_result")
flood_damage = f_bldg_dmg.get_output_dataset("result")

# Combined building damage to determine maximum damage state
combined_bldg_dmg = CombinedWindWaveSurgeBuildingDamage(client)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pyincore import IncoreClient, FragilityService, MappingSet
from pyincore.analyses.combinedwindwavesurgebuildingloss import CombinedWindWaveSurgeBuildingLoss
from pyincore.analyses.buildingdamage import BuildingDamage
from pyincore.analyses.nonstructbuildingdamage import NonStructBuildingDamage
import pyincore.globals as pyglobals
from timeit import default_timer as timer

Expand Down Expand Up @@ -52,10 +53,11 @@ def run_with_base_class():
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))

# flood building damage
f_bldg_dmg = BuildingDamage(client)
f_bldg_dmg = NonStructBuildingDamage(client)
f_bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id)
f_bldg_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)
f_bldg_dmg.set_parameter("result_name", "Galveston-flood-dmg")
f_bldg_dmg.set_parameter("fragility_key", "Non-Retrofit Fragility ID Code")
f_bldg_dmg.set_parameter("hazard_type", hazard_type)
f_bldg_dmg.set_parameter("hazard_id", hazard_id)
f_bldg_dmg.set_parameter("num_cpu", 4)
Expand All @@ -64,7 +66,7 @@ def run_with_base_class():
# Get damage outputs from different hazards
surge_wave_damage = sw_bldg_dmg.get_output_dataset("ds_result")
wind_damage = w_bldg_dmg.get_output_dataset("ds_result")
flood_damage = f_bldg_dmg.get_output_dataset("ds_result")
flood_damage = f_bldg_dmg.get_output_dataset("result")

start = timer()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from pyincore import IncoreClient, FragilityService, MappingSet, Flood, HazardService
from pyincore.analyses.nonstructbuildingdamage import NonStructBuildingDamage
import pyincore.globals as pyglobals


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

# lumberton flood
flood = Flood.from_hazard_service("5f4d02e99f43ee0dde768406", hazardsvc)

# lumberton building inventory v7
# bldg_dataset_id = "603010f7b1db9c28aef53214" # 40 building subset
bldg_dataset_id = "603010a4b1db9c28aef5319f" # 21k full building

# lumberton building mapping (with equation)
mapping_id = "602f3cf981bd2c09ad8f4f9d"
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))

non_structural_building_dmg_flood = NonStructBuildingDamage(client)
non_structural_building_dmg_flood.load_remote_input_dataset("buildings", bldg_dataset_id)
non_structural_building_dmg_flood.set_input_dataset('dfr3_mapping_set', mapping_set)
non_structural_building_dmg_flood.set_parameter("result_name", "non_structural_building_dmg_result_flood")
non_structural_building_dmg_flood.set_input_hazard("hazard", flood)
non_structural_building_dmg_flood.set_parameter("num_cpu", 4)
non_structural_building_dmg_flood.set_parameter("fragility_key", "Lumberton Flood Building Fragility ID Code")
non_structural_building_dmg_flood.run_analysis()


if __name__ == '__main__':
run_with_base_class()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pyincore import IncoreClient, FragilityService, MappingSet
from pyincore.analyses.nonstructbuildingdamage import NonStructBuildingDamage
from pyincore.analyses.nonstructbuildingdamage import NonStructBuildingDamage, NonStructBuildingUtil
import pyincore.globals as pyglobals


Expand All @@ -15,36 +15,39 @@ def run_with_base_class():

# Default Building Fragility Mapping v1.0
mapping_id = "5b47b350337d4a3629076f2c"

non_structural_building_dmg = NonStructBuildingDamage(client)

# Load input datasets
non_structural_building_dmg.load_remote_input_dataset("buildings", building_dataset_id)

# Load fragility mapping
fragility_service = FragilityService(client)
mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))
non_structural_building_dmg.set_input_dataset('dfr3_mapping_set', mapping_set)

# Specify the result name
result_name = "non_structural_building_dmg_result"

# Set analysis parameters
non_structural_building_dmg.set_parameter("result_name", result_name)
non_structural_building_dmg.set_parameter("hazard_type", hazard_type)
non_structural_building_dmg.set_parameter("hazard_id", hazard_id)
non_structural_building_dmg.set_parameter("num_cpu", 4)

# use liquefaction (slow)
# Shelby County Liquefaction Susceptibility
use_liquefaction = True
liq_geology_dataset_id = "5a284f55c7d30d13bc0824ba"

non_structural_building_dmg.set_parameter("use_liquefaction", use_liquefaction)
non_structural_building_dmg.set_parameter("liq_geology_dataset_id", liq_geology_dataset_id)

# Run analysis
non_structural_building_dmg.run_analysis()
# Acceleration sensitive
non_structural_building_dmg_as = NonStructBuildingDamage(client)
non_structural_building_dmg_as.load_remote_input_dataset("buildings", building_dataset_id)
non_structural_building_dmg_as.set_input_dataset('dfr3_mapping_set', mapping_set)
non_structural_building_dmg_as.set_parameter("result_name", "non_structural_building_dmg_result_as")
non_structural_building_dmg_as.set_parameter("hazard_type", hazard_type)
non_structural_building_dmg_as.set_parameter("hazard_id", hazard_id)
non_structural_building_dmg_as.set_parameter("num_cpu", 4)
non_structural_building_dmg_as.set_parameter("fragility_key", NonStructBuildingUtil.DEFAULT_FRAGILITY_KEY_AS)
non_structural_building_dmg_as.set_parameter("use_liquefaction", use_liquefaction)
non_structural_building_dmg_as.set_parameter("liq_geology_dataset_id", liq_geology_dataset_id)
non_structural_building_dmg_as.run_analysis()

# Drift sensitive
non_structural_building_dmg_ds = NonStructBuildingDamage(client)
non_structural_building_dmg_ds.load_remote_input_dataset("buildings", building_dataset_id)
non_structural_building_dmg_ds.set_input_dataset('dfr3_mapping_set', mapping_set)
non_structural_building_dmg_ds.set_parameter("result_name", "non_structural_building_dmg_result_ds")
non_structural_building_dmg_ds.set_parameter("hazard_type", hazard_type)
non_structural_building_dmg_ds.set_parameter("hazard_id", hazard_id)
non_structural_building_dmg_ds.set_parameter("num_cpu", 4)
non_structural_building_dmg_ds.set_parameter("fragility_key", NonStructBuildingUtil.DEFAULT_FRAGILITY_KEY_DS)
non_structural_building_dmg_ds.set_parameter("use_liquefaction", use_liquefaction)
non_structural_building_dmg_ds.set_parameter("liq_geology_dataset_id", liq_geology_dataset_id)
non_structural_building_dmg_ds.run_analysis()


if __name__ == '__main__':
Expand Down
Loading
Loading