wolfhece 2.1.25__py3-none-any.whl → 2.1.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wolfhece/PyPalette.py +26 -10
 - wolfhece/acceptability/Parallels.py +44 -19
 - wolfhece/acceptability/acceptability.py +187 -130
 - wolfhece/acceptability/func.py +538 -169
 - wolfhece/apps/version.py +1 -1
 - wolfhece/libs/WolfOGL.c +16164 -2680
 - wolfhece/libs/WolfOGL.pyx +357 -0
 - wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
 - wolfhece/pyviews.py +3 -3
 - wolfhece/wolf_array.py +394 -157
 - wolfhece/wolfresults_2D.py +2 -2
 - {wolfhece-2.1.25.dist-info → wolfhece-2.1.27.dist-info}/METADATA +2 -1
 - {wolfhece-2.1.25.dist-info → wolfhece-2.1.27.dist-info}/RECORD +16 -18
 - wolfhece/libs/wolfogl.cp39-win_amd64.pyd +0 -0
 - wolfhece/libs/wolfpy.cp39-win_amd64.pyd +0 -0
 - {wolfhece-2.1.25.dist-info → wolfhece-2.1.27.dist-info}/WHEEL +0 -0
 - {wolfhece-2.1.25.dist-info → wolfhece-2.1.27.dist-info}/entry_points.txt +0 -0
 - {wolfhece-2.1.25.dist-info → wolfhece-2.1.27.dist-info}/top_level.txt +0 -0
 
| 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            from .Parallels import parallel_gpd_clip, parallel_v2r 
         
     | 
| 
       2 
     | 
    
         
            -
            from .func import data_modification,  
     | 
| 
      
 1 
     | 
    
         
            +
            from .Parallels import parallel_gpd_clip, parallel_v2r, parallel_datamod 
         
     | 
| 
      
 2 
     | 
    
         
            +
            from .func import data_modification, compute_vulnerability, compute_vulnerability4scenario, match_vulnerability2sim, compute_acceptability, shp_to_raster, Accept_Manager, cleaning_directory, EXTENT, Vulnerability_csv
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            import pandas as pd
         
     | 
| 
       5 
5 
     | 
    
         
             
            import os
         
     | 
| 
         @@ -11,26 +11,28 @@ import geopandas as gpd 
     | 
|
| 
       11 
11 
     | 
    
         
             
            from pathlib import Path
         
     | 
| 
       12 
12 
     | 
    
         
             
            import logging
         
     | 
| 
       13 
13 
     | 
    
         
             
            from tqdm import tqdm
         
     | 
| 
      
 14 
     | 
    
         
            +
            from enum import Enum
         
     | 
| 
      
 15 
     | 
    
         
            +
            from pyogrio import read_dataframe
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                 
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                
         
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
            class steps_base_data_creation(Enum):
         
     | 
| 
      
 18 
     | 
    
         
            +
                """ 
         
     | 
| 
      
 19 
     | 
    
         
            +
                Enum for the steps in the base data creation
         
     | 
| 
      
 20 
     | 
    
         
            +
                """
         
     | 
| 
      
 21 
     | 
    
         
            +
                CLIP_GDB = 1
         
     | 
| 
      
 22 
     | 
    
         
            +
                CLIP_CADASTER = 2
         
     | 
| 
      
 23 
     | 
    
         
            +
                CLIP_PICC = 3
         
     | 
| 
      
 24 
     | 
    
         
            +
                POINTS2POLYS = 4
         
     | 
| 
      
 25 
     | 
    
         
            +
                RASTERIZE_IGN = 5
         
     | 
| 
      
 26 
     | 
    
         
            +
                PREPROCESS_VULNCODE = 6
         
     | 
| 
      
 27 
     | 
    
         
            +
                DATABASE_TO_RASTER = 7
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            class steps_vulnerability(Enum):
         
     | 
| 
      
 30 
     | 
    
         
            +
                """ 
         
     | 
| 
      
 31 
     | 
    
         
            +
                Enum for the steps in the vulnerability computation
         
     | 
| 
      
 32 
     | 
    
         
            +
                """
         
     | 
| 
      
 33 
     | 
    
         
            +
                CREATE_RASTERS = 1
         
     | 
| 
      
 34 
     | 
    
         
            +
                APPLY_MODIFS = 2
         
     | 
| 
      
 35 
     | 
    
         
            +
                MATCH_SIMUL = 3
         
     | 
| 
       34 
36 
     | 
    
         | 
| 
       35 
37 
     | 
    
         
             
            def Base_data_creation(main_dir:str = 'Data', 
         
     | 
| 
       36 
38 
     | 
    
         
             
                                   Original_gdb:str = 'GT_Resilence_dataRisques202010.gdb', 
         
     | 
| 
         @@ -39,7 +41,8 @@ def Base_data_creation(main_dir:str = 'Data', 
     | 
|
| 
       39 
41 
     | 
    
         
             
                                   PICC_Walloon:str = 'PICC_vDIFF.gdb', 
         
     | 
| 
       40 
42 
     | 
    
         
             
                                   CE_IGN_top10v:str = 'CE_IGN_TOP10V/CE_IGN_TOP10V.shp',
         
     | 
| 
       41 
43 
     | 
    
         
             
                                   resolution:float = 1.,
         
     | 
| 
       42 
     | 
    
         
            -
                                   number_procs:int = 8 
     | 
| 
      
 44 
     | 
    
         
            +
                                   number_procs:int = 8,
         
     | 
| 
      
 45 
     | 
    
         
            +
                                   steps:list[int] | list[steps_base_data_creation] = [1,2,3,4,5,6,7]):
         
     | 
| 
       43 
46 
     | 
    
         
             
                """
         
     | 
| 
       44 
47 
     | 
    
         
             
                Create the databse.
         
     | 
| 
       45 
48 
     | 
    
         | 
| 
         @@ -61,100 +64,143 @@ def Base_data_creation(main_dir:str = 'Data', 
     | 
|
| 
       61 
64 
     | 
    
         
             
                :param number_procs: The number of processors to use for parallel processing
         
     | 
| 
       62 
65 
     | 
    
         | 
| 
       63 
66 
     | 
    
         
             
                """
         
     | 
| 
       64 
     | 
    
         
            -
                 
     | 
| 
      
 67 
     | 
    
         
            +
                LAYER_CABU = "CaBu"
         
     | 
| 
      
 68 
     | 
    
         
            +
                LAYER_CAPA = "CaPa"
         
     | 
| 
      
 69 
     | 
    
         
            +
                LAYER_BATIEMPRISE = "CONSTR_BATIEMPRISE"
         
     | 
| 
       65 
70 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
                 
     | 
| 
      
 71 
     | 
    
         
            +
                manager = Accept_Manager(main_dir, 
         
     | 
| 
       67 
72 
     | 
    
         
             
                                       Study_area,
         
     | 
| 
       68 
73 
     | 
    
         
             
                                       Original_gdb=Original_gdb,
         
     | 
| 
       69 
74 
     | 
    
         
             
                                       CaPa_Walloon=CaPa_Walloon,
         
     | 
| 
       70 
75 
     | 
    
         
             
                                       PICC_Walloon=PICC_Walloon,
         
     | 
| 
       71 
76 
     | 
    
         
             
                                       CE_IGN_top10v=CE_IGN_top10v)
         
     | 
| 
       72 
77 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
                if not  
     | 
| 
      
 78 
     | 
    
         
            +
                if not manager.check_before_database_creation():
         
     | 
| 
       74 
79 
     | 
    
         
             
                    logging.error("The necessary files are missing - Verify logs for more information")
         
     | 
| 
       75 
80 
     | 
    
         
             
                    return
         
     | 
| 
       76 
81 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
                 
     | 
| 
      
 82 
     | 
    
         
            +
                manager.change_dir()
         
     | 
| 
      
 83 
     | 
    
         
            +
                done = []
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                if 1 in steps or 6 in steps or steps_base_data_creation.PREPROCESS_VULNCODE in steps or steps_base_data_creation.CLIP_GDB in steps:
         
     | 
| 
      
 86 
     | 
    
         
            +
                    # Load the vulnerability CSV to get the layers
         
     | 
| 
      
 87 
     | 
    
         
            +
                    vulnerability_csv = Vulnerability_csv(manager.VULNERABILITY_CSV)
         
     | 
| 
       78 
88 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
                 
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 89 
     | 
    
         
            +
                if 1 in steps or steps_base_data_creation.CLIP_GDB in steps:
         
     | 
| 
      
 90 
     | 
    
         
            +
                    # Clean the directory to avoid any conflict
         
     | 
| 
      
 91 
     | 
    
         
            +
                    # GPKG driver does not overwrite the existing file but adds new layers
         
     | 
| 
      
 92 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_CLIPGDB)
         
     | 
| 
       82 
93 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
      
 94 
     | 
    
         
            +
                    # ********************************************************************************************************************
         
     | 
| 
      
 95 
     | 
    
         
            +
                    # Step 1, Clip Original GDB
         
     | 
| 
       85 
96 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 97 
     | 
    
         
            +
                    # Clip the GDB file and store it in dirsnames.SA_DATABASE
         
     | 
| 
      
 98 
     | 
    
         
            +
                    parallel_gpd_clip(vulnerability_csv.get_layers(), manager.ORIGINAL_GDB, manager.SA, manager.TMP_CLIPGDB, number_procs)
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                    done.append(steps_base_data_creation.CLIP_GDB)
         
     | 
| 
       90 
101 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
                 
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
      
 102 
     | 
    
         
            +
                if 2 in steps or steps_base_data_creation.CLIP_CADASTER in steps:
         
     | 
| 
      
 103 
     | 
    
         
            +
                    # ********************************************************************************************************************
         
     | 
| 
      
 104 
     | 
    
         
            +
                    # Step 2, Clip Cadaster data
         
     | 
| 
      
 105 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_CADASTER)
         
     | 
| 
       93 
106 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                # Clip the Cadastre Walloon file and store it in dirsnames.SA_CAPA
         
     | 
| 
       98 
     | 
    
         
            -
                parallel_gpd_clip([LAYER_CABU, LAYER_CAPA], dirsnames.CAPA_WALLOON, dirsnames.SA, dirsnames.SA_CAPA, min(2, NUMBER_PROCS))
         
     | 
| 
      
 107 
     | 
    
         
            +
                    # Only 2 layers are present in the Cadastre Walloon file
         
     | 
| 
      
 108 
     | 
    
         
            +
                    # Clip the Cadastre Walloon file and store it in dirsnames.SA_CAPA
         
     | 
| 
      
 109 
     | 
    
         
            +
                    parallel_gpd_clip([LAYER_CABU, LAYER_CAPA], manager.CAPA_WALLOON, manager.SA, manager.TMP_CADASTER, min(2, number_procs))
         
     | 
| 
       99 
110 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
                # Step 3, Clip PICC data
         
     | 
| 
      
 111 
     | 
    
         
            +
                    done.append(steps_base_data_creation.CLIP_CADASTER)
         
     | 
| 
       102 
112 
     | 
    
         | 
| 
       103 
     | 
    
         
            -
                 
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 113 
     | 
    
         
            +
                if 3 in steps or steps_base_data_creation.CLIP_PICC in steps:
         
     | 
| 
      
 114 
     | 
    
         
            +
                    # ********************************************************************************************************************
         
     | 
| 
      
 115 
     | 
    
         
            +
                    # Step 3, Clip PICC data
         
     | 
| 
      
 116 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_PICC)
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                    # ONly 1 layer is needed from the PICC Walloon file
         
     | 
| 
      
 119 
     | 
    
         
            +
                    # Clip the PICC Walloon file and store it in dirsnames.SA_PICC
         
     | 
| 
      
 120 
     | 
    
         
            +
                    parallel_gpd_clip([LAYER_BATIEMPRISE], manager.PICC_WALLOON, manager.SA, manager.TMP_PICC, min(1, number_procs))
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                    done.append(steps_base_data_creation.CLIP_PICC)
         
     | 
| 
       107 
123 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
                 
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
      
 124 
     | 
    
         
            +
                if 4 in steps or steps_base_data_creation.POINTS2POLYS in steps:
         
     | 
| 
      
 125 
     | 
    
         
            +
                    # ********************************************************************************************************************
         
     | 
| 
      
 126 
     | 
    
         
            +
                    # Step 4, create database based on changes in report
         
     | 
| 
       110 
127 
     | 
    
         | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                # PreLoad Picc and CaPa from clipped files
         
     | 
| 
       113 
     | 
    
         
            -
                Picc:gpd.GeoDataFrame = gpd.read_file(dirsnames.SA_PICC, layer = LAYER_BATIEMPRISE)
         
     | 
| 
       114 
     | 
    
         
            -
                CaPa:gpd.GeoDataFrame = gpd.read_file(dirsnames.SA_CAPA, layer = LAYER_CAPA)
         
     | 
| 
      
 128 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_WMODIF)
         
     | 
| 
       115 
129 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 130 
     | 
    
         
            +
                    # PreLoad Picc and CaPa from clipped files
         
     | 
| 
      
 131 
     | 
    
         
            +
                    Picc:gpd.GeoDataFrame = read_dataframe(str(manager.TMP_PICC / (LAYER_BATIEMPRISE+EXTENT)), layer=LAYER_BATIEMPRISE)
         
     | 
| 
      
 132 
     | 
    
         
            +
                    CaPa:gpd.GeoDataFrame = read_dataframe(str(manager.TMP_CADASTER / (LAYER_CAPA+EXTENT)), layer=LAYER_CAPA)
         
     | 
| 
       117 
133 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                    data_modification(dirsnames.SA_DATABASE, curlayer, dirsnames.SA_FINAL, Picc, CaPa)
         
     | 
| 
      
 134 
     | 
    
         
            +
                    assert Picc.crs == CaPa.crs, "The crs of the two shapefiles are different"
         
     | 
| 
       120 
135 
     | 
    
         | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
                # Step 5 : Rasaterize the IGN data "Course d'eau" to get the riverbed mask
         
     | 
| 
       123 
     | 
    
         
            -
                shp_to_raster(dirsnames.CE_IGN_TOP10V, dirsnames.SA_MASKED_RIVER, resolution)
         
     | 
| 
       124 
     | 
    
         
            -
                
         
     | 
| 
       125 
     | 
    
         
            -
                # ********************************************************************************************************************
         
     | 
| 
       126 
     | 
    
         
            -
                # Step 6 :  Pre-processing for Vulnerability
         
     | 
| 
       127 
     | 
    
         
            -
                #           Save the database with vulnerability levels and codes
         
     | 
| 
       128 
     | 
    
         
            -
                # This database will be rasterized in 'Database_to_raster'
         
     | 
| 
      
 136 
     | 
    
         
            +
                    parallel_datamod(manager=manager, picc=Picc, capa=CaPa, number_procs=number_procs)
         
     | 
| 
       129 
137 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
                layers_csv = vulnerability_csv.get_layers()
         
     | 
| 
       132 
     | 
    
         
            -
                
         
     | 
| 
       133 
     | 
    
         
            -
                # Search difference between the two lists of layers
         
     | 
| 
       134 
     | 
    
         
            -
                list_shp = list(set(layers_csv).difference(layers_sa))
         
     | 
| 
      
 138 
     | 
    
         
            +
                    done.append(steps_base_data_creation.POINTS2POLYS)
         
     | 
| 
       135 
139 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
                 
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
      
 140 
     | 
    
         
            +
                if 5 in steps or steps_base_data_creation.RASTERIZE_IGN in steps:
         
     | 
| 
      
 141 
     | 
    
         
            +
                    # ********************************************************************************************************************
         
     | 
| 
      
 142 
     | 
    
         
            +
                    # Step 5 : Rasaterize the IGN data "Course d'eau" to get the riverbed mask
         
     | 
| 
      
 143 
     | 
    
         
            +
                    shp_to_raster(manager.CE_IGN_TOP10V, manager.SA_MASKED_RIVER, resolution)
         
     | 
| 
       138 
144 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
                 
     | 
| 
       142 
     | 
    
         
            -
                     
     | 
| 
      
 145 
     | 
    
         
            +
                    done.append(steps_base_data_creation.RASTERIZE_IGN)
         
     | 
| 
      
 146 
     | 
    
         
            +
                    
         
     | 
| 
      
 147 
     | 
    
         
            +
                if 6 in steps or steps_base_data_creation.PREPROCESS_VULNCODE in steps:
         
     | 
| 
      
 148 
     | 
    
         
            +
                    # ********************************************************************************************************************
         
     | 
| 
      
 149 
     | 
    
         
            +
                    # Step 6 :  Pre-processing for Vulnerability
         
     | 
| 
      
 150 
     | 
    
         
            +
                    #           Save the database with vulnerability levels and codes
         
     | 
| 
      
 151 
     | 
    
         
            +
                    # This database will be rasterized in 'Database_to_raster'
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                    layers_sa = manager.get_layers_in_wmodif()
         
     | 
| 
      
 154 
     | 
    
         
            +
                    layers_csv = vulnerability_csv.get_layers()
         
     | 
| 
      
 155 
     | 
    
         
            +
                    
         
     | 
| 
      
 156 
     | 
    
         
            +
                    # Search difference between the two lists of layers
         
     | 
| 
      
 157 
     | 
    
         
            +
                    list_shp = list(set(layers_csv).difference(layers_sa))
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
                    logging.info("Excluded layers due to no features in shapefiles:")
         
     | 
| 
      
 160 
     | 
    
         
            +
                    logging.info(list_shp)
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                    not_in_csv = [curlayer for curlayer in layers_sa if curlayer not in layers_csv]
         
     | 
| 
      
 163 
     | 
    
         
            +
                    if len(not_in_csv) > 0:
         
     | 
| 
      
 164 
     | 
    
         
            +
                        logging.error("Not treated layers due to no vulnerability level or code:")
         
     | 
| 
      
 165 
     | 
    
         
            +
                        logging.error(not_in_csv)
         
     | 
| 
       143 
166 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
                     
     | 
| 
      
 167 
     | 
    
         
            +
                    logging.info("STEP1: Saving the database for Vulnerability with attributes Vulne and Code")
         
     | 
| 
       145 
168 
     | 
    
         | 
| 
       146 
     | 
    
         
            -
                     
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
                         
     | 
| 
       150 
     | 
    
         
            -
                         
     | 
| 
       151 
     | 
    
         
            -
                         
     | 
| 
       152 
     | 
    
         
            -
                        shp. 
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
      
 169 
     | 
    
         
            +
                    for curlayer in layers_sa:
         
     | 
| 
      
 170 
     | 
    
         
            +
                        logging.info(curlayer)
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                        in_file  = str(manager.TMP_WMODIF    / (curlayer+EXTENT))
         
     | 
| 
      
 173 
     | 
    
         
            +
                        out_file = str(manager.TMP_CODEVULNE / (curlayer+EXTENT))
         
     | 
| 
      
 174 
     | 
    
         
            +
                        
         
     | 
| 
      
 175 
     | 
    
         
            +
                        shp:gpd.GeoDataFrame = gpd.read_file(in_file)
         
     | 
| 
      
 176 
     | 
    
         
            +
                        
         
     | 
| 
      
 177 
     | 
    
         
            +
                        nb_lines, _ = shp.shape
         
     | 
| 
      
 178 
     | 
    
         
            +
                        if nb_lines > 0:
         
     | 
| 
      
 179 
     | 
    
         
            +
                            shp["Path"]  = curlayer
         
     | 
| 
      
 180 
     | 
    
         
            +
                            shp["Vulne"] = vulnerability_csv.get_vulnerability_level(curlayer)
         
     | 
| 
      
 181 
     | 
    
         
            +
                            shp["Code"]  = vulnerability_csv.get_vulnerability_code(curlayer)
         
     | 
| 
      
 182 
     | 
    
         
            +
                            shp = shp[["geometry", "Path", "Vulne","Code"]]
         
     | 
| 
      
 183 
     | 
    
         
            +
                            shp.to_file(out_file)
         
     | 
| 
      
 184 
     | 
    
         
            +
                        else:
         
     | 
| 
      
 185 
     | 
    
         
            +
                            # Normally, Phase 1 should have removed the empty shapefiles
         
     | 
| 
      
 186 
     | 
    
         
            +
                            # But, we never know... ;-)
         
     | 
| 
      
 187 
     | 
    
         
            +
                            logging.warning(f"Empty shapefile {curlayer} in {in_file}")
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                    done.append(steps_base_data_creation.PREPROCESS_VULNCODE)
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                if 7 in steps or steps_base_data_creation.DATABASE_TO_RASTER in steps:
         
     | 
| 
      
 192 
     | 
    
         
            +
                    # Rasterize the database
         
     | 
| 
      
 193 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_RASTERS)
         
     | 
| 
      
 194 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_RASTERS_CODE)
         
     | 
| 
      
 195 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_RASTERS_VULNE)
         
     | 
| 
      
 196 
     | 
    
         
            +
                    
         
     | 
| 
      
 197 
     | 
    
         
            +
                    Database_to_raster(main_dir, Study_area, resolution, number_procs=number_procs)
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                    done.append(steps_base_data_creation.DATABASE_TO_RASTER)
         
     | 
| 
       156 
200 
     | 
    
         | 
| 
       157 
     | 
    
         
            -
                 
     | 
| 
      
 201 
     | 
    
         
            +
                manager.restore_dir()
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                return done
         
     | 
| 
       158 
204 
     | 
    
         | 
| 
       159 
205 
     | 
    
         
             
            def Database_to_raster(main_dir:str = 'Data',
         
     | 
| 
       160 
206 
     | 
    
         
             
                                   Study_area:str = 'Bassin_Vesdre.shp',
         
     | 
| 
         @@ -163,7 +209,7 @@ def Database_to_raster(main_dir:str = 'Data', 
     | 
|
| 
       163 
209 
     | 
    
         
             
                """ 
         
     | 
| 
       164 
210 
     | 
    
         
             
                Convert the vector database to raster database based on their vulnerability values 
         
     | 
| 
       165 
211 
     | 
    
         | 
| 
       166 
     | 
    
         
            -
                 
     | 
| 
      
 212 
     | 
    
         
            +
                Each leyer is converted to a raster file with the vulnerability values
         
     | 
| 
       167 
213 
     | 
    
         
             
                and the code values.
         
     | 
| 
       168 
214 
     | 
    
         | 
| 
       169 
215 
     | 
    
         
             
                They are stored in the TEMP/DATABASES/*StudyArea*/VULNERABILITY/RASTERS in:
         
     | 
| 
         @@ -175,33 +221,32 @@ def Database_to_raster(main_dir:str = 'Data', 
     | 
|
| 
       175 
221 
     | 
    
         
             
                :param resolution: The resolution of the output raster files - default is 1 meter
         
     | 
| 
       176 
222 
     | 
    
         
             
                :param number_procs: The number of processors to use for parallel processing
         
     | 
| 
       177 
223 
     | 
    
         | 
| 
       178 
     | 
    
         
            -
                The  
     | 
| 
      
 224 
     | 
    
         
            +
                The parallel processing is safe as each layer is processed independently.
         
     | 
| 
       179 
225 
     | 
    
         
             
                """
         
     | 
| 
       180 
226 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
                 
     | 
| 
      
 227 
     | 
    
         
            +
                manager = Accept_Manager(main_dir, Study_area)
         
     | 
| 
       182 
228 
     | 
    
         | 
| 
       183 
229 
     | 
    
         
             
                resolution = float(resolution)
         
     | 
| 
       184 
230 
     | 
    
         | 
| 
       185 
     | 
    
         
            -
                if not  
     | 
| 
      
 231 
     | 
    
         
            +
                if not manager.check_before_rasterize():
         
     | 
| 
       186 
232 
     | 
    
         
             
                    logging.error("The necessary files are missing - Verify logs for more information")
         
     | 
| 
       187 
233 
     | 
    
         
             
                    return
         
     | 
| 
       188 
234 
     | 
    
         | 
| 
       189 
     | 
    
         
            -
                 
     | 
| 
      
 235 
     | 
    
         
            +
                manager.change_dir()
         
     | 
| 
       190 
236 
     | 
    
         | 
| 
       191 
237 
     | 
    
         
             
                logging.info("Convert vectors to raster based on their vulnerability values")
         
     | 
| 
       192 
     | 
    
         
            -
                layers = fiona.listlayers(dirsnames.SA_FINAL_V)
         
     | 
| 
       193 
238 
     | 
    
         | 
| 
       194 
239 
     | 
    
         
             
                attributes = ["Vulne", "Code"]
         
     | 
| 
       195 
240 
     | 
    
         
             
                for cur_attrib in attributes:
         
     | 
| 
       196 
     | 
    
         
            -
                    parallel_v2r( 
     | 
| 
      
 241 
     | 
    
         
            +
                    parallel_v2r(manager, cur_attrib, resolution, number_procs)
         
     | 
| 
       197 
242 
     | 
    
         | 
| 
       198 
     | 
    
         
            -
                 
     | 
| 
      
 243 
     | 
    
         
            +
                manager.restore_dir()
         
     | 
| 
       199 
244 
     | 
    
         | 
| 
       200 
245 
     | 
    
         
             
            def Vulnerability(main_dir:str = 'Data',
         
     | 
| 
       201 
246 
     | 
    
         
             
                              scenario:str = 'Scenario1',
         
     | 
| 
       202 
247 
     | 
    
         
             
                              Study_area:str = 'Bassin_Vesdre.shp',
         
     | 
| 
       203 
248 
     | 
    
         
             
                              resolution:float = 1.,
         
     | 
| 
       204 
     | 
    
         
            -
                              steps:list[int] = [1,2,3]):
         
     | 
| 
      
 249 
     | 
    
         
            +
                              steps:list[int] | list[steps_vulnerability] = [1,2,3]):
         
     | 
| 
       205 
250 
     | 
    
         
             
                """
         
     | 
| 
       206 
251 
     | 
    
         
             
                Compute the vulnerability for the study area and the scenario, if needed.
         
     | 
| 
       207 
252 
     | 
    
         | 
| 
         @@ -228,81 +273,90 @@ def Vulnerability(main_dir:str = 'Data', 
     | 
|
| 
       228 
273 
     | 
    
         | 
| 
       229 
274 
     | 
    
         
             
                """
         
     | 
| 
       230 
275 
     | 
    
         | 
| 
       231 
     | 
    
         
            -
                 
     | 
| 
      
 276 
     | 
    
         
            +
                manager = Accept_Manager(main_dir, Study_area, scenario=scenario)
         
     | 
| 
       232 
277 
     | 
    
         | 
| 
       233 
     | 
    
         
            -
                if not  
     | 
| 
      
 278 
     | 
    
         
            +
                if not manager.check_before_vulnerability():
         
     | 
| 
       234 
279 
     | 
    
         
             
                    logging.error("The necessary files are missing - Verify logs for more information")
         
     | 
| 
       235 
280 
     | 
    
         
             
                    return
         
     | 
| 
       236 
281 
     | 
    
         | 
| 
       237 
282 
     | 
    
         
             
                logging.info("Starting VULNERABILITY computations at {} m resolution".format(resolution))
         
     | 
| 
       238 
283 
     | 
    
         | 
| 
       239 
     | 
    
         
            -
                 
     | 
| 
      
 284 
     | 
    
         
            +
                manager.change_dir()
         
     | 
| 
      
 285 
     | 
    
         
            +
                done = []	
         
     | 
| 
       240 
286 
     | 
    
         | 
| 
       241 
     | 
    
         
            -
                if 1 in steps:
         
     | 
| 
      
 287 
     | 
    
         
            +
                if 1 in steps or steps_vulnerability.CREATE_RASTERS in steps:
         
     | 
| 
       242 
288 
     | 
    
         
             
                    # Step 1 :  Compute the vulnerability rasters for the study area
         
     | 
| 
       243 
289 
     | 
    
         
             
                    #           The data **will not** be impacted by the scenario modifications
         
     | 
| 
       244 
290 
     | 
    
         | 
| 
       245 
291 
     | 
    
         
             
                    logging.info("Generate Vulnerability rasters {}m".format(resolution))
         
     | 
| 
       246 
292 
     | 
    
         | 
| 
       247 
     | 
    
         
            -
                    cleaning_directory( 
     | 
| 
      
 293 
     | 
    
         
            +
                    cleaning_directory(manager.TMP_SCEN_DIR)
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
                    compute_vulnerability(manager)
         
     | 
| 
       248 
296 
     | 
    
         | 
| 
       249 
     | 
    
         
            -
                     
     | 
| 
      
 297 
     | 
    
         
            +
                    done.append(steps_vulnerability.CREATE_RASTERS)
         
     | 
| 
       250 
298 
     | 
    
         | 
| 
       251 
     | 
    
         
            -
                if 2 in steps:
         
     | 
| 
      
 299 
     | 
    
         
            +
                if 2 in steps or steps_vulnerability.APPLY_MODIFS in steps:
         
     | 
| 
       252 
300 
     | 
    
         
             
                    # Step 2 :  Compute the vulnerability rasters for the scenario
         
     | 
| 
       253 
301 
     | 
    
         
             
                    #           The data **will be** impacted by the scenario modifications  
         
     | 
| 
       254 
302 
     | 
    
         | 
| 
       255 
     | 
    
         
            -
                    if not  
     | 
| 
      
 303 
     | 
    
         
            +
                    if not manager.check_vuln_code_sa():
         
     | 
| 
       256 
304 
     | 
    
         
             
                        logging.error("The vulnerability and code files for the study area are missing")
         
     | 
| 
       257 
305 
     | 
    
         
             
                        logging.warning("Force the computation even if not prescribed in the steps")
         
     | 
| 
       258 
306 
     | 
    
         | 
| 
       259 
307 
     | 
    
         
             
                        Vulnerability(main_dir, scenario, Study_area, resolution, [1])
         
     | 
| 
       260 
308 
     | 
    
         | 
| 
       261 
     | 
    
         
            -
                    bu:list[Path] =  
     | 
| 
      
 309 
     | 
    
         
            +
                    bu:list[Path] = manager.get_files_in_rm_buildings()
         
     | 
| 
       262 
310 
     | 
    
         | 
| 
       263 
311 
     | 
    
         
             
                    if len(bu)>0:
         
     | 
| 
       264 
312 
     | 
    
         
             
                        for curfile in bu:
         
     | 
| 
       265 
     | 
    
         
            -
                            tiff_file =  
     | 
| 
      
 313 
     | 
    
         
            +
                            tiff_file = manager.TMP_RM_BUILD_DIR / (curfile.stem + ".tiff")
         
     | 
| 
       266 
314 
     | 
    
         
             
                            shp_to_raster(curfile, tiff_file)
         
     | 
| 
       267 
315 
     | 
    
         | 
| 
       268 
     | 
    
         
            -
                         
     | 
| 
      
 316 
     | 
    
         
            +
                        compute_vulnerability4scenario(manager)
         
     | 
| 
       269 
317 
     | 
    
         
             
                    else:
         
     | 
| 
       270 
     | 
    
         
            -
                        logging.warning(f"No buildings were removed in water depth analysis OR No shapefiles in { 
     | 
| 
      
 318 
     | 
    
         
            +
                        logging.warning(f"No buildings were removed in water depth analysis OR No shapefiles in {manager.IN_RM_BUILD_DIR}")
         
     | 
| 
       271 
319 
     | 
    
         | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
      
 320 
     | 
    
         
            +
                    done.append(steps_vulnerability.APPLY_MODIFS)
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
                if 3 in steps or steps_vulnerability.MATCH_SIMUL in steps:
         
     | 
| 
       273 
323 
     | 
    
         
             
                    # Step 3 :  Clip the vulnerability/code rasters to the **simulation area**
         
     | 
| 
       274 
324 
     | 
    
         | 
| 
       275 
325 
     | 
    
         
             
                    logging.info("Save Vulnerability files for the area of interest")
         
     | 
| 
       276 
326 
     | 
    
         | 
| 
       277 
     | 
    
         
            -
                    return_periods =  
     | 
| 
       278 
     | 
    
         
            -
                    TMAX =  
     | 
| 
      
 327 
     | 
    
         
            +
                    return_periods = manager.get_return_periods()
         
     | 
| 
      
 328 
     | 
    
         
            +
                    TMAX = manager.get_filepath_for_return_period(return_periods[-1])
         
     | 
| 
       279 
329 
     | 
    
         | 
| 
       280 
330 
     | 
    
         
             
                    if TMAX is None:
         
     | 
| 
       281 
331 
     | 
    
         
             
                        logging.error("The file for the maximum return period is missing")
         
     | 
| 
       282 
332 
     | 
    
         
             
                        return
         
     | 
| 
       283 
333 
     | 
    
         | 
| 
       284 
     | 
    
         
            -
                     
     | 
| 
       285 
     | 
    
         
            -
                     
     | 
| 
       286 
     | 
    
         
            -
                     
     | 
| 
      
 334 
     | 
    
         
            +
                    match_vulnerability2sim(manager.SA_MASKED_RIVER,manager.OUT_MASKED_RIVER, TMAX)
         
     | 
| 
      
 335 
     | 
    
         
            +
                    match_vulnerability2sim(manager.SA_VULN,        manager.OUT_VULN,         TMAX)
         
     | 
| 
      
 336 
     | 
    
         
            +
                    match_vulnerability2sim(manager.SA_CODE,        manager.OUT_CODE,         TMAX)
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
                    done.append(steps_vulnerability.MATCH_SIMUL)
         
     | 
| 
       287 
339 
     | 
    
         | 
| 
       288 
     | 
    
         
            -
                 
     | 
| 
      
 340 
     | 
    
         
            +
                manager.restore_dir()
         
     | 
| 
      
 341 
     | 
    
         
            +
             
     | 
| 
      
 342 
     | 
    
         
            +
                return done
         
     | 
| 
       289 
343 
     | 
    
         | 
| 
       290 
344 
     | 
    
         
             
            def Acceptability(main_dir:str = 'Vesdre',
         
     | 
| 
       291 
345 
     | 
    
         
             
                              scenario:str = 'Scenario1',
         
     | 
| 
       292 
346 
     | 
    
         
             
                              Study_area:str = 'Bassin_Vesdre.shp'):
         
     | 
| 
       293 
347 
     | 
    
         
             
                """ Compute acceptability for the scenario """
         
     | 
| 
       294 
348 
     | 
    
         | 
| 
       295 
     | 
    
         
            -
                 
     | 
| 
      
 349 
     | 
    
         
            +
                manager = Accept_Manager(main_dir, Study_area, scenario=scenario)
         
     | 
| 
       296 
350 
     | 
    
         | 
| 
       297 
     | 
    
         
            -
                 
     | 
| 
      
 351 
     | 
    
         
            +
                manager.change_dir()
         
     | 
| 
       298 
352 
     | 
    
         | 
| 
       299 
353 
     | 
    
         
             
                # Load the vulnerability raster **for the scenario**
         
     | 
| 
       300 
     | 
    
         
            -
                vulne = gdal.Open(str( 
     | 
| 
      
 354 
     | 
    
         
            +
                vulne = gdal.Open(str(manager.OUT_VULN))
         
     | 
| 
       301 
355 
     | 
    
         
             
                # Convert to numpy array
         
     | 
| 
       302 
356 
     | 
    
         
             
                vulne = vulne.GetRasterBand(1).ReadAsArray() 
         
     | 
| 
       303 
357 
     | 
    
         | 
| 
       304 
358 
     | 
    
         
             
                # Load the river mask
         
     | 
| 
       305 
     | 
    
         
            -
                riv = gdal.Open(str( 
     | 
| 
      
 359 
     | 
    
         
            +
                riv = gdal.Open(str(manager.OUT_MASKED_RIVER))
         
     | 
| 
       306 
360 
     | 
    
         | 
| 
       307 
361 
     | 
    
         
             
                # Get the geotransform and projection for the output tiff
         
     | 
| 
       308 
362 
     | 
    
         
             
                geotrans = riv.GetGeoTransform()  
         
     | 
| 
         @@ -312,7 +366,7 @@ def Acceptability(main_dir:str = 'Vesdre', 
     | 
|
| 
       312 
366 
     | 
    
         
             
                riv = riv.GetRasterBand(1).ReadAsArray()    
         
     | 
| 
       313 
367 
     | 
    
         | 
| 
       314 
368 
     | 
    
         
             
                # Get the return periods available
         
     | 
| 
       315 
     | 
    
         
            -
                return_periods =  
     | 
| 
      
 369 
     | 
    
         
            +
                return_periods = manager.get_return_periods()
         
     | 
| 
       316 
370 
     | 
    
         | 
| 
       317 
371 
     | 
    
         
             
                # Prepare the river bed filter
         
     | 
| 
       318 
372 
     | 
    
         
             
                # Useful as we iterate over the return periods
         
     | 
| 
         @@ -323,24 +377,25 @@ def Acceptability(main_dir:str = 'Vesdre', 
     | 
|
| 
       323 
377 
     | 
    
         
             
                for curT in tqdm(return_periods):
         
     | 
| 
       324 
378 
     | 
    
         | 
| 
       325 
379 
     | 
    
         
             
                    # Load the **FILLED** modelled water depth for the return period
         
     | 
| 
       326 
     | 
    
         
            -
                    model_h = gdal.Open(str( 
     | 
| 
      
 380 
     | 
    
         
            +
                    model_h = gdal.Open(str(manager.get_sim_file_for_return_period(curT)))
         
     | 
| 
       327 
381 
     | 
    
         
             
                    # Convert to numpy array
         
     | 
| 
       328 
382 
     | 
    
         
             
                    model_h = model_h.GetRasterBand(1).ReadAsArray()
         
     | 
| 
       329 
383 
     | 
    
         | 
| 
       330 
     | 
    
         
            -
                    # Set nan if the water depth is 0
         
     | 
| 
      
 384 
     | 
    
         
            +
                    # Set nan if the water depth is 0.
         
     | 
| 
      
 385 
     | 
    
         
            +
                    # 'nan' is a good choice as it will not be considered in the computation.
         
     | 
| 
       331 
386 
     | 
    
         
             
                    model_h[model_h == 0] = np.nan
         
     | 
| 
       332 
387 
     | 
    
         
             
                    # Set nan in the river bed
         
     | 
| 
       333 
388 
     | 
    
         
             
                    model_h[ij_riv] = np.nan
         
     | 
| 
       334 
389 
     | 
    
         | 
| 
       335 
390 
     | 
    
         
             
                    logging.info("Return period {}".format(curT))
         
     | 
| 
       336 
391 
     | 
    
         
             
                    # Compute the local acceptability for the return period
         
     | 
| 
       337 
     | 
    
         
            -
                     
     | 
| 
      
 392 
     | 
    
         
            +
                    compute_acceptability(manager, model_h, vulne, curT, (geotrans, proj))
         
     | 
| 
       338 
393 
     | 
    
         | 
| 
       339 
394 
     | 
    
         
             
                # At this point, the local acceptability for each return period is computed
         
     | 
| 
       340 
395 
     | 
    
         
             
                # and stored in tiff files in the TEMP/SutyArea/scenario/Q_FILES directory
         
     | 
| 
       341 
396 
     | 
    
         | 
| 
       342 
397 
     | 
    
         
             
                # Get the list of Q files
         
     | 
| 
       343 
     | 
    
         
            -
                qs =  
     | 
| 
      
 398 
     | 
    
         
            +
                qs = manager.get_q_files()
         
     | 
| 
       344 
399 
     | 
    
         
             
                # Initialize the dictionary to store the acceptability values
         
     | 
| 
       345 
400 
     | 
    
         
             
                q_dict = {}
         
     | 
| 
       346 
401 
     | 
    
         | 
| 
         @@ -349,7 +404,7 @@ def Acceptability(main_dir:str = 'Vesdre', 
     | 
|
| 
       349 
404 
     | 
    
         
             
                    logging.info("vm"+str(curT))
         
     | 
| 
       350 
405 
     | 
    
         | 
| 
       351 
406 
     | 
    
         
             
                    # We set the filename from the return period, not the "qs" list
         
     | 
| 
       352 
     | 
    
         
            -
                    q_filename =  
     | 
| 
      
 407 
     | 
    
         
            +
                    q_filename = manager.TMP_QFILES / "Q{}.tif".format(curT)
         
     | 
| 
       353 
408 
     | 
    
         | 
| 
       354 
409 
     | 
    
         
             
                    # Check if the file exists
         
     | 
| 
       355 
410 
     | 
    
         
             
                    assert q_filename.exists(), "The file {} does not exist".format(q_filename)
         
     | 
| 
         @@ -391,7 +446,7 @@ def Acceptability(main_dir:str = 'Vesdre', 
     | 
|
| 
       391 
446 
     | 
    
         
             
                # pond.set_index("Interval", inplace=True)
         
     | 
| 
       392 
447 
     | 
    
         | 
| 
       393 
448 
     | 
    
         
             
                # Get ponderations for the return periods
         
     | 
| 
       394 
     | 
    
         
            -
                pond =  
     | 
| 
      
 449 
     | 
    
         
            +
                pond = manager.get_ponderations()
         
     | 
| 
       395 
450 
     | 
    
         | 
| 
       396 
451 
     | 
    
         
             
                assert len(pond) == len(return_periods), "The number of ponderations is not equal to the number of return periods"
         
     | 
| 
       397 
452 
     | 
    
         
             
                assert pond["Ponderation"].sum() > 0.999999 and pond["Ponderation"].sum()<1.0000001, "The sum of the ponderations is not equal to 1"
         
     | 
| 
         @@ -406,7 +461,7 @@ def Acceptability(main_dir:str = 'Vesdre', 
     | 
|
| 
       406 
461 
     | 
    
         | 
| 
       407 
462 
     | 
    
         
             
                # Set up output GeoTIFF
         
     | 
| 
       408 
463 
     | 
    
         
             
                driver = gdal.GetDriverByName('GTiff')
         
     | 
| 
       409 
     | 
    
         
            -
                dataset = driver.Create(str( 
     | 
| 
      
 464 
     | 
    
         
            +
                dataset = driver.Create(str(manager.OUT_ACCEPT), x_pixels, y_pixels, 1, gdal.GDT_Float32, options=["COMPRESS=LZW"])
         
     | 
| 
       410 
465 
     | 
    
         
             
                dataset.GetRasterBand(1).WriteArray(comb.astype(np.float32))   
         
     | 
| 
       411 
466 
     | 
    
         
             
                dataset.SetGeoTransform(geotrans)
         
     | 
| 
       412 
467 
     | 
    
         
             
                dataset.SetProjection(proj)
         
     | 
| 
         @@ -414,7 +469,9 @@ def Acceptability(main_dir:str = 'Vesdre', 
     | 
|
| 
       414 
469 
     | 
    
         
             
                del(dataset)
         
     | 
| 
       415 
470 
     | 
    
         | 
| 
       416 
471 
     | 
    
         
             
                # Resample to 100m
         
     | 
| 
       417 
     | 
    
         
            -
                Agg = gdal.Warp(str( 
     | 
| 
      
 472 
     | 
    
         
            +
                Agg = gdal.Warp(str(manager.OUT_ACCEPT_100M), str(manager.OUT_ACCEPT), xRes=100, yRes=100, resampleAlg='Average')
         
     | 
| 
       418 
473 
     | 
    
         
             
                del(Agg)
         
     | 
| 
       419 
474 
     | 
    
         | 
| 
       420 
     | 
    
         
            -
                 
     | 
| 
      
 475 
     | 
    
         
            +
                manager.restore_dir()
         
     | 
| 
      
 476 
     | 
    
         
            +
             
     | 
| 
      
 477 
     | 
    
         
            +
                return 0
         
     |