wolfhece 2.1.107__py3-none-any.whl → 2.1.108__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/PyDraw.py +38 -9
- wolfhece/PyGui.py +1 -1
- wolfhece/PyVertexvectors.py +12 -0
- wolfhece/PyWMS.py +61 -1
- wolfhece/acceptability/acceptability.py +59 -51
- wolfhece/acceptability/acceptability_gui.py +1043 -153
- wolfhece/acceptability/func.py +83 -48
- wolfhece/apps/version.py +1 -1
- wolfhece/picc.py +2 -2
- wolfhece/scenario/config_manager.py +25 -6
- wolfhece/wolf_array.py +94 -40
- wolfhece/wolf_texture.py +12 -3
- wolfhece/wolf_tiles.py +2 -0
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/METADATA +2 -2
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/RECORD +18 -18
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/WHEEL +1 -1
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.108.dist-info}/top_level.txt +0 -0
wolfhece/PyDraw.py
CHANGED
@@ -4001,10 +4001,17 @@ class WolfMapViewer(wx.Frame):
|
|
4001
4001
|
'2006-2007': 'ORTHO_2006_2007',
|
4002
4002
|
'2009-2010': 'ORTHO_2009_2010',
|
4003
4003
|
'2012-2013': 'ORTHO_2012_2013',
|
4004
|
-
'2015': 'ORTHO_2015',
|
4005
|
-
'
|
4006
|
-
'
|
4004
|
+
'2015': 'ORTHO_2015',
|
4005
|
+
'2016': 'ORTHO_2016',
|
4006
|
+
'2017': 'ORTHO_2017',
|
4007
|
+
'2018': 'ORTHO_2018',
|
4008
|
+
'2019': 'ORTHO_2019',
|
4009
|
+
'2020': 'ORTHO_2020',
|
4010
|
+
'2021': 'ORTHO_2021',
|
4011
|
+
'2022 printemps': 'ORTHO_2022_PRINTEMPS',
|
4012
|
+
'2022 été': 'ORTHO_2022_ETE',
|
4007
4013
|
'2023 été': 'ORTHO_2023_ETE',
|
4014
|
+
'Last one': 'ORTHO_LAST',
|
4008
4015
|
}}
|
4009
4016
|
data_2021 = {'EAU': {'IDW': 'ZONES_INONDEES_IDW',
|
4010
4017
|
'Emprise': 'ZONES_INONDEES',
|
@@ -4030,9 +4037,14 @@ class WolfMapViewer(wx.Frame):
|
|
4030
4037
|
ToCheck=False, id='Orthos France')
|
4031
4038
|
|
4032
4039
|
forelist = {'EAU': {'Aqualim': 'RES_LIMNI_DGARNE', 'Alea': 'ALEA_INOND', 'Lidaxes': 'LIDAXES'},
|
4033
|
-
'LIMITES': {'Secteurs Statistiques': 'LIMITES_QS_STATBEL'
|
4034
|
-
|
4035
|
-
'
|
4040
|
+
'LIMITES': {'Secteurs Statistiques': 'LIMITES_QS_STATBEL',
|
4041
|
+
'Limites administratives': 'LIMITES_ADMINISTRATIVES'},
|
4042
|
+
'R3C': {'Limites Communes': 'Municipalities'},
|
4043
|
+
# 'INSPIRE': {'Limites administratives': 'AU_wms'},
|
4044
|
+
'PLAN_REGLEMENT': {'Plan Parcellaire 2021': 'CADMAP_2021_PARCELLES',
|
4045
|
+
'Plan Parcellaire 2022': 'CADMAP_2022_PARCELLES',
|
4046
|
+
'Plan Parcellaire 2023': 'CADMAP_2023_PARCELLES',
|
4047
|
+
'Plan Parcellaire 2024': 'CADMAP_2024_PARCELLES'}}
|
4036
4048
|
|
4037
4049
|
for idx, (k, item) in enumerate(forelist.items()):
|
4038
4050
|
for kdx, (m, subitem) in enumerate(item.items()):
|
@@ -4041,6 +4053,12 @@ class WolfMapViewer(wx.Frame):
|
|
4041
4053
|
self, xmin, xmax, ymin, ymax, -99999, 1024),
|
4042
4054
|
ToCheck=False, id=m)
|
4043
4055
|
|
4056
|
+
# self.add_object(which='wmsfore',
|
4057
|
+
# newobj=imagetexture('Cadastre Flandres', 'Plan Parcellaire 2024 (Flandres)', 'Adpf', '',
|
4058
|
+
# self, xmin, xmax, ymin, ymax, -99999, 1024, Vlaanderen=True),
|
4059
|
+
# ToCheck=False, id='Plan Parcellaire 2024 (Flandres)')
|
4060
|
+
|
4061
|
+
|
4044
4062
|
def set_compare(self, ListArrays:list[WolfArray]=None, share_colormap:bool=True):
|
4045
4063
|
"""
|
4046
4064
|
Comparison of 2 arrays
|
@@ -6713,7 +6731,7 @@ class WolfMapViewer(wx.Frame):
|
|
6713
6731
|
autoscale = False
|
6714
6732
|
|
6715
6733
|
from .scenario.config_manager import Config_Manager_2D_GPU
|
6716
|
-
newmanager = Config_Manager_2D_GPU(mapviewer=self)
|
6734
|
+
newmanager = Config_Manager_2D_GPU(mapviewer=self, create_ui_if_wx=True)
|
6717
6735
|
|
6718
6736
|
elif itemlabel == _('Create acceptability manager...'):
|
6719
6737
|
autoscale = False
|
@@ -8846,7 +8864,11 @@ class WolfMapViewer(wx.Frame):
|
|
8846
8864
|
curobj = self.getobj_from_id(nameitem)
|
8847
8865
|
myobj = self.treelist.GetItemData(myitem)
|
8848
8866
|
|
8849
|
-
|
8867
|
+
if curobj is not myobj:
|
8868
|
+
logging.error(_('Bad association between object and tree item'))
|
8869
|
+
logging.error(_('Do you have 2 objects with the same id ?'))
|
8870
|
+
logging.error(_('It could be the case if you have drag/drop an object in the viewer...'))
|
8871
|
+
logging.error(_('I will continue but it is not normal...'))
|
8850
8872
|
|
8851
8873
|
self.treelist.SetToolTip(self.treelist.GetItemText(myitem))
|
8852
8874
|
|
@@ -10504,7 +10526,14 @@ class WolfMapViewer(wx.Frame):
|
|
10504
10526
|
|
10505
10527
|
newarray.nullify_border(width=1)
|
10506
10528
|
|
10507
|
-
|
10529
|
+
#keys for arrays
|
10530
|
+
keys = self.get_list_keys(draw_type.ARRAYS, checked_state=False)
|
10531
|
+
new_key = self.active_array.idx + '_crop'
|
10532
|
+
|
10533
|
+
while new_key in keys:
|
10534
|
+
new_key += '_'
|
10535
|
+
|
10536
|
+
self.add_object('array', newobj = newarray, id = new_key)
|
10508
10537
|
|
10509
10538
|
self.Refresh()
|
10510
10539
|
|
wolfhece/PyGui.py
CHANGED
wolfhece/PyVertexvectors.py
CHANGED
@@ -4663,6 +4663,8 @@ class Zones(wx.Frame, Element_To_Draw):
|
|
4663
4663
|
for idx, row in content.iterrows():
|
4664
4664
|
if 'NAME' in row.keys():
|
4665
4665
|
name = row['NAME']
|
4666
|
+
elif 'location' in row.keys():
|
4667
|
+
name = row['location'] # tuilage gdal
|
4666
4668
|
elif 'name' in row.keys():
|
4667
4669
|
name = row['name']
|
4668
4670
|
elif 'MAJ_NIV3T' in row.keys():
|
@@ -4794,11 +4796,21 @@ class Zones(wx.Frame, Element_To_Draw):
|
|
4794
4796
|
content = gpd.read_file(fn, bbox=bbox, layer=curlayer)
|
4795
4797
|
|
4796
4798
|
if len(content)>1000:
|
4799
|
+
logging.warning(_('Number of elements in layer {} : {}'.format(curlayer, len(content))))
|
4797
4800
|
logging.warning(_('Layer {} contains more than 1000 elements -- it may take a while to import'.format(curlayer)))
|
4798
4801
|
|
4802
|
+
if self.wx_exists:
|
4803
|
+
dlg = wx.MessageDialog(None, _('Layer {} contains more than 1000 elements -- it may take a while to import\n\nContinue ?'.format(curlayer)), _('Warning'), wx.OK | wx.CANCEL | wx.ICON_WARNING)
|
4804
|
+
ret = dlg.ShowModal()
|
4805
|
+
dlg.Destroy()
|
4806
|
+
if ret == wx.ID_CANCEL:
|
4807
|
+
return
|
4808
|
+
|
4799
4809
|
for idx, row in content.iterrows():
|
4800
4810
|
if 'NAME' in row.keys():
|
4801
4811
|
name = row['NAME']
|
4812
|
+
elif 'CANU' in row.keys():
|
4813
|
+
name = row['CANU']
|
4802
4814
|
elif 'MAJ_NIV3T' in row.keys():
|
4803
4815
|
# WALOUS
|
4804
4816
|
name = row['MAJ_NIV3T']
|
wolfhece/PyWMS.py
CHANGED
@@ -42,8 +42,10 @@ def getWalonmap(cat:Literal['IMAGERIE/ORTHO_2021', 'ALEA', 'CADMAP', 'LIDAXES',
|
|
42
42
|
wms=WebMapService('https://geoservices.wallonie.be/arcgis/services/'
|
43
43
|
+ catloc+'/MapServer/WMSServer',version='1.3.0')
|
44
44
|
except:
|
45
|
-
wms=WebMapService('
|
45
|
+
wms=WebMapService('https://eservices.minfin.fgov.be/arcgis/services/'
|
46
46
|
+ catloc+'/MapServer/WMSServer',version='1.3.0')
|
47
|
+
# wms=WebMapService('http://ccff02.minfin.fgov.be/geoservices/arcgis/services/'
|
48
|
+
# + catloc+'/MapServer/WMSServer',version='1.3.0')
|
47
49
|
|
48
50
|
ppkm = 300
|
49
51
|
if w is None and h is None:
|
@@ -84,6 +86,9 @@ def getWalonmap(cat:Literal['IMAGERIE/ORTHO_2021', 'ALEA', 'CADMAP', 'LIDAXES',
|
|
84
86
|
elif cat.find('CADMAP')>0:
|
85
87
|
curcont=['0,1']
|
86
88
|
curstyles=['default,default']
|
89
|
+
elif cat.find('LIMITES_ADMINISTRATIVES')>0:
|
90
|
+
curcont=['0,1,2,3']
|
91
|
+
curstyles=['default,default,default,default']
|
87
92
|
elif cat.find('wms')>0:
|
88
93
|
curcont=['1,2,3,4,5']
|
89
94
|
curstyles=['default,default,default,default,default']
|
@@ -108,6 +113,61 @@ def getWalonmap(cat:Literal['IMAGERIE/ORTHO_2021', 'ALEA', 'CADMAP', 'LIDAXES',
|
|
108
113
|
except:
|
109
114
|
logging.warning(_('Impossible to get data from web services'))
|
110
115
|
|
116
|
+
def getVlaanderen(cat:Literal['Adpf'],
|
117
|
+
xl:float,
|
118
|
+
yl:float,
|
119
|
+
xr:float,
|
120
|
+
yr:float,
|
121
|
+
w:int = None,
|
122
|
+
h:int = None,
|
123
|
+
tofile=True) -> BytesIO:
|
124
|
+
|
125
|
+
catloc=cat
|
126
|
+
|
127
|
+
try:
|
128
|
+
wms=WebMapService('https://geo.api.vlaanderen.be/'
|
129
|
+
+ catloc+'/wms',version='1.3.0')
|
130
|
+
except:
|
131
|
+
logging.warning(_('Impossible to get data from web services'))
|
132
|
+
return
|
133
|
+
|
134
|
+
ppkm = 300
|
135
|
+
if w is None and h is None:
|
136
|
+
real_w = (xr-xl)/1000
|
137
|
+
real_h = (yr-yl)/1000
|
138
|
+
w = int(real_w * ppkm)
|
139
|
+
h = int(real_h * ppkm)
|
140
|
+
elif w is None:
|
141
|
+
real_w = (xr-xl)/1000
|
142
|
+
real_h = (yr-yl)/1000
|
143
|
+
ppkm = h/real_h
|
144
|
+
w = int(real_w * ppkm)
|
145
|
+
# h = int(real_h * ppkm)
|
146
|
+
elif h is None:
|
147
|
+
real_w = (xr-xl)/1000
|
148
|
+
real_h = (yr-yl)/1000
|
149
|
+
ppkm = w/real_w
|
150
|
+
# w = int(real_w * ppkm)
|
151
|
+
h = int(real_h * ppkm)
|
152
|
+
|
153
|
+
if tofile:
|
154
|
+
img=wms.getmap(layers=['0'],styles=['default'],srs='EPSG:31370',bbox=(xl,yl,xr,yr),size=(w,h),format='image/png',transparent=True)
|
155
|
+
out = open('aqualim.png', 'wb')
|
156
|
+
out.write(img.read())
|
157
|
+
out.close()
|
158
|
+
return BytesIO(b'1')
|
159
|
+
else:
|
160
|
+
mycontents=list(wms.contents)
|
161
|
+
curcont=['Adpf']
|
162
|
+
curstyles=['default']
|
163
|
+
|
164
|
+
try:
|
165
|
+
img=wms.getmap(layers=curcont,styles=curstyles,srs='EPSG:31370',bbox=(xl,yl,xr,yr),size=(w,h),format='image/png',transparent=True)
|
166
|
+
return BytesIO(img.read())
|
167
|
+
except:
|
168
|
+
logging.warning(_('Impossible to get data from web services'))
|
169
|
+
|
170
|
+
|
111
171
|
def getIGNFrance(cat:str,epsg:str,xl,yl,xr,yr,w,h,tofile=True) -> BytesIO:
|
112
172
|
|
113
173
|
if epsg!='EPSG:4326':
|
@@ -51,6 +51,7 @@ class steps_vulnerability(Enum):
|
|
51
51
|
CREATE_RASTERS_CODE = 11
|
52
52
|
APPLY_MODIFS = 2
|
53
53
|
MATCH_SIMUL = 3
|
54
|
+
APPLY_SCENARIOSVULN = 4
|
54
55
|
|
55
56
|
@classmethod
|
56
57
|
def get_list_names(cls):
|
@@ -63,8 +64,9 @@ class steps_acceptability(Enum):
|
|
63
64
|
COMPUTE_LOCAL_ACCEPT = 1
|
64
65
|
LOAD_FROM_FILES = 2
|
65
66
|
COMPUTE_MEAN_ACCEPT = 3
|
66
|
-
|
67
|
+
COMPUTE_BASELINE_WITHOUT_SCENARIOS = 4
|
67
68
|
COMPUTE_WITH_SCENARIOS = 5
|
69
|
+
RESAMPLING = 6
|
68
70
|
|
69
71
|
@classmethod
|
70
72
|
def get_list_names(cls):
|
@@ -106,12 +108,12 @@ def Base_data_creation(main_dir:str = 'Data',
|
|
106
108
|
LAYER_BATIEMPRISE = "CONSTR_BATIEMPRISE"
|
107
109
|
|
108
110
|
manager = Accept_Manager(main_dir,
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
111
|
+
Study_area,
|
112
|
+
Original_gdb=Original_gdb,
|
113
|
+
CaPa_Walloon=CaPa_Walloon,
|
114
|
+
PICC_Walloon=PICC_Walloon,
|
115
|
+
CE_IGN_top10v=CE_IGN_top10v,
|
116
|
+
Vuln_csv=Vuln_csv)
|
115
117
|
|
116
118
|
if not manager.check_before_database_creation():
|
117
119
|
logging.error("The necessary files are missing - Verify logs for more information")
|
@@ -284,7 +286,7 @@ def Vulnerability(main_dir:str = 'Data',
|
|
284
286
|
scenario:str = 'Scenario1',
|
285
287
|
Study_area:str = 'Bassin_Vesdre.shp',
|
286
288
|
resolution:float = 1.,
|
287
|
-
steps:list[int] | list[steps_vulnerability] = [1,10,11,2,3],
|
289
|
+
steps:list[int] | list[steps_vulnerability] = [1,10,11,2,3,4],
|
288
290
|
Vuln_csv:str = 'Vulnerability.csv',
|
289
291
|
Intermediate_csv:str = 'Intermediate.csv'):
|
290
292
|
"""
|
@@ -310,6 +312,7 @@ def Vulnerability(main_dir:str = 'Data',
|
|
310
312
|
- [1,2,3] : All steps are computed - Necessary for the first time
|
311
313
|
- [2,3] : Only the scenario and clipping steps are computed -- Useful for scenario changes
|
312
314
|
- [3] : Only the clipping step is computed -- Useful if simulation area changes but scenario is the same
|
315
|
+
- [4] : Compute the vulnerability for vuln_ scenarios
|
313
316
|
|
314
317
|
"""
|
315
318
|
|
@@ -337,11 +340,11 @@ def Vulnerability(main_dir:str = 'Data',
|
|
337
340
|
cleaning_directory(manager.TMP_SCEN_DIR)
|
338
341
|
|
339
342
|
if 10 in steps or steps_vulnerability.CREATE_RASTERS_VULN in steps:
|
340
|
-
compute_vulnerability(manager)
|
343
|
+
compute_vulnerability(manager)
|
341
344
|
done.append(steps_vulnerability.CREATE_RASTERS_VULN)
|
342
345
|
|
343
346
|
if 11 in steps or steps_vulnerability.CREATE_RASTERS_CODE in steps:
|
344
|
-
compute_code(manager)
|
347
|
+
compute_code(manager)
|
345
348
|
done.append(steps_vulnerability.CREATE_RASTERS_CODE)
|
346
349
|
|
347
350
|
done.append(steps_vulnerability.CREATE_RASTERS)
|
@@ -383,27 +386,30 @@ def Vulnerability(main_dir:str = 'Data',
|
|
383
386
|
match_vulnerability2sim(manager.SA_MASKED_RIVER, manager.OUT_MASKED_RIVER, TMAX)
|
384
387
|
match_vulnerability2sim(manager.SA_VULN, manager.OUT_VULN, TMAX)
|
385
388
|
match_vulnerability2sim(manager.SA_CODE, manager.OUT_CODE, TMAX)
|
386
|
-
|
387
|
-
# Scenarios including change in vulnerability
|
388
|
-
existence=False
|
389
|
-
existence = manager.create_vrtIfExists()
|
390
|
-
|
391
|
-
if existence == True :
|
392
|
-
logging.info("Scenarios have been applied to the vulnerability matrix see _scenarios")
|
393
|
-
manager.translate_vrt2tif()
|
394
|
-
|
395
389
|
done.append(steps_vulnerability.MATCH_SIMUL)
|
396
|
-
|
390
|
+
|
391
|
+
if 4 in steps or steps_vulnerability.APPLY_SCENARIOSVULN in steps:
|
392
|
+
if os.path.exists(manager.OUT_VULN):
|
393
|
+
existence=False
|
394
|
+
existence = manager.create_vrtIfExists(manager.OUT_VULN, manager.IN_CH_SA_SC, manager.OUT_VULN_VRT, name="vuln")
|
395
|
+
if existence == True :
|
396
|
+
logging.info("Scenarios have been applied to the vulnerability matrix see _scenarios")
|
397
|
+
manager.translate_vrt2tif(manager.OUT_VULN_VRT, manager.OUT_VULN_S)
|
398
|
+
else :
|
399
|
+
logging.error(f"The baseline vulnerability does not exist ({manager.OUT_VULN}). Please, compute first the vulnerability without scenarios vuln_.")
|
400
|
+
done.append(steps_vulnerability.APPLY_SCENARIOSVULN)
|
401
|
+
#Delete _scenario folder is no scenario
|
402
|
+
if os.path.isdir(manager.OUT_WITHVULN) and not os.listdir(manager.OUT_WITHVULN):
|
403
|
+
os.rmdir(manager.OUT_WITHVULN)
|
397
404
|
return done
|
398
405
|
|
399
|
-
|
400
406
|
def Acceptability(main_dir:str = 'Vesdre',
|
401
407
|
scenario:str = 'Scenario1',
|
402
408
|
Study_area:str = 'Bassin_Vesdre.shp',
|
403
409
|
coeff_auto:bool = True,
|
404
410
|
Ponderation_csv:str = 'Ponderation.csv',
|
405
411
|
resample_size:int = 100,
|
406
|
-
steps:list[int] | list[steps_acceptability] = [1,2,3,4,5]):
|
412
|
+
steps:list[int] | list[steps_acceptability] = [1,2,3,4,5,6]):
|
407
413
|
""" Compute acceptability for the scenario """
|
408
414
|
|
409
415
|
done = []
|
@@ -416,27 +422,27 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
416
422
|
# Load the vulnerability raster **for the scenario**, and check if an assembly exists and is asked by the user
|
417
423
|
# Initialization of lists to read/ write according to the needed steps
|
418
424
|
VulneToCompute, PathsToSaveA, PathsToSaveA100 = [], [], []
|
419
|
-
if 4 in steps or steps_acceptability.
|
425
|
+
if 4 in steps or steps_acceptability.COMPUTE_BASELINE_WITHOUT_SCENARIOS in steps:
|
420
426
|
VulneToCompute.append(manager.OUT_VULN)
|
421
427
|
PathsToSaveA.append(manager.OUT_ACCEPT)
|
422
|
-
PathsToSaveA100.append(manager.
|
428
|
+
PathsToSaveA100.append(manager.OUT_ACCEPT_RESAMP)
|
429
|
+
river_trace = manager.OUT_MASKED_RIVER
|
423
430
|
|
424
|
-
|
425
431
|
if 5 in steps or steps_acceptability.COMPUTE_WITH_SCENARIOS in steps:
|
426
|
-
|
432
|
+
river_trace = manager.wich_river_trace()
|
433
|
+
change_vuln_files = [Path(a) for a in glob.glob(str(manager.IN_CH_SA_SC / "vuln_*.tif")) + glob.glob(str(manager.IN_CH_SA_SC / "vuln_*.tiff"))]
|
427
434
|
if len(change_vuln_files) != 0:
|
428
435
|
VulneToCompute.append(manager.OUT_VULN_Stif)
|
429
436
|
PathsToSaveA.append(manager.OUT_ACCEPT_Stif)
|
430
|
-
PathsToSaveA100.append(manager.
|
437
|
+
PathsToSaveA100.append(manager.OUT_ACCEPT_RESAMP_Stif)
|
431
438
|
else :
|
432
439
|
logging.info("No vulnerability rasters in CHANGE_VULNE. The code goes on without them.")
|
433
|
-
|
434
440
|
for i in range(len(VulneToCompute)) :
|
435
441
|
vulne = gdal.Open(str(VulneToCompute[i]))
|
436
442
|
saveA = PathsToSaveA[i]
|
437
443
|
saveA100 = PathsToSaveA100[i]
|
438
|
-
# Load the river mask
|
439
|
-
riv = gdal.Open(str(
|
444
|
+
# Load the river mask
|
445
|
+
riv = gdal.Open(str(river_trace))
|
440
446
|
|
441
447
|
# Get the geotransform and projection for the output tiff
|
442
448
|
geotrans = riv.GetGeoTransform()
|
@@ -462,8 +468,9 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
462
468
|
|
463
469
|
if 1 in steps or steps_acceptability.COMPUTE_LOCAL_ACCEPT in steps:
|
464
470
|
# Compute acceptability for each return period
|
471
|
+
message="Some adjustments have been done :"
|
472
|
+
message2=""
|
465
473
|
for curT in tqdm(return_periods):
|
466
|
-
|
467
474
|
# Load the **FILLED** modelled water depth for the return period
|
468
475
|
model_h = gdal.Open(str(manager.get_sim_file_for_return_period(curT)))
|
469
476
|
# Convert to numpy array
|
@@ -479,15 +486,13 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
479
486
|
assert model_h[ij_riv[0][0], ij_riv[0][1]] == 0, "The river bed is not set to 0 in the modelled water depth"
|
480
487
|
assert model_h.max() > 0, "The maximum water depth is 0"
|
481
488
|
if model_h.min() < 0:
|
482
|
-
|
483
|
-
logging.warning("Setting the negative values to 0")
|
489
|
+
message2+= f"\nFor T{curT}, the minimum water depth is negative - {np.count_nonzero(model_h<0)} cells, these values were set to 0."
|
484
490
|
model_h[model_h < 0] = 0
|
485
|
-
|
486
|
-
logging.info("Return period {}".format(curT))
|
487
|
-
|
491
|
+
#logging.info("Return period {}".format(curT))
|
488
492
|
# Compute the local acceptability for the return period
|
489
493
|
part_accept[curT] = compute_acceptability(manager, model_h, vulne, curT, (geotrans, proj))
|
490
|
-
|
494
|
+
if message2 != "":
|
495
|
+
logging.error(message + message2)
|
491
496
|
done.append(steps_acceptability.COMPUTE_LOCAL_ACCEPT)
|
492
497
|
|
493
498
|
# At this point, the local acceptability for each return period is computed
|
@@ -500,8 +505,7 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
500
505
|
if 1 in steps or steps_acceptability.COMPUTE_LOCAL_ACCEPT in steps:
|
501
506
|
# We have computed/updted the acceptibility values.
|
502
507
|
# We do not need to reload them.
|
503
|
-
logging.warning("The acceptability values have been computed in step 1
|
504
|
-
logging.info("If you want to reload the acceptability values, please remove step 1 from the list of steps")
|
508
|
+
logging.warning("The acceptability values have been computed in step 1 – reloading is unnecessary. To avoid this, exclude step 1.")
|
505
509
|
else:
|
506
510
|
|
507
511
|
# Get the list of Q files
|
@@ -509,7 +513,7 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
509
513
|
|
510
514
|
# Iterate over the return periods
|
511
515
|
for curT in return_periods:
|
512
|
-
logging.info(curT)
|
516
|
+
#logging.info(curT)
|
513
517
|
|
514
518
|
# We set the filename from the return period, not the "qs" list
|
515
519
|
q_filename = manager.TMP_QFILES / "Q{}.tif".format(curT)
|
@@ -580,16 +584,20 @@ def Acceptability(main_dir:str = 'Vesdre',
|
|
580
584
|
dataset.SetProjection(proj)
|
581
585
|
dataset.FlushCache()
|
582
586
|
dataset=None
|
583
|
-
|
584
|
-
# Resample to XXm
|
585
|
-
Agg = gdal.Warp(str(saveA100),
|
586
|
-
str(saveA),
|
587
|
-
xRes=resample_size,
|
588
|
-
yRes=resample_size,
|
589
|
-
resampleAlg='Average')
|
590
|
-
Agg.FlushCache()
|
591
|
-
Agg = None
|
592
|
-
|
587
|
+
|
593
588
|
done.append(steps_acceptability.COMPUTE_MEAN_ACCEPT)
|
594
|
-
|
589
|
+
|
590
|
+
if 6 in steps or steps_acceptability.RESAMPLING in steps:
|
591
|
+
if os.path.exists(manager.OUT_ACCEPT):
|
592
|
+
Agg = gdal.Warp(str(saveA100),
|
593
|
+
str(saveA),
|
594
|
+
xRes=resample_size,
|
595
|
+
yRes=resample_size,
|
596
|
+
resampleAlg='Average')
|
597
|
+
Agg.FlushCache()
|
598
|
+
Agg = None
|
599
|
+
else :
|
600
|
+
logging.error(f"The acceptability without resampling does not exist ({manager.OUT_ACCEPT}). Please, compute it first to agglomerate it afterwards.")
|
601
|
+
if os.path.isdir(manager.OUT_WITHVULN) and not os.listdir(manager.OUT_WITHVULN):
|
602
|
+
os.rmdir(manager.OUT_WITHVULN)
|
595
603
|
return done
|