diff --git a/hydromt_fiat/fiat.py b/hydromt_fiat/fiat.py index 0332669a..daf4d9f2 100644 --- a/hydromt_fiat/fiat.py +++ b/hydromt_fiat/fiat.py @@ -281,7 +281,7 @@ def setup_exposure_buildings( unit: str, occupancy_type_field: Union[str, None] = None, extraction_method: str = "centroid", - damage_types: Union[List[str], None] = ["structure", "content"], + damage_types: List[str] = ["structure", "content"], country: Union[str, None] = None, ) -> None: """Setup building exposure (vector) data for Delft-FIAT. diff --git a/hydromt_fiat/workflows/exposure_vector.py b/hydromt_fiat/workflows/exposure_vector.py index c6e3dbd9..d4d08429 100644 --- a/hydromt_fiat/workflows/exposure_vector.py +++ b/hydromt_fiat/workflows/exposure_vector.py @@ -979,6 +979,13 @@ def link_exposure_vulnerability( exposure_linking_table: pd.DataFrame, damage_types: Optional[List[str]] = ["Structure", "Content"], ): + exposure_linking_table["Damage function name"] = [ + name + "_" + type + for name, type in zip( + exposure_linking_table["FIAT Damage Function Name"].values, + exposure_linking_table["Damage Type"].values, + ) + ] for damage_type in damage_types: linking_per_damage_type = exposure_linking_table.loc[ exposure_linking_table["Damage Type"] == damage_type, : @@ -989,7 +996,7 @@ def link_exposure_vulnerability( linking_dict = dict( zip( linking_per_damage_type["Exposure Link"], - linking_per_damage_type["FIAT Damage Function Name"], + linking_per_damage_type["Damage function name"], ) ) unique_linking_types = set(linking_dict.keys()) diff --git a/hydromt_fiat/workflows/vulnerability.py b/hydromt_fiat/workflows/vulnerability.py index d36bf891..89515178 100644 --- a/hydromt_fiat/workflows/vulnerability.py +++ b/hydromt_fiat/workflows/vulnerability.py @@ -288,23 +288,27 @@ def create_step_function( max_hazard_value: float = 10, step_hazard_value: float = 1.0, ): - #list before threshold + # list before threshold if threshold_value <= 1: - list_bt = np.arange(min_hazard_value,threshold_value, 0.01).tolist() + list_bt = np.arange(min_hazard_value, threshold_value, 0.01).tolist() del list_bt[1:-1] list_bt.append(threshold_value) else: - list_bt = np.arange(0,threshold_value, step_hazard_value).tolist() - list_bt.append(threshold_value-0.01) + list_bt = np.arange(0, threshold_value, step_hazard_value).tolist() + list_bt.append(threshold_value - 0.01) list_bt.append(threshold_value) - list_bt = [ round(elem, 2) for elem in list_bt] + list_bt = [round(elem, 2) for elem in list_bt] # list after threshold - list_at = np.arange(math.ceil(threshold_value), max_hazard_value+1, step_hazard_value).tolist() + list_at = np.arange( + math.ceil(threshold_value), max_hazard_value + 1, step_hazard_value + ).tolist() # merge list before and after threshold - hazard_values = list_bt +list_at + hazard_values = list_bt + list_at # create fraction_values - fraction_values = [0 if value < threshold_value else 1 for value in hazard_values] + fraction_values = [ + 0 if value < threshold_value else 1 for value in hazard_values + ] self.add(name, hazard_values, fraction_values) @@ -346,7 +350,13 @@ def get_vulnerability_functions_from_one_file( if vulnerability_values.max() > 1: vulnerability_values = vulnerability_values / 100 - vf_names = df_identifiers_linking["FIAT Damage Function Name"].values + vf_names = [ + name + "_" + type + for name, type in zip( + df_identifiers_linking["FIAT Damage Function Name"].values, + df_identifiers_linking["Damage Type"].values, + ) + ] self.add_multiple(vf_names, hazard_values, vulnerability_values) diff --git a/tests/test_vulnerability_exposure.py b/tests/test_vulnerability_exposure.py index 444ac492..de0731b7 100644 --- a/tests/test_vulnerability_exposure.py +++ b/tests/test_vulnerability_exposure.py @@ -55,7 +55,7 @@ "asset_locations": "NSI", "occupancy_type": "NSI", "max_potential_damage": "NSI", - "damage_types": ["structure"], + "damage_types": ["structure", "content"], "ground_floor_height": "NSI", "unit": "ft", }, @@ -84,8 +84,8 @@ "asset_locations": "NSI", "occupancy_type": "NSI", "max_potential_damage": "NSI", - "damage_types": ["structure"], - "ground_floor_height": 1, + "damage_types": ["structure", "content"], + "ground_floor_height": "NSI", "unit": "ft", }, "setup_social_vulnerability_index": {