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

Reflects input changes to CBR #311

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed
- Added semantic data type url linking for the data type in the analyses markdowns [#299](https://github.com/IN-CORE/incore-docs/issues/299)
- Updated docs and notebook to reflect input changes to Commercial Building Recovery analysis [#310](https://github.com/IN-CORE/incore-docs/issues/310)

## [Unreleased]

Expand Down
12 changes: 7 additions & 5 deletions manual_jb/content/analyses/commercial_building_recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ key name | type | name | description

**Input datasets**

key name | type | name | description
--- | --- | --- | ---
key name | type | name | description
--- | --- |------------------| ---
`buildings` <sup>*</sup> | [`ergo:buildingInventoryVer4`](https://incore.ncsa.illinois.edu/semantics/api/types/ergo:buildingInventoryVer4)<br>[`ergo:buildingInventoryVer5`](https://incore.ncsa.illinois.edu/semantics/api/types/ergo:buildingInventoryVer5)<br>[`ergo:buildingInventoryVer6`](https://incore.ncsa.illinois.edu/semantics/api/types/ergo:buildingInventoryVer6)<br>[`ergo:buildingInventoryVer7`](https://incore.ncsa.illinois.edu/semantics/api/types/ergo:buildingInventoryVer7) | Building dataset | A building dataset.
`dfr3_mapping_set` <sup>*</sup> | [`incore:dfr3MappingSet`](https://incore.ncsa.illinois.edu/semantics/api/types/incore:dfr3MappingSet) | DFR3 Mapping Set | DFR3 Mapping Set.
`sample_damage_states` <sup>*</sup> | [`incore:sampleDamageState`](https://incore.ncsa.illinois.edu/semantics/api/types/incore:sampleDamageState) | Damage states | Sample damage states.
`mcs_failure` <sup>*</sup> | [`incore:failureProbability`](https://incore.ncsa.illinois.edu/semantics/api/types/incore:failureProbability) | MCS failure | mcs_failure.
`delay_factors` <sup>*</sup> | [`incore:buildingRecoveryFactors`](https://incore.ncsa.illinois.edu/semantics/api/types/incore:buildingRecoveryFactors) | Delay factors | Delay impeding factors such as post-disaster inspection, insurance claim,<br>and government permit based on building's damage state. Provided by REDi framework.
`sample_damage_states` <sup>*</sup> | [`incore:sampleDamageState`](https://incore.ncsa.illinois.edu/semantics/api/types/incore:sampleDamageState) | Damage states | Sample damage states.
`mcs_failure` <sup>*</sup> | [`incore:failureProbability`](https://incore.ncsa.illinois.edu/semantics/api/types/incore:failureProbability) | MCS failure | mcs_failure.
`delay_factors` <sup>*</sup> | [`incore:buildingRecoveryFactors`](https://incore.ncsa.illinois.edu/semantics/api/types/incore:buildingRecoveryFactors) | Delay factors | Delay impeding factors such as post-disaster inspection, insurance claim,<br>and government permit based on building's damage state. Provided by REDi framework.
`building_dmg` <sup>*</sup> | [`ergo:buildingDamageVer6`](https://incore.ncsa.illinois.edu/semantics/api/types/ergo:buildingDamageVer6) | Building Damage | Damage result that has damage intervals.


**Output datasets**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Damage analyses use fragility curve sets to calculate the limit state (LS) and damage stsate (DS). Mapping then determines which fragility curve set applying to which inventory. For example, a building that has certain number of stories could be mapped to a specific set of fragility curves.\r\n",
"\r\n",
"Damage analyses use fragility curve sets to calculate the limit state (LS) and damage stsate (DS). Mapping then determines which fragility curve set applying to which inventory. For example, a building that has certain number of stories could be mapped to a specific set of fragility curves.\n",
"\n",
"In IN-CORE, A user can both upload a set of fragility curves and mapping to the DFR3 services, or use local curve and mapping set object DFR3 stands for Damage, Functionality, Repair, Reconstruction, and Recovery.\n",
"\n",
"* **DFR3 Service** is the IN-CORE web service to manage curves (equations) of fragility, repair, damage, etc.s.\r\n",
"\r\n",
"* **DFR3 Service** is the IN-CORE web service to manage curves (equations) of fragility, repair, damage, etc.s.\n",
"\n",
"This section briefly shows how to access fragility curves. A detailed instrcution of how to create your own fragility entities and mapping entities can be found in our Mannu[al: Toutorial - Create DFR3 Ob](https://incore.ncsa.illinois.edu/doc/incore/notebooks/create_dfr3_object/create_dfr3_object.html)\n",
"\n",
"Note that you will learn detail about this matter at Session 4.ject\r\n",
"\r\n",
"Note that you will learn detail about this matter at Session 4.ject\n",
"\n",
"User can easily browsing and searching Fragility Curves and Mappings via DFR3 \n",
"\n",
"* **DFR3 Viewer:** https://incore.ncsa.illinois.edu/DFR3Viewer\n",
Expand Down Expand Up @@ -378,10 +378,10 @@
"bldg_dmg = BuildingDamage(client)\n",
"\n",
"# setting input data and parameters\n",
"bldg_dmg.set_input_dataset(\"buildings\", ) # needs a variable\n",
"bldg_dmg.set_input_dataset(\"dfr3_mapping_set\", ) # needs a variable\n",
"bldg_dmg.set_input_dataset(\"buildings\", bldg_dataset ) # needs a variable\n",
"bldg_dmg.set_input_dataset(\"dfr3_mapping_set\", mapping_set ) # needs a variable\n",
"bldg_dmg.set_parameter(\"hazard_type\", \"tornado\")\n",
"bldg_dmg.set_parameter(\"hazard_id\", ) # needs a variable\n",
"bldg_dmg.set_parameter(\"hazard_id\", tornado_id ) # needs a variable\n",
"bldg_dmg.set_parameter(\"num_cpu\", 4) # Define the result name, etc., and choose the number of CPU locally\n",
"\n",
"# setting output info\n",
Expand Down Expand Up @@ -732,7 +732,7 @@
"\n",
"mc_bldg = MonteCarloFailureProbability(client)\n",
"\n",
"mc_bldg.set_input_dataset(\"damage\", ) # needs a varialbe\n",
"mc_bldg.set_input_dataset(\"damage\",building_dmg_result ) # needs a varialbe\n",
"mc_bldg.set_parameter(\"num_samples\", 500)\n",
"mc_bldg.set_parameter(\"damage_interval_keys\", [\"DS_0\", \"DS_1\", \"DS_2\", \"DS_3\"])\n",
"mc_bldg.set_parameter(\"failure_state_keys\", [\"DS_1\", \"DS_2\", \"DS_3\"])\n",
Expand Down Expand Up @@ -971,6 +971,8 @@
"delay_factors = \"64ee0bcd553ecf0768e21e55\"\n",
"com_recovery.load_remote_input_dataset(\"delay_factors\", delay_factors)\n",
"com_recovery.set_parameter(\"num_samples\", 50)\n",
"# using the building damage results from the building damage analysis\n",
"com_recovery.set_input_dataset(\"building_dmg\", building_dmg_result)\n",
"\n",
"# Specify the result name\n",
"result_name = \"joplin_commercial_test\"\n",
Expand Down Expand Up @@ -1094,13 +1096,6 @@
"ax.set_ylabel(\"Recovery State\") # 0 means damaged completely and 1 means fully recovered\n",
"ax.set_title(\"Joplin Commercial Building Recovery Curves by Archetype\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -1118,8 +1113,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,8 @@
"source": [
"# set other parameters\n",
"commercial_recovery.set_parameter(\"result_name\", \"joplin_tornado_commercial_bldg_recovery\")\n",
"commercial_recovery.set_parameter(\"num_samples\", 10)"
"commercial_recovery.set_parameter(\"num_samples\", 10)\n",
"commercial_recovery.set_input_dataset(\"building_dmg\", bldg_dmg_result)"
]
},
{
Expand Down Expand Up @@ -1555,8 +1556,7 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
Expand Down
101 changes: 87 additions & 14 deletions notebooks/commercial_building_recovery.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2023-09-29T15:02:55.785647Z",
"start_time": "2023-09-29T15:02:55.777915Z"
}
},
"metadata": {},
"outputs": [],
"source": [
"from pyincore import IncoreClient, RepairService, MappingSet\n",
"from pyincore import IncoreClient, RepairService, MappingSet, FragilityService\n",
"from pyincore.analyses.commercialbuildingrecovery.commercialbuildingrecovery import CommercialBuildingRecovery\n",
"\n",
"import pyincore.globals as pyglobals"
"from pyincore.analyses.montecarlofailureprobability import MonteCarloFailureProbability\n",
"from pyincore.analyses.buildingdamage import BuildingDamage"
]
},
{
Expand Down Expand Up @@ -52,6 +47,83 @@
"com_recovery.load_remote_input_dataset(\"buildings\", buildings)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fragility_service = FragilityService(client)\n",
"mapping_id = \"5d8942dfb9219c068ea795ea\"\n",
"mapping_set = MappingSet(fragility_service.get_mapping(mapping_id))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"# Perform building damage analysis\n",
"bldg_dmg = BuildingDamage(client)\n",
"tornado_id = \"5d07cbeab9219c065b080930\"\n",
"\n",
"# setting input data and parameters\n",
"bldg_dmg.load_remote_input_dataset(\"buildings\", buildings ) \n",
"bldg_dmg.set_input_dataset(\"dfr3_mapping_set\", mapping_set )\n",
"bldg_dmg.set_parameter(\"hazard_type\", \"tornado\")\n",
"bldg_dmg.set_parameter(\"hazard_id\",tornado_id )\n",
"bldg_dmg.set_parameter(\"num_cpu\", 4)\n",
"bldg_dmg.set_parameter(\"result_name\", \"joplin_tornado_commerical_bldg_dmg\")\n",
"bldg_dmg.run_analysis()\n",
"building_dmg_result = bldg_dmg.get_output_dataset(\"ds_result\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"### MCS Analysis\n",
"mc_bldg = MonteCarloFailureProbability(client)\n",
"\n",
"mc_bldg.set_input_dataset(\"damage\", building_dmg_result ) \n",
"mc_bldg.set_parameter(\"num_samples\", 500)\n",
"mc_bldg.set_parameter(\"damage_interval_keys\", [\"DS_0\", \"DS_1\", \"DS_2\", \"DS_3\"])\n",
"mc_bldg.set_parameter(\"failure_state_keys\", [\"DS_1\", \"DS_2\", \"DS_3\"])\n",
"mc_bldg.set_parameter(\"num_cpu\", 8)\n",
"\n",
"# name of csv file with results\n",
"mc_bldg.set_parameter(\"result_name\", \"tornado_mc_failure_probability_buildings\")\n",
"mc_bldg.run_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [],
"source": [
"building_failure_probability = mc_bldg.get_output_dataset(\"failure_probability\")\n",
"building_damage_states_mcs_output = mc_bldg.get_output_dataset(\"sample_damage_states\")"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -85,9 +157,10 @@
"outputs": [],
"source": [
"# Load input datasets\n",
"com_recovery.load_remote_input_dataset(\"sample_damage_states\", sample_damage_states)\n",
"com_recovery.load_remote_input_dataset(\"mcs_failure\", mcs_failure)\n",
"com_recovery.load_remote_input_dataset(\"delay_factors\", delay_factors)"
"com_recovery.set_input_dataset(\"sample_damage_states\", building_damage_states_mcs_output)\n",
"com_recovery.set_input_dataset(\"mcs_failure\", building_failure_probability)\n",
"com_recovery.load_remote_input_dataset(\"delay_factors\", delay_factors)\n",
"com_recovery.set_input_dataset(\"building_dmg\", building_dmg_result)"
]
},
{
Expand Down Expand Up @@ -161,9 +234,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
"version": "3.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
Binary file modified workshops/20231115/workshop-2023-11-15.zip
Binary file not shown.
Loading