wolfhece 2.2.15__py3-none-any.whl → 2.2.17__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.
@@ -57,6 +57,8 @@ KIWIS WebServices command :
57
57
  checkValueLimit checks value limitations for time range value requests
58
58
  """
59
59
 
60
+ TIMEOUT = 5
61
+
60
62
  URL_SERVICE = 'https://hydrometrie.wallonie.be/services'
61
63
  URL_SERVICE_WATERINFO = 'https://download.waterinfo.be/tsmdownload'
62
64
  URL_SERVICE_HICWS = 'https://hicws.vlaanderen.be'
@@ -400,6 +402,13 @@ class hydrometry():
400
402
  if url=='':
401
403
  self.url=URL_SPW
402
404
 
405
+ # check if url is responding
406
+ try:
407
+ requests.get(self.url, timeout=TIMEOUT)
408
+ except requests.exceptions.RequestException as e:
409
+ logging.error(f"Error connecting to {self.url}: {e}")
410
+ return
411
+
403
412
  if urltoken=='':
404
413
  self.urltoken=URL_TOKEN
405
414
 
@@ -413,7 +422,7 @@ class hydrometry():
413
422
  self.get_sites()
414
423
  self.get_stations()
415
424
  self.get_groups()
416
- self.save_struct(self.dir)
425
+ self.save_struct()
417
426
  except Exception as e:
418
427
  print('Error in hydrometry init :', e)
419
428
  self.realstations = None
@@ -501,7 +510,11 @@ class hydrometry():
501
510
  """
502
511
 
503
512
  if dir=='':
504
- return
513
+ if self.dir:
514
+ dir = self.dir
515
+ else:
516
+ logging.warning('No directory to save structure')
517
+ return
505
518
 
506
519
  dir = Path(dir)
507
520
  dir.mkdir(parents=True, exist_ok=True)
@@ -572,7 +585,7 @@ class hydrometry():
572
585
  # returnfields += 'ts_id,ts_name,'
573
586
  # returnfields += 'ts_unitname,ts_unitsymbol,'
574
587
 
575
- if self.dir!='' and self.get_path(self.dir, 'stations.csv').exists():
588
+ if self.dir!='' and self.get_path(self.dir,'stations.csv').exists():
576
589
  self.stations = pd.read_csv(self.get_path(self.dir, 'stations.csv'),index_col=0)
577
590
  elif self.url!='':
578
591
  try:
@@ -583,14 +596,16 @@ class hydrometry():
583
596
  +'&ca_sta_returnfields='+ca_sta_returnfields \
584
597
  +'&orderby=station_no', \
585
598
  verify=True, \
586
- headers=self._header).json()
599
+ headers=self._header,
600
+ timeout=TIMEOUT).json()
587
601
  else:
588
602
  json_data = requests.get(self._get_commandstr(kiwis_command.getStationList, 'json') \
589
603
  +'&metadata=true' \
590
604
  +'&returnfields='+returnfields \
591
605
  +'&orderby=station_no', \
592
606
  verify=True, \
593
- headers=self._header)
607
+ headers=self._header,
608
+ timeout=TIMEOUT)
594
609
 
595
610
  json_data = json_data.text.replace('\x1a', ' ')
596
611
  json_data = json.loads(json_data)
@@ -802,7 +817,9 @@ class hydrometry():
802
817
  '&timeseriesgroup_id='+str(group_id)+
803
818
  '&orderby=station_no'+
804
819
  returnFields,
805
- verify=True, headers=self._header).json()
820
+ verify=True,
821
+ headers=self._header,
822
+ timeout=TIMEOUT).json()
806
823
  stations = pd.DataFrame(json_data[1:], columns = json_data[0])
807
824
  else:
808
825
  logging.error(f'{time} not found in Enum')
@@ -831,7 +848,10 @@ class hydrometry():
831
848
  '&timeseriesgroup_id='+str(group_id)+
832
849
  '&orderby=station_no'+
833
850
  returnFields,
834
- verify=True, headers=self._header).json()
851
+ verify=True,
852
+ headers=self._header,
853
+ timeout=TIMEOUT).json()
854
+
835
855
  stations = pd.DataFrame(json_data[1:], columns = json_data[0])
836
856
 
837
857
  return stations
@@ -844,7 +864,11 @@ class hydrometry():
844
864
  if self.dir!='' and self.get_path(self.dir, 'sites.csv').exists() and not forcerequest:
845
865
  self.sites = pd.read_csv(self.get_path(self.dir, 'sites.csv'),index_col=0)
846
866
  elif self.url!='' or forcerequest:
847
- json_data = requests.get(self._get_commandstr(kiwis_command.getSiteList),verify=True, headers=self._header).json()
867
+ json_data = requests.get(self._get_commandstr(kiwis_command.getSiteList),
868
+ verify=True,
869
+ headers=self._header,
870
+ timeout=TIMEOUT).json()
871
+
848
872
  self.sites = pd.DataFrame(json_data[1:], columns = json_data[0])
849
873
  else:
850
874
  self.sites = None
@@ -857,7 +881,10 @@ class hydrometry():
857
881
  if self.dir!='' and self.get_path(self.dir, 'groups.csv').exists() and not forcerequest:
858
882
  self.groups = pd.read_csv(self.get_path(self.dir, 'groups.csv'),index_col=0)
859
883
  elif self.url!='' or forcerequest:
860
- json_data = requests.get(self._get_commandstr(kiwis_command.getGroupList),verify=True, headers=self._header).json()
884
+ json_data = requests.get(self._get_commandstr(kiwis_command.getGroupList),
885
+ verify=True,
886
+ headers=self._header,
887
+ timeout=TIMEOUT).json()
861
888
  self.groups = pd.DataFrame(json_data[1:], columns = json_data[0])
862
889
  else:
863
890
  self.groups = None
@@ -878,7 +905,11 @@ class hydrometry():
878
905
  if self.dir!='' and self.get_path(self.dir, 'requests.csv').exists() and not forcerequest:
879
906
  self.requests = pd.read_csv(self.get_path(self.dir, 'requests.csv'),index_col=0)
880
907
  elif self.url!='' or forcerequest:
881
- json_data = requests.get(self._get_commandstr(kiwis_command.getrequestinfo),verify=True, headers=self._header).json()
908
+ json_data = requests.get(self._get_commandstr(kiwis_command.getrequestinfo),
909
+ verify=True,
910
+ headers=self._header,
911
+ timeout=TIMEOUT).json()
912
+
882
913
  self.requests = pd.DataFrame(json_data[0]['Requests'])
883
914
  else:
884
915
  self.requests = None
@@ -913,7 +944,9 @@ class hydrometry():
913
944
  json_data = requests.get(self._get_commandstr(kiwis_command.getTimeseriesList)
914
945
  +'&station_id='+str(id)
915
946
  +'&format=json'
916
- ,verify=True, headers=self._header).json()
947
+ ,verify=True,
948
+ headers=self._header,
949
+ timeout=TIMEOUT).json()
917
950
 
918
951
  try:
919
952
  if json_data[0] == 'No matches.':
@@ -978,7 +1011,7 @@ class hydrometry():
978
1011
 
979
1012
  id,list=self.timeseries_list(stationname=stationname,stationcode=stationcode)
980
1013
  filename = self._get_filename_list(stationname,stationcode)
981
- list.to_csv(dir / filename)
1014
+ list.to_csv(self.get_path(dir,filename))
982
1015
 
983
1016
  def timeseries(self, stationname:str='', stationcode:str='', stationid:str='',
984
1017
  dir:str='',
@@ -1027,7 +1060,8 @@ class hydrometry():
1027
1060
  "station_id":str(id),
1028
1061
  "ts_name":ts_name,
1029
1062
  "timezone":timezone})
1030
- ,verify=True).json()
1063
+ ,verify=True,
1064
+ timeout=TIMEOUT).json()
1031
1065
  if len(json_data)==1:
1032
1066
  return None
1033
1067
 
@@ -1090,7 +1124,9 @@ class hydrometry():
1090
1124
  "to":todate.strftime("%Y-%m-%dT%H:%M:%S"),
1091
1125
  # "format":"json",
1092
1126
  "timezone":timezone})
1093
- ,verify=True, headers=self._header).json()
1127
+ ,verify=True,
1128
+ headers=self._header,
1129
+ timeout=TIMEOUT).json()
1094
1130
 
1095
1131
  df = pd.DataFrame(json_data[0]['data'], columns = json_data[0]['columns'].split(','))
1096
1132
  df.set_index('Timestamp', inplace = True)
@@ -1139,7 +1175,8 @@ class hydrometry():
1139
1175
  "ts_name":ts_name,
1140
1176
  "timezone":timezone})+
1141
1177
  "&returnfields=Timestamp,Quality%20Code"
1142
- ,verify=True).json()
1178
+ ,verify=True,
1179
+ timeout=TIMEOUT).json()
1143
1180
  if len(json_data)==1:
1144
1181
  return None
1145
1182
 
@@ -1189,7 +1226,9 @@ class hydrometry():
1189
1226
  "to":todate.strftime("%Y-%m-%dT%H:%M:%S"),
1190
1227
  "timezone":timezone})+
1191
1228
  "&returnfields=Timestamp,Quality%20Code"
1192
- ,verify=True, headers=self._header).json()
1229
+ ,verify=True,
1230
+ headers=self._header,
1231
+ timeout=TIMEOUT).json()
1193
1232
 
1194
1233
  df = pd.DataFrame(json_data[0]['data'], columns = json_data[0]['columns'].split(','))
1195
1234
  df.set_index('Timestamp', inplace = True)
@@ -95,12 +95,12 @@ class Classification_LAZ():
95
95
  10 : ['Ponts', 'Les ponts ont été classés à part pour améliorer la définition du MNT. Ils ont été ouverts grâce',Colors.rgb_withalpha_float('lightyellow1',1.)],
96
96
  11 : ['Mur de berges', 'Mur et muret en berge de la Vesdre dépassant le sol à des vocation de réaliser une modélisation 3D hydraulique avec ces obstacles.',Colors.rgb_withalpha_float('red1',1.)],
97
97
  13 : ['Inconnu', 'A vérifier auSPW', Colors.rgb_withalpha_float('lightslategray',.2)],
98
- 15 : ['Tranche d\'eau', 'Echo intermédiaire dans l\’eau n\’appartenant ni à la surface d\’eau ni au fond du lit', Colors.rgb_withalpha_float('lightblue',.2)],
99
- 16 : ['Surface bathymétrique', 'Fond du lit de la Vesdre et de ses affluents et des autres surfaces d\’eau mesurées à partir du scanner 3 FWF discrétisé',Colors.rgb_withalpha_float('sandybrown',1.)],
98
+ 15 : [r'Tranche d\'eau', r'Echo intermédiaire dans l\’eau n\’appartenant ni à la surface d\’eau ni au fond du lit', Colors.rgb_withalpha_float('lightblue',.2)],
99
+ 16 : ['Surface bathymétrique', r'Fond du lit de la Vesdre et de ses affluents et des autres surfaces d\’eau mesurées à partir du scanner 3 FWF discrétisé',Colors.rgb_withalpha_float('sandybrown',1.)],
100
100
  17 : ['Surface bathymétrique incertaine', 'Surface bathymétrique sur les zones peu profondes principalement sous végétation où les intensités des échos sont parfois trop faibles pour avoir la certitude qu\’ils représentent le fond de rivière. La classe 17 est néanmoins plus certaine que la classe 18. Elle est utilisée dans la génération des MNT par défaut.',Colors.rgb_withalpha_float('rosybrown',.5)],
101
- 19 : ['Surface d\eau calculée', 'Points sous échantillonnés de la surface d\’eau ayant servis à faire les calculs de correction de réfraction bathymétrique',Colors.rgb_withalpha_float('lightblue',.2)],
101
+ 19 : [r'Surface d\eau calculée', r'Points sous échantillonnés de la surface d\’eau ayant servis à faire les calculs de correction de réfraction bathymétrique',Colors.rgb_withalpha_float('lightblue',.2)],
102
102
  20 : ['Surface bathymétrique incertaine profonde', 'Surface bathymétrique sur les zones plus profondes principalement au centre de la rivière où les intensités des échos sont parfois trop faibles pour avoir la certitude qu\’ils représentent le fond de rivière. Non utilisée dans la génération du MNT. + Surface proche bathy mais potentiellement émergée pour les scanner 1 à 3',Colors.rgb_withalpha_float('lightblue',.5)],
103
- 29 : ['Surface d\'eau héliportée', 'La hauteur d\’eau du vol héliporté étant largement supérieure (de 30 à 40cm au vol Titan, les points matérialisant cette surface ont été reclassés dans cette classe séparée pour ne pas perturbé le reste du nuage de point.',Colors.rgb_withalpha_float('cyan',.3)]}
103
+ 29 : [r'Surface d\'eau héliportée', r'La hauteur d\’eau du vol héliporté étant largement supérieure (de 30 à 40cm au vol Titan, les points matérialisant cette surface ont été reclassés dans cette classe séparée pour ne pas perturbé le reste du nuage de point.',Colors.rgb_withalpha_float('cyan',.3)]}
104
104
 
105
105
  def callback_colors(self):
106
106
  """ Update from wx GUI """
@@ -1748,6 +1748,29 @@ class prev_parameters_blocks:
1748
1748
 
1749
1749
  self.parent._scheme_centered_slope = 2
1750
1750
 
1751
+ @property
1752
+ def is_Manning_surface_friction(self) -> bool:
1753
+ """ Retourne True si le modèle de surface de friction est de type Manning-Strickler """
1754
+ i, name = self.get_params_surface_friction()
1755
+ if i in [0, 1, 2, 3, 4, 5, 6, 7]:
1756
+ return True
1757
+ else:
1758
+ return False
1759
+
1760
+ @property
1761
+ def is_manning_strickler(self) -> bool:
1762
+ """ Retourne True si le modèle de surface de friction est de type Manning-Strickler """
1763
+ return self.is_Manning_surface_friction
1764
+
1765
+ @property
1766
+ def is_Colebrook_surface_friction(self) -> bool:
1767
+ """ Retourne True si le modèle de surface de friction est de type Colebrook """
1768
+ i, name = self.get_params_surface_friction()
1769
+ if i in [-3, -34, -5]:
1770
+ return True
1771
+ else:
1772
+ return False
1773
+
1751
1774
  def get_params_surface_friction(self) -> tuple[int, str]:
1752
1775
 
1753
1776
  if self._friction_law == 0:
wolfhece/pyshields.py CHANGED
@@ -15,7 +15,7 @@ from scipy.optimize import root_scalar
15
15
  from typing import Literal
16
16
  import logging
17
17
 
18
- from .friction_law import f_barr_bathurst
18
+ from .friction_law import f_barr_bathurst, f_colebrook, f_colebrook_pure
19
19
 
20
20
  RHO_PUREWATER = 1000. # kg/m3
21
21
  RHO_SEAWATER = 1025. # kg/m3
@@ -530,6 +530,26 @@ def get_friction_slope_2D_Manning(q:float, h:float, n:float) -> float:
530
530
 
531
531
  return j
532
532
 
533
+ def get_friction_slope_2D_Colebrook(q:float, h:float, K:float) -> float:
534
+ """
535
+ Compute friction slope j for 2D flow with Colebrook-White friction law
536
+
537
+ :param q : discharge [m3/s]
538
+ :param h : water depth [m]
539
+ :param K : Colebrook-White friction coefficient [m]
540
+ """
541
+
542
+ four_hydraulic_radius = 4.0 * h
543
+
544
+ if four_hydraulic_radius > 0.:
545
+ reynolds = (q/h) * four_hydraulic_radius / KIN_VISCOSITY # u*4h/nu == 4q/nu
546
+ k_sur_D = K / four_hydraulic_radius
547
+ j = f_colebrook(k_sur_D, reynolds) / four_hydraulic_radius * (q/h)**2.0/2.0/GRAVITY
548
+ else:
549
+ j = 0.
550
+
551
+ return j
552
+
533
553
  def get_shear_velocity_2D_Manning(q:float, h:float, n:float) -> float:
534
554
  """
535
555
  Compute shear velocity u_* for 2D flow with Manning/Strickler friction law
@@ -542,7 +562,23 @@ def get_shear_velocity_2D_Manning(q:float, h:float, n:float) -> float:
542
562
 
543
563
  j = get_friction_slope_2D_Manning(q,h,n)
544
564
 
545
- ushear = (h*j*GRAVITY)**0.5
565
+ ushear = (GRAVITY*h*j)**0.5
566
+
567
+ return ushear
568
+
569
+ def get_shear_velocity_2D_Colebrook(q:float, h:float, K:float) -> float:
570
+ """
571
+ Compute shear velocity u_* for 2D flow with Colebrook-White friction law
572
+
573
+ :param j : friction slope [-]
574
+ :param h : water depth [m]
575
+ :param q : discharge [m3/s]
576
+ :param K : Colebrook-White friction coefficient [m]
577
+ """
578
+
579
+ j = get_friction_slope_2D_Colebrook(q,h,K)
580
+
581
+ ushear = (GRAVITY*h*j)**0.5
546
582
 
547
583
  return ushear
548
584
 
wolfhece/wolf_array.py CHANGED
@@ -7699,7 +7699,7 @@ class WolfArray(Element_To_Draw, header_wolf):
7699
7699
  self.nby)
7700
7700
  cursel = [(x, y) for x in xall for y in yall]
7701
7701
 
7702
- z = griddata(curlist, z, cursel, fill_value=np.NaN)
7702
+ z = griddata(curlist, z, cursel, fill_value=np.nan)
7703
7703
 
7704
7704
  for cur, curz in zip(cursel, z):
7705
7705
  if not np.isnan(curz):
@@ -7976,6 +7976,9 @@ class WolfArray(Element_To_Draw, header_wolf):
7976
7976
  if type(other) == float:
7977
7977
  if other != 0.:
7978
7978
  newArray.array = np.ma.masked_array(self.array * other, self.array.mask, dtype=self.array.dtype)
7979
+ else:
7980
+ logging.debug(_('Multiplication by 0'))
7981
+ newArray.array = np.ma.masked_array(self.array * other, self.array.mask, dtype=self.array.dtype)
7979
7982
  else:
7980
7983
  newArray.array = np.ma.masked_array(self.array * other.array, self.array.mask, dtype=self.array.dtype)
7981
7984
  newArray.count()
@@ -10065,7 +10068,8 @@ class WolfArray(Element_To_Draw, header_wolf):
10065
10068
  figsize:tuple=None,
10066
10069
  Walonmap:bool=False,
10067
10070
  cat:str='IMAGERIE/ORTHO_2022_ETE',
10068
- first_mask_data:bool=True):
10071
+ first_mask_data:bool=True,
10072
+ with_legend:bool=False):
10069
10073
  """
10070
10074
  Plot the array - Matplotlib version
10071
10075
 
@@ -10114,13 +10118,17 @@ class WolfArray(Element_To_Draw, header_wolf):
10114
10118
  - `'IMAGERIE/ORTHO_2023_ETE'`
10115
10119
  - `'IMAGERIE/ORTHO_LAST'`
10116
10120
  :type cat: str, optional (Default value = `'IMAGERIE/ORTHO_2022_ETE'`)
10121
+ :param first_mask_data: If True, applies the mask to the data before plotting. Default is True.
10122
+ :type first_mask_data: bool, optional (Default value = True)
10123
+ :param with_legend: If True, adds a color legend to the plot. Default is False.
10124
+ :type with_legend: bool, optional (Default value = False)
10117
10125
  :return: If `getdata_im` is False, returns (fig, ax), where `fig` is the Matplotlib figure and `ax` is the axis. If `getdata_im` is True, returns (fig, ax, im), where `im` is the image object created by `imshow`.
10118
10126
  :rtype: tuple
10119
10127
  """
10120
10128
 
10121
10129
  if first_mask_data:
10122
10130
  self.mask_data(self.nullvalue)
10123
-
10131
+
10124
10132
  if update_palette:
10125
10133
  self.updatepalette(0)
10126
10134
 
@@ -10143,6 +10151,11 @@ class WolfArray(Element_To_Draw, header_wolf):
10143
10151
  logging.error(_('Error while fetching the map image from WalOnMap'))
10144
10152
  logging.error(e)
10145
10153
 
10154
+ if vmin is None and vmax is not None:
10155
+ vmin = self.mypal.values[0]
10156
+ elif vmax is None and vmin is not None:
10157
+ vmax = self.mypal.values[-1]
10158
+
10146
10159
  if (vmin is None) and (vmax is None):
10147
10160
  # im = ax.imshow(self.array.transpose(), origin='lower', cmap=self.mypal,
10148
10161
  # extent=(self.origx, self.origx + self.dx * self.nbx, self.origy, self.origy + self.dy * self.nby))
@@ -10155,8 +10168,23 @@ class WolfArray(Element_To_Draw, header_wolf):
10155
10168
  self.origx + self.dx * self.nbx,
10156
10169
  self.origy,
10157
10170
  self.origy + self.dy * self.nby),
10158
- alpha=np.select([self.array.mask.T, ~self.array.mask.T],
10171
+ alpha=np.select([self.array.mask.T, ~self.array.mask.T],
10159
10172
  [np.zeros(self.shape).T, np.ones(self.shape).T]))
10173
+
10174
+ if with_legend:
10175
+ # add a legend in a new axis
10176
+ ax_leg = fig.add_axes([0.92, 0.12, 0.04, 0.8])
10177
+ from matplotlib.colorbar import ColorbarBase
10178
+ from matplotlib import colors
10179
+ cbar = ColorbarBase(ax_leg, cmap=self.mypal.cmap, norm=self.mypal.norm, orientation='vertical')
10180
+ cbar.set_ticks(self.mypal.values)
10181
+ cbar.set_ticklabels(self.mypal.values)
10182
+ cbar.ax.tick_params(labelsize=8)
10183
+ cbar.ax.yaxis.set_label_position('left')
10184
+ cbar.ax.yaxis.set_ticks_position('right')
10185
+ cbar.ax.yaxis.set_tick_params(width=0.5, size=2, direction='in', color='black')
10186
+
10187
+
10160
10188
  else:
10161
10189
  im = ax.imshow(self.array.transpose(),
10162
10190
  origin='lower',
@@ -10166,9 +10194,29 @@ class WolfArray(Element_To_Draw, header_wolf):
10166
10194
  self.origy,
10167
10195
  self.origy + self.dy * self.nby),
10168
10196
  vmin=vmin, vmax=vmax,
10169
- alpha=np.select([self.array.mask.T, ~self.array.mask.T],
10197
+ alpha=np.select([self.array.mask.T, ~self.array.mask.T],
10170
10198
  [np.zeros(self.shape).T, np.ones(self.shape).T]) )
10199
+
10200
+
10201
+ if with_legend:
10202
+ # add a legend in a new axis
10203
+ ax_leg = fig.add_axes([0.92, 0.12, 0.04, 0.8])
10204
+ from matplotlib.colorbar import ColorbarBase
10205
+ from matplotlib import colors
10206
+ from matplotlib.colors import Normalize
10207
+ cbar = ColorbarBase(ax_leg, cmap=self.mypal.cmap, norm= Normalize(vmin, vmax), orientation='vertical')
10208
+ vals = list(np.linspace(vmin, vmax, self.mypal.nb, endpoint=True))
10209
+ # limit to 2 decimal places
10210
+ vals = [round(val, 2) for val in vals]
10211
+ cbar.set_ticks(vals)
10212
+ cbar.set_ticklabels(vals)
10213
+ cbar.ax.tick_params(labelsize=8)
10214
+ cbar.ax.yaxis.set_label_position('left')
10215
+ cbar.ax.yaxis.set_ticks_position('right')
10216
+ cbar.ax.yaxis.set_tick_params(width=0.5, size=2, direction='in', color='black')
10217
+
10171
10218
  ax.set_aspect('equal')
10219
+ fig.tight_layout()
10172
10220
 
10173
10221
  if getdata_im:
10174
10222
  return fig, ax, im
@@ -11434,7 +11482,7 @@ class WolfArrayMB(WolfArray):
11434
11482
  :param j: j index
11435
11483
  :param which_block: block index 1-based
11436
11484
  """
11437
- h = np.NaN
11485
+ h = np.nan
11438
11486
  if which_block == 0:
11439
11487
  logging.warning("Block index is probably 0-based. It should be 1-based.")
11440
11488
  return h
@@ -11455,7 +11503,7 @@ class WolfArrayMB(WolfArray):
11455
11503
  Read the value at world coordinate (x,y). if `abs` is
11456
11504
  given, then the translation is is taken into account.
11457
11505
 
11458
- If no block covers the coordinate, then np.NaN is returned
11506
+ If no block covers the coordinate, then np.nan is returned
11459
11507
  If several blocks cover the given coordinate then the first
11460
11508
  match is returned (and thus, the others are ignored).
11461
11509
 
@@ -11463,10 +11511,10 @@ class WolfArrayMB(WolfArray):
11463
11511
  :param y: y coordinate
11464
11512
  :param abs: if True, then the translation is taken into account
11465
11513
 
11466
- :return: the value at (x,y) or np.NaN if no block covers the coordinate
11514
+ :return: the value at (x,y) or np.nan if no block covers the coordinate
11467
11515
  """
11468
11516
 
11469
- h = np.NaN
11517
+ h = np.nan
11470
11518
  for curblock in self.myblocks.values():
11471
11519
  curblock: WolfArray
11472
11520
  nbx = curblock.nbx
@@ -12090,15 +12138,16 @@ class WolfArrayMB(WolfArray):
12090
12138
 
12091
12139
  return newArray
12092
12140
 
12093
- def plot_matplotlib(self,
12094
- figax:tuple=None,
12095
- getdata_im:bool=False,
12096
- update_palette:bool=True,
12097
- vmin:float=None, vmax:float=None,
12098
- figsize:tuple=None,
12099
- Walonmap:bool=False,
12141
+ def plot_matplotlib(self,
12142
+ figax:tuple=None,
12143
+ getdata_im:bool=False,
12144
+ update_palette:bool=True,
12145
+ vmin:float=None, vmax:float=None,
12146
+ figsize:tuple=None,
12147
+ Walonmap:bool=False,
12100
12148
  cat:str='IMAGERIE/ORTHO_2022_ETE',
12101
- first_mask_data:bool=True):
12149
+ first_mask_data:bool=True,
12150
+ with_legend:bool=False):
12102
12151
  """
12103
12152
  Plot the multi-block (MB) array - Matplotlib version
12104
12153
 
@@ -12150,6 +12199,10 @@ class WolfArrayMB(WolfArray):
12150
12199
  - `'IMAGERIE/ORTHO_2023_ETE'`
12151
12200
  - `'IMAGERIE/ORTHO_LAST'`
12152
12201
  :type cat: str, optional (Default value = `'IMAGERIE/ORTHO_2022_ETE'`)
12202
+ :param first_mask_data: If True, applies the mask to the data before plotting. Default is True.
12203
+ :type first_mask_data: bool, optional (Default value = True)
12204
+ :param with_legend: If True, adds a color legend to the plot. Default is False.
12205
+ :type with_legend: bool, optional (Default value = False)
12153
12206
  :return: If `getdata_im` is False, returns (fig, ax), where `fig` is the Matplotlib figure and `ax` is the axis. If `getdata_im` is True, returns (fig, ax, im), where `im` is the image object created by `imshow`.
12154
12207
  :rtype: tuple
12155
12208
  """
@@ -12157,14 +12210,15 @@ class WolfArrayMB(WolfArray):
12157
12210
  # Convert to single block
12158
12211
  single_block = self.as_WolfArray()
12159
12212
 
12160
- return single_block.plot_matplotlib(figax=figax,
12161
- getdata_im=getdata_im,
12162
- update_palette=update_palette,
12163
- vmin=vmin, vmax=vmax,
12164
- figsize=figsize,
12165
- Walonmap=Walonmap,
12213
+ return single_block.plot_matplotlib(figax=figax,
12214
+ getdata_im=getdata_im,
12215
+ update_palette=update_palette,
12216
+ vmin=vmin, vmax=vmax,
12217
+ figsize=figsize,
12218
+ Walonmap=Walonmap,
12166
12219
  cat=cat,
12167
- first_mask_data=first_mask_data)
12220
+ first_mask_data=first_mask_data,
12221
+ with_legend=with_legend)
12168
12222
 
12169
12223
 
12170
12224
  class WolfArrayMNAP(WolfArrayMB):