wolfhece 2.2.27__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.
@@ -637,6 +637,8 @@ class vectorproperties:
637
637
 
638
638
  self.used=True
639
639
 
640
+ self.plot_indices = False
641
+
640
642
  self._values = {}
641
643
 
642
644
  # FIXME : to be changed
@@ -699,6 +701,8 @@ class vectorproperties:
699
701
  self.imagevisible = False
700
702
  self.textureimage:genericImagetexture = None
701
703
 
704
+ self.plot_indices = False
705
+
702
706
  def get_extra(self) -> list[float,float,int,float,str,bool]:
703
707
  """ Return extra properties """
704
708
  return [self.legendlength,
@@ -706,7 +710,8 @@ class vectorproperties:
706
710
  self.legendpriority,
707
711
  self.legendorientation,
708
712
  str(self.attachedimage),
709
- self.imagevisible]
713
+ self.imagevisible,
714
+ self.plot_indices]
710
715
 
711
716
  def set_extra(self, linesextra:list[float,float,int,float,str,bool] = None):
712
717
  """ Set extra properties """
@@ -725,6 +730,9 @@ class vectorproperties:
725
730
  self.attachedimage = Path(linesextra[4])
726
731
  self.imagevisible = linesextra[5].lower() == 'true'
727
732
 
733
+ if len(linesextra)>6:
734
+ self.plot_indices = linesextra[6].lower() == 'true'
735
+
728
736
  def load_extra(self, lines:list[str]) -> int:
729
737
  """ Load extra properties from lines """
730
738
 
@@ -817,7 +825,7 @@ class vectorproperties:
817
825
 
818
826
  self.color = getIfromRGB(props[('Draw','Color')])
819
827
  self.width = props[('Draw','Width')]
820
- self.style = props[('Draw','Style')]
828
+ # self.style = props[('Draw','Style')]
821
829
 
822
830
  old_closed = self.closed
823
831
  self.closed = props[('Draw','Closed')]
@@ -828,7 +836,8 @@ class vectorproperties:
828
836
  self.filled = props[('Draw','Filled')]
829
837
  self.transparent = props[('Draw','Transparent')]
830
838
  self.alpha = props[('Draw','Alpha')]
831
- self.flash = props[('Draw','Flash')]
839
+ # self.flash = props[('Draw','Flash')]
840
+ self.plot_indices = props[('Draw','Plot indices if active')]
832
841
 
833
842
  self.legendunderlined = props[('Legend','Underlined')]
834
843
  self.legendbold = props[('Legend','Bold')]
@@ -928,14 +937,18 @@ class vectorproperties:
928
937
 
929
938
  self.myprops.hide_selected_buttons() # only 'Apply' button
930
939
 
940
+ self.myprops.addparam('Geometry','Length 2D',99999.,Type_Param.Float,'',whichdict='Default')
941
+ self.myprops.addparam('Geometry','Length 3D',99999.,Type_Param.Float,'',whichdict='Default')
942
+ self.myprops.addparam('Geometry','Surface',99999.,Type_Param.Float,'',whichdict='Default')
943
+
931
944
  self.myprops.addparam('Draw','Color',(0,0,0),'Color','Drawing color',whichdict='Default')
932
945
  self.myprops.addparam('Draw','Width',1,'Integer','Drawing width',whichdict='Default')
933
- self.myprops.addparam('Draw','Style',1,'Integer','Drawing style',whichdict='Default')
946
+ # self.myprops.addparam('Draw','Style',1,'Integer','Drawing style',whichdict='Default')
934
947
  self.myprops.addparam('Draw','Closed',False,'Logical','',whichdict='Default')
935
948
  self.myprops.addparam('Draw','Filled',False,'Logical','',whichdict='Default')
936
949
  self.myprops.addparam('Draw','Transparent',False,'Logical','',whichdict='Default')
937
950
  self.myprops.addparam('Draw','Alpha',0,'Integer','Transparency intensity (255 is opaque)',whichdict='Default')
938
- self.myprops.addparam('Draw','Flash',False,'Logical','',whichdict='Default')
951
+ # self.myprops.addparam('Draw','Flash',False,'Logical','',whichdict='Default')
939
952
 
940
953
  self.myprops.addparam('Legend','Visible',False,'Logical','',whichdict='Default')
941
954
 
@@ -991,10 +1004,6 @@ if :\n \
991
1004
  self.myprops.addparam('Image','Attached image','',Type_Param.File, '', whichdict='Default')
992
1005
  self.myprops.addparam('Image','To show',False,Type_Param.Logical,'',whichdict='Default')
993
1006
 
994
- self.myprops.addparam('Geometry','Length 2D',99999.,Type_Param.Float,'',whichdict='Default')
995
- self.myprops.addparam('Geometry','Length 3D',99999.,Type_Param.Float,'',whichdict='Default')
996
- self.myprops.addparam('Geometry','Surface',99999.,Type_Param.Float,'',whichdict='Default')
997
-
998
1007
  def destroyprop(self):
999
1008
  """
1000
1009
  Nullify the properties UI
@@ -1063,14 +1072,20 @@ if :\n \
1063
1072
  """ Update the properties """
1064
1073
 
1065
1074
  if self.myprops is not None:
1075
+ self.parent.update_lengths()
1076
+ self.myprops[( 'Geometry','Length 2D')] = self.parent.length2D if self.parent.length2D is not None else 0.
1077
+ self.myprops[( 'Geometry','Length 3D')] = self.parent.length3D if self.parent.length3D is not None else 0.
1078
+ self.myprops[( 'Geometry','Surface')] = self.parent.area if self.parent.area is not None else 0.
1079
+
1066
1080
  self.myprops[('Draw','Color')] = getRGBfromI(self.color)
1067
1081
  self.myprops[('Draw','Width')] = self.width
1068
- self.myprops[('Draw','Style')] = self.style
1082
+ # self.myprops[('Draw','Style')] = self.style
1069
1083
  self.myprops[('Draw','Closed')] = self.closed
1070
1084
  self.myprops[('Draw','Filled')] = self.filled
1071
1085
  self.myprops[('Draw','Transparent')]= self.transparent
1072
1086
  self.myprops[('Draw','Alpha')] = self.alpha
1073
- self.myprops[('Draw','Flash')] = self.flash
1087
+ # self.myprops[('Draw','Flash')] = self.flash
1088
+ self.myprops[('Draw','Plot indices if active')] = self.plot_indices
1074
1089
 
1075
1090
  self.myprops[('Legend','Visible')] = self.legendvisible
1076
1091
  self.myprops[('Legend','Text')] = self.legendtext
@@ -1123,11 +1138,6 @@ if :\n \
1123
1138
  self.myprops[('Move','Delta X')] = 0.
1124
1139
  self.myprops[('Move','Delta Y')] = 0.
1125
1140
 
1126
- self.parent.update_lengths()
1127
- self.myprops[( 'Geometry','Length 2D')] = self.parent.length2D if self.parent.length2D is not None else 0.
1128
- self.myprops[( 'Geometry','Length 3D')] = self.parent.length3D if self.parent.length3D is not None else 0.
1129
- self.myprops[( 'Geometry','Surface')] = self.parent.area if self.parent.area is not None else 0.
1130
-
1131
1141
  self.myprops.Populate()
1132
1142
  class vector:
1133
1143
  """
@@ -2124,6 +2134,99 @@ class vector:
2124
2134
  else:
2125
2135
  return [self.myvertices]
2126
2136
 
2137
+ def _plot_square_at_vertices(self, size=5):
2138
+ """
2139
+ Plot small squares at each vertex, in OpenGL
2140
+ """
2141
+
2142
+ if self.nbvertices == 0:
2143
+ return
2144
+
2145
+ curvert: wolfvertex
2146
+ ongoing = True
2147
+
2148
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
2149
+ # if filled:
2150
+ # glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
2151
+
2152
+ glPointSize(size)
2153
+ rgb = getRGBfromI(self.myprop.color)
2154
+ glBegin(GL_POINTS)
2155
+ for curvert in self.myvertices:
2156
+ glColor3ub(int(rgb[0]), int(rgb[1]), int(rgb[2]))
2157
+ glVertex2f(curvert.x, curvert.y)
2158
+ glEnd()
2159
+
2160
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
2161
+
2162
+ ongoing = False
2163
+
2164
+ def _plot_index_vertex(self, idx:int = None, xy:tuple[float,float] = None,
2165
+ sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None):
2166
+ """
2167
+ Plot OpenGL
2168
+
2169
+ :param idx: index of the vertex to plot
2170
+ :param xy: coordinates (x,y) of the vertex to plot
2171
+ :param sx: scale x
2172
+ :param sy: scale y
2173
+ :param xmin: minimum x
2174
+ :param ymin: minimum y
2175
+ :param xmax: maximum x
2176
+ :param ymax: maximum y
2177
+ :param size: size of the text
2178
+ """
2179
+ if self.get_mapviewer() is None:
2180
+ logging.warning(_('No mapviewer available for legend plot'))
2181
+ return
2182
+
2183
+ if xy is not None:
2184
+ x, y = xy
2185
+ curvert = self.find_nearest_vert(x, y)
2186
+ idx = self.myvertices.index(curvert)
2187
+ elif idx is not None:
2188
+ if idx < 0 or idx >= self.nbvertices:
2189
+ logging.warning(_('Index {} out of range for vector {}').format(idx, self.myname))
2190
+ return
2191
+ curvert = self.myvertices[idx]
2192
+ else:
2193
+ logging.warning(_('No index or coordinates provided for plotting index vertex'))
2194
+ return
2195
+
2196
+ if not (xmin is None or ymin is None or xmax is None or ymax is None):
2197
+ if curvert.x < xmin or curvert.x > xmax or curvert.y < ymin or curvert.y > ymax:
2198
+ logging.debug(_('Vertex {} at ({},{}) is out of bounds ({},{},{},{}))'.format(idx, curvert.x, curvert.y, xmin, ymin, xmax, ymax)))
2199
+ return
2200
+
2201
+ self._textimage = Text_Image_Texture(str(idx+1),
2202
+ self.get_mapviewer(), # mapviewer de l'instance Zones qui contient le vecteur
2203
+ self._get_textfont_idx(),
2204
+ self,
2205
+ curvert.x,
2206
+ curvert.y)
2207
+ self._textimage.paint()
2208
+
2209
+ def _plot_all_indices(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None):
2210
+ """
2211
+ Plot all indices of the vertices in OpenGL
2212
+ :param sx: scale x
2213
+ :param sy: scale y
2214
+ :param xmin: minimum x
2215
+ :param ymin: minimum y
2216
+ :param xmax: maximum x
2217
+ :param ymax: maximum y
2218
+ :param size: size of the text
2219
+ """
2220
+ if self.get_mapviewer() is None:
2221
+ logging.warning(_('No mapviewer available for legend plot'))
2222
+ return
2223
+ if self.nbvertices == 0:
2224
+ logging.warning(_('No vertices to plot indices for vector {}').format(self.myname))
2225
+ return
2226
+ if self.myprop.used:
2227
+ for idx in range(self.nbvertices):
2228
+ self._plot_index_vertex(idx=idx, sx=sx, sy=sy, xmin=xmin, ymin=ymin, xmax=xmax, ymax=ymax, size=size)
2229
+
2127
2230
  def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None):
2128
2231
  """
2129
2232
  Plot OpenGL
@@ -2279,10 +2382,12 @@ class vector:
2279
2382
  ax.fill([curvert.x for curvert in self.myvertices], [curvert.y for curvert in self.myvertices], color=(rgb[0]/255.,rgb[1]/255.,rgb[2]/255.))
2280
2383
  else:
2281
2384
  rgb=getRGBfromI(self.myprop.color)
2282
- if self.myprop.transparent:
2283
- ax.plot([curvert.x for curvert in self.myvertices], [curvert.y for curvert in self.myvertices], color=(rgb[0]/255.,rgb[1]/255.,rgb[2]/255.,self.myprop.alpha), linewidth=self.myprop.width)
2284
- else:
2285
- ax.plot([curvert.x for curvert in self.myvertices], [curvert.y for curvert in self.myvertices], color=(rgb[0]/255.,rgb[1]/255.,rgb[2]/255.), linewidth=self.myprop.width)
2385
+ subpoly = self.get_subpolygons()
2386
+ for curpoly in subpoly:
2387
+ if self.myprop.transparent:
2388
+ ax.plot([curvert.x for curvert in curpoly], [curvert.y for curvert in curpoly], color=(rgb[0]/255.,rgb[1]/255.,rgb[2]/255.,self.myprop.alpha), linewidth=self.myprop.width)
2389
+ else:
2390
+ ax.plot([curvert.x for curvert in curpoly], [curvert.y for curvert in curpoly], color=(rgb[0]/255.,rgb[1]/255.,rgb[2]/255.), linewidth=self.myprop.width)
2286
2391
 
2287
2392
  self.plot_legend_mpl(ax)
2288
2393
 
@@ -2302,6 +2407,21 @@ class vector:
2302
2407
 
2303
2408
  return tinfos
2304
2409
 
2410
+ def _get_textfont_idx(self):
2411
+ """ Retunr a 'Text_Infos' instance for the legend """
2412
+
2413
+ r,g,b = getRGBfromI(self.myprop.color)
2414
+ tinfos = Text_Infos(3,
2415
+ (1., 0.),
2416
+ self.myprop.legendfontname,
2417
+ 12,
2418
+ colour=(r,g,b,255),
2419
+ dimsreal=(self.myprop.legendlength,
2420
+ self.myprop.legendheight),
2421
+ relative_position=7)
2422
+
2423
+ return tinfos
2424
+
2305
2425
  def add2tree(self, tree:TreeListCtrl, root):
2306
2426
  """
2307
2427
  Ajout de l'objte à un TreeListCtrl wx
@@ -4111,7 +4231,7 @@ class zone:
4111
4231
  else:
4112
4232
  mypl = vector(name=self.active_vector.myname+"_duplicate")
4113
4233
  mypl.myvertices = [wolfvertex(cur.x,cur.y,cur.z) for cur in self.active_vector.myvertices]
4114
- # mypl.nbvertices = self.active_vector.nbvertices # No longer needed
4234
+
4115
4235
 
4116
4236
  if mypl is None:
4117
4237
  return
@@ -4567,7 +4687,6 @@ class zone:
4567
4687
  vr = sublsr.myvertices.copy()
4568
4688
  vr.reverse()
4569
4689
  curvec.myvertices = sublsl.myvertices.copy() + vr
4570
- # curvec.nbvertices = len(curvec.myvertices) FIXME Not needed anymore
4571
4690
  for curv in curvec.myvertices:
4572
4691
  curv.z = smean
4573
4692
  else:
@@ -4631,8 +4750,6 @@ class zone:
4631
4750
  curv.z = smean
4632
4751
  for curv in curvecright.myvertices:
4633
4752
  curv.z = smean
4634
- curvecleft.nbvertices = len(curvecleft.myvertices)
4635
- curvecright.nbvertices = len(curvecright.myvertices)
4636
4753
  else:
4637
4754
  #left poly
4638
4755
  if sublsl.geom_type=='Point':
@@ -6932,7 +7049,11 @@ class Zones(wx.Frame, Element_To_Draw):
6932
7049
  box_s.Add(self.update_from_s,1,wx.EXPAND)
6933
7050
  box_s.Add(self.getxyfromsz,1,wx.EXPAND) # Added
6934
7051
 
6935
- boxright.Add(self.interpxyz,0,wx.EXPAND)
7052
+ box_interp_indices = wx.BoxSizer(wx.HORIZONTAL)
7053
+ box_interp_indices.Add(self.interpxyz,1,wx.EXPAND)
7054
+
7055
+ boxright.Add(box_interp_indices,0,wx.EXPAND)
7056
+
6936
7057
 
6937
7058
  _sizer_ascbuffer = wx.BoxSizer(wx.HORIZONTAL)
6938
7059
  _sizer_ascbuffer.Add(self.sascending,1,wx.EXPAND)
@@ -7556,6 +7677,16 @@ class Zones(wx.Frame, Element_To_Draw):
7556
7677
  self.mapviewer.mimicme()
7557
7678
  self.active_zone.reset_listogl()
7558
7679
 
7680
+ def OnPlotIndices(self, event:wx.MouseEvent):
7681
+ """
7682
+ Plot the indices of the active vector in the mapviewer
7683
+ """
7684
+
7685
+ if self.wx_exists:
7686
+ if self.verify_activevec():
7687
+ return
7688
+ self.mapviewer._force_to_plot_indices = True
7689
+
7559
7690
  def Onzoom(self, event:wx.MouseEvent):
7560
7691
  """
7561
7692
  Zoom sur le vecteur actif dans le mapviewer
wolfhece/PyWMS.py CHANGED
@@ -293,9 +293,12 @@ def getNGI(cat:Literal['orthoimage_coverage',
293
293
  tofile=True,
294
294
  format:Literal['image/png', 'image/GeoTIFF']='image/png') -> BytesIO:
295
295
 
296
- wms=WebMapService(f'https://wms.ngi.be/inspire/ortho/service?',
297
- version='1.3.0', timeout=10)
298
-
296
+ try:
297
+ wms=WebMapService(f'https://wms.ngi.be/inspire/ortho/service?',
298
+ version='1.3.0', timeout=10)
299
+ except:
300
+ logging.warning(_('Impossible to get data from web services'))
301
+ return None
299
302
  ppkm = 300
300
303
  if w is None and h is None:
301
304
  real_w = (xr-xl)/1000
wolfhece/__init__.py CHANGED
@@ -11,10 +11,37 @@ except ImportError as e:
11
11
  # print(e)
12
12
  raise Exception(_('Error importing GDAL library\nPlease ensure GDAL is installed and the Python bindings are available\n\ngdal wheels can be found at https://github.com/cgohlke/geospatial-wheels'))
13
13
 
14
+ try:
15
+ import pyproj
16
+ except ImportError as e:
17
+ raise ImportError(_('pyproj is not installed. Please install it to use this function.')) from e
18
+
14
19
  from .apps.version import WolfVersion
15
20
  from packaging.version import Version
21
+ from pathlib import Path
22
+
23
+
24
+ def ensure_ntv2grid_exists():
25
+ """
26
+ Check if the NTV2 grid file exists in the expected location.
27
+ """
28
+
29
+ from shutil import copyfile
30
+
31
+ # print('Version de pyproj :', pyproj.__version__)
32
+ files = ['be_ign_bd72lb72_etrs89lb08.tif', 'be_ign_hBG18.tif', 'be_ign_README.txt']
33
+
34
+ pyproj_datadir = Path(pyproj.datadir.get_data_dir())
35
+
36
+ for file in files:
37
+ if not (pyproj_datadir / file).exists():
38
+ # copy the NTV2 grid file to the pyproj data directory
39
+ ntv2_grid_path = Path(__file__).parent / 'lb7208_ntv2' / file
40
+ copyfile(ntv2_grid_path, pyproj_datadir / file)
41
+ print(f"Copied {file} to {pyproj_datadir}")
16
42
 
17
43
  __version__ = WolfVersion().get_version()
44
+ ensure_ntv2grid_exists()
18
45
 
19
46
  def is_enough(version: str) -> bool:
20
47
  """
@@ -8,7 +8,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
10
 
11
- from .Parallels import parallel_gpd_clip, parallel_v2r, parallel_datamod
11
+ from .Parallels import parallel_gpd_clip, parallel_v2r, parallel_datamod
12
12
  from .func import data_modification, compute_vulnerability, compute_vulnerability4scenario
13
13
  from .func import match_vulnerability2sim, compute_acceptability, shp_to_raster, clip_layer
14
14
  from .func import Accept_Manager, cleaning_directory, EXTENT, Vulnerability_csv, compute_code
@@ -316,13 +316,13 @@ def Vulnerability(main_dir:str = 'Data',
316
316
 
317
317
  """
318
318
 
319
- #Call of the Manager Class --> allows structure
319
+ #Call of the Manager Class --> allows structure
320
320
  manager = Accept_Manager(main_dir,
321
321
  Study_area,
322
322
  scenario=scenario,
323
323
  Vuln_csv=Vuln_csv,
324
324
  Intermediate_csv=Intermediate_csv)
325
-
325
+
326
326
  if not manager.check_before_vulnerability():
327
327
  logging.error("The necessary files are missing - Verify logs for more information")
328
328
  return
@@ -340,7 +340,7 @@ def Vulnerability(main_dir:str = 'Data',
340
340
  cleaning_directory(manager.TMP_SCEN_DIR)
341
341
 
342
342
  if 10 in steps or steps_vulnerability.CREATE_RASTERS_VULN in steps:
343
- compute_vulnerability(manager)
343
+ compute_vulnerability(manager)
344
344
  done.append(steps_vulnerability.CREATE_RASTERS_VULN)
345
345
 
346
346
  if 11 in steps or steps_vulnerability.CREATE_RASTERS_CODE in steps:
@@ -382,12 +382,12 @@ def Vulnerability(main_dir:str = 'Data',
382
382
  if TMAX is None:
383
383
  logging.error("The file for the maximum return period is missing")
384
384
  return
385
-
385
+
386
386
  match_vulnerability2sim(manager.SA_MASKED_RIVER, manager.OUT_MASKED_RIVER, TMAX)
387
387
  match_vulnerability2sim(manager.SA_VULN, manager.OUT_VULN, TMAX)
388
388
  match_vulnerability2sim(manager.SA_CODE, manager.OUT_CODE, TMAX)
389
389
  done.append(steps_vulnerability.MATCH_SIMUL)
390
-
390
+
391
391
  if 4 in steps or steps_vulnerability.APPLY_SCENARIOSVULN in steps:
392
392
  if os.path.exists(manager.OUT_VULN):
393
393
  existence=False
@@ -398,7 +398,7 @@ def Vulnerability(main_dir:str = 'Data',
398
398
  else :
399
399
  logging.error(f"The baseline vulnerability does not exist ({manager.OUT_VULN}). Please, compute first the vulnerability without scenarios vuln_.")
400
400
  done.append(steps_vulnerability.APPLY_SCENARIOSVULN)
401
- #Delete _scenario folder is no scenario
401
+ #Delete _scenario folder is no scenario
402
402
  if os.path.isdir(manager.OUT_WITHVULN) and not os.listdir(manager.OUT_WITHVULN):
403
403
  os.rmdir(manager.OUT_WITHVULN)
404
404
  return done
@@ -409,7 +409,7 @@ def Acceptability(main_dir:str = 'Vesdre',
409
409
  coeff_auto:bool = True,
410
410
  Ponderation_csv:str = 'Ponderation.csv',
411
411
  resample_size:int = 100,
412
- steps:list[int] | list[steps_acceptability] = [1,2,3,4,5,6]):
412
+ steps:list[int] | list[steps_acceptability] = [1,2,3,4,5,6]):
413
413
  """ Compute acceptability for the scenario """
414
414
 
415
415
  done = []
@@ -418,30 +418,35 @@ def Acceptability(main_dir:str = 'Vesdre',
418
418
  Study_area,
419
419
  scenario=scenario,
420
420
  Ponderation_csv=Ponderation_csv)
421
-
422
- # Load the vulnerability raster **for the scenario**, and check if an assembly exists and is asked by the user
423
- # Initialization of lists to read/ write according to the needed steps
421
+
422
+ # Load the vulnerability raster **for the scenario**, and check if an assembly exists and is asked by the user
423
+ # Initialization of lists to read/ write according to the needed steps
424
424
  VulneToCompute, PathsToSaveA, PathsToSaveA100 = [], [], []
425
- if 4 in steps or steps_acceptability.COMPUTE_BASELINE_WITHOUT_SCENARIOS in steps:
425
+ if 4 in steps or steps_acceptability.COMPUTE_BASELINE_WITHOUT_SCENARIOS in steps:
426
426
  VulneToCompute.append(manager.OUT_VULN)
427
427
  PathsToSaveA.append(manager.OUT_ACCEPT)
428
428
  PathsToSaveA100.append(manager.OUT_ACCEPT_RESAMP)
429
429
  river_trace = manager.OUT_MASKED_RIVER
430
430
 
431
- if 5 in steps or steps_acceptability.COMPUTE_WITH_SCENARIOS in steps:
432
- river_trace = manager.wich_river_trace()
431
+ if 5 in steps or steps_acceptability.COMPUTE_WITH_SCENARIOS in steps:
432
+ river_trace = manager.wich_river_trace()
433
433
  change_vuln_files = [Path(a) for a in glob.glob(str(manager.IN_CH_SA_SC / "vuln_*.tif")) + glob.glob(str(manager.IN_CH_SA_SC / "vuln_*.tiff"))]
434
434
  if len(change_vuln_files) != 0:
435
435
  VulneToCompute.append(manager.OUT_VULN_Stif)
436
436
  PathsToSaveA.append(manager.OUT_ACCEPT_Stif)
437
437
  PathsToSaveA100.append(manager.OUT_ACCEPT_RESAMP_Stif)
438
- else :
438
+ else :
439
439
  logging.info("No vulnerability rasters in CHANGE_VULNE. The code goes on without them.")
440
+
441
+ if len(VulneToCompute) == 0:
442
+ logging.error("No vulnerability rasters to compute acceptability. Please, compute the vulnerability first.")
443
+ return done
444
+
440
445
  for i in range(len(VulneToCompute)) :
441
446
  vulne = gdal.Open(str(VulneToCompute[i]))
442
447
  saveA = PathsToSaveA[i]
443
448
  saveA100 = PathsToSaveA100[i]
444
- # Load the river mask
449
+ # Load the river mask
445
450
  riv = gdal.Open(str(river_trace))
446
451
 
447
452
  # Get the geotransform and projection for the output tiff
@@ -566,7 +571,7 @@ def Acceptability(main_dir:str = 'Vesdre',
566
571
 
567
572
  comb += part_accept[curT] * float(pond["Ponderation"][curT])
568
573
 
569
- y_pixels, x_pixels = comb.shape
574
+ y_pixels, x_pixels = comb.shape
570
575
 
571
576
  driver = gdal.GetDriverByName('GTiff')
572
577
 
@@ -583,14 +588,14 @@ def Acceptability(main_dir:str = 'Vesdre',
583
588
  dataset.SetGeoTransform(geotrans)
584
589
  dataset.SetProjection(proj)
585
590
  band = dataset.GetRasterBand(1)
586
- band.WriteArray(comb)
587
- band.FlushCache()
591
+ band.WriteArray(comb)
592
+ band.FlushCache()
588
593
  dataset.SetGeoTransform(geotrans)
589
594
  dataset.SetProjection(proj)
590
595
  dataset = None
591
596
 
592
597
  done.append(steps_acceptability.COMPUTE_MEAN_ACCEPT)
593
-
598
+
594
599
  if 6 in steps or steps_acceptability.RESAMPLING in steps:
595
600
  if os.path.exists(manager.OUT_ACCEPT):
596
601
  Agg = gdal.Warp(str(saveA100),