def run_with_base_class(): client = IncoreClient(INCORE_API_DEV_URL) # Memphis Earthquake damage # New madrid earthquake using Atkinson Boore 1995 hazard_type = "earthquake" hazard_id = "5b902cb273c3371e1236b36b" # Building dataset # 5a284f0bc7d30d13bc081a28 5kb # 5bcf2fcbf242fe047ce79dad 300kb # 5a284f37c7d30d13bc08219c 20mb bldg_dataset_id = "5a284f0bc7d30d13bc081a28" bldg_dmg = BuildingDamage(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 = "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) # 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 = BuildingDamage(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 = "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()
def run_with_base_class(): client = IncoreClient(INCORE_API_DEV_URL) hazard_type = "earthquake" hazard_id = "5eebcbb08f80fe3899ad6039" epf_dataset_id = "5eebcaa17a00803abc85ec11" # Earthquake mapping mapping_id = "5eebcc13e7226233ce4ef0d7" # Run epf damage epf_dmg = EpfDamage(client) epf_dmg.load_remote_input_dataset("epfs", epf_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) epf_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) epf_dmg.set_parameter("result_name", "earthquake_epf_dmg_result") epf_dmg.set_parameter("hazard_type", hazard_type) epf_dmg.set_parameter("hazard_id", hazard_id) epf_dmg.set_parameter("num_cpu", 1) # Run Analysis epf_dmg.run_analysis() hazard_type = "tsunami" hazard_id = "5bc9eaf7f7b08533c7e610e1" epf_dataset_id = "5eebcaa17a00803abc85ec11" # Tsunami mapping mapping_id = "5eebce11e7226233ce4ef305" # Run epf damage epf_dmg = EpfDamage(client) epf_dmg.load_remote_input_dataset("epfs", epf_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) epf_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) epf_dmg.set_parameter("fragility_key", "Non-Retrofit inundationDepth Fragility ID Code") epf_dmg.set_parameter("result_name", "tsunami_epf_dmg_result") epf_dmg.set_parameter("hazard_type", hazard_type) epf_dmg.set_parameter("hazard_id", hazard_id) epf_dmg.set_parameter("num_cpu", 1) # Run Analysis epf_dmg.run_analysis()
def test_pipeline_dmg(): client = IncoreClient(service_url=INCORE_API_DEV_URL, token_file_name=".incrtesttoken") pipeline_dmg = PipelineDamage(client) # test tsunami pipeline pipeline_dmg.load_remote_input_dataset("pipeline", "5ef1171b2367ff111d082f0c") # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping("5ef11888da15730b13b84353")) pipeline_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) pipeline_dmg.set_parameter("result_name", "seaside_tsunami_pipeline_result") pipeline_dmg.set_parameter("hazard_type", "tsunami") pipeline_dmg.set_parameter("fragility_key", "Non-Retrofit inundationDepth Fragility ID Code") pipeline_dmg.set_parameter("hazard_id", "5bc9eaf7f7b08533c7e610e1") pipeline_dmg.set_parameter("num_cpu", 4) # Run pipeline damage analysis result = pipeline_dmg.run_analysis() assert result is True
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) epf_rest = EpfRestoration(client) restorationsvc = RestorationService(client) mapping_set = MappingSet( restorationsvc.get_mapping( "61f302e6e3a03e465500b3eb")) # new format of mapping epf_rest.load_remote_input_dataset('epfs', '6189c103d5b02930aa3efc35') epf_rest.set_input_dataset('dfr3_mapping_set', mapping_set) epf_rest.set_parameter("result_name", "epf_restoration.csv") epf_rest.set_parameter("restoration_key", "Restoration ID Code") epf_rest.set_parameter("end_time", 100.0) epf_rest.set_parameter("time_interval", 1.0) epf_rest.set_parameter("pf_interval", 0.01) epf_rest.run_analysis() # test utility function epf_rest_util = EpfRestorationUtil(epf_rest) functionality = epf_rest_util.get_percentage_func( guid="60748fbd-67c3-4f8d-beb9-26685a53d3c5", damage_state="DS_0", time=2.0) time = epf_rest_util.get_restoration_time( guid="60748fbd-67c3-4f8d-beb9-26685a53d3c5", damage_state="DS_1", pf=0.81) print(functionality, time)
def test_road_failure(): client = IncoreClient(INCORE_API_DEV_URL, token_file_name=".incrtesttoken") # road inventory for Galveston island road_dataset_id = "5f0dd5ecb922f96f4e962caf" # distance table for Galveston island distance_dataset_id = "5f1883abfeef2d758c4e857d" # road damage by hurricane inundation mapping mapping_id = "5f0cb04fe392b24d4800f316" # Galveston Deterministic Hurricane - Kriging inundationDuration hazard_type = "hurricane" hazard_id = "5f10837c01d3241d77729a4f" # Create road damage road_failure = RoadFailure(client) # Load input datasets road_failure.load_remote_input_dataset("roads", road_dataset_id) road_failure.load_remote_input_dataset("distance_table", distance_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) road_failure.set_input_dataset('dfr3_mapping_set', mapping_set) # Specify the result name result_name = "road_result" # Set analysis parameters road_failure.set_parameter("result_name", result_name) road_failure.set_parameter("hazard_type", hazard_type) road_failure.set_parameter("hazard_id", hazard_id) road_failure.set_parameter("num_cpu", 4) # Run road damage by hurricane inundation analysis result = road_failure.run_analysis() assert result is True
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) client.clear_cache() pipeline_restoration = PipelineRestoration(client) # shelby county pipelines pipeline_restoration.load_remote_input_dataset("pipeline", "5a284f28c7d30d13bc081d14") pipeline_restoration.load_remote_input_dataset("pipeline_damage", "61f36023c53b3620b6b614c6") # Load fragility mapping restoration_service = RestorationService(client) mapping_set = MappingSet( restoration_service.get_mapping("61f35f09903e515036cee106")) pipeline_restoration.set_input_dataset('dfr3_mapping_set', mapping_set) pipeline_restoration.set_parameter("result_name", "pipeline_restoration_times") pipeline_restoration.set_parameter("restoration_key", "Restoration ID Code") pipeline_restoration.set_parameter("num_available_workers", 4) pipeline_restoration.set_parameter("num_cpu", 4) # Run pipeline restoration analysis pipeline_restoration.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) wf_rest = WaterFacilityRestoration(client) # Load restoration mapping restorationsvc = RestorationService(client) mapping_set = MappingSet( restorationsvc.get_mapping( "61f075ee903e515036cee0a5")) # new format of mapping wf_rest.load_remote_input_dataset( "water_facilities", "5a284f2ac7d30d13bc081e52") # water facility wf_rest.set_input_dataset('dfr3_mapping_set', mapping_set) wf_rest.set_parameter("result_name", "wf_restoration") wf_rest.set_parameter("restoration_key", "Restoration ID Code") wf_rest.set_parameter("end_time", 100.0) wf_rest.set_parameter("time_interval", 1.0) wf_rest.set_parameter("pf_interval", 0.05) wf_rest.run_analysis() # test utility function wf_util = WaterFacilityRestorationUtil(wf_rest) functionality = wf_util.get_percentage_func( guid="e1bce78d-00a1-4605-95f3-3776ff907f73", damage_state="DS_0", time=2.0) time = wf_util.get_restoration_time( guid="e1bce78d-00a1-4605-95f3-3776ff907f73", damage_state="DS_1", pf=0.81) print(functionality, time)
def run_with_base_class(): client = IncoreClient(INCORE_API_DEV_URL) hazard_type = "earthquake" hazard_id = "5b902cb273c3371e1236b36b" facility_datasetid = "5a284f2ac7d30d13bc081e52" mapping_id = "5b47c3b1337d4a387e85564b" # Hazus Potable Water Facility Fragility Mapping - Only PGA liq_geology_dataset_id = "5a284f53c7d30d13bc08249c" uncertainty = False liquefaction = False liq_fragility_key = "pgd" wf_dmg = WaterFacilityDamage(client) wf_dmg.load_remote_input_dataset("water_facilities", facility_datasetid) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) wf_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) result_name = "wf-dmg-results.csv" wf_dmg.set_parameter("result_name", result_name) wf_dmg.set_parameter("hazard_type", hazard_type) wf_dmg.set_parameter("hazard_id", hazard_id) wf_dmg.set_parameter("fragility_key", "pga") wf_dmg.set_parameter("use_liquefaction", liquefaction) wf_dmg.set_parameter("liquefaction_geology_dataset_id", liq_geology_dataset_id) wf_dmg.set_parameter("liquefaction_fragility_key", liq_fragility_key) wf_dmg.set_parameter("use_hazard_uncertainty", uncertainty) wf_dmg.set_parameter("num_cpu", 4) wf_dmg.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) pipeline_dmg = PipelineDamage(client) # test tsunami pipeline pipeline_dmg.load_remote_input_dataset("pipeline", "5ef1171b2367ff111d082f0c") # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet( fragility_service.get_mapping( "60b124e01f2b7d4a916ba456")) # new format fragility curves # mapping_set = MappingSet(fragility_service.get_mapping("5ef11888da15730b13b84353")) # legacy fragility curves pipeline_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) pipeline_dmg.set_parameter("result_name", "seaside_tsunami_pipeline_result") pipeline_dmg.set_parameter("hazard_type", "tsunami") pipeline_dmg.set_parameter( "fragility_key", "Non-Retrofit inundationDepth Fragility ID Code") pipeline_dmg.set_parameter("hazard_id", "5bc9eaf7f7b08533c7e610e1") pipeline_dmg.set_parameter("num_cpu", 4) # Run pipeline damage analysis result = pipeline_dmg.run_analysis()
def run_with_base_class(): client = IncoreClient(INCORE_API_DEV_URL) # EQ Road Dataset - Seaside roads road_dataset_id = "5ee7af50772cf80008577ae3" hazard_type = "tsunami" liq_geology_dataset_id = None if hazard_type == 'earthquake': # Seaside Earthquake hazard_id = "5ba8f379ec2309043520906f" # Earthquake mapping mapping_id = "5ee7b145c54361000148dcc5" fragility_key = "pgd" liquefaction = False elif hazard_type == 'tsunami': # Seaside Tsunami hazard_id = "5bc9eaf7f7b08533c7e610e1" # Tsunami Mapping for Seaside mapping_id = "5ee7b2c9c54361000148de37" fragility_key = "Non-Retrofit inundationDepth Fragility ID Code" liquefaction = False else: raise ValueError( "Earthquake and tsunami are the only testable hazards with road damage currently" ) uncertainty = False # Run Seaside earthquake road damage road_dmg = RoadDamage(client) road_dmg.load_remote_input_dataset("roads", road_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) road_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) road_dmg.set_parameter("result_name", "seaside_road_dmg_" + hazard_type) road_dmg.set_parameter("hazard_type", hazard_type) road_dmg.set_parameter("hazard_id", hazard_id) if fragility_key is not None: road_dmg.set_parameter("fragility_key", fragility_key) road_dmg.set_parameter("num_cpu", 1) road_dmg.set_parameter("use_liquefaction", liquefaction) if liquefaction and liq_geology_dataset_id is not None: road_dmg.set_parameter("liquefaction_geology_dataset_id", liq_geology_dataset_id) road_dmg.set_parameter("use_hazard_uncertainty", uncertainty) # Run Analysis road_dmg.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) # Joplin tornado building damage bldg_dataset_id = "5df7d0de425e0b00092d0082" # joplin building v6 bldg_dmg = BuildingDamage(client) bldg_dmg.load_remote_input_dataset("buildings", bldg_dataset_id) mapping_id = "5e8e3a21eaa8b80001f04f1c" # 19 archetype, non-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", "Non-Retrofit Fragility ID Code") # The simulated EF-5 tornado shows geographical locations and the range of wind speed # of tornado hazard in Joplin. hazard_type = "tornado" hazard_id = "5dfa32bbc0601200080893fb" result_name = "joplin_tornado_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("seed", 1000) bldg_dmg.run_analysis() # end of Building damage analysis # get csv results from Building damage analysis building_dmg_result = bldg_dmg.get_output_dataset("ds_result") building_dmg_result.get_dataframe_from_csv() restoration = JoplinEmpiricalRestoration(client) # Building final target level dataset defining custom final restoration values building_fl_id = "61a68979d5b02930aa43ae39" restoration.load_remote_input_dataset("buildings", bldg_dataset_id) # restoration.load_remote_input_dataset("building_dmg", building_dmg_result) restoration.set_input_dataset("building_dmg", building_dmg_result) restoration.load_remote_input_dataset("building_functionality_level", building_fl_id) result_name = "Joplin_empirical_restoration_result" restoration.set_parameter("result_name", result_name) restoration.set_parameter("target_functionality_level", 0) # restoration.set_parameter("seed", 1234) # Run Analysis restoration.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) epf_rest = ElectricPowerFacilityRestoration(client) restorationsvc = RestorationService(client) mapping_set = MappingSet( restorationsvc.get_mapping( "61f302e6e3a03e465500b3eb")) # new format of mapping epf_rest.set_input_dataset('dfr3_mapping_set', mapping_set) epf_rest.set_parameter("result_name", "epf_restoration.csv") epf_rest.set_parameter("restoration_key", "Restoration ID Code") epf_rest.set_parameter("end_time", 100.0) epf_rest.set_parameter("time_interval", 1.0) epf_rest.set_parameter("pf_interval", 0.01) epf_rest.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) # Memphis 7.9 AB-95 hazard_type = "earthquake" hazard_id = "5b902cb273c3371e1236b36b" # Shelby County Essential Facilities building_dataset_id = "5a284f42c7d30d13bc0821ba" # 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()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) wf_rest = WaterFacilityRestoration(client) # Load restoration mapping restorationsvc = RestorationService(client) mapping_set = MappingSet( restorationsvc.get_mapping( "61f075ee903e515036cee0a5")) # new format of mapping wf_rest.set_input_dataset('dfr3_mapping_set', mapping_set) wf_rest.set_parameter("result_name", "wf_restoration") wf_rest.set_parameter("restoration_key", "Restoration ID Code") wf_rest.set_parameter("end_time", 100.0) wf_rest.set_parameter("time_interval", 1.0) wf_rest.set_parameter("pf_interval", 0.05) wf_rest.run_analysis()
def test_pipeline_dmg_w_repair_rate(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) # This is the Memphis Water Buried Pipeline with Topology dataset the Ergo repository pipeline_dataset_id = "5a284f28c7d30d13bc081d14" # pipeline mapping mapping_id = "5b47c227337d4a38464efea8" # New madrid earthquake using Atkinson Boore 1995 hazard_type = "earthquake" hazard_id = "5b902cb273c3371e1236b36b" # Geology dataset liq_geology_dataset_id = "5a284f53c7d30d13bc08249c" # Create pipeline damage test_pipeline_dmg_w_rr = PipelineDamageRepairRate(client) # Load input datasets test_pipeline_dmg_w_rr.load_remote_input_dataset("pipeline", pipeline_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) test_pipeline_dmg_w_rr.set_input_dataset('dfr3_mapping_set', mapping_set) # Specify the result name result_name = "pipeline_result" # Set analysis parameters test_pipeline_dmg_w_rr.set_parameter("result_name", result_name) test_pipeline_dmg_w_rr.set_parameter("hazard_type", hazard_type) test_pipeline_dmg_w_rr.set_parameter("hazard_id", hazard_id) test_pipeline_dmg_w_rr.set_parameter("liquefaction_fragility_key", "pgd") # test_pipeline_dmg_w_rr.set_parameter("use_liquefaction", False) test_pipeline_dmg_w_rr.set_parameter( "use_liquefaction", True) # toggle on and off to see liquefaction test_pipeline_dmg_w_rr.set_parameter("num_cpu", 4) test_pipeline_dmg_w_rr.set_parameter("liquefaction_geology_dataset_id", liq_geology_dataset_id) # Run pipeline damage analysis result = test_pipeline_dmg_w_rr.run_analysis() assert result is True
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) # Joplin buildings = "5df7d0de425e0b00092d0082" # joplin ergo:buildingInventoryVer6 28k buildings # sample_damage_states = "6112d9ccca3e973ce144b4d9" # 500 samples 28k buildings - MCS output format sample_damage_states = "60f883c059a8cc52bab4dd77" # 10 samples 28k buildings - MCS output format socio_demographic_data = "60dbd77602897f12fcd449c3" financial_resources = "60dbd64702897f12fcd448f5" delay_factors = "60eca71302897f12fcd70843" # DS_0, etc. result_name = "joplin_recovery" seed = 1238 # not used yet num_samples = 10 res_recovery = ResidentialBuildingRecovery(client) res_recovery.load_remote_input_dataset("buildings", buildings) mapping_id = "60edfa3efc0f3a7af53a21b5" repair_service = RepairService(client) mapping_set = MappingSet(repair_service.get_mapping(mapping_id)) res_recovery.set_input_dataset('dfr3_mapping_set', mapping_set) res_recovery.load_remote_input_dataset("sample_damage_states", sample_damage_states) res_recovery.load_remote_input_dataset("socio_demographic_data", socio_demographic_data) res_recovery.load_remote_input_dataset("financial_resources", financial_resources) res_recovery.load_remote_input_dataset("delay_factors", delay_factors) res_recovery.set_parameter("result_name", result_name) res_recovery.set_parameter("seed", seed) res_recovery.set_parameter("num_samples", num_samples) res_recovery.run_analysis() return True
def run_with_base_class(chained): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) if chained: # ************************************************************* # Set up and run Building damage, Galveston, TX analysis # ************************************************************* hazard_type = "hurricane" # Galveston deterministic Hurricane, 3 datasets - Kriging # hazard_id = "5fa5a228b6429615aeea4410" # prod hazard_id = "5fa472033c1f0c73fe81461a" # Galveston, TX Building inventory # bldg_inv_id = "60354b6c123b4036e6837ef7" # prod 19k buildings with age_group bldg_inv_id = "602eba8bb1db9c28aef01358" # Hurricane building mapping (with equation) mapping_id = "602c381a1d85547cdc9f0675" # dev & prod fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) bldg_dmg = BuildingDamage(client) bldg_dmg.load_remote_input_dataset("buildings", bldg_inv_id) bldg_dmg.set_input_dataset("dfr3_mapping_set", mapping_set) result_name = "Galveston_bldg_dmg_result" bldg_dmg.set_parameter("fragility_key", "Hurricane SurgeLevel and WaveHeight Fragility ID Code") 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) # Run Building damage bldg_dmg.run_analysis() # Retrieve result dataset building_dmg_result = bldg_dmg.get_output_dataset("ds_result") # Convert dataset to Pandas DataFrame # bdmg_df = building_dmg_result.get_dataframe_from_csv(low_memory=False) # print(bdmg_df[["guid", "DS_0", "DS_1", "DS_2", "DS_3", "haz_expose"]]) # ************************************************************* # Set up and run Housing Unit Allocation (HUA) analysis # ************************************************************* # Housing unit inventory # housing_unit_inv = "5fc6ab1cd2066956f49e7a03" # prod housing_unit_inv = "5fc6a757eba0eb743dc7739f" # Address point inventory # address_point_inv = "5fc6aadcc38a0722f563392e" address_point_inv = "5fc6a4ddeba0eb743dc77301" # Create housing allocation hua = HousingUnitAllocation(client) # Load input dataset hua.load_remote_input_dataset("housing_unit_inventory", housing_unit_inv) hua.load_remote_input_dataset("address_point_inventory", address_point_inv) hua.load_remote_input_dataset("buildings", bldg_inv_id) # Specify the result name result_name = "Galveston_HUA" seed = 1238 iterations = 1 # Set analysis parameters hua.set_parameter("result_name", result_name) hua.set_parameter("seed", seed) hua.set_parameter("iterations", iterations) # Run Housing unit allocation analysis hua.run_analysis() # Retrieve result dataset hua_result = hua.get_output_dataset("result") # Convert dataset to Pandas DataFrame # hua_df = hua_result.get_dataframe_from_csv(low_memory=False) # Display top 5 rows of output data # print(hua_df[["guid", "numprec", "incomegroup"]].head()) # ************************************************************* # Set up and run Population Dislocation analysis # ************************************************************* # Block group data, IN-CORE_BGMAP_2021-01-19_GalvestonTX # bg_data = "603545f2dcda03378087e708" # prod bg_data = "6035445b1e456929c86094c8" # Value loss parameters DS 0-3 # value_loss = "60354810e379f22e16560dbd" value_loss = "613901d9ca423a005e422feb" pop_dis = PopulationDislocation(client) pop_dis.load_remote_input_dataset("block_group_data", bg_data) pop_dis.load_remote_input_dataset("value_loss_param", value_loss) pop_dis.set_input_dataset("building_dmg", building_dmg_result) pop_dis.set_input_dataset("housing_unit_allocation", hua_result) result_name = "galveston-pop-disl-results" seed = 1111 pop_dis.set_parameter("result_name", result_name) pop_dis.set_parameter("seed", seed) pop_dis.run_analysis() # Retrieve result dataset pd_result = pop_dis.get_output_dataset("result") # Convert dataset to Pandas DataFrame # pd_df = pd_result.get_dataframe_from_csv(low_memory=False) # Display top 5 rows of output data # print(pd_df[["guid", "dislocated"]].head()) # ************************************************************* # Set up and run Housing Recovery analysis # ************************************************************* # Additional inventory data (assessed damage, square area) bldg_sqft_id = "62193c19a42a3e546ae2d9f8" # Census block groups data (required) census_bg_id = "62193b7ca42a3e546ae2d9f2" # Census appraisal file; id of external Census json census_appr_id = "6241fbd153302c512d685181" # dev result_name = "Galveston_building_values_chained" housing_rec = HousingRecovery(client) housing_rec.set_input_dataset("population_dislocation", pd_result) housing_rec.load_remote_input_dataset("building_area", bldg_sqft_id) housing_rec.load_remote_input_dataset("census_block_groups_data", census_bg_id) # Census appraisal data housing_rec.load_remote_input_dataset("census_appraisal_data", census_appr_id) housing_rec.set_parameter("result_name", result_name) housing_rec.run_analysis() else: # Run Housing Recovery analysis without chaining # Additional inventory data (assessed damage, square area) bldg_add_id = "62193c19a42a3e546ae2d9f8" # bldg_add_id = "6243638e89dbb809c6432501" # no dmg, uses value_loss # Census block groups data (required) census_bg_id = "62193b7ca42a3e546ae2d9f2" # Census appraisal file; id of external Census json census_appr_id = "6241fbd153302c512d685181" result_name = "Galveston_building_values" housing_rec = HousingRecovery(client) pop_disl_id = "623d1e1ca42a3e546aeba25f" # dev housing_rec.load_remote_input_dataset("population_dislocation", pop_disl_id) housing_rec.load_remote_input_dataset("building_area", bldg_add_id) housing_rec.load_remote_input_dataset("census_block_groups_data", census_bg_id) # Census appraisal data housing_rec.load_remote_input_dataset("census_appraisal_data", census_appr_id) housing_rec.set_parameter("result_name", result_name) housing_rec.run_analysis()
def run_with_base_class(): client = IncoreClient(INCORE_API_DEV_URL) # New madrid earthquake using Atkinson Boore 1995 hazard_type = "earthquake" hazard_id = "5b902cb273c3371e1236b36b" # NBSR bridges bridge_dataset_id = "5a284f2dc7d30d13bc082040" # Default Bridge Fragility Mapping on incore-service mapping_id = "5b47bcce337d4a37755e0cb2" # Use hazard uncertainty for computing damage use_hazard_uncertainty = False # Use liquefaction (LIQ) column of bridges to modify fragility curve use_liquefaction = False # Create bridge damage bridge_dmg = BridgeDamage(client) # Load input datasets bridge_dmg.load_remote_input_dataset("bridges", bridge_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) bridge_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) # Set analysis parameters bridge_dmg.set_parameter("result_name", "bridge_result") bridge_dmg.set_parameter("hazard_type", hazard_type) bridge_dmg.set_parameter("hazard_id", hazard_id) bridge_dmg.set_parameter("num_cpu", 4) # Run bridge damage analysis bridge_dmg.run_analysis() ################################################################### # Test liquefaction # south carolina eq damage hazard_type = "earthquake" hazard_id = "5ee9309bc9f1b70008fdbd26" # south carolina bridges bridge_dataset_id = "5ee92f884210b80008f9377e" # Default Bridge Fragility Mapping on incore-service mapping_id = "5b47bcce337d4a37755e0cb2" # Use hazard uncertainty for computing damage use_hazard_uncertainty = False # Use liquefaction (LIQ) column of bridges to modify fragility curve use_liquefaction = True # Create bridge damage bridge_dmg = BridgeDamage(client) # Load input datasets bridge_dmg.load_remote_input_dataset("bridges", bridge_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) bridge_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) # Set analysis parameters bridge_dmg.set_parameter("result_name", "bridge_result_w_liquefaction") bridge_dmg.set_parameter("hazard_type", hazard_type) bridge_dmg.set_parameter("hazard_id", hazard_id) bridge_dmg.set_parameter("use_liquefaction", use_liquefaction) bridge_dmg.set_parameter("num_cpu", 1) # Run bridge damage analysis bridge_dmg.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) # New madrid earthquake using Atkinson Boore 1995 hazard_type = "earthquake" hazard_id = "5b902cb273c3371e1236b36b" # NBSR bridges bridge_dataset_id = "5a284f2dc7d30d13bc082040" # Default Bridge Fragility Mapping on incore-service mapping_id = "5b47bcce337d4a37755e0cb2" # Use hazard uncertainty for computing damage use_hazard_uncertainty = False # Use liquefaction (LIQ) column of bridges to modify fragility curve use_liquefaction = False # Create bridge damage bridge_dmg = BridgeDamage(client) # Load input datasets bridge_dmg.load_remote_input_dataset("bridges", bridge_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) bridge_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) # Set analysis parameters bridge_dmg.set_parameter("result_name", "bridge_result") bridge_dmg.set_parameter("hazard_type", hazard_type) bridge_dmg.set_parameter("hazard_id", hazard_id) bridge_dmg.set_parameter("num_cpu", 4) # Run bridge damage analysis bridge_dmg.run_analysis() ################################################################### # Test liquefaction # south carolina eq damage hazard_type = "earthquake" hazard_id = "5ee9309bc9f1b70008fdbd26" # south carolina bridges bridge_dataset_id = "5ee92f884210b80008f9377e" # Default Bridge Fragility Mapping on incore-service mapping_id = "5b47bcce337d4a37755e0cb2" # Use hazard uncertainty for computing damage use_hazard_uncertainty = False # Use liquefaction (LIQ) column of bridges to modify fragility curve use_liquefaction = True # Create bridge damage bridge_dmg = BridgeDamage(client) # Load input datasets bridge_dmg.load_remote_input_dataset("bridges", bridge_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) bridge_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) # Set analysis parameters bridge_dmg.set_parameter("result_name", "bridge_result_w_liquefaction") bridge_dmg.set_parameter("hazard_type", hazard_type) bridge_dmg.set_parameter("hazard_id", hazard_id) bridge_dmg.set_parameter("use_liquefaction", use_liquefaction) bridge_dmg.set_parameter("num_cpu", 1) # Run bridge damage analysis bridge_dmg.run_analysis() ################################################################### # test Galveston Bridge Damage hazard_type = "hurricane" hazard_id = "5f11e50cc6491311a814584c" # Galveston bridge bridge_dataset_id = "6062058ac57ada48e48c31e3" # Galveston hurricane bridge mapping refactored_mapping_id = "6062254b618178207f66226c" # Create bridge damage bridge_dmg = BridgeDamage(client) # Load input datasets bridge_dmg.load_remote_input_dataset("bridges", bridge_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) refactored_mapping_set = MappingSet( fragility_service.get_mapping(refactored_mapping_id)) bridge_dmg.set_input_dataset('dfr3_mapping_set', refactored_mapping_set) # Set analysis parameters bridge_dmg.set_parameter( "fragility_key", "Hurricane SurgeLevel and WaveHeight Fragility ID Code") bridge_dmg.set_parameter("result_name", "galveston_bridge_dmg_result") bridge_dmg.set_parameter("hazard_type", hazard_type) bridge_dmg.set_parameter("hazard_id", hazard_id) bridge_dmg.set_parameter("num_cpu", 4) # Run bridge damage analysis bridge_dmg.run_analysis()
def run_with_base_class(): client = IncoreClient() # New madrid earthquake using Atkinson Boore 1995 hazard_type = "earthquake" hazard_id = "5b902cb273c3371e1236b36b" # mmsa highway bridges highway_bridges_id_list = { "Highway_Bridges": "60e86d6b544e944c3ce622d2" } # mmsa railway bridges railway_bridges_id_list = { "Railway_Bridges_BNSF": "60e86e6f60b3f41243fb9df3", "Railway_Bridges_CN": "60e86e91544e944c3ce62376", "Railway_Bridges_CSXT": "60e86eab60b3f41243fb9e44", "Railway_Bridges_NS": "60e86ed1544e944c3ce6241a", "Railway_Bridges_UP": "60e86ee960b3f41243fb9ee8" } # Default Bridge Fragility Mapping on incore-service highway_bridge_mapping_id_list = { "ABP": "60f89fce52e10319df8086c4", "ABA": "60f89fd647290977c8994353", "EBL": "60f89fd7a0c8a24d7eedf916", "EBT": "60f89fd96fb1bc236b68d3f7", "Col": "60f89fdc47290977c8994578", "FBL": "60f89fdda0c8a24d7eedfa9f", "ABT": "60f89fdf6fb1bc236b68d61c", "FBT": "60f89fdf52e10319df808b5f" } railway_bridge_mapping_id_list = { "ABT": "60f89fc947290977c8994215", "FBL": "60f89fcba0c8a24d7eedf6a0", "FBT": "60f89fcd6fb1bc236b68d049", "Col": "60f89fd047290977c8994302", "EBL": "60f89fd2a0c8a24d7eedf6f1", "EBT": "60f89fd36fb1bc236b68d3a6", "ABA": "60f89fd452e10319df8088e9", "ABP": "60f89fda52e10319df808a72" } # Use hazard uncertainty for computing damage use_hazard_uncertainty = False # Use liquefaction (LIQ) column of bridges to modify fragility curve use_liquefaction = False # Create bridge damage bridge_dmg = BridgeDamage(client) # Load input datasets for bridge_name, highway_bridge_id in highway_bridges_id_list.items(): bridge_dmg.load_remote_input_dataset("bridges", highway_bridge_id) # Load fragility mapping fragility_service = FragilityService(client) for component_name, highway_bridge_mapping_id in highway_bridge_mapping_id_list.items(): mapping_set = MappingSet(fragility_service.get_mapping(highway_bridge_mapping_id)) bridge_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) # Set analysis parameters bridge_dmg.set_parameter("result_name", bridge_name + "_" + component_name) bridge_dmg.set_parameter("hazard_type", hazard_type) bridge_dmg.set_parameter("hazard_id", hazard_id) bridge_dmg.set_parameter("num_cpu", 4) # Run bridge damage analysis bridge_dmg.run_analysis() # Load input datasets for bridge_name, railway_bridge_id in railway_bridges_id_list.items(): bridge_dmg.load_remote_input_dataset("bridges", railway_bridge_id) # Load fragility mapping fragility_service = FragilityService(client) for component_name, railway_bridge_mapping_id in railway_bridge_mapping_id_list.items(): mapping_set = MappingSet(fragility_service.get_mapping(railway_bridge_mapping_id)) bridge_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) # Set analysis parameters bridge_dmg.set_parameter("result_name", bridge_name + "_" + component_name) bridge_dmg.set_parameter("hazard_type", hazard_type) bridge_dmg.set_parameter("hazard_id", hazard_id) bridge_dmg.set_parameter("num_cpu", 4) # Run bridge damage analysis bridge_dmg.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) # EQ Road Dataset - Seaside roads road_dataset_id = "5ee7af50772cf80008577ae3" hazard_type = "tsunami" # hazard_type = "earthquake" liq_geology_dataset_id = None if hazard_type == 'earthquake': # Seaside Earthquake hazard_id = "5ba8f379ec2309043520906f" # Earthquake mapping mapping_id = "5d545b0bb9219c0689f1f3f4" fragility_key = "pgd" liquefaction = False elif hazard_type == 'tsunami': # Seaside Tsunami hazard_id = "5bc9eaf7f7b08533c7e610e1" # Tsunami Mapping for Seaside mapping_id = "5ee7b2c9c54361000148de37" fragility_key = "Non-Retrofit inundationDepth Fragility ID Code" liquefaction = False else: raise ValueError( "Earthquake and tsunami are the only testable hazards with road damage currently" ) uncertainty = False # Run road damage road_dmg = RoadDamage(client) road_dmg.load_remote_input_dataset("roads", road_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) road_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) road_dmg.set_parameter("result_name", "seaside_road_dmg_" + hazard_type) road_dmg.set_parameter("hazard_type", hazard_type) road_dmg.set_parameter("hazard_id", hazard_id) if fragility_key is not None: road_dmg.set_parameter("fragility_key", fragility_key) road_dmg.set_parameter("num_cpu", 1) road_dmg.set_parameter("use_liquefaction", liquefaction) if liquefaction and liq_geology_dataset_id is not None: road_dmg.set_parameter("liquefaction_geology_dataset_id", liq_geology_dataset_id) road_dmg.set_parameter("use_hazard_uncertainty", uncertainty) # Run Analysis road_dmg.run_analysis() ###################################################################### # test galveston hurricane road failure # road inventory for Galveston island road_dataset_id = "60ba5ee94219ee25a56b6999" # road damage by hurricane inundation mapping mapping_id = "60ba583b1f2b7d4a916faf03" # Galveston Deterministic Hurricane - Kriging inundationDuration hazard_type = "hurricane" hazard_id = "5f10837c01d3241d77729a4f" # Create road damage hurr_road_dmg = RoadDamage(client) # Load input datasets hurr_road_dmg.load_remote_input_dataset("roads", road_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) hurr_road_dmg.set_input_dataset('dfr3_mapping_set', mapping_set) # Specify the result name result_name = "galveston_hurricane_road_result" # Set analysis parameters hurr_road_dmg.set_parameter("result_name", result_name) hurr_road_dmg.set_parameter("hazard_type", hazard_type) hurr_road_dmg.set_parameter( "fragility_key", "Non-Retrofit inundationDepth Fragility ID Code") hurr_road_dmg.set_parameter("hazard_id", hazard_id) hurr_road_dmg.set_parameter("num_cpu", 4) # Run road damage by hurricane inundation analysis hurr_road_dmg.run_analysis()
def run_with_base_class(): client = IncoreClient(pyglobals.INCORE_API_DEV_URL) # ## Memphis EPF Damage with Earthquake ## hazard_type_eq = "earthquake" hazard_id_eq = "5b902cb273c3371e1236b36b" epf_dataset_id = "6189c103d5b02930aa3efc35" # mapping_id = "61980b11e32da63f4b9d86f4" mapping_id = "61980cf5e32da63f4b9d86f5" # PGA and PGD use_liquefaction = True use_hazard_uncertainty = False liquefaction_geology_dataset_id = "5a284f53c7d30d13bc08249c" # Run epf damage epf_dmg_eq_memphis = EpfDamage(client) epf_dmg_eq_memphis.load_remote_input_dataset("epfs", epf_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) epf_dmg_eq_memphis.set_input_dataset('dfr3_mapping_set', mapping_set) epf_dmg_eq_memphis.set_parameter("result_name", "memphis_eq_epf_dmg_result") epf_dmg_eq_memphis.set_parameter("hazard_type", hazard_type_eq) epf_dmg_eq_memphis.set_parameter("hazard_id", hazard_id_eq) epf_dmg_eq_memphis.set_parameter("use_liquefaction", use_liquefaction) epf_dmg_eq_memphis.set_parameter("use_hazard_uncertainty", use_hazard_uncertainty) epf_dmg_eq_memphis.set_parameter("liquefaction_geology_dataset_id", liquefaction_geology_dataset_id) epf_dmg_eq_memphis.set_parameter("num_cpu", 1) # Run Analysis epf_dmg_eq_memphis.run_analysis() # ## Seaside EPF Damage with Earthquake ## hazard_type_eq = "earthquake" hazard_id_eq = "5eebcbb08f80fe3899ad6039" epf_dataset_id = "5eebcaa17a00803abc85ec11" # Earthquake mapping mapping_id = "5eebcc13e7226233ce4ef0d7" # only PGA # Run epf damage epf_dmg_eq = EpfDamage(client) epf_dmg_eq.load_remote_input_dataset("epfs", epf_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) epf_dmg_eq.set_input_dataset('dfr3_mapping_set', mapping_set) epf_dmg_eq.set_parameter("result_name", "seaside_eq_epf_dmg_result") epf_dmg_eq.set_parameter("hazard_type", hazard_type_eq) epf_dmg_eq.set_parameter("hazard_id", hazard_id_eq) epf_dmg_eq.set_parameter("num_cpu", 1) epf_dmg_eq.run_analysis() # ## Seaside Tsunami EPF Damage ## hazard_type_tsu = "tsunami" hazard_id_tsu = "5bc9eaf7f7b08533c7e610e1" epf_dataset_id = "5eebcaa17a00803abc85ec11" # Tsunami mapping mapping_id = "605bf9e1618178207f6475c6" # Run epf damage epf_dmg_tsu_re = EpfDamage(client) epf_dmg_tsu_re.load_remote_input_dataset("epfs", epf_dataset_id) epf_dmg_eq = EpfDamage(client) epf_dmg_eq.load_remote_input_dataset("epfs", epf_dataset_id) # Load fragility mapping fragility_service = FragilityService(client) mapping_set = MappingSet(fragility_service.get_mapping(mapping_id)) epf_dmg_tsu_re.set_input_dataset('dfr3_mapping_set', mapping_set) epf_dmg_tsu_re.set_parameter( "fragility_key", "Non-Retrofit inundationDepth Fragility ID Code") epf_dmg_tsu_re.set_parameter("result_name", "seaside_tsunami_epf_dmg_result") epf_dmg_tsu_re.set_parameter("hazard_type", hazard_type_tsu) epf_dmg_tsu_re.set_parameter("hazard_id", hazard_id_tsu) epf_dmg_tsu_re.set_parameter("num_cpu", 1) epf_dmg_tsu_re.set_input_dataset('dfr3_mapping_set', mapping_set) # Run Analysis epf_dmg_tsu_re.run_analysis()