wolfhece.insyde_be.INBE_func

Author: University of Liege, HECE, Damien Sansen Date: 2025

Copyright (c) 2025 University of Liege. All rights reserved.

This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited.

Module Contents

class wolfhece.insyde_be.INBE_func.INBE_functions[source]
riverbed_trace_existingdanger(wd_tif: pathlib.Path, interation_choice: int = 2, rivermask_out: pathlib.Path = None, threshold=0.5)[source]

Creates a bool matrix with the largest connected component of a raster after thresholding.

This function opens a GeoTIFF (float32), applies a threshold to create a mask, isolates the largest object (the riverbed) by removing noise, and then applies a binary dilation to ensure INSYDE-BE does not use hazards values from the river. This returns a boolean matrix mask.

riverbed_trace_simu(fn_read_simu, fn_output, threshold, type_extraction, id_begin=None, id_end=None, id_step=None)[source]

Recognizes the riverbed trace based on a simulation or existing danger map, where water depth above a given threshold is considered part of the riverbed. Inputs:

  • fn_read_simu: the simulation file to read.

  • fn_output: the location to save the riverbed trace as a .tiff file.

  • threshold: the water depth threshold above which the areas are considered riverbed.

dilatation_mask_river(manager_inbe)[source]
apply_bathy_to_rivermask(rivermask_out: pathlib.Path, source_tif: pathlib.Path, output_tif: pathlib.Path)[source]
tree_name_tif(folder_path, name)[source]

Find all .tiff files starting with ‘vuln’ in the directory and return paths

select_name_tif(path_baseline: pathlib.Path, folder_path: pathlib.Path, name, filter_type=False) tuple[list[pathlib.Path], list[pathlib.Path]][source]

Collects all .tiff files starting with name from folder_path and appends them to a list. Checks each file’s data type against the baseline raster and renames files with a mismatched type, (allowing it not to be surimposed as it does not begin by “vuln_” anymore).

Parameters:
  • path_baseline (pathlib.Path) – Path to the baseline raster file.

  • folder_path (pathlib.Path) – Path to the folder containing raster files to check.

  • name (str) – Prefix name to filter .tiff files in the folder.

Returns:

A tuple containing two lists: - files: List of paths with matching data type. - unused_files: List of paths renamed due to type mismatch.

Return type:

tuple[list[pathlib.Path], list[pathlib.Path]]

check_nodata(name, path_baseline, fn_scenario)[source]

Check nodata in a path

create_vrtIfExists(fn_baseline, fn_scenario, fn_vrt, name)[source]

Create a vrt file from a path

translate_vrt2tif(fn_VRT, fn_vuln_s)[source]

Translate vrt from OUTPUT > … > Scenario to tif saved in the same folder, and delete the vrt file

copy_tif_files(files: list[pathlib.Path], destination_dir: pathlib.Path) None[source]
name_existence(Zones1, key, name)[source]
PICC_read(manager_inbe, name: str = 'Habitation')[source]
create_table_wolfsimu(manager_inbe, simu, operator_wd: str, operator_doi: str, hazard=['wd', 'velocity', 'flood duration'], ZonesX: wolfhece.PyVertexvectors.Zones = None, Zones_v_doi: wolfhece.PyVertexvectors.Zones = None, removed_buildings=[], percentil: float = None, percentil_doi: float = None, percentil_v: float = None, title: str = 'table_wolfsimu.xlsx')[source]

Creates the minimum inputs needed for INBE based on the simulations, via interpolated files and operator for wd, and via buffer for other (doi, v). One table per simulations.

pre_processing_auto(name_conditionnel, Ti_list, main_dir, Study_area, scenario, multiple, dx, removed_buildings=[], percentil=None, percentil_doi=None, percentil_v=None, operator_wd='median', operator_doi='median', hazard=['wd', 'velocity', 'flood duration'])[source]
pre_processing_for_MAX(name_conditionnel, main_dir, Study_area, scenario, removed_buildings=[])[source]
computation_dfresults(input_table, type_computation, inflation)[source]
get_alpha(relative_damage, model_name)[source]

Return the risk aversion factor alpha for a given relative damage and model.

Parameters:
  • relative_damage (float) – Relative damage value (%) for the municipality.

  • model_name (str) – Model identifier (“A1”, “A2”, “A3”).

Returns:

Risk aversion factor corresponding to the given relative damage.

Return type:

float

Note

Implements the multiplicative aversion model from Merz et al. (2009):

  • A1: alpha_max=10, D_l=1.0, D_u=20.0

  • A2: alpha_max=10, D_l=1.0, D_u=10.0

  • A3: alpha_max=50, D_l=1.0, D_u=10.0

plotting_oneslike_alpha(D, alpha_max, D_l, D_u)[source]

Compute the multiplicative risk aversion factor alpha(D) as proposed by Merz et al. (2009), DOI 10.5194/nhess-9-1033-2009.

The function models the increase in risk aversion with the relative damage D, using a linear transition between $D_l$ and $D_u$, and a constant alpha beyond $D_u$.

Parameters:
  • D (array_like) – Relative damage values (%) at the intervention zone scale (ratio of total event damage to total exposed asset value).

  • alpha_max (float) – Maximum aversion factor applied for high-damage events.

  • D_l (float) – Lower threshold of relative damage beyond which aversion starts increasing.

  • D_u (float) – Upper threshold of relative damage at which alpha reaches its maximum.

Returns:

Risk aversion factor corresponding to each relative damage value.

Return type:

ndarray

get_aversion_params(model_name)[source]

Return parameter set (alpha_max, D_l, D_u) for the selected aversion model (Merz et al., 2009).

It is used to derive the A1, A2, and A3 aversion models defined as:

  • A1: alpha_max = 10, D_l = 1.0, D_u = 20.0

  • A2: alpha_max = 10, D_l = 1.0, D_u = 10.0

  • A3: alpha_max = 50, D_l = 1.0, D_u = 10.0

Parameters:

model_name (str) – Model identifier (“A1”, “A2”, or “A3”).

Returns:

(alpha_max, D_l, D_u) corresponding to the selected model.

Return type:

tuple

plot_aversion_curves(path_output=None)[source]

Display the A1, A2, A3 aversion curves as a matplotlib figure.

computation_combined_damage(pond: dict, manager_inbe, aversion_model='A0', total_damage=0) pandas.DataFrame[source]

Compute the weighted sum of damage results across multiple return‑period DataFrames.

Parameters:
  • df_results_Ti (dict) – Dictionary mapping return‑period keys (e.g. “T2”, “T5”, …) to pandas DataFrames. Each DataFrame must have a “code” column identifying each building and one or more numeric columns representing damage categories.

  • pond (dict) – Dictionary mapping the same return‑period keys to their weighting coefficients (e.g. {“T2”: 0.65, “T5”: 0.216667, …}).

Returns:

A DataFrame with one row per unique building “code” (coordinate of the center of the polygon), containing the column “code” plus each damage category column equal to the weighted sum across all Ti.

Return type:

pd.DataFrame

plot_combinaison(manager_inbe, pond: dict)[source]
plot_damage(df_results, idx=None, cat=None, sorted_cond=None)[source]

Displays a damage bar chart for a specific index (specific building) or for all entries, and for all damage categories or only one.

Parameters:
  • df_results (pd.DataFrame) – DataFrame containing damage computed by INBE.

  • idx (int, optional) – Index of a specific row to plot. Defaults to None (every building plotted).

  • cat (str, optional) – Specific damage category to plot if idx is None (global mode). Defaults to None (every category plotted).

type_computation = 'from_wolfsimu'[source]
computation_dfesults_forfolder(manager_inbe, type_computation, Ti_list, inflation, ifMAX=False)[source]

Process Excel files in the folder INPUT>CSVs matching the pattern ‘table_wolfsimu_T<number>.xlsx’, extracts and sorts the T identifiers numerically, computes results (INBE) for each file using computation_dfresults, and returns a dictionary of results keyed by each T identifier.

Parameters:
  • manager_inbe (Any) – Object containing the path to the input CSV scenario folder.

  • type_computation (Any) – Parameter specifying the type of computation to perform.

  • inflation (Any) – Inflation parameter used in the computation.

IfMAX:

Boolean to indicate if maximum damage computation for aversion

Returns:

Dictionary with keys as T identifiers (e.g., ‘T2’) and values as computation results.

Return type:

dict

adding_INBEresults_toZones(manager_inbex, Zones_trix, Ti=None)[source]
label_0_needed(Zones1)[source]
raster_damage_in_zones(path_damage_out, path_onedanger, Zones_torasterize, scenario, Ti)[source]
select_and_count_in_zones(Zones1, name)[source]
raster_auto(name_conditionnel, manager_inbe, which_result, Ti_list=None)[source]
load_quant_sum_backup(path, quant)[source]
load_quant_sum(path, quant)[source]
extract_scenario_label(path_str)[source]
histo_total_from_list(list_path, quant, type=None)[source]
NO_division_by_zero(numerator, denominator)[source]
analysis_table(instances, path_analysis, ref='comb')[source]
scatter_INBE_dtotal(manager1, manager2, max_val=None, Ti=None, quant=None)[source]