wolfhece 2.2.38__py3-none-any.whl → 2.2.40__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 (50) hide show
  1. wolfhece/Coordinates_operations.py +5 -0
  2. wolfhece/GraphNotebook.py +72 -1
  3. wolfhece/GraphProfile.py +1 -1
  4. wolfhece/MulticriteriAnalysis.py +1579 -0
  5. wolfhece/PandasGrid.py +62 -1
  6. wolfhece/PyCrosssections.py +194 -43
  7. wolfhece/PyDraw.py +891 -73
  8. wolfhece/PyGui.py +913 -72
  9. wolfhece/PyGuiHydrology.py +528 -74
  10. wolfhece/PyPalette.py +26 -4
  11. wolfhece/PyParams.py +33 -0
  12. wolfhece/PyPictures.py +2 -2
  13. wolfhece/PyVertex.py +25 -0
  14. wolfhece/PyVertexvectors.py +94 -28
  15. wolfhece/PyWMS.py +52 -36
  16. wolfhece/acceptability/acceptability.py +15 -8
  17. wolfhece/acceptability/acceptability_gui.py +507 -360
  18. wolfhece/acceptability/func.py +80 -183
  19. wolfhece/apps/version.py +1 -1
  20. wolfhece/compare_series.py +480 -0
  21. wolfhece/drawing_obj.py +12 -1
  22. wolfhece/hydrology/Catchment.py +228 -162
  23. wolfhece/hydrology/Internal_variables.py +43 -2
  24. wolfhece/hydrology/Models_characteristics.py +69 -67
  25. wolfhece/hydrology/Optimisation.py +893 -182
  26. wolfhece/hydrology/PyWatershed.py +267 -165
  27. wolfhece/hydrology/SubBasin.py +185 -140
  28. wolfhece/hydrology/cst_exchanges.py +76 -1
  29. wolfhece/hydrology/forcedexchanges.py +413 -49
  30. wolfhece/hydrology/read.py +65 -5
  31. wolfhece/hydrometry/kiwis.py +14 -7
  32. wolfhece/insyde_be/INBE_func.py +746 -0
  33. wolfhece/insyde_be/INBE_gui.py +1776 -0
  34. wolfhece/insyde_be/__init__.py +3 -0
  35. wolfhece/interpolating_raster.py +366 -0
  36. wolfhece/irm_alaro.py +1457 -0
  37. wolfhece/irm_qdf.py +889 -57
  38. wolfhece/lazviewer/laz_viewer.py +4 -1
  39. wolfhece/lifewatch.py +6 -3
  40. wolfhece/picc.py +124 -8
  41. wolfhece/pyLandUseFlanders.py +146 -0
  42. wolfhece/pydownloader.py +35 -1
  43. wolfhece/pywalous.py +225 -31
  44. wolfhece/toolshydrology_dll.py +149 -0
  45. wolfhece/wolf_array.py +63 -25
  46. {wolfhece-2.2.38.dist-info → wolfhece-2.2.40.dist-info}/METADATA +3 -1
  47. {wolfhece-2.2.38.dist-info → wolfhece-2.2.40.dist-info}/RECORD +50 -41
  48. {wolfhece-2.2.38.dist-info → wolfhece-2.2.40.dist-info}/WHEEL +0 -0
  49. {wolfhece-2.2.38.dist-info → wolfhece-2.2.40.dist-info}/entry_points.txt +0 -0
  50. {wolfhece-2.2.38.dist-info → wolfhece-2.2.40.dist-info}/top_level.txt +0 -0
wolfhece/PyPalette.py CHANGED
@@ -653,7 +653,6 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
653
653
  self.colors[2, :] = [255, 0, 0, 255] # Rouge
654
654
  self.fill_segmentdata()
655
655
 
656
-
657
656
  def set_values_colors(self,
658
657
  values: typing.Union[list[float], np.ndarray],
659
658
  colors: typing.Union[list[tuple[int]], np.ndarray]):
@@ -698,6 +697,16 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
698
697
 
699
698
  self.fill_segmentdata()
700
699
 
700
+ def set_values(self,
701
+ values: typing.Union[list[float], np.ndarray]):
702
+ """ Mise à jour des valeurs de la palette """
703
+
704
+ assert len(values) == self.nb, "Length of values must match the number of colors"
705
+
706
+ self.values = np.asarray(values, dtype=np.float64)
707
+
708
+ self.fill_segmentdata()
709
+
701
710
  def defaultgray(self):
702
711
  """Palette grise par défaut dans WOLF"""
703
712
 
@@ -882,7 +891,8 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
882
891
  self.nb = 2
883
892
  self.values = np.asarray([np.min(array), np.max(array)], dtype=np.float64)
884
893
  self.colors = np.asarray([[255, 255, 255, 255], [0, 0, 255, 255]], dtype=np.int32)
885
- self.colorsflt = np.asarray([[0., 0., 0., 1.], [1., 1., 1., 1.]], dtype=np.float64)
894
+ self.colorsflt = self.colors.astype(float)/255.
895
+ # self.colorsflt = np.asarray([[0., 0., 0., 1.], [1., 1., 1., 1.]], dtype=np.float64)
886
896
 
887
897
  self.fill_segmentdata()
888
898
 
@@ -892,7 +902,8 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
892
902
  self.nb = 2
893
903
  self.values = np.asarray([np.min(array), np.max(array)], dtype=np.float64)
894
904
  self.colors = np.asarray([[255, 255, 255, 255], [255, 0, 0, 255]], dtype=np.int32)
895
- self.colorsflt = np.asarray([[0., 0., 0., 1.], [1., 1., 1., 1.]], dtype=np.float64)
905
+ self.colorsflt = self.colors.astype(float)/255.
906
+ # self.colorsflt = np.asarray([[0., 0., 0., 1.], [1., 1., 1., 1.]], dtype=np.float64)
896
907
 
897
908
  self.fill_segmentdata()
898
909
 
@@ -902,6 +913,17 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
902
913
  self.nb = 2
903
914
  self.values = np.asarray([0., 1.], dtype=np.float64)
904
915
  self.colors = np.asarray([[255, 255, 255, 255], [0, 0, 255, 255]], dtype=np.int32)
905
- self.colorsflt = np.asarray([[0., 0., 0., 1.], [1., 1., 1., 1.]], dtype=np.float64)
916
+ self.colorsflt = self.colors.astype(float)/255.
917
+ # self.colorsflt = np.asarray([[0., 0., 0., 1.], [1., 1., 1., 1.]], dtype=np.float64)
918
+
919
+ self.fill_segmentdata()
920
+
921
+ def defaultblue3(self):
922
+ """Remplissage des valeurs de palette sur base d'une équirépartition de valeurs"""
923
+
924
+ self.nb = 3
925
+ self.values = np.asarray([0., 1., 10.], dtype=np.float64)
926
+ self.colors = np.asarray([[255, 255, 255, 255], [50, 130, 246, 255], [0, 0, 255, 255]], dtype=np.int32)
927
+ self.colorsflt = self.colors.astype(float)/255.
906
928
 
907
929
  self.fill_segmentdata()
wolfhece/PyParams.py CHANGED
@@ -846,6 +846,39 @@ class Wolf_Param(wx.Frame):
846
846
  dlg = wx.MessageDialog(None,'Nothing to do!')
847
847
  dlg.ShowModal()
848
848
 
849
+ def compare_active_to_default(self, remove_from_active_if_same:bool = True):
850
+ """
851
+ Compare active parameters to default parameters and remove those that are the same.
852
+
853
+ :param remove_from_active_if_same: If True, remove parameters from active if they are the same as default.
854
+ """
855
+
856
+ for group in self.myparams_default.keys():
857
+ for param_name in self.myparams_default[group].keys():
858
+ if self.is_in_active(group, param_name):
859
+
860
+ val_default = self.myparams_default[group][param_name][key_Param.VALUE]
861
+ val_active = self.myparams[group][param_name][key_Param.VALUE]
862
+
863
+ if val_active == val_default:
864
+ if remove_from_active_if_same:
865
+ # Remove from active parameters
866
+ del self.myparams[group][param_name]
867
+ # # Remove from property grid
868
+ # if self._is_in_propperty_page(self.page_active, group, param_name):
869
+ # self.prop.DeleteProperty(group + param_name)
870
+ else:
871
+ logging.debug(_('Parameter {} is the same as default and will not be removed'.format(param_name)))
872
+
873
+ # Iterate through the groups and remove empty ones
874
+ groups_to_remove = []
875
+ for group in self.myparams.keys():
876
+ if not self.myparams[group]:
877
+ groups_to_remove.append(group)
878
+
879
+ for group in groups_to_remove:
880
+ del self.myparams[group]
881
+
849
882
  @property
850
883
  def page_active(self) -> pg.PropertyGridPage:
851
884
  """ Return the active page """
wolfhece/PyPictures.py CHANGED
@@ -332,7 +332,7 @@ class PictureCollection(Zones):
332
332
 
333
333
  df = pd.read_excel(excel_file, sheet_name=sheet_name)
334
334
 
335
- for _, row in df.iterrows():
335
+ for __, row in df.iterrows():
336
336
  picture = row['Picture']
337
337
  x = row.get('X', None)
338
338
  y = row.get('Y', None)
@@ -405,7 +405,7 @@ class PictureCollection(Zones):
405
405
  name_column = column
406
406
  break
407
407
 
408
- for _, row in gdf.iterrows():
408
+ for __, row in gdf.iterrows():
409
409
  picture_path = row[name_column]
410
410
  if not isinstance(picture_path, str):
411
411
  logging.error(f"Invalid picture path in shapefile: {picture_path}")
wolfhece/PyVertex.py CHANGED
@@ -1011,6 +1011,18 @@ class cloud_vertices(Element_To_Draw):
1011
1011
  self._updatebounds(newcloud=cloud)
1012
1012
  pass
1013
1013
 
1014
+ def remove_vertex(self, id: int):
1015
+ """ Remove a vertex from the cloud
1016
+
1017
+ :param id: id of the vertex to remove
1018
+ """
1019
+
1020
+ if id in self.myvertices:
1021
+ del self.myvertices[id]
1022
+ self._updatebounds()
1023
+ else:
1024
+ logging.warning(_('Vertex with id {} not found in the cloud').format(id))
1025
+
1014
1026
  def add_vertices(self, vertices:list[wolfvertex]):
1015
1027
  """ Add a list of vertices to the cloud """
1016
1028
 
@@ -1109,6 +1121,19 @@ class cloud_vertices(Element_To_Draw):
1109
1121
 
1110
1122
  text.paint()
1111
1123
 
1124
+ def reset_listogl(self):
1125
+ """
1126
+ Reset the OpenGL list
1127
+
1128
+ """
1129
+
1130
+ if self.gllist != 0:
1131
+ glDeleteLists(self.gllist, 1)
1132
+ self.gllist = 0
1133
+
1134
+ self.forceupdategl = True
1135
+ self.ongoing = False
1136
+
1112
1137
  def plot(self, update:bool=False, *args, **kwargs):
1113
1138
  """
1114
1139
  OpenGL plot of the cloud of vertices
@@ -877,11 +877,26 @@ class vectorproperties:
877
877
  added = '#TRUE#' if self.used else '#FALSE#'
878
878
  f.write(added+'\n')
879
879
 
880
+ @property
881
+ def image_path(self) -> Path:
882
+ """ Return the path of the attached image """
883
+ return Path(self.attachedimage)
884
+
885
+ @image_path.setter
886
+ def image_path(self, value:Path):
887
+ """ Set the path of the attached image """
888
+
889
+ if self.attachedimage != value:
890
+ self.unload_image()
891
+
892
+ self.attachedimage = Path(value)
893
+
880
894
  def load_unload_image(self):
881
895
  """ Load an attached image """
882
896
 
883
897
  if self.imagevisible:
884
898
  if self.attachedimage is not None:
899
+ self.attachedimage = Path(self.attachedimage)
885
900
  if self.attachedimage.exists():
886
901
 
887
902
  (xmin,xmax),(ymin,ymax) = self.parent.get_bounds_xx_yy()
@@ -911,9 +926,14 @@ class vectorproperties:
911
926
  else:
912
927
  logging.warning('Image not found : {}'.format(self.attachedimage))
913
928
  else:
914
- if self.textureimage is not None:
915
- self.textureimage.unload()
916
- self.textureimage = None
929
+ self.unload_image()
930
+
931
+ def unload_image(self):
932
+ """ Unload the attached image """
933
+
934
+ if self.textureimage is not None:
935
+ self.textureimage.unload()
936
+ self.textureimage = None
917
937
 
918
938
  def fill_property(self, props:Wolf_Param = None, updateOGL:bool = True):
919
939
  """
@@ -2661,13 +2681,17 @@ class vector:
2661
2681
 
2662
2682
  if self.myprop.imagevisible and self.myprop.used:
2663
2683
 
2664
- if self.myprop.textureimage is None:
2665
- self.myprop.load_unload_image()
2684
+ try:
2666
2685
 
2667
- if self.myprop.textureimage is not None:
2668
- self.myprop.textureimage.paint()
2669
- else:
2670
- logging.warning(_('No image texture available for plot'))
2686
+ if self.myprop.textureimage is None:
2687
+ self.myprop.load_unload_image()
2688
+
2689
+ if self.myprop.textureimage is not None:
2690
+ self.myprop.textureimage.paint()
2691
+ else:
2692
+ logging.warning(_('No image texture available for plot'))
2693
+ except Exception as e:
2694
+ logging.error(_('Error while plotting image texture: {}').format(e))
2671
2695
 
2672
2696
  def plot_matplotlib(self, ax:plt.Axes | tuple[Figure, Axes] = None):
2673
2697
  """
@@ -3314,8 +3338,8 @@ class vector:
3314
3338
  k1,cums1,lengthparts1=self.get_segment(s1,is3D,adim,True)
3315
3339
  k2,cums2,lengthparts2=self.get_segment(s2,is3D,adim,False)
3316
3340
 
3317
- pond1 = max((cums1-s1)/lengthparts1[k1],0.)
3318
- pond2 = min((cums2-s2)/lengthparts2[k2],1.)
3341
+ pond1 = max((cums1-s1)/lengthparts1[k1],0.) if lengthparts1[k1] > 0. else 0.
3342
+ pond2 = min((cums2-s2)/lengthparts2[k2],1.) if lengthparts2[k2] > 0. else 1.
3319
3343
 
3320
3344
  v1= wolfvertex(self.myvertices[k1].x*pond1+self.myvertices[k1+1].x*(1.-pond1),
3321
3345
  self.myvertices[k1].y*pond1+self.myvertices[k1+1].y*(1.-pond1),
@@ -3892,6 +3916,8 @@ class vector:
3892
3916
  """ Permet de retrouver un vertex sur base de son index """
3893
3917
  if ndx>=0 and ndx < self.nbvertices:
3894
3918
  return self.myvertices[ndx]
3919
+ elif ndx < 0 and abs(ndx) <= self.nbvertices:
3920
+ return self.myvertices[ndx + self.nbvertices]
3895
3921
  else:
3896
3922
  logging.warning(_('Index out of range'))
3897
3923
 
@@ -3901,15 +3927,27 @@ class vector:
3901
3927
  self.myvertices[ndx] = value
3902
3928
  self._reset_listogl()
3903
3929
  self.reset_linestring()
3930
+ elif ndx < 0 and abs(ndx) <= self.nbvertices:
3931
+ self.myvertices[ndx + self.nbvertices] = value
3932
+ self._reset_listogl()
3933
+ self.reset_linestring()
3904
3934
  else:
3905
3935
  logging.warning(_('Index out of range'))
3906
3936
 
3907
3937
  def __delitem__(self, ndx:int):
3908
- """ Permet de supprimer un vertex sur base de son index """
3938
+ """ Permet de supprimer un vertex sur base de son index.
3939
+
3940
+ Exemple:
3941
+ del myvector[0] # Supprime le premier vertex
3942
+ """
3909
3943
  if ndx>=0 and ndx < self.nbvertices:
3910
3944
  self.myvertices.pop(ndx)
3911
3945
  self._reset_listogl()
3912
3946
  self.reset_linestring()
3947
+ elif ndx < 0 and abs(ndx) <= self.nbvertices:
3948
+ self.myvertices.pop(ndx + self.nbvertices)
3949
+ self._reset_listogl()
3950
+ self.reset_linestring()
3913
3951
  else:
3914
3952
  logging.warning(_('Index out of range'))
3915
3953
 
@@ -3976,6 +4014,25 @@ class vector:
3976
4014
  inside = [self.polygon.contains(Point(curxy)) for curxy in xy]
3977
4015
 
3978
4016
  return inside
4017
+
4018
+ def get_first_point_inside(self, xy: cloud_vertices | np.ndarray):
4019
+ """
4020
+ Returns the first point (x, y) inside the polygon.
4021
+
4022
+ :param xy: Point cloud (cloud_vertices or np.ndarray)
4023
+ :type xy: cloud_vertices | np.ndarray
4024
+ :return: Coordinates (x, y) of the first point found inside, or None if none
4025
+ :rtype: tuple[float, float] | None
4026
+ """
4027
+ self.prepare_shapely(True)
4028
+
4029
+ if isinstance(xy, cloud_vertices):
4030
+ xy = xy.get_xyz()[:, 0:2]
4031
+
4032
+ for curxy in xy:
4033
+ if self.polygon.contains(Point(curxy)):
4034
+ return float(curxy[0]), float(curxy[1])
4035
+ return None
3979
4036
 
3980
4037
  def split_cloud(self, cloud_to_split:cloud_vertices):
3981
4038
  """ Split a cloud of vertices on the vector """
@@ -4033,7 +4090,7 @@ class vector:
4033
4090
  def area(self):
4034
4091
  """ Alias for surface """
4035
4092
  return self.surface
4036
-
4093
+
4037
4094
  def interpolate_coordinates(self):
4038
4095
  """
4039
4096
  Interpole les valeurs Z des vertices sur base des seules valeurs connues,
@@ -4900,6 +4957,7 @@ class zone:
4900
4957
  # cs.set_zones(True)
4901
4958
 
4902
4959
  interp = Interpolators(banks, cs, ds)
4960
+ interp.export_gltf()
4903
4961
 
4904
4962
  return interp
4905
4963
 
@@ -6327,6 +6385,7 @@ class Zones(wx.Frame, Element_To_Draw):
6327
6385
  parent=None,
6328
6386
  is2D=True,
6329
6387
  idx: str = '',
6388
+ colname: str = None,
6330
6389
  plotted: bool = True,
6331
6390
  mapviewer=None,
6332
6391
  need_for_wx: bool = False,
@@ -6433,7 +6492,7 @@ class Zones(wx.Frame, Element_To_Draw):
6433
6492
 
6434
6493
  elif self.filename.endswith('.shp'):
6435
6494
  self.is2D=False
6436
- self.import_shapefile(self.filename, bbox=bbox)
6495
+ self.import_shapefile(self.filename, bbox=bbox, colname=colname)
6437
6496
  only_firstlast = True # We limit the number of vertices to the first and last ones to accelerate the process
6438
6497
 
6439
6498
  elif self.filename.endswith('.gpkg'):
@@ -6497,9 +6556,9 @@ class Zones(wx.Frame, Element_To_Draw):
6497
6556
  self.colorize_data(colors, filled=True)
6498
6557
 
6499
6558
  if plotted and self.has_OGLContext and not self.shared:
6500
- logging.info(_('Preparing OpenGL lists'))
6559
+ logging.debug(_('Preparing OpenGL lists'))
6501
6560
  self.prep_listogl()
6502
- logging.info(_('OpenGL lists ready'))
6561
+ logging.debug(_('OpenGL lists ready'))
6503
6562
 
6504
6563
  @property
6505
6564
  def mynames(self) -> list[str]:
@@ -6765,9 +6824,10 @@ class Zones(wx.Frame, Element_To_Draw):
6765
6824
 
6766
6825
  logging.info(_('Importing shapefile {}'.format(fn)))
6767
6826
  content = gpd.read_file(fn, bbox=bbox)
6768
-
6769
- self.import_GeoDataFrame(content, colname=colname)
6770
-
6827
+
6828
+ self.import_GeoDataFrame(content=content, colname=colname)
6829
+
6830
+
6771
6831
  def import_GeoDataFrame(self, content:gpd.GeoDataFrame,
6772
6832
  bbox:Polygon = None, colname:str = None):
6773
6833
  """
@@ -6792,24 +6852,24 @@ class Zones(wx.Frame, Element_To_Draw):
6792
6852
  idx, row = row
6793
6853
  keys = list(row.keys())
6794
6854
  if colname in keys:
6795
- name = row[colname]
6855
+ name = str(row[colname])
6796
6856
  elif 'NAME' in keys:
6797
- name = row['NAME']
6857
+ name = str(row['NAME'])
6798
6858
  elif 'location' in keys:
6799
- name = row['location'] # tuilage gdal
6859
+ name = str(row['location']) # tuilage gdal
6800
6860
  elif 'Communes' in keys:
6801
- name = row['Communes']
6861
+ name = str(row['Communes'])
6802
6862
  elif 'name' in keys:
6803
- name = row['name']
6863
+ name = str(row['name'])
6804
6864
  elif 'MAJ_NIV3T' in keys:
6805
6865
  # WALOUS
6806
- name = row['MAJ_NIV3T']
6866
+ name = str(row['MAJ_NIV3T'])
6807
6867
  elif 'NATUR_DESC' in keys:
6808
- name = row['NATUR_DESC']
6868
+ name = str(row['NATUR_DESC'])
6809
6869
  elif 'mun_name_f' in keys:
6810
- name = row['mun_name_f'].replace('[','').replace(']','').replace("'",'')
6870
+ name = str(row['mun_name_f']).replace('[','').replace(']','').replace("'",'')
6811
6871
  elif 'mun_name_fr' in keys:
6812
- name = row['mun_name_fr']
6872
+ name = str(row['mun_name_fr'])
6813
6873
  else:
6814
6874
  name = str(idx)
6815
6875
 
@@ -7306,6 +7366,12 @@ class Zones(wx.Frame, Element_To_Draw):
7306
7366
  if forceparent:
7307
7367
  addedzone.parent = self
7308
7368
 
7369
+ def create_zone(self, name:str = '') -> zone:
7370
+ """ Create a new zone and add it to the list of zones """
7371
+ newzone = zone(name=name, parent=self, is2D=self.is2D)
7372
+ self.myzones.append(newzone)
7373
+ return newzone
7374
+
7309
7375
  def find_minmax(self, update=False, only_firstlast:bool=False):
7310
7376
  """
7311
7377
  Trouve les bornes des vertices pour toutes les zones et tous les vecteurs
wolfhece/PyWMS.py CHANGED
@@ -216,10 +216,14 @@ def getLifeWatch(cat:Literal['None'],
216
216
  wms=WebMapService(f'https://maps.elie.ucl.ac.be/cgi-bin/mapserv72?map=/maps_server/lifewatch/mapfiles/LW_Ecotopes/latest/{cat}.map&SERVICE=wms',
217
217
  version='1.3.0', timeout=10)
218
218
 
219
- ppkm = 300
219
+ # _p_ixel _p_er _k_ilo_m_etre
220
+ ppkm = 500
221
+
220
222
  if w is None and h is None:
223
+ # Bounding dimensions width in kilometres
221
224
  real_w = (xr-xl)/1000
222
225
  real_h = (yr-yl)/1000
226
+ # Size in pixels of the requested area.
223
227
  w = int(real_w * ppkm)
224
228
  h = int(real_h * ppkm)
225
229
  elif w is None:
@@ -235,6 +239,8 @@ def getLifeWatch(cat:Literal['None'],
235
239
  # w = int(real_w * ppkm)
236
240
  h = int(real_h * ppkm)
237
241
 
242
+ # If we ask for too many pixels, well, we reduce the number
243
+ # of pixels we ask for (keeping the aspect ratio)
238
244
  MAXSIZE = 2048
239
245
  if w > MAXSIZE:
240
246
  pond = w / MAXSIZE
@@ -250,6 +256,8 @@ def getLifeWatch(cat:Literal['None'],
250
256
  # styles=['default'],
251
257
  srs='EPSG:31370',
252
258
  bbox=(xl,yl,xr,yr),
259
+ # Width/Height of map output, in pixels.
260
+ # See: https://docs.geoserver.org/stable/en/user/services/wms/reference.html#getmap
253
261
  size=(w,h),
254
262
  format='image/png',
255
263
  transparent=False)
@@ -540,41 +548,49 @@ def get_Alaro_legend(layer:str):
540
548
  """
541
549
  import requests
542
550
  from io import BytesIO
543
- layers = ['10_m_u__wind_component',
544
- '10_m_v__wind_component',
545
- '2_m_Max_temp_since_ppp',
546
- '2_m_Min_temp_since_ppp',
547
- '2_m_dewpoint_temperature',
548
- '2_m_temperature',
549
- '2m_Relative_humidity',
550
- 'Convective_rain',
551
- 'Convective_snow',
552
- 'Geopotential',
553
- 'Inst_flx_Conv_Cld_Cover',
554
- 'Inst_flx_High_Cld_Cover',
555
- 'Inst_flx_Low_Cld_Cover',
556
- 'Inst_flx_Medium_Cld_Cover',
557
- 'Inst_flx_Tot_Cld_cover',
558
- 'Large_scale_rain',
559
- 'Large_scale_snow',
560
- 'Mean_sea_level_pressure',
561
- 'Relative_humidity',
562
- 'Relative_humidity_isobaric',
563
- 'SBL_Meridian_gust',
564
- 'SBL_Zonal_gust',
565
- 'Specific_humidity',
566
- 'Surf_Solar_radiation',
567
- 'Surf_Thermal_radiation',
568
- 'Surface_CAPE',
569
- 'Surface_Temperature',
570
- 'Surface_orography',
571
- 'Temperature',
572
- 'Total_precipitation',
573
- 'U-velocity',
574
- 'V-velocity',
575
- 'Vertical_velocity',
576
- 'Wet_Bulb_Poten_Temper',
577
- 'freezing_level_zeroDegC_isotherm']
551
+ # layers = ['10_m_u__wind_component',
552
+ # '10_m_v__wind_component',
553
+ # '2_m_Max_temp_since_ppp',
554
+ # '2_m_Min_temp_since_ppp',
555
+ # '2_m_dewpoint_temperature',
556
+ # '2_m_temperature',
557
+ # '2m_Relative_humidity',
558
+ # 'Convective_rain',
559
+ # 'Convective_snow',
560
+ # 'Geopotential',
561
+ # 'Inst_flx_Conv_Cld_Cover',
562
+ # 'Inst_flx_High_Cld_Cover',
563
+ # 'Inst_flx_Low_Cld_Cover',
564
+ # 'Inst_flx_Medium_Cld_Cover',
565
+ # 'Inst_flx_Tot_Cld_cover',
566
+ # 'Large_scale_rain',
567
+ # 'Large_scale_snow',
568
+ # 'Mean_sea_level_pressure',
569
+ # 'Relative_humidity',
570
+ # 'Relative_humidity_isobaric',
571
+ # 'SBL_Meridian_gust',
572
+ # 'SBL_Zonal_gust',
573
+ # 'Specific_humidity',
574
+ # 'Surf_Solar_radiation',
575
+ # 'Surf_Thermal_radiation',
576
+ # 'Surface_CAPE',
577
+ # 'Surface_Temperature',
578
+ # 'Surface_orography',
579
+ # 'Temperature',
580
+ # 'Total_precipitation',
581
+ # 'U-velocity',
582
+ # 'V-velocity',
583
+ # 'Vertical_velocity',
584
+ # 'Wet_Bulb_Poten_Temper',
585
+ # 'freezing_level_zeroDegC_isotherm']
586
+ layers = ['2_m_temperature',
587
+ 'Surface_Temperature',
588
+ 'Convective_rain',
589
+ 'Convective_snow',
590
+ 'Large_scale_rain',
591
+ 'Large_scale_snow',
592
+ 'Mean_sea_level_pressure',
593
+ 'Total_precipitation',]
578
594
 
579
595
  layers_lowercase = [l.lower() for l in layers]
580
596
  if layer.lower() not in layers_lowercase:
@@ -5,7 +5,7 @@ Date: 2024
5
5
  Copyright (c) 2024 University of Liege. All rights reserved.
6
6
 
7
7
  This script and its content are protected by copyright law. Unauthorized
8
- copying or distribution of this file, via any medium, is strictly prohibited.
8
+ copying or distribution of this file, via any medium, is strictly prohibited.batch_creation_and_interpolation
9
9
  """
10
10
 
11
11
  from .Parallels import parallel_gpd_clip, parallel_v2r, parallel_datamod
@@ -13,6 +13,7 @@ from .func import data_modification, compute_vulnerability, compute_vulnerabilit
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
15
15
 
16
+ from ..PyTranslate import _
16
17
  import pandas as pd
17
18
  import os
18
19
  from osgeo import gdal
@@ -52,6 +53,7 @@ class steps_vulnerability(Enum):
52
53
  APPLY_MODIFS = 2
53
54
  MATCH_SIMUL = 3
54
55
  APPLY_SCENARIOSVULN = 4
56
+ APPLY_SCENARIOSVULN_BUG = 42
55
57
 
56
58
  @classmethod
57
59
  def get_list_names(cls):
@@ -215,7 +217,7 @@ def Base_data_creation(main_dir:str = 'Data',
215
217
 
216
218
  shp:gpd.GeoDataFrame = gpd.read_file(in_file)
217
219
 
218
- nb_lines, _ = shp.shape
220
+ nb_lines, unused = shp.shape
219
221
  if nb_lines > 0:
220
222
  shp["Path"] = curlayer
221
223
  shp["Vulne"] = vulnerability_csv.get_vulnerability_level(curlayer)
@@ -391,13 +393,18 @@ def Vulnerability(main_dir:str = 'Data',
391
393
  if 4 in steps or steps_vulnerability.APPLY_SCENARIOSVULN in steps:
392
394
  if os.path.exists(manager.OUT_VULN):
393
395
  existence=False
394
- existence = manager.create_vrtIfExists(manager.OUT_VULN, manager.IN_CH_SA_SC, manager.OUT_VULN_VRT, name="vuln")
395
- if existence == True :
396
- logging.info("Scenarios have been applied to the vulnerability matrix see _scenarios")
396
+ existence, fail = manager.create_vrtIfExists(manager.OUT_VULN, manager.IN_CH_SA_SC, manager.OUT_VULN_VRT, name="vuln")
397
+ if existence == None:
398
+ logging.error(_(f"Error in MNT_ files type : {fail}. Please correct them (int8 and Null value = 127)."))
399
+ return done.append(steps_vulnerability.APPLY_SCENARIOSVULN_BUG)
400
+
401
+ elif existence == True :
397
402
  manager.translate_vrt2tif(manager.OUT_VULN_VRT, manager.OUT_VULN_S)
403
+ logging.info("Scenarios have been applied to the vulnerability matrix see _scenarios")
398
404
  else :
399
405
  logging.error(f"The baseline vulnerability does not exist ({manager.OUT_VULN}). Please, compute first the vulnerability without scenarios vuln_.")
400
406
  done.append(steps_vulnerability.APPLY_SCENARIOSVULN)
407
+
401
408
  #Delete _scenario folder is no scenario
402
409
  if os.path.isdir(manager.OUT_WITHVULN) and not os.listdir(manager.OUT_WITHVULN):
403
410
  os.rmdir(manager.OUT_WITHVULN)
@@ -429,7 +436,7 @@ def Acceptability(main_dir:str = 'Vesdre',
429
436
  river_trace = manager.OUT_MASKED_RIVER
430
437
 
431
438
  if 5 in steps or steps_acceptability.COMPUTE_WITH_SCENARIOS in steps:
432
- river_trace = manager.wich_river_trace()
439
+ river_trace = manager.wich_river_trace(True)
433
440
  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
441
  if len(change_vuln_files) != 0:
435
442
  VulneToCompute.append(manager.OUT_VULN_Stif)
@@ -563,8 +570,8 @@ def Acceptability(main_dir:str = 'Vesdre',
563
570
  assert len(pond) == len(return_periods), "The number of ponderations is not equal to the number of return periods"
564
571
 
565
572
  # Initialize the combined acceptability matrix -- Ponderate mean of the local acceptability
566
- comb = np.zeros(part_accept[return_periods[-1]].shape, dtype=np.float32)
567
-
573
+ comb = np.zeros(part_accept[return_periods[0]].shape, dtype=np.float32)
574
+
568
575
  for curT in return_periods:
569
576
  assert part_accept[curT].dtype == np.float32, "The dtype of the acceptability matrix is not np.float32"
570
577
  assert part_accept[curT].shape == comb.shape, "The shape of the acceptability matrix is not the right one"