wolfhece.acceptability.func
Author: University of Liege, HECE, LEMA Date: 2024
Copyright (c) 2024 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.acceptability.func.Modif_Type[source]
Bases:
enum.Enum
Enum class for the type of modification
- class wolfhece.acceptability.func.GPU_2D_file_extensions[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class wolfhece.acceptability.func.Accept_Manager(main_dir: str = 'Data', Study_area: str = 'Bassin_Vesdre.shp', scenario=None, Original_gdb: str = 'GT_Resilence_dataRisques202010.gdb', CaPa_Walloon: str = 'Cadastre_Walloon.gpkg', PICC_Walloon: str = 'PICC_vDIFF.gdb', CE_IGN_top10v: str = 'CE_IGN_TOP10V/CE_IGN_TOP10V.shp', EPU_Stations: str = 'AJOUT_PDET_EPU_DG03_STATIONS.shp', Ponderation_csv: str = 'Ponderation.csv', Vuln_csv: str = 'Vulnerability.csv', Intermediate_csv: str = 'Intermediate.csv')[source]
Structure to store the directories and names of the files.
- In the main directory, the following directories are mandatory/created:
INPUT : filled by the user - contains the input data
TEMP : created by the script - contains the temporary data for the study area
OUTPUT: created by the script - contains the output data for each scenario of the study area
- The INPUT directory contains the following subdirectories:
- DATABASE: contains the data for the entire Walloon region
Cadastre_Walloon.gpkg: the Cadastre Walloon file
GT_Resilence_dataRisques202010.gdb: the original gdb file from SPW - GT Resilience
PICC-vDIFF.gdb: the PICC Walloon file
CE_IGN_TOP10V: the IGN top10v shapefile
- EPU_STATIONS_NEW:
AJOUT_PDET_EPU_DG03_STATIONS.shp: the EPU stations shapefile
STUDY_AREA: contains the study area shapefiles - one for each study area - e.g. Bassin_Vesdre.shp
- CSVs: contains the CSV files
Intermediate.csv: contains the matrices data for the acceptability computation
# - Ponderation.csv: contains the ponderation data for the acceptability computation - Vulnerability.csv: contains the mapping between layers and vulnerability levels - a code value is also provided
- WATER_DEPTH: contains the water depth data for each scenario
- Study_area1:
Scenario1
Scenario2
-… - ScenarioN
- Study_area2:
Scenario1
Scenario2
-… - ScenarioN
-… - Study_areaN:
Scenario1
Scenario2
-… - ScenarioN
- The TEMP directory contains the following subdirectories:
- DATABASES: contains the temporary data each study area
- Study_area1:
database.gpkg: the clipped database
CaPa.gpkg: the clipped Cadastre Walloon file
PICC.gpkg: the clipped PICC Walloon file
CE_IGN_TOP10V.tiff: the IGN top10v raster file
Maske_River_extent.tiff: the river extent raster file from IGN
- VULNERABILITY: the vulnerability data
- RASTERS:
Code : one file for each layer
Vulne : one file for each layer
Scenario1:
- is_same_types(file: str) tuple[bool, str] [source]
Check if the file contains only the same type of geometry
- get_return_periods() list[int] [source]
Get the return periods from the simulations
- Return list[int]:
the sorted list of return periods
- check_inputs() bool [source]
Check if the input directories exist.
Inputs can not be created automatically. The user must provide them.
- check_before_database_creation() bool [source]
Check if the necessary files are present before the database creation
- get_operand(file: str) Modif_Type [source]
Get the operand based on the layer name
- tree_vuln_tif()[source]
Find all .tiff files starting with ‘vuln’ in the directory and return paths
- select_vuln_tif(path_baseline: pathlib.Path, folder_path: pathlib.Path) list[pathlib.Path] [source]
Collects and appends all .tiff files starting with ‘vuln’ from folder_path into a list.
- wolfhece.acceptability.func.clip_layer(layer: str, file_path: str, Study_Area: str, output_dir: str)[source]
Clip the input data based on the selected bassin and saves it in separate shape files.
As shape file doen not support DateTime, the columns with DateTime are converted to string.
- Parameters:
layer – the layer name in the GDB file
file_path – the path to the GDB file
Study_Area – the path to the study area shapefile
output_dir – the path to the output directory
- wolfhece.acceptability.func.data_modification(layer: str, manager: Accept_Manager, picc: geopandas.GeoDataFrame, capa: geopandas.GeoDataFrame)[source]
Apply the data modifications as described in the LEMA report
FIXME : Add more doc in this docstring
- Parameters:
input_database – the path to the input database
layer – the layer name in the database
output_database – the path to the output database
picc – the PICC Walloon file – Preloaded
capa – the Cadastre Walloon file – Preloaded
- wolfhece.acceptability.func.compute_vulnerability(manager: Accept_Manager)[source]
Compute the vulnerability for the Study Area
This function will not modify the data by the removed buildings/scenarios.
- Parameters:
dirsnames – the Dirs_Names object from the calling function
- wolfhece.acceptability.func.compute_code(manager: Accept_Manager)[source]
Compute the code for the Study Area
This function will not modify the data by the removed buildings/scenarios.
- Parameters:
dirsnames – the Dirs_Names object from the calling function
- wolfhece.acceptability.func.compute_vulnerability4scenario(manager: Accept_Manager)[source]
Compute the vulnerability for the scenario
This function will modify the data by the removed buildings/scenarios.
FIXME: It could be interseting to permit the user to provide tiff files for the removed buildings and other scenarios.
- Parameters:
dirsnames – the Dirs_Names object from the calling function
- wolfhece.acceptability.func.match_vulnerability2sim(inRas: pathlib.Path, outRas: pathlib.Path, MODREC: pathlib.Path)[source]
Clip the raster to the MODREC/simulation extent
- Parameters:
inRas – the input raster file
outRas – the output raster file
MODREC – the MODREC/simulation extent file
- wolfhece.acceptability.func.compute_acceptability(manager: Accept_Manager, model_h: numpy.ndarray, vulnerability: numpy.ndarray, interval: int, geo_projection: tuple, save_to_file: bool = True) numpy.ndarray [source]
- Compute the local acceptability based on :
the vulnerability
the water depth
the matrices
- Parameters:
manager – the Accept_Manager object from the calling function
model_h – the water depth matrix
vulnerability – the vulnerability matrix
interval – the return period
geo_projection – the geotransform and the projection - tuple extracted from another raster file
- wolfhece.acceptability.func.shp_to_raster(vector_fn: str | pathlib.Path, raster_fn: str | pathlib.Path, pixel_size: float = 1.0, manager: Accept_Manager = None)[source]
Convert a vector layer to a raster tiff file.
The raster will contain only 2 values : 0 and 1
1 : the inside of the vector layer
0 : the rest == NoData/NullValue
- Parameters:
vector_fn – the path to the vector file
raster_fn – the path to the raster file
pixel_size – the pixel size of the raster
- wolfhece.acceptability.func.vector_to_raster(layer: str, manager: Accept_Manager, attribute: str, pixel_size: float, convert_to_sparse: bool = True)[source]
Convert a vector layer to a raster tiff file
FIXME: Test de vulerability value and return immedialty if it is 1 if attribute == “Vulne”
- Parameters:
layer – the layer name in the GDB file
vector_input – the path to the vector file
extent – the path to the extent file
attribute – the attribute to rasterize
pixel_size – the pixel size of the raster