Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Merge develop to master for 0.5.0 release

See merge request incore/pyincore!129
  • Loading branch information
navarroc committed Aug 29, 2019
2 parents 4331c39 + 486c38f commit a96c8ef
Show file tree
Hide file tree
Showing 32 changed files with 1,043 additions and 281 deletions.
2 changes: 2 additions & 0 deletions pyincore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from pyincore.utils.geoutil import GeoUtil
from pyincore.dataservice import DataService
from pyincore.fragilityservice import FragilityService
from pyincore.repairservice import RepairService
from pyincore.restorationservice import RestorationService
from pyincore.spaceservice import SpaceService
from pyincore.utils.analysisutil import AnalysisUtil
from pyincore.dataset import Dataset, InventoryDataset, DamageRatioDataset
Expand Down
2 changes: 1 addition & 1 deletion pyincore/analyses/bridgedamage/bridgedamage.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def bridge_damage_analysis_bulk_input(self, bridges, hazard_dataset_id, dmg_rati
"""
result = []
fragility_sets = self.fragilitysvc.map_fragilities(self.get_parameter("mapping_id"), bridges, fragility_key)
fragility_sets = self.fragilitysvc.map_inventory(self.get_parameter("mapping_id"), bridges, fragility_key)
for bridge in bridges:
fragility_set = None
if bridge["id"] in fragility_sets:
Expand Down
2 changes: 1 addition & 1 deletion pyincore/analyses/bridgedamage/test_bridge_dmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def run_with_base_class():
client = InsecureIncoreClient(
"http://incore2-services.ncsa.illinois.edu:8888", "incrtest")
"http://incore2-services-dev.ncsa.illinois.edu:8888", "incrtest")

# New madrid earthquake using Atkinson Boore 1995
hazard_type = "earthquake"
Expand Down
4 changes: 2 additions & 2 deletions pyincore/analyses/buildingdamage/buildingdamage.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ def building_damage_analysis_bulk_input(self, buildings, hazard_type, hazard_dat
fragility_key = self.get_parameter("fragility_key")

fragility_sets = dict()
fragility_sets[fragility_key] = self.fragilitysvc.map_fragilities(self.get_parameter("mapping_id"), buildings,
fragility_sets[fragility_key] = self.fragilitysvc.map_inventory(self.get_parameter("mapping_id"), buildings,
fragility_key)

if hazard_type == 'tsunami':
other_fragility_sets = self.fragilitysvc.map_fragilities(self.get_parameter("mapping_id"), buildings,
other_fragility_sets = self.fragilitysvc.map_inventory(self.get_parameter("mapping_id"), buildings,
BuildingUtil.DEFAULT_TSUNAMI_HMAX_FRAGILITY_KEY)
fragility_sets[BuildingUtil.DEFAULT_TSUNAMI_HMAX_FRAGILITY_KEY] = other_fragility_sets

Expand Down
4 changes: 2 additions & 2 deletions pyincore/analyses/buildingdamage/buildingutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def get_building_period(num_stories, fragility_set):
fragility_curve = fragility_set['fragilityCurves'][0]

fragility_class_name = fragility_curve['className']
if fragility_class_name in ['edu.illinois.ncsa.incore.service.fragility.models.PeriodStandardFragilityCurve',
'edu.illinois.ncsa.incore.service.fragility.models.PeriodBuildingFragilityCurve']:
if fragility_class_name in ['edu.illinois.ncsa.incore.service.dfr3.models.PeriodStandardFragilityCurve',
'edu.illinois.ncsa.incore.service.dfr3.models.PeriodBuildingFragilityCurve']:

period_equation_type = fragility_curve['periodEqnType']
if period_equation_type == 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def run_with_base_class():
client = InsecureIncoreClient(
"http://incore2-services.ncsa.illinois.edu:8888", "incrtest")
"http://incore2-services-dev.ncsa.illinois.edu:8888", "incrtest")

# Setting up Id's for Dataset inputs: Earthquake building damage, Tsunami Building Damage and Damage Ratios
eq_bldg_dmg_id = "5c5c9686c5c0e488fcf91903"
Expand Down
8 changes: 8 additions & 0 deletions pyincore/analyses/montecarlofailureprobability/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 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.montecarlofailureprobability.montecarlofailureprobability import MonteCarloFailureProbability
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"from pyincore.analyses.montecarlofailureprobability import MonteCarloFailureProbability\n",
"from pyincore.analyses.buildingdamage import BuildingDamage\n",
"from pyincore.analyses.waterfacilitydamage import WaterFacilityDamage\n",
"from pyincore.analyses.bridgedamage import BridgeDamage\n",
"from pyincore.client import InsecureIncoreClient"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### define client"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client = InsecureIncoreClient(\"http://incore2-services-dev.ncsa.illinois.edu:8888\", \"incrtest\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mc = MonteCarloFailureProbability(client)\n",
"mc.load_remote_input_dataset(\"damage\", \"5a29782fc7d30d4af537ace5\")\n",
"mc.set_parameter(\"result_name\", \"mc_failure_probability\")\n",
"mc.set_parameter(\"num_cpu\", 8)\n",
"mc.set_parameter(\"num_samples\", 10)\n",
"mc.set_parameter(\"damage_interval_keys\",\n",
" [\"insignific\", \"moderate\", \"heavy\", \"complete\"])\n",
"mc.set_parameter(\"failure_state_keys\", [\"moderate\", \"heavy\", \"complete\"])\n",
"mc.run_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mc.get_output_datasets()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### chaining with building damage"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bldg_dmg = BuildingDamage(client)\n",
"bldg_dmg.load_remote_input_dataset(\"buildings\", \"5a284f0bc7d30d13bc081a28\")\n",
"bldg_dmg.load_remote_input_dataset(\"dmg_ratios\", \"5a284f2ec7d30d13bc08209a\")\n",
"bldg_dmg.set_parameter(\"result_name\", \"memphis_building_damage\")\n",
"bldg_dmg.set_parameter(\"mapping_id\", \"5b47b350337d4a3629076f2c\")\n",
"bldg_dmg.set_parameter(\"hazard_type\", \"earthquake\")\n",
"bldg_dmg.set_parameter(\"hazard_id\", \"5b902cb273c3371e1236b36b\")\n",
"bldg_dmg.set_parameter(\"num_cpu\", 1)\n",
"bldg_dmg.run_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"building_dmg_result = bldg_dmg.get_output_dataset('result')\n",
"\n",
"mc = MonteCarloFailureProbability(client)\n",
"mc.set_input_dataset(\"damage\", building_dmg_result)\n",
"mc.set_parameter(\"result_name\", \"bldg_mc_failure_probability\")\n",
"mc.set_parameter(\"num_cpu\", 8)\n",
"mc.set_parameter(\"num_samples\", 10)\n",
"mc.set_parameter(\"damage_interval_keys\",\n",
" [\"insignific\", \"moderate\", \"heavy\", \"complete\"])\n",
"mc.set_parameter(\"failure_state_keys\", [\"moderate\", \"heavy\", \"complete\"])\n",
"mc.run_analysis()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### chaining with water facility damage"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wf_dmg = WaterFacilityDamage(client)\n",
"wf_dmg.load_remote_input_dataset(\"water_facilities\", \"5a284f2ac7d30d13bc081e52\")\n",
"wf_dmg.set_parameter(\"result_name\", \"wf_dmg_results\")\n",
"wf_dmg.set_parameter(\"hazard_type\", \"earthquake\")\n",
"wf_dmg.set_parameter(\"hazard_id\", \"5b902cb273c3371e1236b36b\")\n",
"wf_dmg.set_parameter(\"mapping_id\", \"5b47c383337d4a387669d592\")\n",
"wf_dmg.set_parameter(\"fragility_key\", \"pga\")\n",
"wf_dmg.set_parameter(\"use_liquefaction\", True)\n",
"wf_dmg.set_parameter(\"liquefaction_geology_dataset_id\", \"5a284f53c7d30d13bc08249c\")\n",
"wf_dmg.set_parameter(\"liquefaction_fragility_key\", \"pgd\")\n",
"wf_dmg.set_parameter(\"use_hazard_uncertainty\", False)\n",
"wf_dmg.set_parameter(\"num_cpu\", 1)\n",
"wf_dmg.run_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"water_facility_dmg_result = wf_dmg.get_output_dataset('result')\n",
"\n",
"mc = MonteCarloFailureProbability(client)\n",
"mc.set_input_dataset(\"damage\", water_facility_dmg_result)\n",
"mc.set_parameter(\"result_name\", \"water_facility_mc_failure_probability\")\n",
"mc.set_parameter(\"num_cpu\", 8)\n",
"mc.set_parameter(\"num_samples\", 10)\n",
"mc.set_parameter(\"damage_interval_keys\",\n",
" [\"none\", \"slight-mod\", \"mod-extens\", \"ext-comple\", \"complete\"])\n",
"mc.set_parameter(\"failure_state_keys\", [\"slight-mod\", \"mod-extens\", \"ext-comple\", \"complete\"])\n",
"mc.run_analysis()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### chaining with electric power facility damage"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### chaining with bridge damage"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bridge_dmg = BridgeDamage(client)\n",
"bridge_dmg.load_remote_input_dataset(\"bridges\", \"5a284f2dc7d30d13bc082040\")\n",
"bridge_dmg.load_remote_input_dataset(\"dmg_ratios\", \"5a284f2cc7d30d13bc081f96\")\n",
"bridge_dmg.set_parameter(\"result_name\", \"bridge_dmg\")\n",
"bridge_dmg.set_parameter(\"mapping_id\", \"5b47bcce337d4a37755e0cb2\")\n",
"bridge_dmg.set_parameter(\"hazard_type\", \"earthquake\")\n",
"bridge_dmg.set_parameter(\"hazard_id\", \"5b902cb273c3371e1236b36b\")\n",
"bridge_dmg.set_parameter(\"num_cpu\", 4)\n",
"\n",
"bridge_dmg.run_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"bridge_dmg_result = bridge_dmg.get_output_dataset('result')\n",
"\n",
"mc = MonteCarloFailureProbability(client)\n",
"mc.set_input_dataset(\"damage\", bridge_dmg_result)\n",
"mc.set_parameter(\"result_name\", \"bridge_facility_mc_failure_probability\")\n",
"mc.set_parameter(\"num_cpu\", 8)\n",
"mc.set_parameter(\"num_samples\", 10)\n",
"mc.set_parameter(\"damage_interval_keys\",\n",
" [\"none\", \"slight-mod\", \"mod-extens\", \"ext-comple\", \"complete\"])\n",
"mc.set_parameter(\"failure_state_keys\", [\"slight-mod\", \"mod-extens\", \"ext-comple\", \"complete\"])\n",
"mc.run_analysis()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit a96c8ef

Please sign in to comment.