wolfhece 2.2.28__py3-none-any.whl → 2.2.29__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.
@@ -34,6 +34,8 @@ from ..PyDraw import WolfMapViewer, draw_type
34
34
  from ..Results2DGPU import wolfres2DGPU
35
35
  from ..PyGui import MapManager
36
36
 
37
+ BATHYMETRY_FOR_SIMULATION = "__bathymetry_after_scripts.tif"
38
+
37
39
  def nullvalue_for_hole(WA):
38
40
  """
39
41
  Sets the null value for a WolfArray to 0 (as per the convention in the interpolation routine).
@@ -51,8 +53,8 @@ def read_export_z_bin(fn_read, fn_write, fn_laststep, type_extraction):
51
53
  """
52
54
 
53
55
  if type_extraction == "last_step":
54
- fn_temp = os.path.join(fn_laststep, 'temp')
55
- os.makedirs(fn_temp, exist_ok=True)
56
+ # fn_temp = os.path.join(fn_laststep, 'temp')
57
+ # os.makedirs(fn_temp, exist_ok=True)
56
58
  wolfres2DGPU_test = wolfres2DGPU(fn_read)
57
59
  #changer ici + vérifier si bien SF ou WD (comparer ;) )
58
60
  wolfres2DGPU_test.read_oneresult(-1)
@@ -63,21 +65,21 @@ def read_export_z_bin(fn_read, fn_write, fn_laststep, type_extraction):
63
65
  wd.array = wd.array + top.array
64
66
  fn_write = fn_write.with_suffix('.bin')
65
67
  wd.write_all(fn_write)
66
- shutil.rmtree(fn_temp)
68
+ # shutil.rmtree(fn_temp)
67
69
 
68
70
  if type_extraction == "danger_map":
69
- fn_temp = os.path.join(fn_laststep, 'temp')
70
- os.makedirs(fn_temp, exist_ok=True)
71
+ # fn_temp = os.path.join(fn_laststep, 'temp')
72
+ # os.makedirs(fn_temp, exist_ok=True)
71
73
  wolfres2DGPU_last = wolfres2DGPU(fn_read)
72
74
  wolfres2DGPU_last.read_oneresult(-1)
73
- danger_map_h = wolfres2DGPU(fn_read) .danger_map_only_h(0,-1,1)
75
+ danger_map_h = wolfres2DGPU(fn_read).danger_map_only_h(0,-1,1)
74
76
  top = wolfres2DGPU_last.get_top_for_block(1)
75
77
  nullvalue_for_hole(danger_map_h)
76
78
  nullvalue_for_hole(top)
77
79
  danger_map_h.array[danger_map_h.array != 0] += top.array[danger_map_h.array != 0]
78
80
  fn_write = fn_write.with_suffix('.bin')
79
81
  danger_map_h.write_all(fn_write)
80
- shutil.rmtree(fn_temp)
82
+ # shutil.rmtree(fn_temp)
81
83
 
82
84
 
83
85
  def riverbed_trace(fn_read_simu, fn_output, threshold, type_extraction):
@@ -209,7 +211,7 @@ def mask_creation_data(mask_file, ground_file, output_file):
209
211
  WA_mask = WolfArray(output_file)
210
212
  WA_mask.write_all(Path(Path(output_file).parent / "MNT_computed_with_mask.bin"))
211
213
 
212
- def MTN_And_mask_creation_all(fn_bathy, fn_mtn_cropped, fn_where_buildings, fn_mask_final):
214
+ def MNT_and_mask_creation_all(fn_bathy, fn_mtn_cropped, fn_where_buildings, fn_mask_final):
213
215
  #couper_raster()
214
216
  soustraction(fn_bathy, fn_mtn_cropped, fn_where_buildings)
215
217
  mask_creation_data(fn_where_buildings, fn_mtn_cropped, fn_mask_final)
@@ -219,24 +221,24 @@ def MTN_And_mask_creation_all(fn_bathy, fn_mtn_cropped, fn_where_buildings, fn_m
219
221
  def create_INPUT_TEMP_OUTPUT_forScenario(maindir, study_area, scenario, simu_gpu):
220
222
  """Creates folder for a new study area or/and scenario. The last argument simu_gpu is used when loading simulation (indicates path to the simulation folder),
221
223
  if not used, indicate None to ignore it."""
222
- base_pathwd = Path(maindir) / "INPUT" / "WATER_DEPTH" / study_area / scenario
224
+ base_pathwd = Path(maindir) / "INPUT" / "WATER_DEPTH" / study_area.stem / scenario
223
225
  subfolders = ["DEM_FILES", "INTERP_WD", "EXTRACTED_LAST_STEP_WD"]
224
226
  os.makedirs(base_pathwd, exist_ok=True)
225
227
  for folder in subfolders:
226
228
  os.makedirs(os.path.join(base_pathwd, folder), exist_ok=True)
227
- base_pathch = Path(maindir) / "INPUT" / "CHANGE_VULNE" / study_area / scenario
229
+ base_pathch = Path(maindir) / "INPUT" / "CHANGE_VULNE" / study_area.stem / scenario
228
230
  os.makedirs(base_pathch, exist_ok=True)
229
231
 
230
232
  if simu_gpu != None:
231
233
  path_bat_gpu = Path(simu_gpu) / "bathymetry.tif"
232
234
  if path_bat_gpu.exists():
233
235
  create_shapefile_from_prop_tif(path_bat_gpu, Path(maindir) / "INPUT" / "STUDY_AREA" / f"{study_area}.shp")
234
- logging.info("Study area file created in INPUT/STUDY_AREA.")
236
+ logging.info(_("Study area file created in INPUT/STUDY_AREA."))
235
237
  else :
236
238
  logging.error(f"Error in the study area creation : no bathymetry.tif file in the given simulation folder {simu_gpu}. Please provide it in this folder and try again.")
237
239
 
238
240
  Accept_Manager(main_dir=maindir, Study_area=study_area, scenario=scenario)
239
- logging.info(f"Files created in INPUT, TEMP and OUTPUT for the study area named '{study_area}', and the scenario named '{scenario}'")
241
+ logging.info(_(f"Files created in INPUT, TEMP and OUTPUT for the study area named '{study_area}', and the scenario named '{scenario}'"))
240
242
  return
241
243
 
242
244
  def get_transform_and_crs(tif_file):
@@ -363,7 +365,7 @@ def search_for_modif_bath_and_copy(main_gpu, from_path, path_vuln):
363
365
 
364
366
  return found_bath
365
367
 
366
- def mapviewer_display(list_path):
368
+ def mapviewer_display(list_path, mapviewer=None):
367
369
  """ Load the output in the mapviewer on WOLF """
368
370
  results = " and ".join(Path(path).name for path in list_path)
369
371
  dlg = wx.MessageDialog(None, _(f'Do you want to load {results} in the mapviewer ?'), _('Load file'), wx.YES_NO)
@@ -372,12 +374,13 @@ def mapviewer_display(list_path):
372
374
  if ret != wx.ID_YES:
373
375
  return
374
376
 
375
- mapviewer = WolfMapViewer(title="OUTPUT Acceptability manager")
377
+ if mapviewer is None:
378
+ mapviewer = WolfMapViewer(title="OUTPUT Acceptability manager")
376
379
  for path in list_path:
377
380
  myarray = WolfArray(path)
378
381
  newid = Path(path).name
379
382
  mapviewer.add_object('array', newobj=myarray, id=newid)
380
- logging.info("Press F5 to refresh the mapviewer.")
383
+ logging.info(_("Press F5 to refresh the mapviewer."))
381
384
  mapviewer.Refresh()
382
385
 
383
386
  class AcceptabilityGui(wx.Frame):
@@ -437,7 +440,7 @@ class AcceptabilityGui(wx.Frame):
437
440
  a no-overflow simulation, allowing the code to create the trace."""
438
441
  menu_id = event.GetId()
439
442
  if menu_id == 1:
440
- logging.info("Option 1 : the file exists, pointing towards it.")
443
+ logging.info(_("Option 1 : the file exists, pointing towards it."))
441
444
  dlg = wx.FileDialog(None, "Please select the .tiff file with the NEW trace of the riverbed.",
442
445
  style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
443
446
  wildcard="TIFF files (*.tiff)|*.tiff")
@@ -446,7 +449,7 @@ class AcceptabilityGui(wx.Frame):
446
449
  selected_file = Path(dlg.GetPath())
447
450
  copied_file = self._manager.OUT_SCEN_DIR / "copy_file"
448
451
  shutil.copy(selected_file, copied_file)
449
- logging.info(f"File copied to: {copied_file}")
452
+ logging.info(_(f"File copied to: {copied_file}"))
450
453
 
451
454
  new_name = self._manager.OUT_MASKED_RIVER_S
452
455
 
@@ -458,18 +461,18 @@ class AcceptabilityGui(wx.Frame):
458
461
  new_name.unlink()
459
462
 
460
463
  copied_file.rename(new_name)
461
- logging.info(f"File renamed to: {new_name}")
464
+ logging.info(_(f"File renamed to: {new_name}"))
462
465
  else:
463
- logging.info('No file selected. Please try again.')
466
+ logging.info(_('No file selected. Please try again.'))
464
467
 
465
468
  elif menu_id == 2: #No file, so need to create
466
- logging.info("Option 2 : pointing to simulation with low discharge (no overflows!).")
469
+ logging.info(_("Option 2 : pointing to simulation with low discharge (no overflows!)."))
467
470
 
468
471
  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:
469
472
  if dir_dlg.ShowModal() == wx.ID_OK:
470
473
  selected_folder = Path(dir_dlg.GetPath())
471
474
  if os.path.basename(selected_folder) == "simul_gpu_results" :
472
- logging.info(f"Selected folder: {selected_folder}")
475
+ logging.info(_(f"Selected folder: {selected_folder}"))
473
476
  fn_output = self._manager.OUT_MASKED_RIVER_S
474
477
  dlg = wx.TextEntryDialog(self, "What water depth threshold (in meters) should be used to define the riverbed trace, above which\n"
475
478
  "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)", "")
@@ -500,9 +503,9 @@ class AcceptabilityGui(wx.Frame):
500
503
  else:
501
504
  type_extraction = "danger_map"
502
505
  dialog.Destroy()
503
- logging.info("Detecting riverbed.")
506
+ logging.info(_("Detecting riverbed."))
504
507
  riverbed_trace(selected_folder, fn_output, threshold, type_extraction=type_extraction)
505
- logging.info("File created.")
508
+ logging.info(_("File created."))
506
509
  with wx.MessageDialog(
507
510
  self,
508
511
  "Masked_River_extent_scenarios.tiff successfully created.",
@@ -518,10 +521,10 @@ class AcceptabilityGui(wx.Frame):
518
521
  break
519
522
 
520
523
  else:
521
- logging.info("Cancelled.")
524
+ logging.info(_("Cancelled."))
522
525
  dlg.Destroy()
523
526
  else:
524
- logging.info("No folder (or wrong one) selected. Please try again (must be simul_gpu_results).")
527
+ logging.info(_("No folder (or wrong one) selected. Please try again (must be simul_gpu_results)."))
525
528
 
526
529
 
527
530
  def layout_listbox(self, self_fct):
@@ -758,12 +761,12 @@ class AcceptabilityGui(wx.Frame):
758
761
  dlg.ShowModal()
759
762
  return
760
763
  else :
761
- if (self._manager._study_area == None) or (self._manager._scenario == None):
764
+ if (self._manager._study_area is None) or (self._manager._scenario is None):
762
765
  logging.error(f"No study area and/or scenario selected, no check of TEMP and OUTPUT.")
763
766
  with wx.MessageDialog(self, f"INPUT is well structured, but TEMP and OUTPUT have not been checked because there is no study area and scenario selected.", "Checking", wx.OK | wx.ICON_INFORMATION) as dlg:
764
767
  dlg.ShowModal()
765
768
  else:
766
- logging.info(f"The folder is well structured.")
769
+ logging.info(_(f"The folder is well structured."))
767
770
  t=self._manager.check_temporary()
768
771
  o=self._manager.check_outputs()
769
772
  with wx.MessageDialog(self, f"Main directory is checked.\nINPUT is well structured, and TEMP and OUTPUT have been checked. If folders were missing, they have been created\nMain directory at {self.maindir}", "Checking", wx.OK | wx.ICON_INFORMATION) as dlg:
@@ -780,10 +783,16 @@ class AcceptabilityGui(wx.Frame):
780
783
  logging.error("No main directory selected -- Nothing to check")
781
784
  return
782
785
 
786
+ if self._manager.IN_SA_INTERP is None:
787
+ logging.error(_("No IN_SA_INTERP attribute found in the manager."))
788
+ with wx.MessageDialog(self, "No simulation found in the manager. Please select the simulations first.", "Error", wx.OK | wx.ICON_ERROR) as dlg:
789
+ dlg.ShowModal()
790
+ return
791
+
783
792
  paths_FilledWD = self._manager.get_sims_files_for_scenario()
784
793
 
785
794
  if len(paths_FilledWD) == 0 :
786
- logging.info("There are no interpolated free surface files.")
795
+ logging.info(_("There are no interpolated free surface files."))
787
796
  dialog = wx.MessageDialog(None, "There are no interpolated free surface files. Please choose an action.", "Checking- Choose an option",
788
797
  wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
789
798
 
@@ -791,20 +800,20 @@ class AcceptabilityGui(wx.Frame):
791
800
  response = dialog.ShowModal()
792
801
 
793
802
  if response == wx.ID_YES:
794
- logging.info("Decision of using baseline simulations.")
803
+ logging.info(_("Decision of using baseline simulations."))
795
804
  paths_FilledWD_base = self._manager.get_sims_files_for_baseline()
796
805
  if len(paths_FilledWD_base) == 0 :
797
- logging.info("Cannot select files in the _baseline folder (no files or no folder!).")
806
+ logging.info(_("Cannot select files in the _baseline folder (no files or no folder!)."))
798
807
  else:
799
808
  self._manager.copy_tif_files(paths_FilledWD_base, self._manager.IN_SA_INTERP)
800
809
 
801
810
  elif response == wx.ID_NO:
802
- logging.info("Decision of loading simulations.")
811
+ logging.info(_("Decision of loading simulations."))
803
812
  with wx.MessageDialog(self, f"Please use the 'Load gpu simulations folder' button of the manager and follow the instructions.", "Redirecting",
804
813
  wx.OK | wx.ICON_INFORMATION) as dlg:
805
814
  dlg.ShowModal()
806
815
  else:
807
- logging.info("Cancelled")
816
+ logging.info(_("Cancelled"))
808
817
 
809
818
  dialog.Destroy()
810
819
 
@@ -812,7 +821,7 @@ class AcceptabilityGui(wx.Frame):
812
821
  name_paths_FilledWD = []
813
822
 
814
823
  for names in paths_FilledWD:
815
- logging.info(f"Interpolated free surface file(s) found: {names.name}. \n Reminder : the names of the simulations MUST be 'T.' or 'Q.' with '.' the return period.")
824
+ logging.info(_(f"Interpolated free surface file(s) found: {names.name}. \n Reminder : the names of the simulations MUST be 'T.' or 'Q.' with '.' the return period."))
816
825
  name_paths_FilledWD.append(names.name)
817
826
  with wx.MessageDialog(self,
818
827
  f"{len(paths_FilledWD)} file(s) of interpolated free surface found in the folder : {name_paths_FilledWD}.",
@@ -822,9 +831,19 @@ class AcceptabilityGui(wx.Frame):
822
831
  update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
823
832
 
824
833
  def OnCheckPond(self,e):
834
+
835
+ if self._manager is None:
836
+ logging.error("No main directory selected -- Nothing to check")
837
+ return
838
+ if self._manager.IN_SA_INTERP is None:
839
+ logging.error(_("No IN_SA_INTERP attribute found in the manager."))
840
+ with wx.MessageDialog(self, "No simulation found in the manager. Please select the simulations first.", "Error", wx.OK | wx.ICON_ERROR) as dlg:
841
+ dlg.ShowModal()
842
+ return
843
+
825
844
  ponds = self._manager.get_ponderations()
826
845
  if isinstance(ponds, pd.DataFrame):
827
- logging.info(f"Plotting the coefficients graph.")
846
+ logging.info(_(f"Plotting the coefficients graph."))
828
847
  ponds.plot(kind='bar', color='gray', edgecolor='black')
829
848
  plt.ylabel("Weighting coefficients [-]")
830
849
  plt.xlabel("Return period [years]")
@@ -849,17 +868,41 @@ class AcceptabilityGui(wx.Frame):
849
868
  if dlg.ShowModal() == wx.ID_OK:
850
869
  self._manager = Accept_Manager(dlg.GetPath())
851
870
  self.maindir=dlg.GetPath()
852
- folders = ["INPUT", "TEMP", "OUTPUT"]
853
871
 
854
- if all(os.path.isdir(os.path.join(self.maindir, folder)) for folder in folders) == False:
855
- logging.info("Folder not loaded (incorrect structure).")
872
+ folders = ["INPUT"]
873
+
874
+ for folder in folders:
875
+ if not os.path.isdir(os.path.join(self.maindir, folder)):
876
+ logging.error(_("INPUT folder is missing."))
877
+ wx.MessageBox(
878
+ f"Missing INPUT folder. Please organize correctly this folder {self.maindir}.",
879
+ "Error",
880
+ wx.OK | wx.ICON_ERROR
881
+ )
882
+ dlg.Destroy()
883
+ return
884
+
885
+ folders = ['CHANGE_VULNE', 'DATABASE', 'STUDY_AREA', 'CSVs', 'WATER_DEPTH', 'EPU_STATIONS_NEW']
886
+ missing = []
887
+ for folder in folders:
888
+ if not os.path.isdir(os.path.join(self.maindir, "INPUT", folder)):
889
+ logging.error(_(f"INPUT/{folder} folder is missing."))
890
+ missing.append(folder)
891
+ if missing:
856
892
  wx.MessageBox(
857
- f"Missing folders among INPUT, TEMP and OUTPUT. Please organize correctly this folder.",
893
+ f"Missing folders : {missing}. Please organize correctly your INPUT folder in {self.maindir}.",
858
894
  "Error",
859
895
  wx.OK | wx.ICON_ERROR
860
896
  )
897
+ dlg.Destroy()
861
898
  return
862
899
 
900
+ folders = ["TEMP", "OUTPUT"]
901
+ for folder in folders:
902
+ if not os.path.isdir(os.path.join(self.maindir, folder)):
903
+ logging.info(_(f"Creating {folder} folder."))
904
+ os.makedirs(os.path.join(self.maindir, folder))
905
+
863
906
  self._but_acceptability.Enable(True)
864
907
  self._but_vulnerability.Enable(True)
865
908
  self._but_creation.Enable(True)
@@ -875,14 +918,12 @@ class AcceptabilityGui(wx.Frame):
875
918
  self._listbox_scenario.Clear()
876
919
  studyareas = self._manager.get_list_studyareas()
877
920
  if len(studyareas) == 0 :
878
- logging.info("Folder loaded but no study areas found in the folder (INPUT/STUDY_AREA). Please use the button to load hydraulic simulations in the manager.")
921
+ logging.info(_("Folder loaded but no study areas found in the folder (INPUT/STUDY_AREA). Please use the button to load hydraulic simulations in the manager."))
879
922
  return
880
923
  self._listbox_studyarea.Clear()
881
924
  self._listbox_studyarea.InsertItems(studyareas, 0)
882
925
 
883
- logging.info("All the files are present")
884
- else:
885
- return
926
+ logging.info(_("All the directories are present"))
886
927
 
887
928
  def OnStudyArea(self, e):
888
929
  """ Change the study area """
@@ -921,6 +962,12 @@ class AcceptabilityGui(wx.Frame):
921
962
  def OnCreation(self, e):
922
963
  """ Create the database """
923
964
  if self._manager is None:
965
+ logging.error("No main directory selected -- Nothing to create")
966
+ return
967
+ if self._manager.IN_SA_INTERP is None:
968
+ logging.error(_("No IN_SA_INTERP attribute found in the manager."))
969
+ with wx.MessageDialog(self, "No simulation found in the manager. Please select the simulations first.", "Error", wx.OK | wx.ICON_ERROR) as dlg:
970
+ dlg.ShowModal()
924
971
  return
925
972
 
926
973
  dx,_,_,_,_,_ = update_info_header(self.input_dx,self.input_nbxy,self.input_O,self._manager.IN_SA_INTERP)
@@ -979,13 +1026,13 @@ class AcceptabilityGui(wx.Frame):
979
1026
  if dlg.ShowModal() == wx.ID_OK:
980
1027
  main_gpu = Path(dlg.GetPath())
981
1028
  study_area = main_gpu.name
982
- logging.info(f"Selected folder for GPU result such as the STUDY AREA is {study_area}")
1029
+ logging.info(_(f"Selected folder for GPU result such as the STUDY AREA is {study_area}"))
983
1030
  dlg = wx.DirDialog(None, "Please select the scenarios folder (containing the 'simulations' folder) of the specific HYDRAULIC SCENARIO.", defaultPath=str(main_gpu), style=wx.DD_DEFAULT_STYLE)
984
1031
  if dlg.ShowModal() == wx.ID_OK:
985
1032
  scenario = Path(dlg.GetPath())
986
1033
  hydraulic_scen=scenario.joinpath("simulations")
987
1034
  scenario=scenario.name
988
- logging.info(f"Selected hydraulic scenario : {scenario}")
1035
+ logging.info(_(f"Selected hydraulic scenario : {scenario}"))
989
1036
  create_INPUT_TEMP_OUTPUT_forScenario(self.maindir, study_area, scenario, main_gpu)
990
1037
  self._manager.change_studyarea(study_area+'.shp')
991
1038
  self._manager.change_scenario(scenario)
@@ -1012,6 +1059,7 @@ class AcceptabilityGui(wx.Frame):
1012
1059
 
1013
1060
  else:
1014
1061
  logging.error('No hydraulic scenario selected.')
1062
+ return
1015
1063
  else:
1016
1064
  logging.error('No folder found / selected. Please try again.')
1017
1065
  return
@@ -1022,19 +1070,20 @@ class AcceptabilityGui(wx.Frame):
1022
1070
  if subdir.is_dir() and subdir.name.startswith("sim_"):
1023
1071
  self.sims[subdir.name] = subdir
1024
1072
  else:
1025
- logging.info('No folder sim_ found / selected. Please try again.')
1073
+ logging.info(_('No folder sim_ found / selected. Please try again.'))
1026
1074
  self.datadir_simulations = hydraulic_scen
1027
1075
  self.file_paths = {Path(sim).name: Path(sim) for sim in sorted(self.sims.keys())}
1028
1076
  self._check_listbox.Set(sorted(sim for sim in self.sims.keys()))
1029
1077
 
1030
- 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'.")
1078
+ 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'."))
1031
1079
  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'."
1032
1080
 
1033
1081
  found_bath = search_for_modif_bath_and_copy(Path(main_gpu), Path(hydraulic_scen.parent), self._manager.IN_CH_SA_SC)
1034
1082
  if found_bath :
1035
1083
  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."
1036
- logging.info(f"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.")
1037
- self.gpu_bathy = hydraulic_scen.parent / "__bathymetry.tif"
1084
+ logging.info(_(f"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."))
1085
+
1086
+ self.gpu_bathy = hydraulic_scen.parent / BATHYMETRY_FOR_SIMULATION # this is the last bathymetry after the scripts have been run
1038
1087
  self._but_extrinterp.Enable(True)
1039
1088
  self._but_DEM.Enable(True)
1040
1089
  with wx.MessageDialog(self,
@@ -1044,7 +1093,7 @@ class AcceptabilityGui(wx.Frame):
1044
1093
  dlg.ShowModal()
1045
1094
 
1046
1095
  def OnDEM(self,e):
1047
- """Import and create the inputs for the interpolation routine holes.exe (name including 'MNT_...' and 'MNT_..._with_mask'.
1096
+ """Import and create the inputs for the interpolation routine (name including 'MNT_...' and 'MNT_..._with_mask'.
1048
1097
  See function MTN_And_mask_creation_all"""
1049
1098
  if not hasattr(self, 'file_paths'):
1050
1099
  with wx.MessageDialog(self,
@@ -1063,9 +1112,9 @@ class AcceptabilityGui(wx.Frame):
1063
1112
  for file_name in names_inDEM:
1064
1113
  file_path = os.path.join(path, file_name)
1065
1114
  os.remove(file_path)
1066
- logging.info("Files in DEM_FILES deleted.")
1115
+ logging.info(_("Files in DEM_FILES deleted."))
1067
1116
  else :
1068
- logging.info("No update of DEM_FILES.")
1117
+ logging.info(_("No update of DEM_FILES."))
1069
1118
  return
1070
1119
 
1071
1120
  with wx.FileDialog(self, "Please select the DEM file in .tif format (without modifications).", wildcard="TIFF files (*.tif)|*.tif",
@@ -1075,7 +1124,7 @@ class AcceptabilityGui(wx.Frame):
1075
1124
  return
1076
1125
 
1077
1126
  path_DEM_base = dlg.GetPath()
1078
- logging.info("DEM file selected.")
1127
+ logging.info(_("DEM file selected."))
1079
1128
 
1080
1129
  #DEM and masked DEM creation
1081
1130
  path = self._manager.IN_CH_SA_SC
@@ -1089,7 +1138,7 @@ class AcceptabilityGui(wx.Frame):
1089
1138
  response = dialog.ShowModal()
1090
1139
 
1091
1140
  if response == wx.ID_NO:
1092
- logging.info("No modifications done in MNTmodifs_ files, process stopped.")
1141
+ logging.info(_("No modifications done in MNTmodifs_ files, process stopped."))
1093
1142
  return
1094
1143
 
1095
1144
  #else :
@@ -1098,11 +1147,11 @@ class AcceptabilityGui(wx.Frame):
1098
1147
  existence = self._manager.create_vrtIfExists(Path(path_DEM_base), self._manager.IN_CH_SA_SC, self._manager.IN_CH_SA_SC_MNT_VRT, name="MNTmodifs_")
1099
1148
  if existence :
1100
1149
  self._manager.translate_vrt2tif(self._manager.IN_CH_SA_SC_MNT_VRT, self._manager.IN_CH_SA_SC_MNT_tif)
1101
- logging.info(f"Scenarios have been applied to DEM see {self._manager.IN_CH_SA_SC_MNT_tif}.tif.")
1150
+ logging.info(_(f"Scenarios have been applied to DEM see {self._manager.IN_CH_SA_SC_MNT_tif}.tif."))
1102
1151
  WA_mask = WolfArray(self._manager.IN_CH_SA_SC_MNT_tif.with_suffix('.tif'))
1103
1152
  WA_mask.write_all(Path(self._manager.IN_SA_DEM / "MNT_loaded.bin"))
1104
1153
  else :
1105
- logging.info(f"No MNTmodifs_ files in {self._manager.IN_CH_SA_SC}. The given file {path_DEM_base} has not been modified")
1154
+ logging.info(_(f"No MNTmodifs_ files in {self._manager.IN_CH_SA_SC}. The given file {path_DEM_base} has not been modified"))
1106
1155
  WA_mask = WolfArray(path_DEM_base)
1107
1156
  WA_mask.write_all(Path(self._manager.IN_SA_DEM / "MNT_loaded.bin"))
1108
1157
  else:
@@ -1111,7 +1160,7 @@ class AcceptabilityGui(wx.Frame):
1111
1160
  #self._manager.IN_CH_SA_SC_MNT_tif ou fn_mnt_cropped : ground + riverbed
1112
1161
  fn_wherebuildings_buffer = self._manager.IN_CH_SA_SC / "buffer_wherebuilding.tif"
1113
1162
  fn_mask = self._manager.IN_SA_DEM / "MNT_computed_with_mask.tif"
1114
- MTN_And_mask_creation_all(self.gpu_bathy, path_MNT_computed, fn_wherebuildings_buffer, fn_mask)
1163
+ MNT_and_mask_creation_all(self.gpu_bathy, path_MNT_computed, fn_wherebuildings_buffer, fn_mask)
1115
1164
  if fn_wherebuildings_buffer.exists():
1116
1165
  fn_wherebuildings_buffer.unlink()
1117
1166
  if fn_mask.exists():
@@ -1126,15 +1175,15 @@ class AcceptabilityGui(wx.Frame):
1126
1175
 
1127
1176
  def OnInterpolation(self,e):
1128
1177
  """Interpolates the last extracted time steps present in LAST_STEP_EXTRACTED using the fast marching
1129
- interpolation routine holes.exe, by creating a batch file
1178
+ interpolation routine, by creating a batch file
1130
1179
  while performing multiple checks on the required input files."""
1131
1180
  menu_id = e.GetId()
1132
1181
  if menu_id == 1:
1133
1182
  type_extraction = "last_step"
1134
- logging.info("Option 1 : last step extraction and interpolation.")
1135
- if menu_id == 2:
1183
+ logging.info(_("Option 1 : last step extraction and interpolation."))
1184
+ elif menu_id == 2:
1136
1185
  type_extraction = "danger_map"
1137
- logging.info("Option 2 : danger map computation and interpolation.")
1186
+ logging.info(_("Option 2 : danger map computation and interpolation."))
1138
1187
 
1139
1188
  if not hasattr(self, 'file_paths'):
1140
1189
  with wx.MessageDialog(self,
@@ -1156,35 +1205,36 @@ class AcceptabilityGui(wx.Frame):
1156
1205
  if sim_.name.startswith("sim_"):
1157
1206
  self.sims[sim_.name] = sim_
1158
1207
  fn_read = Path(path_simulations/ sim_ / "simul_gpu_results")
1159
- logging.info(f"Found simulation folder: {sim_}")
1208
+ logging.info(_(f"Found simulation folder: {sim_}"))
1160
1209
  parts = sim_.name.split("sim_")
1161
1210
  if len(parts) > 1:
1162
1211
  name = parts[1]
1163
1212
  fn_write = Path(path_LastSteps / name )
1164
- dx,dy,nbx,nby,X,Y = display_info_header(self.input_dx, self.input_nbxy, self.input_O, fn_write.with_suffix(".bin"))
1213
+ # dx,dy,nbx,nby,X,Y = display_info_header(self.input_dx, self.input_nbxy, self.input_O, fn_write.with_suffix(".bin"))
1165
1214
  read_export_z_bin(fn_read, fn_write, path_LastSteps, type_extraction = type_extraction)
1166
1215
  else:
1167
- logging.info(f"Please, ensure your simulations are named with the return period, e.g sim_T4")
1216
+ logging.info(_(f"Please, ensure your simulations are named with the return period, e.g sim_T4"))
1168
1217
  else:
1169
- logging.info('No folder found / selected. Please try again...')
1218
+ logging.info(_('No folder found / selected. Please try again...'))
1170
1219
  else:
1171
1220
  logging.error('No simulation selected! Please select some in the checkbox.')
1172
1221
 
1173
1222
  checked_names = self._check_listbox.GetCheckedStrings()
1174
1223
  if not checked_names:
1175
- logging.info("No items selected. Adding all paths.")
1224
+ logging.info(_("No items selected. Adding all paths."))
1176
1225
  checked_paths = list(self.file_paths.values())
1177
1226
  else:
1178
- logging.info("Adding only the selected simulations.")
1227
+ logging.info(_("Adding only the selected simulations."))
1179
1228
  checked_paths = [self.file_paths[name] for name in checked_names]
1180
1229
 
1181
1230
  if len(self.file_paths) == 0 :
1182
- return logging.info("No files in EXTRACTED_LAST_STEP_WD. Please provide some or use the 'Load gpu simulation' button.")
1231
+ return logging.info(_("No files in EXTRACTED_LAST_STEP_WD. Please provide some or use the 'Load gpu simulation' button."))
1183
1232
 
1184
- interp_bool, renamed_files = self._manager.batch_creation_and_interpolation(checked_paths,None)
1233
+ # interp_bool, renamed_files = self._manager.batch_creation_and_interpolation_fotran_holes(checked_paths, False)
1234
+ interp_bool, renamed_files = self._manager.batch_creation_and_interpolation_python_eikonal(checked_paths, False)
1185
1235
 
1186
- if interp_bool == True:
1187
- logging.info("Filling completed.")
1236
+ if interp_bool:
1237
+ logging.info(_("Filling completed."))
1188
1238
  with wx.MessageDialog(self, f"Filling completed. Created files : {renamed_files}",
1189
1239
  "Redirecting", wx.OK | wx.ICON_INFORMATION) as dlg:
1190
1240
  dlg.ShowModal()
@@ -1196,7 +1246,7 @@ class AcceptabilityGui(wx.Frame):
1196
1246
  """Creates a toggle button to be activated if the scenarios vuln_ have to be taken into account."""
1197
1247
  self.toggle_state = False
1198
1248
  if self._but_toggle_scen.GetValue():
1199
- logging.info("Activating the scenario button.")
1249
+ logging.info(_("Activating the scenario button."))
1200
1250
  self._but_toggle_scen.SetBackgroundColour(wx.Colour(175, 175, 175))
1201
1251
  self._but_toggle_scen_state = True
1202
1252
  tif_files = [file for file in Path(self._manager.IN_CH_SA_SC).glob("*.tif") if file.name.startswith("vuln_")]
@@ -1206,7 +1256,7 @@ class AcceptabilityGui(wx.Frame):
1206
1256
  "Information",
1207
1257
  wx.OK | wx.ICON_INFORMATION
1208
1258
  )
1209
- logging.info("Desactivating the scenario button.")
1259
+ logging.info(_("Desactivating the scenario button."))
1210
1260
  self._but_toggle_scen.SetValue(False)
1211
1261
  self._but_toggle_scen.SetBackgroundColour(wx.NullColour)
1212
1262
  self._but_toggle_scen_state = False
@@ -1215,7 +1265,7 @@ class AcceptabilityGui(wx.Frame):
1215
1265
  else:
1216
1266
  self._but_toggle_scen.SetBackgroundColour(wx.NullColour)
1217
1267
  self.toggle_state = False
1218
- logging.info("Desactivating the scenario button.")
1268
+ logging.info(_("Desactivating the scenario button."))
1219
1269
 
1220
1270
  def OnToggleResampling(self,e):
1221
1271
  """Creates a toggle button for the acceptability resampling to be activated."""
@@ -1224,7 +1274,7 @@ class AcceptabilityGui(wx.Frame):
1224
1274
  if toggle.GetValue():
1225
1275
  self._but_toggle_resamp.SetBackgroundColour(wx.Colour(175, 175, 175))
1226
1276
  self.toggle_resamp_state = True
1227
- logging.info("Resampling activated")
1277
+ logging.info(_("Resampling activated"))
1228
1278
  current_res = self._but_resampling.GetValue()
1229
1279
  resolution = self.input_dx.GetLabel()
1230
1280
  if resolution != '':
@@ -1240,26 +1290,26 @@ class AcceptabilityGui(wx.Frame):
1240
1290
  self.toggle_resamp_state = False
1241
1291
  self._but_toggle_resamp.SetValue(False)
1242
1292
  self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
1243
- logging.info("Resampling disactivated because of a bad resampling size.")
1293
+ logging.info(_("Resampling disactivated because of a bad resampling size."))
1244
1294
  else :
1245
- logging.info(f"Allowed resampling value : {current_res}[m].")
1295
+ logging.info(_(f"Allowed resampling value : {current_res}[m]."))
1246
1296
  else:
1247
1297
  self.toggle_resamp_state = False
1248
1298
  self._but_toggle_resamp.SetValue(False)
1249
1299
  self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
1250
- logging.info("No simulations in INTERP_WD.")
1300
+ logging.info(_("No simulations in INTERP_WD."))
1251
1301
 
1252
1302
 
1253
1303
  else:
1254
1304
  self.toggle_resamp_state = False
1255
1305
  self._but_toggle_resamp.SetValue(False)
1256
1306
  self._but_toggle_resamp.SetBackgroundColour(wx.NullColour)
1257
- logging.info("Resampling disactivated")
1307
+ logging.info(_("Resampling disactivated"))
1258
1308
 
1259
1309
  def OnCheckScenario(self,e):
1260
1310
  """Checks if scenarios exist in CHANGE_VULNE."""
1261
1311
  tif_files = self._manager.get_modifiedrasters()
1262
- logging.info("checking the scenarios for vulnerability and acceptability.")
1312
+ logging.info(_("checking the scenarios for vulnerability and acceptability."))
1263
1313
  if not tif_files:
1264
1314
  wx.MessageBox(
1265
1315
  "No files 'vuln_' or 'MNTmodifs_' found in CHANGE_VULNE.",
@@ -1294,10 +1344,10 @@ class AcceptabilityGui(wx.Frame):
1294
1344
  steps = [1,10,11,2,3,4]
1295
1345
  if self._manager.OUT_VULN.exists:
1296
1346
  message_supp = " FOR scenario(s) (vuln_ taken into account)"
1297
- logging.info("Attention - The manager ONLY computes Vulnerability_scenario, as Vulnerability_baseline already computed.")
1347
+ logging.info(_("Attention - The manager ONLY computes Vulnerability_scenario, as Vulnerability_baseline already computed."))
1298
1348
  steps=[4]
1299
1349
  else :
1300
- logging.info("Attention - The manager computes also Vulnerability_baseline, as Vulnerability_scenario needs it as input.")
1350
+ logging.info(_("Attention - The manager computes also Vulnerability_baseline, as Vulnerability_scenario needs it as input."))
1301
1351
  path = [self._manager.OUT_VULN_Stif]
1302
1352
  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)
1303
1353
  dialog.SetYesNoLabels("Done, continue", "Not done, stop")
@@ -1305,7 +1355,7 @@ class AcceptabilityGui(wx.Frame):
1305
1355
  if response == wx.ID_NO:
1306
1356
  return
1307
1357
 
1308
- logging.info("No steps selected. By default every steps will be performed" + message_supp)
1358
+ logging.info(_("No steps selected. By default every steps will be performed" + message_supp))
1309
1359
  Vulnerability(str(self._manager.main_dir),
1310
1360
  scenario=str(self._manager.scenario),
1311
1361
  Study_area=str(self._manager.Study_area),
@@ -1322,10 +1372,10 @@ class AcceptabilityGui(wx.Frame):
1322
1372
  message_supp = " AND scenario(s) vuln_ taken into account"
1323
1373
  if self._manager.OUT_VULN.exists:
1324
1374
  message_supp = " FOR scenario(s) (vuln_ taken into account)"
1325
- logging.info("Attention - The manager ONLY computes Vulnerability_scenario, as Vulnerability_baseline already computed.")
1375
+ logging.info(_("Attention - The manager ONLY computes Vulnerability_scenario, as Vulnerability_baseline already computed."))
1326
1376
  steps=[4]
1327
1377
  else :
1328
- logging.info("Attention - The manager computes also Vulnerability_baseline, as Vulnerability_scenario needs it as input.")
1378
+ logging.info(_("Attention - The manager computes also Vulnerability_baseline, as Vulnerability_scenario needs it as input."))
1329
1379
 
1330
1380
  path = [self._manager.OUT_VULN_Stif]
1331
1381
  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)
@@ -1344,7 +1394,7 @@ class AcceptabilityGui(wx.Frame):
1344
1394
  "Information",
1345
1395
  wx.OK | wx.ICON_INFORMATION
1346
1396
  )
1347
- mapviewer_display(path)
1397
+ mapviewer_display(path, self.mapviewer)
1348
1398
 
1349
1399
  def OnAcceptability(self, e):
1350
1400
  """ Run the acceptability """
@@ -1373,7 +1423,7 @@ class AcceptabilityGui(wx.Frame):
1373
1423
  path = [self._manager.OUT_ACCEPT_Stif]
1374
1424
  if self._manager.OUT_ACCEPT.exists:
1375
1425
  steps = [x for x in steps if x != 4]
1376
- logging.info('Acceptability_baseline not computed because it already exists.')
1426
+ logging.info(_('Acceptability_baseline not computed because it already exists.'))
1377
1427
  message_supp = " FOR scenario(s) vuln_ taken into account"
1378
1428
 
1379
1429
  if river_trace == self._manager.OUT_MASKED_RIVER : message_supp=message_supp +" WITH the _baseline riverbed trace."
@@ -1388,7 +1438,7 @@ class AcceptabilityGui(wx.Frame):
1388
1438
 
1389
1439
  message_supp+= f" It has been created for the resolution {resolution}m and the resampling size {resampling}m."
1390
1440
 
1391
- logging.info("No steps selected. By default every steps will be performed.")
1441
+ logging.info(_("No steps selected. By default every steps will be performed."))
1392
1442
  Acceptability(self._manager.main_dir,
1393
1443
  scenario=self._manager.scenario,
1394
1444
  Study_area=self._manager.Study_area,
@@ -1405,7 +1455,7 @@ class AcceptabilityGui(wx.Frame):
1405
1455
  message_supp = " AND scenario(s) vuln_ taken into account"
1406
1456
  if self._manager.OUT_ACCEPT.exists:
1407
1457
  steps = [x for x in steps if x != 4]
1408
- logging.info('Acceptability_baseline not computed because it already exists.')
1458
+ logging.info(_('Acceptability_baseline not computed because it already exists.'))
1409
1459
  message_supp = "FOR scenario(s) (vuln_taken into account)"
1410
1460
  path = [self._manager.OUT_ACCEPT_Stif]
1411
1461
  river_trace = self._manager.wich_river_trace()
@@ -1415,15 +1465,23 @@ class AcceptabilityGui(wx.Frame):
1415
1465
  resampling = self._but_resampling.GetValue()
1416
1466
  steps.append(6)
1417
1467
 
1418
- Acceptability(self._manager.main_dir,
1468
+ done = Acceptability(self._manager.main_dir,
1419
1469
  scenario=self._manager.scenario,
1420
1470
  Study_area=self._manager.Study_area,
1421
1471
  resample_size=resampling,
1422
1472
  steps=steps)
1423
1473
 
1424
- wx.MessageBox(
1425
- "Acceptability computed with the selected steps" + message_supp,
1474
+ if len(done) == 0:
1475
+ wx.MessageBox(
1476
+ "No acceptability computed with the selected steps" + message_supp,
1426
1477
  "Information",
1427
1478
  wx.OK | wx.ICON_INFORMATION
1428
1479
  )
1429
- mapviewer_display(path)
1480
+ else :
1481
+
1482
+ wx.MessageBox(
1483
+ "Acceptability computed with the selected steps" + message_supp,
1484
+ "Information",
1485
+ wx.OK | wx.ICON_INFORMATION
1486
+ )
1487
+ mapviewer_display(path, self.mapviewer)