wolfhece 2.1.112__py3-none-any.whl → 2.1.114__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 +1 -1
- wolfhece/PyVertexvectors.py +57 -4
- wolfhece/acceptability/acceptability_gui.py +244 -244
- wolfhece/apps/version.py +1 -1
- wolfhece/irm_qdf.py +34 -7
- wolfhece/mar/commontools.py +203 -196
- wolfhece/wolf_array.py +53 -14
- {wolfhece-2.1.112.dist-info → wolfhece-2.1.114.dist-info}/METADATA +1 -2
- {wolfhece-2.1.112.dist-info → wolfhece-2.1.114.dist-info}/RECORD +12 -12
- {wolfhece-2.1.112.dist-info → wolfhece-2.1.114.dist-info}/WHEEL +0 -0
- {wolfhece-2.1.112.dist-info → wolfhece-2.1.114.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.112.dist-info → wolfhece-2.1.114.dist-info}/top_level.txt +0 -0
@@ -40,7 +40,7 @@ def nullvalue_for_hole(WA):
|
|
40
40
|
Sets the null value for a WolfArray to 0 (as per the convention in the interpolation routine).
|
41
41
|
"""
|
42
42
|
WA.nullvalue = 0.
|
43
|
-
WA.set_nullvalue_in_mask()
|
43
|
+
WA.set_nullvalue_in_mask()
|
44
44
|
|
45
45
|
def read_export_z_bin(fn_read, fn_write, fn_laststep):
|
46
46
|
"""
|
@@ -58,15 +58,15 @@ def read_export_z_bin(fn_read, fn_write, fn_laststep):
|
|
58
58
|
top = wolfres2DGPU_test.get_top_for_block(1)
|
59
59
|
nullvalue_for_hole(wd)
|
60
60
|
nullvalue_for_hole(top)
|
61
|
-
wd.array = wd.array + top.array
|
61
|
+
wd.array = wd.array + top.array
|
62
62
|
fn_write = fn_write.with_suffix('.bin')
|
63
63
|
wd.write_all(fn_write)
|
64
64
|
shutil.rmtree(fn_temp)
|
65
|
-
|
65
|
+
|
66
66
|
def riverbed_trace(fn_read_simu, fn_output, threshold):
|
67
67
|
"""
|
68
|
-
Recognizes the riverbed trace based on a simulation, where water depth above a given threshold is considered part of the riverbed.
|
69
|
-
Inputs:
|
68
|
+
Recognizes the riverbed trace based on a simulation, where water depth above a given threshold is considered part of the riverbed.
|
69
|
+
Inputs:
|
70
70
|
- fn_read_simu: the simulation file to read.
|
71
71
|
- fn_output: the location to save the riverbed trace as a .tiff file.
|
72
72
|
- threshold: the water depth threshold above which the areas are considered riverbed.
|
@@ -79,7 +79,7 @@ def riverbed_trace(fn_read_simu, fn_output, threshold):
|
|
79
79
|
wd.array[wd.array < threshold] = 0
|
80
80
|
wd.as_WolfArray()
|
81
81
|
wd.nodata=0
|
82
|
-
wd.write_all(Path(fn_output))
|
82
|
+
wd.write_all(Path(fn_output))
|
83
83
|
|
84
84
|
def empty_folder(folder):
|
85
85
|
"""
|
@@ -90,9 +90,9 @@ def empty_folder(folder):
|
|
90
90
|
fn = os.path.join(folder, files)
|
91
91
|
try:
|
92
92
|
if os.path.isfile(fn) or os.path.islink(fn):
|
93
|
-
os.unlink(fn)
|
93
|
+
os.unlink(fn)
|
94
94
|
elif os.path.isdir(fn):
|
95
|
-
shutil.rmtree(fn)
|
95
|
+
shutil.rmtree(fn)
|
96
96
|
except Exception as e:
|
97
97
|
print(f"Error when deleting file {fn}: {e}")
|
98
98
|
else:
|
@@ -117,7 +117,7 @@ Note: the computations are perfomed with tifs .tif rasters but should be transla
|
|
117
117
|
#----------------------------------------------------------------------------------------------------------
|
118
118
|
|
119
119
|
#1 - Soustraction bathymetry.tif (from simulations) - DEM (MNT, cfr "projet tuilage") ---------------------
|
120
|
-
|
120
|
+
|
121
121
|
def soustraction(fn_a,fn_b,fn_result):
|
122
122
|
with rasterio.open(fn_a) as src_a, rasterio.open(fn_b) as src_b:
|
123
123
|
if (
|
@@ -127,36 +127,36 @@ def soustraction(fn_a,fn_b,fn_result):
|
|
127
127
|
src_a.crs != src_b.crs
|
128
128
|
):
|
129
129
|
logging.error(f"{fn_a} and {fn_b} do not have the same properties, please edit them.")
|
130
|
-
|
131
130
|
|
132
|
-
|
133
|
-
|
134
|
-
|
131
|
+
|
132
|
+
data_a = src_a.read(1)
|
133
|
+
data_b = src_b.read(1)
|
134
|
+
|
135
135
|
#(A - B)
|
136
136
|
data_diff = data_a - data_b
|
137
137
|
nodata_value = src_a.nodata if src_a.nodata == src_b.nodata else None
|
138
138
|
if nodata_value is not None:
|
139
139
|
data_diff[(data_a == nodata_value) | (data_b == nodata_value)] = nodata_value
|
140
|
-
|
140
|
+
|
141
141
|
data_diff[data_diff > 5000] = 0
|
142
142
|
labeled, n = label(data_diff)
|
143
143
|
# Remove small objects
|
144
|
-
threshold = 5
|
144
|
+
threshold = 5
|
145
145
|
sizes = np.bincount(labeled.ravel())
|
146
|
-
idx_small = np.where(sizes <= threshold)[0]
|
147
|
-
data_diff[np.isin(labeled, idx_small)] = 0
|
148
|
-
|
146
|
+
idx_small = np.where(sizes <= threshold)[0]
|
147
|
+
data_diff[np.isin(labeled, idx_small)] = 0
|
148
|
+
|
149
149
|
out_meta = src_a.meta.copy()
|
150
150
|
out_meta.update({
|
151
|
-
"dtype": "float32",
|
151
|
+
"dtype": "float32",
|
152
152
|
"driver": "GTiff"
|
153
153
|
})
|
154
154
|
|
155
155
|
with rasterio.open(fn_result, "w", **out_meta) as dst:
|
156
156
|
dst.write(data_diff, 1)
|
157
|
-
|
158
|
-
|
159
|
-
|
157
|
+
|
158
|
+
|
159
|
+
|
160
160
|
#2 - DEM (MNT) value in the buildings traces ------------------------------------------------------------------
|
161
161
|
def mask_creation_data(mask_file, ground_file, output_file):
|
162
162
|
with rasterio.open(mask_file) as mask_src:
|
@@ -170,21 +170,21 @@ def mask_creation_data(mask_file, ground_file, output_file):
|
|
170
170
|
|
171
171
|
mask[indices] = bathy[indices]
|
172
172
|
mask[mask <= 0] = 275
|
173
|
-
|
173
|
+
|
174
174
|
output_meta = mask_meta.copy()
|
175
175
|
output_meta.update({"dtype": 'float32'})
|
176
176
|
|
177
177
|
with rasterio.open(output_file, "w", **output_meta) as dst:
|
178
178
|
dst.write(mask, 1)
|
179
|
-
|
179
|
+
|
180
180
|
WA_mask = WolfArray(output_file)
|
181
181
|
WA_mask.write_all(Path(Path(output_file).parent / "MNT_computed_with_mask.bin"))
|
182
182
|
|
183
183
|
def MTN_And_mask_creation_all(fn_bathy, fn_mtn_cropped, fn_where_buildings, fn_mask_final):
|
184
|
-
#couper_raster()
|
185
|
-
soustraction(fn_bathy, fn_mtn_cropped, fn_where_buildings)
|
184
|
+
#couper_raster()
|
185
|
+
soustraction(fn_bathy, fn_mtn_cropped, fn_where_buildings)
|
186
186
|
mask_creation_data(fn_where_buildings, fn_mtn_cropped, fn_mask_final)
|
187
|
-
|
187
|
+
|
188
188
|
#--------------------------------------------------------------------------------------------------------------
|
189
189
|
|
190
190
|
def get_transform_and_crs(tif_file):
|
@@ -205,17 +205,17 @@ def create_shapefile_from_prop_tif(fn_tif, shapefile_path):
|
|
205
205
|
- shapefile_path: the location to save the output shapefile.
|
206
206
|
"""
|
207
207
|
_,_,width,height,_,_ = get_header_info(fn_tif)
|
208
|
-
transform, crs = get_transform_and_crs(fn_tif)
|
208
|
+
transform, crs = get_transform_and_crs(fn_tif)
|
209
209
|
top_left = transform * (0, 0)
|
210
210
|
bottom_left = transform * (0, height)
|
211
211
|
top_right = transform * (width, 0)
|
212
212
|
bottom_right = transform * (width, height)
|
213
|
-
|
213
|
+
|
214
214
|
rectangle = Polygon([top_left, top_right, bottom_right, bottom_left, top_left])
|
215
215
|
gdf = gpd.GeoDataFrame({'geometry': [rectangle]})
|
216
216
|
gdf.set_crs(crs, allow_override=True, inplace=True)
|
217
217
|
gdf.to_file(shapefile_path)
|
218
|
-
|
218
|
+
|
219
219
|
def get_header_info(fn):
|
220
220
|
"""
|
221
221
|
Reads the headers from the file at path 'fn'.
|
@@ -235,8 +235,8 @@ def get_header_comparison(list_fn):
|
|
235
235
|
header_infos = [get_header_info(fn) for fn in list_fn]
|
236
236
|
variable_names = ["dx", "dy", "nbx", "nby", "X", "Y"]
|
237
237
|
for idx, name in enumerate(variable_names):
|
238
|
-
values = [header[idx] for header in header_infos]
|
239
|
-
if len(set(values)) > 1:
|
238
|
+
values = [header[idx] for header in header_infos]
|
239
|
+
if len(set(values)) > 1:
|
240
240
|
comp = False
|
241
241
|
else:
|
242
242
|
comp = True
|
@@ -250,13 +250,13 @@ def display_info_header(self_dx, self_nbxy, self_O, fn):
|
|
250
250
|
dx,dy,nbx,nby,X,Y= get_header_info(fn)
|
251
251
|
self_dx.SetLabel(f"({dx},{dy})")
|
252
252
|
self_nbxy.SetLabel(f"({nbx},{nby})")
|
253
|
-
self_O.SetLabel(f"({X},{Y})")
|
253
|
+
self_O.SetLabel(f"({X},{Y})")
|
254
254
|
return dx,dy,nbx,nby,X,Y
|
255
|
-
|
255
|
+
|
256
256
|
def vanish_info_header(self_dx, self_nbxy, self_O):
|
257
257
|
self_dx.SetLabel("")
|
258
258
|
self_nbxy.SetLabel("")
|
259
|
-
self_O.SetLabel("")
|
259
|
+
self_O.SetLabel("")
|
260
260
|
|
261
261
|
def update_info_header(self_dx, self_nbxy, self_O, fn):
|
262
262
|
"""
|
@@ -264,11 +264,11 @@ def update_info_header(self_dx, self_nbxy, self_O, fn):
|
|
264
264
|
"""
|
265
265
|
if not os.path.exists(fn):
|
266
266
|
os.makedirs(fn)
|
267
|
-
|
267
|
+
|
268
268
|
tif_files = [f for f in os.listdir(fn) if f.lower().endswith('.tif')]
|
269
269
|
tif_list_fn = [os.path.join(fn, tif_file) for tif_file in tif_files]
|
270
|
-
if tif_files:
|
271
|
-
if get_header_comparison(tif_list_fn) :
|
270
|
+
if tif_files:
|
271
|
+
if get_header_comparison(tif_list_fn) :
|
272
272
|
dx,dy,nbx,nby,X,Y = display_info_header(self_dx, self_nbxy, self_O, tif_list_fn[0])
|
273
273
|
return dx,dy,nbx,nby,X,Y
|
274
274
|
else:
|
@@ -276,8 +276,8 @@ def update_info_header(self_dx, self_nbxy, self_O, fn):
|
|
276
276
|
return False, False, False, False, False, False
|
277
277
|
else :
|
278
278
|
vanish_info_header(self_dx, self_nbxy, self_O)
|
279
|
-
return False, False, False, False, False, False
|
280
|
-
|
279
|
+
return False, False, False, False, False, False
|
280
|
+
|
281
281
|
def search_for_modif_bath_and_copy(main_gpu, from_path, path_vuln):
|
282
282
|
"""
|
283
283
|
When loading gpu simulations for last step extraction, search for modified bath_ topography file, according to
|
@@ -290,9 +290,9 @@ def search_for_modif_bath_and_copy(main_gpu, from_path, path_vuln):
|
|
290
290
|
curdicts = scen_manager.get_dicts(curtree)
|
291
291
|
all_tif_bath = [scen_manager._select_tif_partname(curdict, 'bath_') for curdict in curdicts]
|
292
292
|
all_tif_bath = [curel for curlist in all_tif_bath if len(curlist)>0 for curel in curlist if curel.name.startswith('bath_')]
|
293
|
-
if len(all_tif_bath) :
|
293
|
+
if len(all_tif_bath) :
|
294
294
|
found_bath = True
|
295
|
-
for tif_file in all_tif_bath:
|
295
|
+
for tif_file in all_tif_bath:
|
296
296
|
found_bath = True
|
297
297
|
with rasterio.open(tif_file) as src:
|
298
298
|
#vuln_ files
|
@@ -308,7 +308,7 @@ def search_for_modif_bath_and_copy(main_gpu, from_path, path_vuln):
|
|
308
308
|
output_file = path_vuln / tif_file.name.replace('bath_', 'MNTmodifs_')
|
309
309
|
with rasterio.open(output_file, 'w', **metadata) as dst:
|
310
310
|
dst.write(data, 1)
|
311
|
-
|
311
|
+
|
312
312
|
return found_bath
|
313
313
|
|
314
314
|
def mapviewer_display(list_path):
|
@@ -319,7 +319,7 @@ def mapviewer_display(list_path):
|
|
319
319
|
dlg.Destroy()
|
320
320
|
if ret != wx.ID_YES:
|
321
321
|
return
|
322
|
-
|
322
|
+
|
323
323
|
mapviewer = WolfMapViewer(title="OUTPUT Acceptability manager")
|
324
324
|
for path in list_path:
|
325
325
|
myarray = WolfArray(path)
|
@@ -351,74 +351,74 @@ class AcceptabilityGui(wx.Frame):
|
|
351
351
|
raise TypeError("The mapviewer must be a WolfMapViewer")
|
352
352
|
|
353
353
|
self._mapviewer = value
|
354
|
-
|
354
|
+
|
355
355
|
def OnHoverEnter(self, event):
|
356
356
|
"""Dynamic colour layout 1"""
|
357
|
-
self._but_creation.SetBackgroundColour(wx.Colour(100,100,100))
|
357
|
+
self._but_creation.SetBackgroundColour(wx.Colour(100,100,100))
|
358
358
|
self._but_creation.Refresh()
|
359
359
|
event.Skip()
|
360
360
|
|
361
361
|
def OnHoverLeave(self, event):
|
362
362
|
"""Dynamic colour layout 2"""
|
363
|
-
self._but_creation.SetBackgroundColour(wx.Colour(150,150,150))
|
363
|
+
self._but_creation.SetBackgroundColour(wx.Colour(150,150,150))
|
364
364
|
self._but_creation.Refresh()
|
365
365
|
event.Skip()
|
366
|
-
|
366
|
+
|
367
367
|
def layout(self, self_fct):
|
368
368
|
"""Update the layers for the main buttons"""
|
369
369
|
font = self_fct.GetFont()
|
370
370
|
font.SetWeight(wx.FONTWEIGHT_BOLD)
|
371
371
|
self_fct.SetFont(font)
|
372
|
-
self_fct.SetBackgroundColour(wx.Colour(150,150,150))
|
372
|
+
self_fct.SetBackgroundColour(wx.Colour(150,150,150))
|
373
373
|
self_fct.Bind(wx.EVT_ENTER_WINDOW, self.OnHoverEnter)
|
374
374
|
self_fct.Bind(wx.EVT_LEAVE_WINDOW, self.OnHoverLeave)
|
375
|
-
|
375
|
+
|
376
376
|
def on_button_click(self, event):
|
377
377
|
self.PopupMenu(self.menu)
|
378
378
|
|
379
379
|
def on_menu_click(self, event):
|
380
|
-
"""Two options for the 'Update Riverbed' button: either the new riverbed trace
|
381
|
-
file already exists and the user selects it, or it does not exist, and the user points to
|
380
|
+
"""Two options for the 'Update Riverbed' button: either the new riverbed trace
|
381
|
+
file already exists and the user selects it, or it does not exist, and the user points to
|
382
382
|
a no-overflow simulation, allowing the code to create the trace."""
|
383
383
|
menu_id = event.GetId()
|
384
|
-
if menu_id == 1:
|
384
|
+
if menu_id == 1:
|
385
385
|
logging.info("Option 1 : the file exists, pointing towards it.")
|
386
|
-
dlg = wx.FileDialog(None, "Please select the .tiff file with the NEW trace of the riverbed.",
|
387
|
-
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
|
386
|
+
dlg = wx.FileDialog(None, "Please select the .tiff file with the NEW trace of the riverbed.",
|
387
|
+
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
|
388
388
|
wildcard="TIFF files (*.tiff)|*.tiff")
|
389
389
|
|
390
390
|
if dlg.ShowModal() == wx.ID_OK:
|
391
|
-
selected_file = Path(dlg.GetPath())
|
391
|
+
selected_file = Path(dlg.GetPath())
|
392
392
|
copied_file = self._manager.OUT_SCEN_DIR / "copy_file"
|
393
393
|
shutil.copy(selected_file, copied_file)
|
394
394
|
logging.info(f"File copied to: {copied_file}")
|
395
|
-
|
395
|
+
|
396
396
|
new_name = self._manager.OUT_MASKED_RIVER_S
|
397
|
-
|
397
|
+
|
398
398
|
with wx.MessageDialog(self, f"Modified riverbed imported and called Masked_River_extent_scenarios.tiff.",
|
399
399
|
"File imported.", wx.OK | wx.ICON_INFORMATION) as dlg:
|
400
400
|
dlg.ShowModal()
|
401
|
-
|
401
|
+
|
402
402
|
if new_name.exists():
|
403
403
|
new_name.unlink()
|
404
|
-
|
404
|
+
|
405
405
|
copied_file.rename(new_name)
|
406
406
|
logging.info(f"File renamed to: {new_name}")
|
407
407
|
else:
|
408
408
|
logging.info('No file selected. Please try again.')
|
409
|
-
|
409
|
+
|
410
410
|
elif menu_id == 2: #No file, so need to create
|
411
411
|
logging.info("Option 2 : pointing to simulation with low discharge (no overflows!).")
|
412
|
-
|
412
|
+
|
413
413
|
with wx.DirDialog(self, "Please select a simul_gpu_results folder of a simulation with low discharges (no overflows).", style=wx.DD_DEFAULT_STYLE) as dir_dlg:
|
414
|
-
if dir_dlg.ShowModal() == wx.ID_OK:
|
415
|
-
selected_folder = Path(dir_dlg.GetPath())
|
416
|
-
if os.path.basename(selected_folder) == "simul_gpu_results" :
|
417
|
-
logging.info(f"Selected folder: {selected_folder}")
|
414
|
+
if dir_dlg.ShowModal() == wx.ID_OK:
|
415
|
+
selected_folder = Path(dir_dlg.GetPath())
|
416
|
+
if os.path.basename(selected_folder) == "simul_gpu_results" :
|
417
|
+
logging.info(f"Selected folder: {selected_folder}")
|
418
418
|
fn_output = self._manager.OUT_MASKED_RIVER_S
|
419
419
|
dlg = wx.TextEntryDialog(self, "What water depth threshold (in meters) should be used to define the riverbed trace, above which\n"
|
420
420
|
"the water depth is considered part of the riverbed? Use a dot as a decimal separator (e.g 0.3).", "Type a water depth threshold in [m] (e.g 0.3)", "")
|
421
|
-
|
421
|
+
|
422
422
|
if dlg.ShowModal() == wx.ID_OK:
|
423
423
|
while True:
|
424
424
|
try:
|
@@ -452,17 +452,17 @@ class AcceptabilityGui(wx.Frame):
|
|
452
452
|
|
453
453
|
else:
|
454
454
|
logging.info("Cancelled.")
|
455
|
-
dlg.Destroy()
|
455
|
+
dlg.Destroy()
|
456
456
|
else:
|
457
457
|
logging.info("No folder (or wrong one) selected. Please try again (must be simul_gpu_results).")
|
458
|
-
|
458
|
+
|
459
459
|
def layout_listbox(self, self_fct):
|
460
460
|
"""Changes the layout for the listbox : light grey."""
|
461
461
|
self_fct.SetBackgroundColour(wx.Colour(220, 220, 220))
|
462
462
|
|
463
463
|
def InitUI(self):
|
464
464
|
self.gpu_bathy = None
|
465
|
-
|
465
|
+
|
466
466
|
sizer_hor_main = wx.BoxSizer(wx.HORIZONTAL)
|
467
467
|
sizer_vert1 = wx.BoxSizer(wx.VERTICAL)
|
468
468
|
sizer_hor_threads = wx.BoxSizer(wx.HORIZONTAL)
|
@@ -478,44 +478,44 @@ class AcceptabilityGui(wx.Frame):
|
|
478
478
|
self._but_maindir = wx.Button(panel, label='Main Directory')
|
479
479
|
self._but_maindir.SetFont(wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
|
480
480
|
self._but_maindir.Bind(wx.EVT_BUTTON, self.OnMainDir)
|
481
|
-
|
481
|
+
|
482
482
|
self._listbox_studyarea = wx.ListBox(panel, choices=[], style=wx.LB_SINGLE)
|
483
483
|
self.layout_listbox(self._listbox_studyarea)
|
484
484
|
self._listbox_studyarea.Bind(wx.EVT_LISTBOX, self.OnStudyArea)
|
485
485
|
self._listbox_studyarea.SetToolTip("Choose the study area")
|
486
486
|
|
487
487
|
self._listbox_scenario = wx.ListBox(panel, choices=[], style=wx.LB_SINGLE)
|
488
|
-
self.layout_listbox(self._listbox_scenario)
|
488
|
+
self.layout_listbox(self._listbox_scenario)
|
489
489
|
self._listbox_scenario.Bind(wx.EVT_LISTBOX, self.OnScenario)
|
490
490
|
self._listbox_scenario.SetToolTip("Choose the scenario")
|
491
|
-
|
491
|
+
|
492
492
|
# 2nd LINE
|
493
493
|
self._but_checkfiles = wx.Button(panel, label='Check directories\n structure')
|
494
494
|
self._but_checkfiles.Bind(wx.EVT_BUTTON, self.OnCheckFiles)
|
495
495
|
self._listbox_scenario.SetToolTip("Check if the folder is correctly structured")
|
496
|
-
|
496
|
+
|
497
497
|
sizer_hor1_1.Add(self._but_checkfiles, 1, wx.ALL | wx.EXPAND, 0)
|
498
|
-
|
498
|
+
|
499
499
|
# Hydrodynamic part
|
500
500
|
self._but_checksim = wx.Button(panel, label='Check existing interpolated\n free surfaces')
|
501
501
|
self._but_checksim.Bind(wx.EVT_BUTTON, self.OnHydrodynInput)
|
502
502
|
|
503
503
|
sizer_hor1_1.Add(self._but_checksim, 1, wx.ALL | wx.EXPAND, 0)
|
504
|
-
|
504
|
+
|
505
505
|
self._but_loadgpu = wx.Button(panel, label='Load and extract\n gpu simulations')
|
506
506
|
self._but_loadgpu.Bind(wx.EVT_BUTTON, self.OnLoadingSimu)
|
507
507
|
sizer_hor1_1.Add(self._but_loadgpu, 1, wx.ALL | wx.EXPAND, 0)
|
508
|
-
|
508
|
+
|
509
509
|
|
510
510
|
self._check_listbox = wx.CheckListBox(panel, choices=[], style=wx.LB_MULTIPLE | wx.CHK_CHECKED)
|
511
|
-
self.layout_listbox(self._check_listbox)
|
511
|
+
self.layout_listbox(self._check_listbox)
|
512
512
|
self.sims = {}
|
513
513
|
sizer_hor1_1.Add(self._check_listbox, 1, wx.ALL | wx.EXPAND, 0) #ajouter!! sinon s'affiche pas
|
514
514
|
|
515
515
|
self._but_DEM = wx.Button(panel, label='Check DEM inputs\n for interpolation')
|
516
516
|
self._but_DEM.Bind(wx.EVT_BUTTON, self.OnDEM)
|
517
517
|
sizer_hor1_1.Add(self._but_DEM, 1, wx.ALL | wx.EXPAND, 0)
|
518
|
-
|
518
|
+
|
519
519
|
self._but_extrinterp = wx.Button(panel, label='Reading and interpolating\n free surface')
|
520
520
|
self._but_extrinterp.Bind(wx.EVT_BUTTON, self.OnInterpolation)
|
521
521
|
sizer_hor1_1.Add(self._but_extrinterp, 1, wx.ALL | wx.EXPAND, 0)
|
@@ -524,7 +524,7 @@ class AcceptabilityGui(wx.Frame):
|
|
524
524
|
sizer_hor1.Add(self._listbox_studyarea, 1, wx.ALL | wx.EXPAND, 0)
|
525
525
|
sizer_hor1.Add(self._listbox_scenario, 1, wx.ALL | wx.EXPAND, 0)
|
526
526
|
|
527
|
-
|
527
|
+
|
528
528
|
#3rd line
|
529
529
|
sizer_hor_threads = wx.BoxSizer(wx.HORIZONTAL)
|
530
530
|
text_dx = wx.StaticText(panel, label='Resolution (dx,dy) [m]:')
|
@@ -539,10 +539,10 @@ class AcceptabilityGui(wx.Frame):
|
|
539
539
|
text_threads = wx.StaticText(panel, label='Number of threads:')
|
540
540
|
self._nb_process = wx.SpinCtrl(panel, value=str(os.cpu_count()), min=1, max=os.cpu_count())
|
541
541
|
self._nb_process.SetToolTip("Number of threads to use")
|
542
|
-
|
542
|
+
|
543
543
|
self._but_sacreation = wx.Button(panel, label='SA creation')
|
544
544
|
self._but_sacreation.Bind(wx.EVT_BUTTON, self.OnSAcreation)
|
545
|
-
|
545
|
+
|
546
546
|
sizer_hor_threads.Add(text_dx, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
547
547
|
sizer_hor_threads.Add(self.input_dx, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
548
548
|
sizer_hor_threads.Add(text_nbxy, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
@@ -552,27 +552,27 @@ class AcceptabilityGui(wx.Frame):
|
|
552
552
|
sizer_hor_threads.Add(self._but_sacreation, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
|
553
553
|
sizer_hor_threads.Add(text_threads, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
554
554
|
sizer_hor_threads.Add(self._nb_process, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
555
|
-
|
555
|
+
|
556
556
|
# 3 last lines + scenarios
|
557
557
|
#--------------------------
|
558
558
|
self._but_creation = wx.Button(panel, label='DataBase Creation')
|
559
|
-
self.layout(self._but_creation)
|
559
|
+
self.layout(self._but_creation)
|
560
560
|
self._but_creation.Bind(wx.EVT_BUTTON, self.OnCreation)
|
561
|
-
|
561
|
+
|
562
562
|
self._steps_db = wx.CheckListBox(panel, choices=steps_base_data_creation.get_list_names(), style=wx.LB_MULTIPLE | wx.CHK_CHECKED)
|
563
563
|
|
564
564
|
self._but_vulnerability = wx.Button(panel, label='Vulnerability')
|
565
|
-
self.layout(self._but_vulnerability)
|
566
|
-
self._but_vulnerability.Bind(wx.EVT_BUTTON, self.OnVulnerability)
|
565
|
+
self.layout(self._but_vulnerability)
|
566
|
+
self._but_vulnerability.Bind(wx.EVT_BUTTON, self.OnVulnerability)
|
567
567
|
step_Vuln_without_withoutscenarios = [item for item in steps_vulnerability.get_list_names() if item != 'APPLY_SCENARIOSVULN - 4']
|
568
568
|
self._steps_vulnerability = wx.CheckListBox(panel, choices=step_Vuln_without_withoutscenarios, style=wx.LB_MULTIPLE | wx.CHK_CHECKED)
|
569
|
-
|
570
|
-
|
569
|
+
|
570
|
+
|
571
571
|
# Scenarios specifics --
|
572
572
|
self._but_checkscenario = wx.Button(panel, label='Check existing scenarios')
|
573
573
|
self._but_checkscenario.Bind(wx.EVT_BUTTON, self.OnCheckScenario)
|
574
|
-
|
575
|
-
|
574
|
+
|
575
|
+
|
576
576
|
self._but_upriverbed = wx.Button(panel, label="Update riverbed")
|
577
577
|
self._but_upriverbed.Bind(wx.EVT_BUTTON, self.on_button_click)
|
578
578
|
|
@@ -580,22 +580,22 @@ class AcceptabilityGui(wx.Frame):
|
|
580
580
|
self.menu.Append(1, "File of riverbed trace exists.")
|
581
581
|
self.menu.Append(2, "Point to a low discharge simulation and calculate the riverbed trace.")
|
582
582
|
self.menu.Bind(wx.EVT_MENU, self.on_menu_click)
|
583
|
-
|
583
|
+
|
584
584
|
self._but_toggle_scen = wx.ToggleButton(panel, label="Accounting for scenarios")
|
585
585
|
self.toggle_state = False
|
586
586
|
self._but_toggle_scen.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle)
|
587
|
-
|
587
|
+
|
588
588
|
sizer_hor_scen.Add(self._but_checkscenario, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
589
589
|
sizer_hor_scen.Add(self._but_upriverbed, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
590
590
|
sizer_hor_scen.Add(self._but_toggle_scen, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 1)
|
591
|
-
|
591
|
+
|
592
592
|
self._but_toggle_resamp = wx.ToggleButton(panel, label="Resampling [m]:")
|
593
593
|
self.toggle_resamp_state = False
|
594
594
|
self._but_toggle_resamp.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggleResampling)
|
595
595
|
sizer_hor_scen.Add(self._but_toggle_resamp, flag=wx.ALIGN_CENTER | wx.TOP)
|
596
596
|
self._but_resampling = wx.SpinCtrl(panel, value="100", min=1, max=1000)
|
597
597
|
sizer_hor_scen.Add(self._but_resampling, flag=wx.ALIGN_CENTER | wx.TOP)
|
598
|
-
|
598
|
+
|
599
599
|
#--
|
600
600
|
|
601
601
|
self._but_acceptability = wx.Button(panel, label='Acceptability')
|
@@ -647,10 +647,10 @@ class AcceptabilityGui(wx.Frame):
|
|
647
647
|
|
648
648
|
self._figure = Figure(figsize=(5, 4), dpi=100)
|
649
649
|
self._axes = self._figure.add_subplot(111)
|
650
|
-
self._axes.set_ylabel("Weighting coefficients")
|
651
|
-
self._axes.set_xlabel("Return period")
|
652
|
-
self._axes.grid(axis='y', linestyle='--', alpha=0.7)
|
653
|
-
|
650
|
+
self._axes.set_ylabel("Weighting coefficients")
|
651
|
+
self._axes.set_xlabel("Return period")
|
652
|
+
self._axes.grid(axis='y', linestyle='--', alpha=0.7)
|
653
|
+
|
654
654
|
self._canvas = FigureCanvas(panel, -1, self._figure)
|
655
655
|
self._toolbar = NavigationToolbar2Wx(self._canvas)
|
656
656
|
self._toolbar.Realize()
|
@@ -659,7 +659,7 @@ class AcceptabilityGui(wx.Frame):
|
|
659
659
|
sizer_vert3.Add(self._toolbar, 0, wx.LEFT | wx.EXPAND, 0)
|
660
660
|
|
661
661
|
# ------
|
662
|
-
|
662
|
+
|
663
663
|
sizer_hor_main.Add(sizer_vert1, 1, wx.EXPAND, 0)
|
664
664
|
sizer_hor_main.Add(sizer_vert2, 1, wx.EXPAND, 0)
|
665
665
|
sizer_hor_main.Add(sizer_vert3, 1, wx.EXPAND, 0)
|
@@ -682,7 +682,7 @@ class AcceptabilityGui(wx.Frame):
|
|
682
682
|
self._but_checksim.Enable(False)
|
683
683
|
self._but_sacreation.Enable(False)
|
684
684
|
self._but_creation.Enable(False)
|
685
|
-
|
685
|
+
|
686
686
|
def OnSims(self, e:wx.ListEvent):
|
687
687
|
""" Load sim into the mapviewer """
|
688
688
|
pass
|
@@ -718,26 +718,26 @@ class AcceptabilityGui(wx.Frame):
|
|
718
718
|
with wx.MessageDialog(self, f"Missing files: \n{ret}", "Error", wx.OK | wx.ICON_ERROR) as dlg:
|
719
719
|
dlg.ShowModal()
|
720
720
|
|
721
|
-
|
721
|
+
|
722
722
|
def OnHydrodynInput(self,e):
|
723
723
|
""" A test to check if the FILLED water depths files exist.
|
724
724
|
-If YES : the code can go on
|
725
725
|
-If NO : either need to be computed, either the code will use the baseline ones
|
726
726
|
"""
|
727
|
-
|
727
|
+
|
728
728
|
if self._manager is None:
|
729
729
|
logging.error("No main directory selected -- Nothing to check")
|
730
730
|
return
|
731
731
|
|
732
732
|
paths_FilledWD = self._manager.get_sims_files_for_scenario()
|
733
|
-
|
733
|
+
|
734
734
|
if len(paths_FilledWD) == 0 :
|
735
735
|
logging.info("There are no interpolated free surface files.")
|
736
|
-
dialog = wx.MessageDialog(None, "There are no interpolated free surface files. Please choose an action.", "Choose an option",
|
736
|
+
dialog = wx.MessageDialog(None, "There are no interpolated free surface files. Please choose an action.", "Choose an option",
|
737
737
|
wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
|
738
|
-
|
739
|
-
dialog.SetYesNoLabels("Use the ones in the Scenario_baseline", "Load other simulations")
|
740
|
-
response = dialog.ShowModal()
|
738
|
+
|
739
|
+
dialog.SetYesNoLabels("Use the ones in the Scenario_baseline", "Load other simulations")
|
740
|
+
response = dialog.ShowModal()
|
741
741
|
|
742
742
|
if response == wx.ID_YES:
|
743
743
|
logging.info("Decision of using baseline simulations.")
|
@@ -746,44 +746,44 @@ class AcceptabilityGui(wx.Frame):
|
|
746
746
|
logging.info("Cannot select files in the _baseline folder.")
|
747
747
|
else:
|
748
748
|
self._manager.copy_tif_files(paths_FilledWD_base, self._manager.IN_SA_INTERP)
|
749
|
-
|
749
|
+
|
750
750
|
elif response == wx.ID_NO:
|
751
751
|
logging.info("Decision of loading simulations.")
|
752
|
-
with wx.MessageDialog(self, f"Please use the 'Load gpu simulations folder' button of the manager and follow the instructions.", "Redirecting",
|
753
|
-
wx.OK | wx.ICON_INFORMATION) as dlg:
|
752
|
+
with wx.MessageDialog(self, f"Please use the 'Load gpu simulations folder' button of the manager and follow the instructions.", "Redirecting",
|
753
|
+
wx.OK | wx.ICON_INFORMATION) as dlg:
|
754
754
|
dlg.ShowModal()
|
755
755
|
else:
|
756
756
|
logging.info("Cancelled")
|
757
|
-
|
758
|
-
dialog.Destroy()
|
759
|
-
|
757
|
+
|
758
|
+
dialog.Destroy()
|
759
|
+
|
760
760
|
else:
|
761
761
|
name_paths_FilledWD = []
|
762
|
-
|
762
|
+
|
763
763
|
for names in paths_FilledWD:
|
764
764
|
logging.info(f"Interpolated free surface file found: {names.name}.")
|
765
765
|
name_paths_FilledWD.append(names.name)
|
766
|
-
with wx.MessageDialog(self,
|
767
|
-
f"{len(paths_FilledWD)} files of interpolated free surface found in the folder : {name_paths_FilledWD}. If you want to change them, click on the 'Load gpu simulations folder button.",
|
768
|
-
"Information",
|
766
|
+
with wx.MessageDialog(self,
|
767
|
+
f"{len(paths_FilledWD)} files of interpolated free surface found in the folder : {name_paths_FilledWD}. If you want to change them, click on the 'Load gpu simulations folder button.",
|
768
|
+
"Information",
|
769
769
|
style=wx.OK | wx.ICON_INFORMATION) as dlg:
|
770
770
|
dlg.ShowModal()
|
771
771
|
#display_info_header(self.input_dx, self.input_nbxy, self.input_O, paths_FilledWD[0].with_suffix(".tif"))
|
772
772
|
update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
|
773
|
-
|
773
|
+
|
774
774
|
def OnLoadingSimu(self,e):
|
775
775
|
""" Link between acceptability and simulations
|
776
776
|
-Either the last steps of the steady simulations for the scenarios already exist : only have to point towards them, then the free surfaces are filled
|
777
777
|
-Or they dont exist and need to be done outside this manager
|
778
778
|
"""
|
779
|
-
|
779
|
+
|
780
780
|
dlg = wx.DirDialog(None, "Please select the scenario manager folder of the scenario manager (containing the scenarios, the folder discharge, the scripts.py...)", style=wx.DD_DEFAULT_STYLE)
|
781
781
|
if dlg.ShowModal() == wx.ID_OK:
|
782
|
-
main_gpu = Path(dlg.GetPath())
|
782
|
+
main_gpu = Path(dlg.GetPath())
|
783
783
|
logging.info(f"Selected folder for GPU result : {main_gpu}")
|
784
784
|
dlg = wx.DirDialog(None, "Please select the simulations folder (containing the sim_ folders) of the specific hydraulic scenario.", defaultPath=str(main_gpu), style=wx.DD_DEFAULT_STYLE)
|
785
785
|
if dlg.ShowModal() == wx.ID_OK:
|
786
|
-
hydraulic_scen = Path(dlg.GetPath())
|
786
|
+
hydraulic_scen = Path(dlg.GetPath())
|
787
787
|
logging.info(f"Selected hydraulic scenario : {hydraulic_scen}")
|
788
788
|
else:
|
789
789
|
logging.error('No hydraulic scenario selected.')
|
@@ -794,21 +794,21 @@ class AcceptabilityGui(wx.Frame):
|
|
794
794
|
self.sims = {}
|
795
795
|
path_LastSteps = Path(self._manager.IN_SA_EXTRACTED)
|
796
796
|
empty_folder(path_LastSteps)
|
797
|
-
|
797
|
+
|
798
798
|
#self.datadir_gpu_sim = main-gpu
|
799
799
|
for subdir in hydraulic_scen.iterdir():
|
800
800
|
if subdir.is_dir() and subdir.name.startswith("sim_"):
|
801
|
-
self.sims[subdir.name] = subdir
|
801
|
+
self.sims[subdir.name] = subdir
|
802
802
|
else:
|
803
803
|
logging.info('No folder sim_ found / selected. Please try again.')
|
804
804
|
self.datadir_simulations = hydraulic_scen
|
805
805
|
self.file_paths = {Path(sim).name: Path(sim) for sim in sorted(self.sims.keys())}
|
806
806
|
self._check_listbox.Set(sorted(sim for sim in self.sims.keys()))
|
807
|
-
|
807
|
+
|
808
808
|
logging.info(f"GPU simulations loaded in the checkbox.\n\nPlease select the ones you want to interpolate and use the button 'Reading and interpolating free surface'.")
|
809
809
|
|
810
810
|
message = "GPU simulations loaded in the checkbox\n\nPlease select the ones you want to interpolate and use the button 'Reading and interpolating free surface'."
|
811
|
-
|
811
|
+
|
812
812
|
found_bath = search_for_modif_bath_and_copy(Path(main_gpu), Path(hydraulic_scen.parent), self._manager.IN_CH_SA_SC)
|
813
813
|
if found_bath :
|
814
814
|
message+= "\nIn addition, modification files for bathymetry (bath_) have been found in the gpu simulations, a copy has been made for a change in the vulnerability and DEM (see vuln_ and MNTmodifs_ in CHANGE_VULNE). Please edit them."
|
@@ -817,19 +817,19 @@ class AcceptabilityGui(wx.Frame):
|
|
817
817
|
self.gpu_bathy = hydraulic_scen.parent / "__bathymetry.tif"
|
818
818
|
self._but_extrinterp.Enable(True)
|
819
819
|
self._but_DEM.Enable(True)
|
820
|
-
with wx.MessageDialog(self,
|
821
|
-
message,
|
822
|
-
"Information",
|
820
|
+
with wx.MessageDialog(self,
|
821
|
+
message,
|
822
|
+
"Information",
|
823
823
|
style=wx.OK | wx.ICON_INFORMATION) as dlg:
|
824
824
|
dlg.ShowModal()
|
825
|
-
|
825
|
+
|
826
826
|
def OnDEM(self,e):
|
827
827
|
"""Import and create the inputs for the interpolation routine holes.exe (name including 'MNT_...' and 'MNT_..._with_mask'.
|
828
828
|
See function MTN_And_mask_creation_all"""
|
829
829
|
if not hasattr(self, 'file_paths'):
|
830
|
-
with wx.MessageDialog(self,
|
831
|
-
f"Please, first load gpu simulations via the previous button.",
|
832
|
-
"Attention",
|
830
|
+
with wx.MessageDialog(self,
|
831
|
+
f"Please, first load gpu simulations via the previous button.",
|
832
|
+
"Attention",
|
833
833
|
style=wx.OK | wx.ICON_ERROR) as dlg:
|
834
834
|
dlg.ShowModal()
|
835
835
|
return
|
@@ -847,15 +847,15 @@ class AcceptabilityGui(wx.Frame):
|
|
847
847
|
else :
|
848
848
|
logging.info("No update of DEM_FILES.")
|
849
849
|
return
|
850
|
-
|
851
|
-
|
850
|
+
|
851
|
+
|
852
852
|
#DEM and masked DEM creation
|
853
853
|
with wx.FileDialog(self, "Please select the DEM file in .tif format (without modifications).", wildcard="TIFF files (*.tif)|*.tif",
|
854
854
|
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as dlg:
|
855
855
|
if dlg.ShowModal() == wx.ID_OK:
|
856
|
-
path_DEM_base = dlg.GetPath()
|
856
|
+
path_DEM_base = dlg.GetPath()
|
857
857
|
logging.info("DEM file selected.")
|
858
|
-
|
858
|
+
|
859
859
|
|
860
860
|
dialog = wx.MessageDialog(None, f"Please modify the 'MNTmodifs_' files in INPUT\CHANGE_VULNE\... as in the hydraulic scenario you want to study.", "Confirmation", wx.YES_NO | wx.ICON_QUESTION)
|
861
861
|
dialog.SetYesNoLabels("Done, continue", "Not done, stop")
|
@@ -876,7 +876,7 @@ class AcceptabilityGui(wx.Frame):
|
|
876
876
|
logging.error(f"No MNTmodifs_ files in {self._manager.IN_CH_SA_SC}.")
|
877
877
|
else:
|
878
878
|
logging.error(f"Path {self._manager.IN_CH_SA_SC} does not exist.")
|
879
|
-
|
879
|
+
|
880
880
|
#self._manager.IN_CH_SA_SC_MNT_tif ou fn_mnt_cropped : ground + riverbed
|
881
881
|
fn_wherebuildings_buffer = self._manager.IN_CH_SA_SC_MNT_tif.parent / "buffer_wherebuilding.tif"
|
882
882
|
fn_mask = self._manager.IN_SA_DEM / "MNT_computed_with_mask.tif"
|
@@ -885,33 +885,33 @@ class AcceptabilityGui(wx.Frame):
|
|
885
885
|
fn_wherebuildings_buffer.unlink()
|
886
886
|
if fn_mask.exists():
|
887
887
|
fn_mask.unlink()
|
888
|
-
dlg = wx.MessageDialog(self,
|
889
|
-
"DEM files created in INPUT\WATER_DEPTH\...\DEM_FILES.",
|
890
|
-
"Success.",
|
888
|
+
dlg = wx.MessageDialog(self,
|
889
|
+
"DEM files created in INPUT\WATER_DEPTH\...\DEM_FILES.",
|
890
|
+
"Success.",
|
891
891
|
wx.OK | wx.ICON_INFORMATION)
|
892
892
|
dlg.ShowModal()
|
893
893
|
dlg.Destroy()
|
894
894
|
return
|
895
|
-
|
896
|
-
|
897
|
-
|
895
|
+
|
896
|
+
|
897
|
+
|
898
898
|
def OnInterpolation(self,e):
|
899
|
-
"""Interpolates the last extracted time steps present in LAST_STEP_EXTRACTED using the fast marching
|
899
|
+
"""Interpolates the last extracted time steps present in LAST_STEP_EXTRACTED using the fast marching
|
900
900
|
interpolation routine holes.exe, by creating a batch file
|
901
901
|
while performing multiple checks on the required input files."""
|
902
902
|
if not hasattr(self, 'file_paths'):
|
903
|
-
with wx.MessageDialog(self,
|
904
|
-
f"Please, first load gpu simulations via the previous button.",
|
905
|
-
"Attention",
|
903
|
+
with wx.MessageDialog(self,
|
904
|
+
f"Please, first load gpu simulations via the previous button.",
|
905
|
+
"Attention",
|
906
906
|
style=wx.OK | wx.ICON_ERROR) as dlg:
|
907
907
|
dlg.ShowModal()
|
908
908
|
return
|
909
|
-
|
909
|
+
|
910
910
|
checked_indices = self._check_listbox.GetCheckedItems()
|
911
911
|
checked_items = [self._check_listbox.GetString(index) for index in checked_indices]
|
912
912
|
selected_paths = [self.file_paths[item] for item in checked_items]
|
913
913
|
path_simulations = self.datadir_simulations
|
914
|
-
|
914
|
+
|
915
915
|
path_LastSteps = Path(self._manager.IN_SA_EXTRACTED)
|
916
916
|
fn_write = None
|
917
917
|
dx,dy,nbx,nby,X,Y = False, False, False, False, False, False
|
@@ -931,8 +931,8 @@ class AcceptabilityGui(wx.Frame):
|
|
931
931
|
else:
|
932
932
|
logging.info('No folder found / selected. Please try again...')
|
933
933
|
else:
|
934
|
-
logging.error('No simulation selected! Please select some in the checkbox.')
|
935
|
-
|
934
|
+
logging.error('No simulation selected! Please select some in the checkbox.')
|
935
|
+
|
936
936
|
C = None
|
937
937
|
D = None
|
938
938
|
for file in os.listdir(Path(self._manager.IN_SA_DEM)):
|
@@ -941,44 +941,44 @@ class AcceptabilityGui(wx.Frame):
|
|
941
941
|
if "mask" not in file:
|
942
942
|
D = file_path
|
943
943
|
else:
|
944
|
-
C = file_path
|
944
|
+
C = file_path
|
945
945
|
if D == None:
|
946
946
|
logging.info("DEM (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and CANNOT include the word 'mask'")
|
947
|
-
with wx.MessageDialog(self,
|
948
|
-
f"DEM (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and CANNOT include the word 'mask'",
|
949
|
-
"Missing file",
|
947
|
+
with wx.MessageDialog(self,
|
948
|
+
f"DEM (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and CANNOT include the word 'mask'",
|
949
|
+
"Missing file",
|
950
950
|
style=wx.OK | wx.ICON_INFORMATION) as dlg:
|
951
951
|
dlg.ShowModal()
|
952
952
|
return
|
953
|
-
|
953
|
+
|
954
954
|
if C == None:
|
955
955
|
logging.info("DEM mask (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and MUST include the word 'mask'")
|
956
|
-
with wx.MessageDialog(self,
|
957
|
-
f"DEM mask (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and MUST include the word 'mask'",
|
958
|
-
"Missing file",
|
956
|
+
with wx.MessageDialog(self,
|
957
|
+
f"DEM mask (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and MUST include the word 'mask'",
|
958
|
+
"Missing file",
|
959
959
|
style=wx.OK | wx.ICON_INFORMATION) as dlg:
|
960
960
|
dlg.ShowModal()
|
961
961
|
return
|
962
|
-
|
962
|
+
|
963
963
|
if not get_header_comparison([fn_write.with_suffix(".bin"), C, D]):
|
964
964
|
logging.info("Files in DEM_FILES do not have the same properties as the simulations files. Please, fix them.")
|
965
|
-
with wx.MessageDialog(self,
|
966
|
-
f"Files in DEM_FILES do not have the same properties as the simulations files. Please, fix them.",
|
967
|
-
"Error in DEM_FILES files",
|
965
|
+
with wx.MessageDialog(self,
|
966
|
+
f"Files in DEM_FILES do not have the same properties as the simulations files. Please, fix them.",
|
967
|
+
"Error in DEM_FILES files",
|
968
968
|
style=wx.OK | wx.ICON_INFORMATION) as dlg:
|
969
969
|
dlg.ShowModal()
|
970
970
|
return
|
971
|
-
|
971
|
+
|
972
972
|
checked_names = self._check_listbox.GetCheckedStrings()
|
973
973
|
if not checked_names:
|
974
974
|
logging.info("No items selected. Adding all paths.")
|
975
|
-
checked_paths = list(self.file_paths.values())
|
975
|
+
checked_paths = list(self.file_paths.values())
|
976
976
|
message_info = "No simulations were checked in the box; so the computations will consider all of them. The interpolation of the given free surface will begin when you press OK, please wait."
|
977
977
|
else:
|
978
978
|
logging.info("Adding only the selected simulations.")
|
979
979
|
checked_paths = [self.file_paths[name] for name in checked_names]
|
980
980
|
message_info = "The interpolation of the given free surface will begin (for the selected simulation(s)) when you press OK, please wait."
|
981
|
-
|
981
|
+
|
982
982
|
if len(self.file_paths) == 0 :
|
983
983
|
with wx.MessageDialog(self, f"No files in EXTRACTED_LAST_STEP_WD. Please provide some or use the 'Load gpu simulation' button.",
|
984
984
|
"OK", wx.OK | wx.ICON_INFORMATION) as dlg:
|
@@ -986,15 +986,15 @@ class AcceptabilityGui(wx.Frame):
|
|
986
986
|
else :
|
987
987
|
path_Interp = Path(self._manager.IN_SA_INTERP)
|
988
988
|
path_bat_file = os.path.join(self._manager.IN_SCEN_DIR, "process_files.bat")
|
989
|
-
|
989
|
+
|
990
990
|
if os.path.exists(path_bat_file):
|
991
991
|
logging.info(f"The file {path_bat_file} already exists and will be replaced.")
|
992
992
|
os.remove(path_bat_file)
|
993
|
-
path_code = os.path.join(self._manager.IN_WATER_DEPTH, "holes.exe")
|
994
|
-
|
993
|
+
path_code = os.path.join(self._manager.IN_WATER_DEPTH, "holes.exe")
|
994
|
+
|
995
995
|
A=[]
|
996
996
|
for path in checked_paths:
|
997
|
-
parts = path.name.split("sim_")
|
997
|
+
parts = path.name.split("sim_")
|
998
998
|
A.extend([os.path.join(path_LastSteps, g) for g in os.listdir(path_LastSteps) if g.endswith(f"{parts[1]}.bin")])
|
999
999
|
B = [os.path.join(path_Interp, os.path.splitext(os.path.basename(f))[0]) for f in A]
|
1000
1000
|
if not A or not B or not C or not D:
|
@@ -1004,7 +1004,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1004
1004
|
dlg.ShowModal()
|
1005
1005
|
with open(path_bat_file, "w") as bat_file:
|
1006
1006
|
for a, b in zip(A, B):
|
1007
|
-
line = f'"{path_code}" filling in="{a}" out="{b}" mask="{C}" dem="{D}"\n'
|
1007
|
+
line = f'"{path_code}" filling in="{a}" out="{b}" mask="{C}" dem="{D} avoid_last=1"\n'
|
1008
1008
|
bat_file.write(line)
|
1009
1009
|
logging.info(message_info)
|
1010
1010
|
with wx.MessageDialog(self, message_info,
|
@@ -1013,14 +1013,14 @@ class AcceptabilityGui(wx.Frame):
|
|
1013
1013
|
empty_folder(self._manager.IN_SA_INTERP)
|
1014
1014
|
path_bat_file = os.path.join(self._manager.IN_SCEN_DIR, "process_files.bat")
|
1015
1015
|
subprocess.run([path_bat_file], check=True)
|
1016
|
-
|
1016
|
+
|
1017
1017
|
renamed_files = []
|
1018
1018
|
path_fichier=self._manager.IN_SA_INTERP
|
1019
1019
|
for file in path_fichier.glob("*.tif"):
|
1020
|
-
if "_h" in file.name:
|
1020
|
+
if "_h" in file.name:
|
1021
1021
|
new_name = file.stem.split("_h")[0].replace(".bin", "") + ".tif"
|
1022
1022
|
file.rename(file.with_name(new_name))
|
1023
|
-
renamed_files.append(new_name)
|
1023
|
+
renamed_files.append(new_name)
|
1024
1024
|
#deleting the other
|
1025
1025
|
for file in path_fichier.glob("*.tif"):
|
1026
1026
|
if "_combl" in file.name or file.name not in renamed_files:
|
@@ -1032,10 +1032,10 @@ class AcceptabilityGui(wx.Frame):
|
|
1032
1032
|
update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
|
1033
1033
|
|
1034
1034
|
|
1035
|
-
|
1035
|
+
|
1036
1036
|
def OnSAcreation(self,e):
|
1037
|
-
"""Creates the shapefile for the study area based on the extent of the provided simulations. A pre-existing shapefile is required;
|
1038
|
-
the menu will display existing ones and the one to be replaced. A placeholder shapefile must be placed if this is the first run."""
|
1037
|
+
"""Creates the shapefile for the study area based on the extent of the provided simulations. A pre-existing shapefile is required;
|
1038
|
+
the menu will display existing ones and the one to be replaced. A placeholder shapefile must be placed if this is the first run."""
|
1039
1039
|
update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
|
1040
1040
|
logging.info("The study area shapefile will be generated in the INPUT STUDY_AREA, based on the simulations present INTERP_WD, whose properties are displayed on the left.")
|
1041
1041
|
with wx.MessageDialog(self, f"The study area shapefile will be generated in the INPUT STUDY_AREA, based on the simulations present INTERP_WD, whose properties are displayed on the left.",
|
@@ -1044,17 +1044,17 @@ class AcceptabilityGui(wx.Frame):
|
|
1044
1044
|
path_fichier=self._manager.IN_SA_INTERP
|
1045
1045
|
tif_files = [f for f in os.listdir(path_fichier) if f.lower().endswith('.tif')]
|
1046
1046
|
tif_list_fn = [os.path.join(path_fichier, tif_file) for tif_file in tif_files]
|
1047
|
-
if tif_files:
|
1048
|
-
if get_header_comparison(tif_list_fn) :
|
1047
|
+
if tif_files:
|
1048
|
+
if get_header_comparison(tif_list_fn) :
|
1049
1049
|
display_info_header(self.input_dx, self.input_nbxy, self.input_O, tif_list_fn[0])
|
1050
1050
|
else:
|
1051
1051
|
logging.error("The interpolated files have different headers. Please fix it.")
|
1052
|
-
|
1052
|
+
|
1053
1053
|
#dlg = wx.TextEntryDialog(None, "What is the name of the study area (please, use underscore '_' for space if required, for example Bassin_Vesdre):", "Input", "")
|
1054
1054
|
#if dlg.ShowModal() == wx.ID_OK:
|
1055
1055
|
# name_shp = dlg.GetValue()
|
1056
1056
|
#dlg.Destroy()
|
1057
|
-
|
1057
|
+
|
1058
1058
|
shp_files = [f for f in os.listdir(Path(self._manager.IN_STUDY_AREA)) if f.endswith('.shp')]
|
1059
1059
|
if shp_files:
|
1060
1060
|
dlg = wx.MultiChoiceDialog(None, "Which Study Area shapefile to replace?", "Choose Shapefile", shp_files)
|
@@ -1062,13 +1062,13 @@ class AcceptabilityGui(wx.Frame):
|
|
1062
1062
|
selections = dlg.GetSelections()
|
1063
1063
|
if selections:
|
1064
1064
|
name_shp = shp_files[selections[0]]
|
1065
|
-
name_shp = Path(self._manager.IN_STUDY_AREA) / name_shp
|
1065
|
+
name_shp = Path(self._manager.IN_STUDY_AREA) / name_shp
|
1066
1066
|
create_shapefile_from_prop_tif(tif_list_fn[0], name_shp)
|
1067
1067
|
logging.info("Study area file created.")
|
1068
1068
|
with wx.MessageDialog(self, f"Study area file created.",
|
1069
1069
|
"Information", wx.OK | wx.ICON_INFORMATION) as dlg:
|
1070
1070
|
dlg.ShowModal()
|
1071
|
-
|
1071
|
+
|
1072
1072
|
else:
|
1073
1073
|
logging.info("No study area files to be replaced.")
|
1074
1074
|
with wx.MessageDialog(self, f"There is no study area shapefile to replace. It must exist at least one, that will be replaced at this stage.",
|
@@ -1079,7 +1079,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1079
1079
|
with wx.MessageDialog(self, f"There are no files in INTERP_WD, please generate them via the previous buttons line.",
|
1080
1080
|
"Attention", wx.OK | wx.ICON_ERROR) as dlg:
|
1081
1081
|
dlg.ShowModal()
|
1082
|
-
|
1082
|
+
|
1083
1083
|
def OnMainDir(self, e):
|
1084
1084
|
"""Selects the main directory to be read."""
|
1085
1085
|
vanish_info_header(self.input_dx,self.input_nbxy,self.input_O)
|
@@ -1111,7 +1111,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1111
1111
|
self._but_sacreation.Enable(True)
|
1112
1112
|
self._but_checksim.Enable(True)
|
1113
1113
|
|
1114
|
-
|
1114
|
+
|
1115
1115
|
else:
|
1116
1116
|
logging.error(f"Missing files: {ret}")
|
1117
1117
|
with wx.MessageDialog(self, f"Missing files: \n{ret}", "Error", wx.OK | wx.ICON_ERROR) as dlg:
|
@@ -1131,7 +1131,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1131
1131
|
self._listbox_scenario.Clear()
|
1132
1132
|
sc = self._manager.get_list_scenarios()
|
1133
1133
|
self._listbox_scenario.InsertItems(sc, 0)
|
1134
|
-
|
1134
|
+
|
1135
1135
|
if self.mapviewer is not None:
|
1136
1136
|
tmp_path = self._manager.IN_STUDY_AREA / study_area
|
1137
1137
|
|
@@ -1147,7 +1147,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1147
1147
|
|
1148
1148
|
scenario = self._manager.get_list_scenarios()[e.GetSelection()]
|
1149
1149
|
self._manager.change_scenario(scenario)
|
1150
|
-
|
1150
|
+
|
1151
1151
|
self._listbox_returnperiods.Clear()
|
1152
1152
|
rt = self._manager.get_return_periods()
|
1153
1153
|
self._listbox_sims.Clear()
|
@@ -1160,25 +1160,25 @@ class AcceptabilityGui(wx.Frame):
|
|
1160
1160
|
if isinstance(ponds, pd.DataFrame):
|
1161
1161
|
self._axes.clear()
|
1162
1162
|
ponds.plot(ax=self._axes, kind='bar', color='gray', edgecolor='black')
|
1163
|
-
self._axes.set_ylabel("Weighting coefficients [-]")
|
1164
|
-
self._axes.set_xlabel("Return period [years]")
|
1165
|
-
self._axes.grid(axis='y', linestyle='--', alpha=0.7)
|
1163
|
+
self._axes.set_ylabel("Weighting coefficients [-]")
|
1164
|
+
self._axes.set_xlabel("Return period [years]")
|
1165
|
+
self._axes.grid(axis='y', linestyle='--', alpha=0.7)
|
1166
1166
|
self._canvas.draw()
|
1167
1167
|
else:
|
1168
1168
|
self._axes.clear()
|
1169
|
-
self._axes.set_ylabel("Weighting coefficients [-]")
|
1170
|
-
self._axes.set_xlabel("Return period [years]")
|
1171
|
-
self._axes.grid(axis='y', linestyle='--', alpha=0.7)
|
1169
|
+
self._axes.set_ylabel("Weighting coefficients [-]")
|
1170
|
+
self._axes.set_xlabel("Return period [years]")
|
1171
|
+
self._axes.grid(axis='y', linestyle='--', alpha=0.7)
|
1172
1172
|
self._canvas.draw()
|
1173
|
-
|
1173
|
+
|
1174
1174
|
update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
|
1175
|
-
|
1175
|
+
|
1176
1176
|
|
1177
1177
|
def OnCreation(self, e):
|
1178
1178
|
""" Create the database """
|
1179
1179
|
if self._manager is None:
|
1180
1180
|
return
|
1181
|
-
|
1181
|
+
|
1182
1182
|
dx,_,_,_,_,_ = update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
|
1183
1183
|
resolution = dx
|
1184
1184
|
if resolution == '':
|
@@ -1187,19 +1187,19 @@ class AcceptabilityGui(wx.Frame):
|
|
1187
1187
|
"Attention",
|
1188
1188
|
wx.OK | wx.ICON_ERROR
|
1189
1189
|
)
|
1190
|
-
else :
|
1190
|
+
else :
|
1191
1191
|
steps = list(self._steps_db.GetCheckedStrings())
|
1192
1192
|
steps = [int(cur.split('-')[1]) for cur in steps]
|
1193
|
-
|
1193
|
+
|
1194
1194
|
if len(steps) != 0:
|
1195
|
-
|
1195
|
+
|
1196
1196
|
wx.MessageBox(
|
1197
1197
|
f"The database will now be created, with a resolution of {dx}. This process may take some time, and the window may temporarily stop responding.",
|
1198
1198
|
"Information",
|
1199
1199
|
wx.OK | wx.ICON_INFORMATION
|
1200
1200
|
)
|
1201
1201
|
Base_data_creation(self._manager.main_dir, number_procs=self._nb_process.GetValue(), resolution=dx, steps=steps)
|
1202
|
-
|
1202
|
+
|
1203
1203
|
wx.MessageBox(
|
1204
1204
|
"The database is created with the selected steps.",
|
1205
1205
|
"Information",
|
@@ -1222,7 +1222,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1222
1222
|
self.toggle_state = False
|
1223
1223
|
if self._but_toggle_scen.GetValue():
|
1224
1224
|
logging.info("Activating the scenario button.")
|
1225
|
-
self._but_toggle_scen.SetBackgroundColour(wx.Colour(175, 175, 175))
|
1225
|
+
self._but_toggle_scen.SetBackgroundColour(wx.Colour(175, 175, 175))
|
1226
1226
|
self._but_toggle_scen_state = True
|
1227
1227
|
tif_files = [file for file in Path(self._manager.IN_CH_SA_SC).glob("*.tif") if file.name.startswith("vuln_")]
|
1228
1228
|
if not tif_files:
|
@@ -1232,27 +1232,27 @@ class AcceptabilityGui(wx.Frame):
|
|
1232
1232
|
wx.OK | wx.ICON_INFORMATION
|
1233
1233
|
)
|
1234
1234
|
logging.info("Desactivating the scenario button.")
|
1235
|
-
self._but_toggle_scen.SetValue(False)
|
1236
|
-
self._but_toggle_scen.SetBackgroundColour(wx.NullColour)
|
1235
|
+
self._but_toggle_scen.SetValue(False)
|
1236
|
+
self._but_toggle_scen.SetBackgroundColour(wx.NullColour)
|
1237
1237
|
self._but_toggle_scen_state = False
|
1238
1238
|
else :
|
1239
1239
|
self.toggle_state = True
|
1240
1240
|
else:
|
1241
|
-
self._but_toggle_scen.SetBackgroundColour(wx.NullColour)
|
1241
|
+
self._but_toggle_scen.SetBackgroundColour(wx.NullColour)
|
1242
1242
|
self.toggle_state = False
|
1243
1243
|
logging.info("Desactivating the scenario button.")
|
1244
|
-
|
1244
|
+
|
1245
1245
|
def OnToggleResampling(self,e):
|
1246
1246
|
"""Creates a toggle button for the acceptability resampling to be activated."""
|
1247
1247
|
self.toggle_resamp_state = False
|
1248
1248
|
toggle = self._but_toggle_resamp
|
1249
|
-
if toggle.GetValue():
|
1250
|
-
self._but_toggle_resamp.SetBackgroundColour(wx.Colour(175, 175, 175))
|
1249
|
+
if toggle.GetValue():
|
1250
|
+
self._but_toggle_resamp.SetBackgroundColour(wx.Colour(175, 175, 175))
|
1251
1251
|
self.toggle_resamp_state = True
|
1252
1252
|
logging.info("Resampling activated")
|
1253
1253
|
current_res = self._but_resampling.GetValue()
|
1254
1254
|
resolution = self.input_dx.GetLabel()
|
1255
|
-
if resolution != '':
|
1255
|
+
if resolution != '':
|
1256
1256
|
values = resolution.strip("()").split(",")
|
1257
1257
|
dx = float(values[0])
|
1258
1258
|
#selection of size
|
@@ -1261,26 +1261,26 @@ class AcceptabilityGui(wx.Frame):
|
|
1261
1261
|
"The resampling size cannot be inferior to the resolution. Please select another resampling size.",
|
1262
1262
|
"Attention",
|
1263
1263
|
wx.OK | wx.ICON_ERROR
|
1264
|
-
)
|
1264
|
+
)
|
1265
1265
|
self.toggle_resamp_state = False
|
1266
|
-
self._but_toggle_resamp.SetValue(False)
|
1267
|
-
self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
|
1266
|
+
self._but_toggle_resamp.SetValue(False)
|
1267
|
+
self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
|
1268
1268
|
logging.info("Resampling disactivated because of a bad resampling size.")
|
1269
1269
|
else :
|
1270
1270
|
logging.info(f"Allowed resampling value : {current_res}[m].")
|
1271
1271
|
else:
|
1272
1272
|
self.toggle_resamp_state = False
|
1273
|
-
self._but_toggle_resamp.SetValue(False)
|
1274
|
-
self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
|
1273
|
+
self._but_toggle_resamp.SetValue(False)
|
1274
|
+
self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
|
1275
1275
|
logging.info("No simulations in INTERP_WD.")
|
1276
1276
|
|
1277
|
-
|
1277
|
+
|
1278
1278
|
else:
|
1279
1279
|
self.toggle_resamp_state = False
|
1280
|
-
self._but_toggle_resamp.SetValue(False)
|
1281
|
-
self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
|
1280
|
+
self._but_toggle_resamp.SetValue(False)
|
1281
|
+
self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
|
1282
1282
|
logging.info("Resampling disactivated")
|
1283
|
-
|
1283
|
+
|
1284
1284
|
def OnCheckScenario(self,e):
|
1285
1285
|
"""Checks if scenarios exist in CHANGE_VULNE."""
|
1286
1286
|
tif_files = list(Path(self._manager.IN_CH_SA_SC).glob("vuln_*.tif"))
|
@@ -1291,11 +1291,11 @@ class AcceptabilityGui(wx.Frame):
|
|
1291
1291
|
"Information",
|
1292
1292
|
wx.OK | wx.ICON_INFORMATION
|
1293
1293
|
)
|
1294
|
-
else :
|
1294
|
+
else :
|
1295
1295
|
wx.MessageBox(
|
1296
|
-
f"There exist vuln_ file(s) in CHANGE_VULNE: {', '.join([tif_file.name for tif_file in tif_files])}",
|
1297
|
-
"Information", wx.OK | wx.ICON_INFORMATION)
|
1298
|
-
|
1296
|
+
f"There exist vuln_ file(s) in CHANGE_VULNE: {', '.join([tif_file.name for tif_file in tif_files])}",
|
1297
|
+
"Information", wx.OK | wx.ICON_INFORMATION)
|
1298
|
+
|
1299
1299
|
def OnVulnerability(self, e):
|
1300
1300
|
""" Run the vulnerability """
|
1301
1301
|
|
@@ -1303,7 +1303,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1303
1303
|
return
|
1304
1304
|
path = [self._manager.OUT_VULN]
|
1305
1305
|
steps = list(self._steps_vulnerability.GetCheckedStrings())
|
1306
|
-
steps = [int(cur.split('-')[1]) for cur in steps]
|
1306
|
+
steps = [int(cur.split('-')[1]) for cur in steps]
|
1307
1307
|
resolution,_,_,_,_,_ =update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
|
1308
1308
|
if resolution == '':
|
1309
1309
|
wx.MessageBox(
|
@@ -1312,7 +1312,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1312
1312
|
wx.OK | wx.ICON_ERROR
|
1313
1313
|
)
|
1314
1314
|
else :
|
1315
|
-
message_supp = "."
|
1315
|
+
message_supp = "."
|
1316
1316
|
if len(steps) == 0:
|
1317
1317
|
steps = [1,10,11,2,3]
|
1318
1318
|
if self.toggle_state == True :
|
@@ -1324,13 +1324,13 @@ class AcceptabilityGui(wx.Frame):
|
|
1324
1324
|
steps=[4]
|
1325
1325
|
else :
|
1326
1326
|
logging.info("Attention - The manager computes also Vulnerability_baseline, as Vulnerability_scenario needs it as input.")
|
1327
|
-
path = [self._manager.OUT_VULN_Stif]
|
1327
|
+
path = [self._manager.OUT_VULN_Stif]
|
1328
1328
|
dialog = wx.MessageDialog(None, f"Please modify the 'vuln_' files in INPUT\CHANGE_VULNE\... as desired. Default value set to one. ", "Confirmation", wx.YES_NO | wx.ICON_QUESTION)
|
1329
1329
|
dialog.SetYesNoLabels("Done, continue", "Not done, stop")
|
1330
1330
|
response = dialog.ShowModal()
|
1331
1331
|
if response == wx.ID_NO:
|
1332
1332
|
return
|
1333
|
-
|
1333
|
+
|
1334
1334
|
logging.info("No steps selected. By default every steps will be performed" + message_supp)
|
1335
1335
|
Vulnerability(str(self._manager.main_dir),
|
1336
1336
|
scenario=str(self._manager.scenario),
|
@@ -1341,7 +1341,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1341
1341
|
"Vulnerability computed with every steps" + message_supp,
|
1342
1342
|
"Information",
|
1343
1343
|
wx.OK | wx.ICON_INFORMATION
|
1344
|
-
)
|
1344
|
+
)
|
1345
1345
|
else :
|
1346
1346
|
if self.toggle_state == True :
|
1347
1347
|
steps.append(4)
|
@@ -1352,14 +1352,14 @@ class AcceptabilityGui(wx.Frame):
|
|
1352
1352
|
steps=[4]
|
1353
1353
|
else :
|
1354
1354
|
logging.info("Attention - The manager computes also Vulnerability_baseline, as Vulnerability_scenario needs it as input.")
|
1355
|
-
|
1356
|
-
path = [self._manager.OUT_VULN_Stif]
|
1355
|
+
|
1356
|
+
path = [self._manager.OUT_VULN_Stif]
|
1357
1357
|
dialog = wx.MessageDialog(None, f"Please modify the 'vuln_' files in INPUT\CHANGE_VULNE\... as desired. Default value set to one. ", "Confirmation", wx.YES_NO | wx.ICON_QUESTION)
|
1358
1358
|
dialog.SetYesNoLabels("Done, continue", "Not done, stop")
|
1359
1359
|
response = dialog.ShowModal()
|
1360
1360
|
if response == wx.ID_NO:
|
1361
1361
|
return
|
1362
|
-
|
1362
|
+
|
1363
1363
|
Vulnerability(self._manager.main_dir,
|
1364
1364
|
scenario=self._manager.scenario,
|
1365
1365
|
Study_area=self._manager.Study_area,
|
@@ -1369,21 +1369,21 @@ class AcceptabilityGui(wx.Frame):
|
|
1369
1369
|
"Vulnerability computed with the selected steps" + message_supp,
|
1370
1370
|
"Information",
|
1371
1371
|
wx.OK | wx.ICON_INFORMATION
|
1372
|
-
)
|
1372
|
+
)
|
1373
1373
|
mapviewer_display(path)
|
1374
|
-
|
1374
|
+
|
1375
1375
|
def OnAcceptability(self, e):
|
1376
1376
|
""" Run the acceptability """
|
1377
1377
|
if self._manager is None:
|
1378
1378
|
return
|
1379
|
-
|
1380
|
-
river_trace = self._manager.wich_river_trace()
|
1379
|
+
|
1380
|
+
river_trace = self._manager.wich_river_trace()
|
1381
1381
|
if self.toggle_state == True and not os.path.isfile(str(self._manager.OUT_VULN_Stif)) and not os.path.isfile(str(river_trace)) :
|
1382
|
-
wx.MessageBox("Necessary files are missing, please ensure the DataBase or Vulnerability steps were performed. ","Error", wx.OK | wx.ICON_ERROR )
|
1382
|
+
wx.MessageBox("Necessary files are missing, please ensure the DataBase or Vulnerability steps were performed. ","Error", wx.OK | wx.ICON_ERROR )
|
1383
1383
|
return
|
1384
|
-
|
1384
|
+
|
1385
1385
|
if self.toggle_state == False and not os.path.isfile(str(self._manager.OUT_VULN)) and not os.path.isfile(str(river_trace)) :
|
1386
|
-
wx.MessageBox("Necessary files are missing, please ensure the DataBase or Vulnerability steps were performed. ","Error", wx.OK | wx.ICON_ERROR )
|
1386
|
+
wx.MessageBox("Necessary files are missing, please ensure the DataBase or Vulnerability steps were performed. ","Error", wx.OK | wx.ICON_ERROR )
|
1387
1387
|
return
|
1388
1388
|
|
1389
1389
|
steps = list(self._steps_acceptability.GetCheckedStrings())
|
@@ -1401,19 +1401,19 @@ class AcceptabilityGui(wx.Frame):
|
|
1401
1401
|
steps = [x for x in steps if x != 4]
|
1402
1402
|
logging.info('Acceptability_baseline not computed because it already exists.')
|
1403
1403
|
message_supp = " FOR scenario(s) vuln_ taken into account"
|
1404
|
-
|
1404
|
+
|
1405
1405
|
if river_trace == self._manager.OUT_MASKED_RIVER : message_supp=message_supp +" WITH the _baseline riverbed trace."
|
1406
1406
|
if river_trace == self._manager.OUT_MASKED_RIVER_S :message_supp+= " WITH the _scenarios riverbed trace."
|
1407
1407
|
if self.toggle_resamp_state == True :
|
1408
1408
|
steps.append(6)
|
1409
|
-
resampling = self._but_resampling.GetValue()
|
1409
|
+
resampling = self._but_resampling.GetValue()
|
1410
1410
|
resolution = self.input_dx.GetLabel()
|
1411
|
-
if resolution != '':
|
1411
|
+
if resolution != '':
|
1412
1412
|
values = resolution.strip("()").split(",")
|
1413
1413
|
resolution = float(values[0])
|
1414
|
-
|
1414
|
+
|
1415
1415
|
message_supp+= f" It has been created for the resolution {resolution}m and the resampling size {resampling}m."
|
1416
|
-
|
1416
|
+
|
1417
1417
|
logging.info("No steps selected. By default every steps will be performed.")
|
1418
1418
|
Acceptability(self._manager.main_dir,
|
1419
1419
|
scenario=self._manager.scenario,
|
@@ -1434,13 +1434,13 @@ class AcceptabilityGui(wx.Frame):
|
|
1434
1434
|
logging.info('Acceptability_baseline not computed because it already exists.')
|
1435
1435
|
message_supp = "FOR scenario(s) (vuln_taken into account)"
|
1436
1436
|
path = [self._manager.OUT_ACCEPT_Stif]
|
1437
|
-
river_trace = self._manager.wich_river_trace()
|
1437
|
+
river_trace = self._manager.wich_river_trace()
|
1438
1438
|
if river_trace == self._manager.OUT_MASKED_RIVER : message_supp =message_supp + " WITH the _baseline riverbed trace."
|
1439
1439
|
if river_trace == self._manager.OUT_MASKED_RIVER_S : message_supp =message_supp + " WITH the _scenarios riverbed trace."
|
1440
1440
|
if self.toggle_resamp_state == True :
|
1441
1441
|
resampling = self._but_resampling.GetValue()
|
1442
1442
|
steps.append(6)
|
1443
|
-
|
1443
|
+
|
1444
1444
|
Acceptability(self._manager.main_dir,
|
1445
1445
|
scenario=self._manager.scenario,
|
1446
1446
|
Study_area=self._manager.Study_area,
|