wolfhece 2.1.129__py3-none-any.whl → 2.2.2__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.
Files changed (36) hide show
  1. wolfhece/PyDraw.py +110 -47
  2. wolfhece/PyGui.py +3 -0
  3. wolfhece/PyGuiHydrology.py +24 -24
  4. wolfhece/PyHydrographs.py +2 -3
  5. wolfhece/PyPalette.py +27 -11
  6. wolfhece/PyParams.py +2 -3
  7. wolfhece/PyVertex.py +7 -7
  8. wolfhece/PyVertexvectors.py +1 -0
  9. wolfhece/Results2DGPU.py +17 -0
  10. wolfhece/acceptability/Parallels.py +25 -19
  11. wolfhece/acceptability/acceptability_gui.py +85 -45
  12. wolfhece/acceptability/func.py +34 -26
  13. wolfhece/apps/version.py +2 -2
  14. wolfhece/eikonal.py +1 -1
  15. wolfhece/hydrology/Catchment.py +2 -2
  16. wolfhece/hydrology/Comparison.py +26 -28
  17. wolfhece/hydrology/plot_hydrology.py +2 -2
  18. wolfhece/lagrangian/particle_system_ui.py +1 -1
  19. wolfhece/lagrangian/particles.py +1 -1
  20. wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
  21. wolfhece/lazviewer/vfuncsdir/vfuncs.cp310-win_amd64.pyd +0 -0
  22. wolfhece/lazviewer/viewer/viewer.exe +0 -0
  23. wolfhece/lazviewer/viewer/viewer_np1_23_5.exe +0 -0
  24. wolfhece/libs/Wolf_tools.dll +0 -0
  25. wolfhece/libs/get_infos.cp310-win_amd64.pyd +0 -0
  26. wolfhece/libs/verify_wolf.cp310-win_amd64.pyd +0 -0
  27. wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
  28. wolfhece/tools2d_dll.py +359 -0
  29. wolfhece/wolf_array.py +27 -24
  30. wolfhece/wolfresults_2D.py +162 -33
  31. {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/METADATA +14 -9
  32. {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/RECORD +35 -33
  33. wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
  34. {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/WHEEL +0 -0
  35. {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/entry_points.txt +0 -0
  36. {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/top_level.txt +0 -0
@@ -15,14 +15,14 @@ from functools import partial
15
15
  import os
16
16
  from pathlib import Path
17
17
 
18
- def parallel_gpd_clip(layer:list[str],
19
- file_path:str,
20
- Study_Area:str,
21
- output_dir:str,
18
+ def parallel_gpd_clip(layer:list[str],
19
+ file_path:str,
20
+ Study_Area:str,
21
+ output_dir:str,
22
22
  number_procs:int = 1):
23
- """
23
+ """
24
24
  Clip the layers to the study area.
25
-
25
+
26
26
  Process the layers in parallel.
27
27
 
28
28
  FIXME: The GPKG driver is it totally parallel compliant?
@@ -50,13 +50,15 @@ def parallel_gpd_clip(layer:list[str],
50
50
  Study_Area=Study_Area,
51
51
  output_dir=output_dir)
52
52
  result_list = pool.map(prod_x, layer)
53
+ pool.close()
54
+ pool.join()
53
55
 
54
56
  def parallel_v2r(manager:Accept_Manager,
55
- attribute:str,
57
+ attribute:str,
56
58
  pixel:float,
57
59
  number_procs:int = 1,
58
60
  convert_to_sparse:bool = False):
59
- """
61
+ """
60
62
  Convert the vector layers to raster.
61
63
 
62
64
  Process the layers in parallel.
@@ -69,7 +71,7 @@ def parallel_v2r(manager:Accept_Manager,
69
71
  :param number_procs: The number of processors to use
70
72
 
71
73
  """
72
-
74
+
73
75
  attribute = str(attribute)
74
76
  layers = manager.get_layers_in_codevulne()
75
77
 
@@ -81,18 +83,20 @@ def parallel_v2r(manager:Accept_Manager,
81
83
  else:
82
84
  pool = multiprocessing.Pool(processes=number_procs)
83
85
  prod_x=partial(vector_to_raster,
84
- manager=manager,
85
- attribute=attribute,
86
+ manager=manager,
87
+ attribute=attribute,
86
88
  pixel_size=pixel,
87
- convert_to_sparse=convert_to_sparse)
88
-
89
+ convert_to_sparse=convert_to_sparse)
90
+
89
91
  result_list = pool.map(prod_x, layers)
92
+ pool.close()
93
+ pool.join()
90
94
 
91
- def parallel_datamod(manager:Accept_Manager,
95
+ def parallel_datamod(manager:Accept_Manager,
92
96
  picc:gpd.GeoDataFrame,
93
97
  capa:gpd.GeoDataFrame,
94
98
  number_procs:int = 1):
95
- """
99
+ """
96
100
  Apply the data modification to the layers.
97
101
 
98
102
  Process the layers in parallel.
@@ -103,7 +107,7 @@ def parallel_datamod(manager:Accept_Manager,
103
107
  :param number_procs: The number of processors to use
104
108
 
105
109
  """
106
-
110
+
107
111
  layers = manager.get_layers_in_clipgdb()
108
112
 
109
113
  if number_procs == 1:
@@ -113,8 +117,10 @@ def parallel_datamod(manager:Accept_Manager,
113
117
  pool = multiprocessing.Pool(processes=number_procs)
114
118
  prod_x=partial(data_modification,
115
119
  manager=manager,
116
- picc=picc,
117
- capa=capa)
118
-
120
+ picc=picc,
121
+ capa=capa)
122
+
119
123
  result_list = pool.map(prod_x, layers)
124
+ pool.close()
125
+ pool.join()
120
126
 
@@ -7,34 +7,32 @@ Copyright (c) 2025 University of Liege. All rights reserved.
7
7
  This script and its content are protected by copyright law. Unauthorized
8
8
  copying or distribution of this file, via any medium, is strictly prohibited.
9
9
  """
10
- from .acceptability import Base_data_creation, Database_to_raster, Vulnerability, Acceptability
11
- from .acceptability import steps_base_data_creation, steps_vulnerability, steps_acceptability
12
- from .func import Accept_Manager
13
- from ..wolf_array import WolfArray, header_wolf
14
- from ..scenario.config_manager import Config_Manager_2D_GPU
15
- from ..PyDraw import WolfMapViewer, draw_type
16
- from ..Results2DGPU import wolfres2DGPU
17
- from ..PyGui import MapManager
18
-
19
10
  import wx
20
- import wx.lib.dialogs
11
+ import numpy as np
21
12
  import logging
22
13
  import subprocess
23
- import matplotlib
24
14
  import shutil
25
15
  import os
26
16
  import geopandas as gpd
17
+ import pandas as pd
27
18
  import matplotlib.pyplot as plt
28
19
  from matplotlib.figure import Figure
29
20
  from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
30
21
  from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar2Wx
31
22
  from pathlib import Path
32
23
  from scipy.ndimage import label
33
- import pandas as pd
34
24
  from gettext import gettext as _
35
25
  import rasterio
36
26
  from shapely.geometry import Polygon
37
- import numpy as np
27
+
28
+ from .acceptability import Base_data_creation, Database_to_raster, Vulnerability, Acceptability
29
+ from .acceptability import steps_base_data_creation, steps_vulnerability, steps_acceptability
30
+ from .func import Accept_Manager
31
+ from ..wolf_array import WolfArray, header_wolf
32
+ from ..scenario.config_manager import Config_Manager_2D_GPU
33
+ from ..PyDraw import WolfMapViewer, draw_type
34
+ from ..Results2DGPU import wolfres2DGPU
35
+ from ..PyGui import MapManager
38
36
 
39
37
  def nullvalue_for_hole(WA):
40
38
  """
@@ -62,6 +60,9 @@ def read_export_z_bin(fn_read, fn_write, fn_laststep):
62
60
  wd.array = wd.array + top.array
63
61
  fn_write = fn_write.with_suffix('.bin')
64
62
  wd.write_all(fn_write)
63
+ fn_write = fn_write.with_suffix('.tif')
64
+ wd.write_all(fn_write)
65
+ top.write_all(fn_write.parent / fn_write.stem / "_dem.tif")
65
66
  shutil.rmtree(fn_temp)
66
67
 
67
68
  def riverbed_trace(fn_read_simu, fn_output, threshold):
@@ -710,7 +711,7 @@ class AcceptabilityGui(wx.Frame):
710
711
  dlg.ShowModal()
711
712
  return
712
713
  else :
713
- if (self._manager._study_area == None) or (self._manager._scenario == None):
714
+ if (self._manager._study_area is None) or (self._manager._scenario is None):
714
715
  logging.error(f"No study area and/or scenario selected, no check of TEMP and OUTPUT.")
715
716
  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:
716
717
  dlg.ShowModal()
@@ -966,6 +967,8 @@ class AcceptabilityGui(wx.Frame):
966
967
  logging.error('No hydraulic scenario selected.')
967
968
  else:
968
969
  logging.error('No folder found / selected. Please try again.')
970
+ return
971
+
969
972
  self._check_listbox.Clear()
970
973
  self.sims = {}
971
974
  for subdir in hydraulic_scen.iterdir():
@@ -1075,9 +1078,11 @@ class AcceptabilityGui(wx.Frame):
1075
1078
  return
1076
1079
 
1077
1080
  def OnInterpolation(self,e):
1078
- """Interpolates the last extracted time steps present in LAST_STEP_EXTRACTED using the fast marching
1081
+ """Interpolates the last extracted time steps present in
1082
+ LAST_STEP_EXTRACTED using the fast marching
1079
1083
  interpolation routine holes.exe, by creating a batch file
1080
1084
  while performing multiple checks on the required input files."""
1085
+
1081
1086
  if not hasattr(self, 'file_paths'):
1082
1087
  with wx.MessageDialog(self,
1083
1088
  f"Please, first load gpu simulations via the previous button.",
@@ -1121,7 +1126,7 @@ class AcceptabilityGui(wx.Frame):
1121
1126
  D = file_path
1122
1127
  else:
1123
1128
  C = file_path
1124
- if D == None:
1129
+ if D is None:
1125
1130
  logging.info("DEM (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and CANNOT include the word 'mask'")
1126
1131
  with wx.MessageDialog(self,
1127
1132
  f"DEM (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and CANNOT include the word 'mask'",
@@ -1130,7 +1135,7 @@ class AcceptabilityGui(wx.Frame):
1130
1135
  dlg.ShowModal()
1131
1136
  return
1132
1137
 
1133
- if C == None:
1138
+ if C is None:
1134
1139
  logging.info("DEM mask (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and MUST include the word 'mask'")
1135
1140
  with wx.MessageDialog(self,
1136
1141
  f"DEM mask (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and MUST include the word 'mask'",
@@ -1171,37 +1176,72 @@ class AcceptabilityGui(wx.Frame):
1171
1176
  os.remove(path_bat_file)
1172
1177
  path_code = os.path.join(self._manager.IN_WATER_DEPTH, "holes.exe")
1173
1178
 
1174
- A=[]
1175
- for path in checked_paths:
1176
- parts = path.name.split("sim_")
1177
- A.extend([os.path.join(path_LastSteps, g) for g in os.listdir(path_LastSteps) if g.endswith(f"{parts[1]}.bin")])
1178
- B = [os.path.join(path_Interp, os.path.splitext(os.path.basename(f))[0]) for f in A]
1179
- if not A or not B or not C or not D:
1180
- logging.info("Missing files.")
1181
- with wx.MessageDialog(self, f"The interpolation cannot go on, as some files are missing (see logs): please check the DEM_FILES or the EXTRACTED_LAST_STEP_WD folders.",
1182
- "Missing files.", wx.OK | wx.ICON_INFORMATION) as dlg:
1183
- dlg.ShowModal()
1184
- with open(path_bat_file, "w") as bat_file:
1185
- for a, b in zip(A, B):
1186
- line = f'"{path_code}" filling in="{a}" out="{b}" mask="{C}" dem="{D} avoid_last=1"\n'
1187
- bat_file.write(line)
1188
- logging.info(message_info)
1189
-
1190
- empty_folder(self._manager.IN_SA_INTERP)
1191
- path_bat_file = os.path.join(self._manager.IN_SCEN_DIR, "process_files.bat")
1192
- subprocess.run([path_bat_file], check=True)
1193
1179
 
1194
1180
  renamed_files = []
1195
- path_fichier=self._manager.IN_SA_INTERP
1196
- for file in path_fichier.glob("*.tif"):
1197
- if "_h" in file.name:
1198
- new_name = file.stem.split("_h")[0].replace(".bin", "") + ".tif"
1199
- file.rename(file.with_name(new_name))
1181
+ if True:
1182
+ A=[]
1183
+ for path in checked_paths:
1184
+ parts = path.name.split("sim_")
1185
+ A.extend([os.path.join(path_LastSteps, g) for g in os.listdir(path_LastSteps) if g.endswith(f"{parts[1]}.bin")])
1186
+ B = [os.path.join(path_Interp, os.path.splitext(os.path.basename(f))[0]) for f in A]
1187
+ if not A or not B or not C or not D:
1188
+ logging.info("Missing files.")
1189
+ with wx.MessageDialog(self, f"The interpolation cannot go on, as some files are missing (see logs): please check the DEM_FILES or the EXTRACTED_LAST_STEP_WD folders.",
1190
+ "Missing files.", wx.OK | wx.ICON_INFORMATION) as dlg:
1191
+ dlg.ShowModal()
1192
+ with open(path_bat_file, "w") as bat_file:
1193
+ for a, b in zip(A, B):
1194
+ line = f'"{path_code}" filling in="{a}" out="{b}" mask="{C}" dem="{D} avoid_last=1"\n'
1195
+ bat_file.write(line)
1196
+ logging.info(message_info)
1197
+
1198
+ empty_folder(self._manager.IN_SA_INTERP)
1199
+ path_bat_file = os.path.join(self._manager.IN_SCEN_DIR, "process_files.bat")
1200
+
1201
+ # FORTRAN HOLES.EXE
1202
+ subprocess.run([path_bat_file], check=True)
1203
+ path_fichier=self._manager.IN_SA_INTERP
1204
+ for file in path_fichier.glob("*.tif"):
1205
+ if "_h" in file.name:
1206
+ new_name = file.stem.split("_h")[0].replace(".bin", "") + ".tif"
1207
+ file.rename(file.with_name(new_name))
1208
+ renamed_files.append(new_name)
1209
+ #deleting the other
1210
+ for file in path_fichier.glob("*.tif"):
1211
+ if "_combl" in file.name or file.name not in renamed_files:
1212
+ file.unlink()
1213
+ else:
1214
+ #Python eikonal model
1215
+ from ..eikonal import inpaint_array, inpaint_waterlevel
1216
+
1217
+ dtm = WolfArray(D)
1218
+
1219
+ A=[]
1220
+ for path in checked_paths:
1221
+ parts = path.name.split("sim_")
1222
+ A.extend([os.path.join(path_LastSteps, g) for g in os.listdir(path_LastSteps) if g.endswith(f"{parts[1]}.tif")])
1223
+ if not A or not C or not D:
1224
+ logging.info("Missing files.")
1225
+ with wx.MessageDialog(self, f"The interpolation cannot go on, as some files are missing (see logs): please check the DEM_FILES or the EXTRACTED_LAST_STEP_WD folders.",
1226
+ "Missing files.", wx.OK | wx.ICON_INFORMATION) as dlg:
1227
+ dlg.ShowModal()
1228
+
1229
+ empty_folder(self._manager.IN_SA_INTERP)
1230
+
1231
+ for a in A:
1232
+ a = Path(a)
1233
+ in_wa = WolfArray(a)
1234
+ dem_wa = WolfArray(a.parent / a.stem / "_dem.tif")
1235
+ _t, _wse, _wd = inpaint_waterlevel(in_wa.array, dem_wa.array.data, dtm.array.data, ignore_last_patches=1)
1236
+
1237
+ b = os.path.join(path_Interp, os.path.splitext(os.path.basename(a))[0])
1238
+ new_name = Path(b).with_suffix('.tif')
1200
1239
  renamed_files.append(new_name)
1201
- #deleting the other
1202
- for file in path_fichier.glob("*.tif"):
1203
- if "_combl" in file.name or file.name not in renamed_files:
1204
- file.unlink()
1240
+
1241
+ in_wa.array.data[:,:] = _wd
1242
+ in_wa.array.mask[:,:] = _wd == 0.
1243
+ in_wa.write_all(new_name)
1244
+
1205
1245
  logging.info("Filling completed.")
1206
1246
  with wx.MessageDialog(self, f"Filling completed. Created files : {renamed_files}",
1207
1247
  "Redirecting", wx.OK | wx.ICON_INFORMATION) as dlg:
@@ -287,14 +287,14 @@ class Accept_Manager():
287
287
 
288
288
  self.scenario:str = str(self._scenario)
289
289
 
290
-
290
+
291
291
  self.IN_SA_BASE = self.IN_WATER_DEPTH / self.SA.stem / "Scenario_baseline"
292
292
  self.IN_SA_BASE_INTERP = self.IN_SA_BASE / "INTERP_WD"
293
-
293
+
294
294
  self.IN_SCEN_DIR = self.IN_WATER_DEPTH / self.SA.stem / self.scenario
295
295
  self.IN_SA_INTERP = self.IN_SCEN_DIR / "INTERP_WD"
296
296
  self.IN_SA_EXTRACTED = self.IN_SCEN_DIR / "EXTRACTED_LAST_STEP_WD"
297
- self.IN_SA_DEM = self.IN_SCEN_DIR / "DEM_FILES"
297
+ self.IN_SA_DEM = self.IN_SCEN_DIR / "DEM_FILES"
298
298
  self.IN_CH_SA_SC = self.IN_CH_VULN /self.SA.stem / self.scenario
299
299
  self.IN_CH_SA_SC_MNT_VRT = self.IN_CH_SA_SC / "__MNT_assembly.vrt"
300
300
  self.IN_CH_SA_SC_MNT_tif = self.IN_CH_SA_SC / "MNTassembly"
@@ -312,19 +312,19 @@ class Accept_Manager():
312
312
 
313
313
  self.OUT_WITHVULN = self.OUT_SCEN_DIR / "vuln_ scenarios"
314
314
  self.OUT_VULN_VRT = self.OUT_WITHVULN / "__vuln_assembly.vrt"
315
- self.OUT_VULN_S = self.OUT_WITHVULN / "Vulnerability_scenarios"
315
+ self.OUT_VULN_S = self.OUT_WITHVULN / "Vulnerability_scenarios"
316
316
  self.OUT_VULN_Stif = self.OUT_WITHVULN / "Vulnerability_scenarios.tif"
317
317
  self.OUT_MASKED_RIVER_S = self.OUT_WITHVULN / "Masked_River_extent_scenarios.tiff"
318
318
  self.OUT_ACCEPT_Stif = self.OUT_WITHVULN / "Acceptability_scenarios.tiff"
319
319
  self.OUT_ACCEPT_RESAMP_Stif = self.OUT_WITHVULN / "Acceptability_scenarios_resampled.tiff"
320
-
320
+
321
321
  self.OUT_BASELINE = self.OUT_SCEN_DIR / "baseline"
322
322
  self.OUT_VULN = self.OUT_BASELINE / "Vulnerability_baseline.tiff"
323
323
  self.OUT_CODE = self.OUT_BASELINE / "Vulnerability_Code_baseline.tiff"
324
324
  self.OUT_MASKED_RIVER = self.OUT_BASELINE / "Masked_River_extent_baseline.tiff"
325
325
  self.OUT_ACCEPT = self.OUT_BASELINE / "Acceptability_baseline.tiff"
326
326
  self.OUT_ACCEPT_RESAMP = self.OUT_BASELINE / "Acceptability_baseline_resampled.tiff"
327
-
327
+
328
328
  else:
329
329
  self.scenario = None
330
330
 
@@ -472,7 +472,7 @@ class Accept_Manager():
472
472
  sims = self.get_sims_files_for_scenario()
473
473
 
474
474
  if len(sims)==0:
475
- logging.info("No simulations found at this stage")
475
+ logging.info("No simulations found at this stage")
476
476
  return None
477
477
 
478
478
  if "_h.tif" in sims[0].name:
@@ -561,7 +561,7 @@ class Accept_Manager():
561
561
  os.path.join(os.path.dirname(path), os.path.basename(path).replace("Q", "T"))
562
562
  for path in sims
563
563
  ]
564
-
564
+
565
565
  if len(sims)==0:
566
566
  logging.info("No simulations found at this stage.")
567
567
  return []
@@ -570,22 +570,22 @@ class Accept_Manager():
570
570
  # searching for the position of the return period in the name
571
571
  idx_T = [Path(cursim).name.find("T") for cursim in sims_modif]
572
572
  idx_h = [Path(cursim).name.find(".tif") for cursim in sims_modif]
573
-
573
+
574
574
  # create the list of return periods -- only the numeric part
575
575
  sims = [int(Path(cursim).name[idx_T[i]+1:idx_h[i]]) for i, cursim in enumerate(sims_modif)]
576
576
  return sorted(sims)
577
-
577
+
578
578
  def get_modifiedrasters(self):
579
579
  folder = Path(self.IN_CH_SA_SC)
580
580
  vuln_tiff_files = [str(file.name) for file in folder.rglob("*.tiff") if file.name.startswith('vuln_')]
581
581
  vuln_tif_files = [str(file.name)for file in folder.rglob("*.tif") if file.name.startswith('vuln_')]
582
- vuln_files = vuln_tiff_files + vuln_tif_files
582
+ vuln_files = vuln_tiff_files + vuln_tif_files
583
583
 
584
584
  folder = Path(self.IN_CH_SA_SC)
585
585
  mnt_tiff_files = [str(file.name) for file in folder.rglob("*.tiff") if file.name.startswith('MNTmodifs_')]
586
586
  mnt_tif_files = [str(file.name) for file in folder.rglob("*.tif") if file.name.startswith('MNTmodifs_')]
587
587
  mnt_files = mnt_tiff_files + mnt_tif_files
588
-
588
+
589
589
  return vuln_files + mnt_files
590
590
 
591
591
  def get_ponderations(self) -> pd.DataFrame:
@@ -732,7 +732,7 @@ class Accept_Manager():
732
732
  self.OUT_SCEN_DIR.mkdir(parents=True, exist_ok=True)
733
733
  self.OUT_WITHVULN.mkdir(parents=True, exist_ok=True)
734
734
  self.OUT_BASELINE.mkdir(parents=True, exist_ok=True)
735
-
735
+
736
736
 
737
737
  return True
738
738
 
@@ -898,15 +898,15 @@ class Accept_Manager():
898
898
 
899
899
  if len(code) == 0:
900
900
  logging.error("The code rasters do not exist")
901
- return False
901
+ return ["The code rasters do not exist"]
902
902
 
903
903
  if len(vuln) == 0:
904
904
  logging.error("The vulnerability rasters do not exist")
905
- return False
905
+ return ["The vulnerability rasters do not exist"]
906
906
 
907
907
  if len(code) != len(vuln):
908
908
  logging.error("The number of code and vulnerability rasters do not match")
909
- return False
909
+ return ["The number of code and vulnerability rasters do not match"]
910
910
 
911
911
  # we take a reference raster
912
912
  ref = gdal.Open(str(code[0]))
@@ -982,14 +982,18 @@ class Accept_Manager():
982
982
 
983
983
  def check_nodata(self, name, path_baseline):
984
984
  """ Check nodata in a path """
985
+ from ..wolf_array import WOLF_ARRAY_FULL_INTEGER8
985
986
  list_tif = Accept_Manager.select_name_tif(self, path_baseline, self.IN_CH_SA_SC, name)
986
987
  for cur_lst in list_tif:
987
988
  curarray:WolfArray = WolfArray(cur_lst)
988
- if curarray.nullvalue != 99999.:
989
- curarray.nullvalue = 99999.
990
- curarray.set_nullvalue_in_mask()
991
- curarray.write_all()
992
- logging.warning(_('nodata changed in favor of 99999. value for file {} !'.format(cur_lst)))
989
+ if curarray.wolftype != WOLF_ARRAY_FULL_INTEGER8:
990
+ if curarray.nullvalue != 99999.:
991
+ curarray.nullvalue = 99999.
992
+ curarray.set_nullvalue_in_mask()
993
+ curarray.write_all()
994
+ logging.warning(_('nodata changed in favor of 99999. value for file {} !'.format(cur_lst)))
995
+ else:
996
+ logging.info(_('nodata value is {} for file {} !'.format(curarray.nullvalue, cur_lst)))
993
997
 
994
998
  def create_vrtIfExists(self, fn_baseline, fn_scenario, fn_vrt, name):
995
999
  """ Create a vrt file from a path """
@@ -1026,7 +1030,7 @@ class Accept_Manager():
1026
1030
  dataset = None
1027
1031
 
1028
1032
  logging.info("All the existing .tif files have been copied to the destination directory.")
1029
-
1033
+
1030
1034
  def wich_river_trace(self):
1031
1035
  """ Searches for existing riverbed traces: if none ending with '_scenarios' are found, it selects the baseline trace."""
1032
1036
  trace = None
@@ -1037,8 +1041,8 @@ class Accept_Manager():
1037
1041
  else :
1038
1042
  logging.error("No Masked_River_extent files. Please provide them.")
1039
1043
  return trace
1040
-
1041
-
1044
+
1045
+
1042
1046
 
1043
1047
 
1044
1048
  def clip_layer(layer:str,
@@ -1503,7 +1507,7 @@ def match_vulnerability2sim(inRas:Path, outRas:Path, MODREC:Path):
1503
1507
  :param MODREC: the MODREC/simulation extent file
1504
1508
 
1505
1509
  """
1506
-
1510
+
1507
1511
  inRas = str(inRas)
1508
1512
  outRas = str(outRas)
1509
1513
  MODREC = str(MODREC)
@@ -1524,7 +1528,7 @@ def update_accept(accept, model_h, ij, bounds, loc_accept):
1524
1528
  for idx in range(len(bounds)):
1525
1529
  for i,j in ij:
1526
1530
  #lit dans wd vs Ti où on est et associe son score d'accept
1527
- if bounds[idx,0] < model_h[i,j] <= bounds[idx,1]:
1531
+ if bounds[idx,0] < model_h[i,j] <= bounds[idx,1]:
1528
1532
  accept[i,j] = loc_accept[idx]
1529
1533
 
1530
1534
  def compute_acceptability(manager:Accept_Manager,
@@ -1569,6 +1573,8 @@ def compute_acceptability(manager:Accept_Manager,
1569
1573
  points_accept["h-1"][idx_pts],
1570
1574
  points_accept["h-2.5"][idx_pts]]
1571
1575
 
1576
+ accept_pts = list(accept_pts).copy()
1577
+
1572
1578
  update_accept(accept, model_h, ij, bounds, accept_pts)
1573
1579
 
1574
1580
  if save_to_file:
@@ -1666,6 +1672,8 @@ def shp_to_raster(vector_fn:str | Path, raster_fn:str | Path, pixel_size:float =
1666
1672
  layer = source_layer,
1667
1673
  burn_values = [1],
1668
1674
  options=["ALL_TOUCHED=TRUE"])
1675
+
1676
+ target_ds.FlushCache()
1669
1677
  target_ds = None
1670
1678
  vector_fn = raster_fn = None
1671
1679
 
wolfhece/apps/version.py CHANGED
@@ -4,8 +4,8 @@ class WolfVersion():
4
4
  def __init__(self):
5
5
 
6
6
  self.major = 2
7
- self.minor = 1
8
- self.patch = 129
7
+ self.minor = 2
8
+ self.patch = 2
9
9
 
10
10
  def __str__(self):
11
11
 
wolfhece/eikonal.py CHANGED
@@ -78,7 +78,7 @@ def __solve_eikonal_with_data(sources:list[list[int,int]],
78
78
  # store the fixed points
79
79
  # - fix sources points
80
80
  # - fix every first element of the heap after pop
81
- fixed = np.zeros(speed.shape, dtype = np.bool8)
81
+ fixed = np.zeros(speed.shape, dtype = np.uint8)
82
82
 
83
83
  # fix the border
84
84
  fixed[:, 0] = True
@@ -33,8 +33,8 @@ else:
33
33
  print(_('Note: do not forget to install the graphviz app and add it to the PATH to make it work'))
34
34
  # --------------------------------
35
35
 
36
- from ..wolf_texture import genericImagetexture
37
- from ..PyDraw import WolfMapViewer
36
+ # from ..wolf_texture import genericImagetexture
37
+ # from ..PyDraw import WolfMapViewer
38
38
  from .SubBasin import *
39
39
  from .RetentionBasin import *
40
40
  from .read import *