wolfhece 2.2.31__py3-none-any.whl → 2.2.33__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.
@@ -3589,6 +3589,32 @@ class vector:
3589
3589
  """ Alias for surface """
3590
3590
  return self.surface
3591
3591
 
3592
+ def interpolate_coordinates(self):
3593
+ """
3594
+ Interpole les valeurs Z des vertices sur base des seules valeurs connues,
3595
+ càd autre que infinity ou -99999 ou 99999.
3596
+ """
3597
+
3598
+ sz = self.get_sz()
3599
+ s = sz[0]
3600
+ z = sz[1]
3601
+
3602
+ # Remove -99999 and empty values
3603
+ valid_indices = np.where((z != -99999.) & (z != 99999.) & (z != '') & (np.isfinite(z)))[0]
3604
+ if len(valid_indices) == 0:
3605
+ logging.warning(_('No valid z values to interpolate'))
3606
+ return
3607
+
3608
+ f = interp1d(s[valid_indices], z[valid_indices])
3609
+
3610
+ for k in range(self.nbvertices):
3611
+ if k not in valid_indices:
3612
+ z = f(s[k])
3613
+ self.myvertices[k].z = z
3614
+
3615
+ self.update_lengths()
3616
+ self._reset_listogl()
3617
+
3592
3618
  class zone:
3593
3619
  """
3594
3620
  Objet de gestion d'informations vectorielles
wolfhece/Results2DGPU.py CHANGED
@@ -274,9 +274,18 @@ class wolfres2DGPU(Wolfresults_2D):
274
274
  idx: str = '',
275
275
  plotted: bool = True,
276
276
  mapviewer=None,
277
- store = None):
277
+ store = None,
278
+ load_from_cache:bool = True) -> None:
278
279
 
279
280
  fname = Path(fname)
281
+
282
+ # Test if fname is an url
283
+ if str(fname).startswith('http:') or str(fname).startswith('https:'):
284
+ from .pydownloader import download_gpu_simulation, DATADIR
285
+ ret = download_gpu_simulation(fname, DATADIR / fname.name, load_from_cache = load_from_cache)
286
+ assert isinstance(ret, ResultsStore), _("Download failed or did not return a ResultsStore instance")
287
+ fname = DATADIR / fname.name
288
+
280
289
  self._nap = None
281
290
 
282
291
  if not fname.name.lower() == 'simul_gpu_results':
wolfhece/analyze_poly.py CHANGED
@@ -35,6 +35,14 @@ class Array_analysis_onepolygon():
35
35
  self._selected_cells = None
36
36
  self._values = None
37
37
 
38
+ @ property
39
+ def centroid(self) -> Point:
40
+ """ Get the centroid of the polygon as a Point object.
41
+
42
+ :return: Shapely Point object representing the centroid of the polygon
43
+ """
44
+ return self._polygon.centroid
45
+
38
46
  def values(self, which:Literal['Mean', 'Std', 'Median', 'Sum', 'Volume', 'Values', 'Area']) -> pd.DataFrame | float:
39
47
  """ Get the values as a pandas DataFrame
40
48
 
@@ -59,6 +67,25 @@ class Array_analysis_onepolygon():
59
67
  else:
60
68
  return self._values[which]
61
69
 
70
+ def as_vector(self, add_values:bool = True):
71
+ """ Return a copy of the polygon with the values as attributes. """
72
+
73
+ newvec = self._polygon.deepcopy()
74
+
75
+ if add_values:
76
+ if self._values is None:
77
+ self.compute_values()
78
+ self._add_area2velues()
79
+
80
+ if self._values is None:
81
+ raise ValueError("No values computed. Please call compute_values() first.")
82
+
83
+ for key, value in self._values.items():
84
+ newvec.add_value(key, value)
85
+
86
+ newvec.myname = self._polygon.myname
87
+ return newvec
88
+
62
89
  def select_cells(self, mode:Literal['polygon', 'buffer'] = 'polygon', **kwargs):
63
90
  """Select the cells inside the polygon.
64
91
 
@@ -127,8 +154,13 @@ class Array_analysis_onepolygon():
127
154
  raise ValueError("No polygon provided. Please provide a polygon to select cells.")
128
155
 
129
156
  self._values['Area'] = self._polygon.area
157
+ centroid = self._polygon.centroid
158
+ self._values['X'] = centroid.x
159
+ self._values['Y'] = centroid.y
130
160
  else:
131
161
  self._values['Area'] = len(self._selected_cells) * self._wa.dx * self._wa.dy
162
+ self._values['X'] = np.mean(self._selected_cells[:, 0])
163
+ self._values['Y'] = np.mean(self._selected_cells[:, 1])
132
164
 
133
165
  @property
134
166
  def n_selected_cells(self) -> int:
@@ -278,6 +310,17 @@ class Array_analysis_polygons():
278
310
 
279
311
  self._active_categories = self.all_categories
280
312
 
313
+ def as_zone(self, add_values:bool = True) -> zone:
314
+ """ Convert the analysis to a zone of polygons """
315
+
316
+ ret_zone = zone(name=self._polygons.myname)
317
+ for name, poly in self._zone.items():
318
+ if name.split('___')[0] in self._active_categories:
319
+ if poly.has_values:
320
+ ret_zone.add_vector(poly.as_vector(add_values), forceparent=True)
321
+
322
+ return ret_zone
323
+
281
324
  @property
282
325
  def _areas(self) -> list[float]:
283
326
  """ Get the areas of the polygons in the zone """
@@ -357,6 +400,36 @@ class Array_analysis_polygons():
357
400
  lst = [pol.values('Values') for key, pol in self._zone.items() if pol.has_values and key.split('___')[0] in self._active_categories]
358
401
  return pd.concat(lst, axis=1)
359
402
 
403
+ def get_geometries(self) -> pd.DataFrame:
404
+ """ Get the centroids of all polygons in the zone as a pandas DataFrame.
405
+
406
+ :return: pandas DataFrame with the centroids of the polygons
407
+ """
408
+ centroids = {key: {'Centroid' : poly.centroid, 'X': poly.centroid.x, 'Y' : poly.centroid.y, 'Geometry': poly._polygon.polygon} for key, poly in self._zone.items() if poly.has_values and key.split('___')[0] in self._active_categories}
409
+ return pd.DataFrame.from_dict(centroids, orient='index')
410
+
411
+ def get_geodataframe_with_values(self, epsg:int = 31370) -> 'gpd.GeoDataFrame':
412
+ """ Create a GeoDataFrame with the centroids and values of the polygons.
413
+
414
+ Values are added as a column named 'Values' as Numpy array."""
415
+
416
+ import geopandas as gpd
417
+
418
+ geom = self.get_geometries()
419
+ # Add values as numpy arrays to the DataFrame
420
+ geom['Values'] = None
421
+ geom['Values'] = geom['Values'].astype(object)
422
+
423
+ # Get values for each polygon and add them to the DataFrame
424
+ for key, poly in self._zone.items():
425
+ if poly.has_values and key.split('___')[0] in self._active_categories:
426
+ values = poly.values('Values')
427
+ geom.at[key, 'Values'] = values.to_numpy().ravel()
428
+
429
+ # Create a GeoDataFrame
430
+ gdf = gpd.GeoDataFrame(geom, geometry='Geometry', crs=f'EPSG:{epsg}')
431
+ return gdf
432
+
360
433
  @property
361
434
  def polygons(self) -> zone:
362
435
  """ Get the zone of polygons """
@@ -510,6 +583,40 @@ class Array_analysis_polygons():
510
583
 
511
584
  return fig
512
585
 
586
+ def clustering(self, n_clusters:int = 5, operator:Literal['Mean', 'Median', 'Sum', 'Volume', 'Area'] = 'Mean'):
587
+ """ Perform clustering on the polygons based on their values. """
588
+ from sklearn.cluster import KMeans
589
+ import geopandas as gpd
590
+
591
+ # Get the values of the polygons
592
+ values = self.values(operator)
593
+ geometries = self.get_geodataframe_with_values()
594
+
595
+ xy = geometries[['X', 'Y']].copy()
596
+
597
+ if values.empty:
598
+ raise ValueError("No values to cluster. Please compute values first.")
599
+
600
+ # Perform clustering
601
+ kmeans = KMeans(n_clusters=n_clusters)
602
+
603
+ kmeans.fit(xy[['X', 'Y']].values)
604
+ labels = kmeans.labels_
605
+ geometries['Cluster'] = labels
606
+
607
+ centroids = kmeans.cluster_centers_
608
+ cluster_centroids = [Point(xy) for xy in centroids]
609
+
610
+ # Find footprints of the clusters
611
+ footprints = []
612
+ for label in np.unique(labels):
613
+ geom_cluster = geometries[geometries['Cluster'] == label]
614
+ footprint = geom_cluster.geometry.unary_union.convex_hull
615
+ footprints.append(footprint)
616
+
617
+ return geometries, (cluster_centroids, footprints)
618
+
619
+
513
620
  class Array_analysis_zones():
514
621
  """ Class for values analysis of an array based on a Zones instance.
515
622
 
@@ -524,6 +631,16 @@ class Array_analysis_zones():
524
631
 
525
632
  self._polygons = {zone.myname: Array_analysis_polygons(self._wa, zone, buffer_size) for zone in self._zones.myzones if zone.used}
526
633
 
634
+ def as_zones(self, add_values:bool = True) -> Zones:
635
+ """ Convert the analysis to a Zones instance """
636
+
637
+ newzones = Zones(idx=self._zones.idx)
638
+ for name, pol in self._polygons.items():
639
+ newzones.add_zone(pol.as_zone(add_values), forceparent=True)
640
+
641
+ return newzones
642
+
643
+
527
644
  def __getitem__(self, key:str) -> Array_analysis_polygons:
528
645
  """ Get the zone by name """
529
646
  if key in self._polygons:
@@ -623,6 +740,46 @@ class Arrays_analysis_zones():
623
740
  self._active_categories = self.all_categories
624
741
  self._active_arrays = self.all_arrays
625
742
 
743
+ def __getitem__(self, key:str | tuple) -> Array_analysis_polygons:
744
+ """ Get the zone by name """
745
+ if isinstance(key, tuple):
746
+ if len(key) != 2:
747
+ raise ValueError("Key must be a tuple of (zone_name, array_name).")
748
+ zone_name, array_name = key
749
+ if zone_name not in self._polygons or array_name not in self._polygons[zone_name]:
750
+ raise KeyError(f"Zone {zone_name} or array {array_name} not found in zones.")
751
+ return self._polygons[zone_name][array_name]
752
+
753
+ elif isinstance(key, str):
754
+ if len(self._polygons) == 1:
755
+ # If there is only one zone, return the first array in that zone
756
+ zone_name = next(iter(self._polygons))
757
+ if key in self._polygons[zone_name]:
758
+ return self._polygons[zone_name][key]
759
+ else:
760
+ raise KeyError(f"Array {key} not found in the only zone available.")
761
+ else:
762
+ if key in self._polygons:
763
+ return self._polygons[key]
764
+ else:
765
+ raise KeyError(f"Zone {key} not found in zones.")
766
+
767
+ def as_zones(self, add_values:bool = True) -> Zones:
768
+ """ Convert the analysis to a Zones instance """
769
+
770
+ newzones = Zones(idx=self._zones.idx)
771
+ for name, dct in self._polygons.items():
772
+ for array_name, pols in dct.items():
773
+ if array_name not in self._active_arrays:
774
+ continue
775
+
776
+ newzone = pols.as_zone(add_values)
777
+ newzone.myname = f"{array_name}"
778
+
779
+ newzones.add_zone(newzone, forceparent=True)
780
+
781
+ return newzones
782
+
626
783
  @property
627
784
  def _areas(self) -> dict[str, list[float]]:
628
785
  """ Get the areas of the polygons in the zones """
@@ -1173,8 +1330,8 @@ class Building_Waterdepth_analysis(Arrays_analysis_zones):
1173
1330
 
1174
1331
  if merge_zones:
1175
1332
  # copy all vectors in an unique zone
1176
- newz = Zones(idx='merged_zones')
1177
- merged_zone = zone(name='merged_zone')
1333
+ newz = Zones(idx='all')
1334
+ merged_zone = zone(name='all')
1178
1335
  newz.add_zone(merged_zone, forceparent= True)
1179
1336
 
1180
1337
  for z in zones.myzones:
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 2
8
- self.patch = 31
8
+ self.patch = 33
9
9
 
10
10
  def __str__(self):
11
11
 
wolfhece/pydownloader.py CHANGED
@@ -36,6 +36,11 @@ class DownloadFiles(Enum):
36
36
  VECFILES = ('vec', 'vec.extra')
37
37
  VECZFILES = ('vecz', 'vecz.extra')
38
38
  PROJECTFILES = ('proj',)
39
+ NUMPYFILES = ('npy',)
40
+ NPZFILES = ('npz',)
41
+ JSONFILES = ('json',)
42
+ TXTFILES = ('txt',)
43
+ CSVFILES = ('csv',)
39
44
 
40
45
  class DonwloadDirectories(Enum):
41
46
  """ Enum to define the directories for downloads. """
@@ -43,6 +48,7 @@ class DonwloadDirectories(Enum):
43
48
 
44
49
 
45
50
  GITLAB_EXAMPLE = 'https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main'
51
+ GITLAB_EXAMPLE_GPU = 'https://gitlab.uliege.be/HECE/wolfgpu_examples/-/raw/main'
46
52
  DATADIR = Path(__file__).parent / 'data' / 'downloads'
47
53
 
48
54
  def clean_url(url: str) -> str:
@@ -63,6 +69,10 @@ def clean_url(url: str) -> str:
63
69
  cleaned_url = re.sub(r'(?<!:)//+', '/', cleaned_url)
64
70
  # Convert Backslashes to forward slashes
65
71
  cleaned_url = cleaned_url.replace('\\', '/')
72
+
73
+ cleaned_url = cleaned_url.replace(':/', '://')
74
+ cleaned_url = cleaned_url.replace(':///', '://')
75
+
66
76
  # Ensure the URL starts with http:// or https://
67
77
  if not cleaned_url.startswith(('http://', 'https://', 'ftp://')):
68
78
  raise ValueError(f"Invalid URL: {url}. Must start with http://, https://, or ftp://")
@@ -171,6 +181,77 @@ def toys_dataset(dir:str, file:str, load_from_cache:bool = True):
171
181
  destination = DATADIR / dir / file
172
182
  return download_file(url, destination, load_from_cache=load_from_cache)
173
183
 
184
+ def download_gpu_simulation(url:str, destination:str | Path, load_from_cache:bool = True):
185
+ """ Download a GPU simulation file from the WOLFHECE dataset.
186
+
187
+ :param url: The URL of the GPU simulation file to download.
188
+ :param destination: The path where the file will be saved.
189
+ :param load_from_cache: If True, will not download the file if it already exists.
190
+ :type url: str
191
+ :type destination: str | Path
192
+ :type load_from_cache: bool
193
+ """
194
+
195
+ url = str(url).strip()
196
+ url = clean_url(url)
197
+ destination = Path(destination)
198
+
199
+ files = ['NAP.npy', 'bathymetry.npy', 'bridge_roof.npy', 'bridge_deck.npy', 'h.npy', 'manning.npy', 'qx.npy', 'qy.npy', 'parameters.json']
200
+ dir_res = 'simul_gpu_results'
201
+ res_files = ['metadata.json', 'nap.npz', 'nb_results.txt', 'sim_times.csv']
202
+
203
+ try:
204
+ for file in files:
205
+ try:
206
+ download_file(f"{url}/{file}", destination / file, load_from_cache=load_from_cache)
207
+ except Exception as e:
208
+ logging.error(f"Error downloading file {file} from {url}: {e}")
209
+
210
+ url = url + '/' + dir_res
211
+ destination = destination / dir_res
212
+ for file in res_files:
213
+ try:
214
+ download_file(f"{url}/{file}", destination / file, load_from_cache=load_from_cache)
215
+ except Exception as e:
216
+ logging.error(f"Error downloading result file {file} from {url}: {e}")
217
+
218
+ with open(destination / 'nb_results.txt', 'r') as f:
219
+ nb_results = int(f.read().strip())
220
+
221
+ for i in range(1,nb_results+1):
222
+ # h_0000001.npz
223
+ # qx_0000001.npz
224
+ # qy_0000001.npz
225
+ for file in ['h', 'qx', 'qy']:
226
+ try:
227
+ download_file(f"{url}/{file}_{i:07d}.npz", destination / f'{file}_{i:07d}.npz', load_from_cache=load_from_cache)
228
+ except Exception as e:
229
+ logging.error(f"Error downloading result file {file}_{i:07d}.npz from {url}: {e}")
230
+
231
+ from wolfgpu.results_store import ResultsStore
232
+ rs = ResultsStore(destination)
233
+
234
+ except Exception as e:
235
+ logging.error(f"Error downloading GPU dataset {dir}: {e}")
236
+ rs = None
237
+
238
+ return rs
239
+
240
+ def toys_gpu_dataset(dir:str, dirweb:str = None, load_from_cache:bool = True):
241
+ """ Download toy simulatoin files from the WOLFHECE dataset for GPU.
242
+
243
+ :param dir: The directory where the file will be saved.
244
+ :param dirweb: The directory of the files to download.
245
+ :type dir: str
246
+ :type dirweb: str
247
+ :return: The path to the downloaded file.
248
+ """
249
+
250
+ if dirweb is None:
251
+ dirweb = dir
252
+
253
+ return download_gpu_simulation(f"{GITLAB_EXAMPLE_GPU}/{dirweb}", DATADIR / dir, load_from_cache=load_from_cache)
254
+
174
255
  if __name__ == "__main__":
175
256
  # Example usage
176
257
  print(download_file(r'https:\\gitlab.uliege.be\HECE\wolf_examples\-\raw\main\Extract_part_array\extraction.vec'))
@@ -180,3 +261,4 @@ if __name__ == "__main__":
180
261
  print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/Array_Theux_Pepinster/mnt.tif'))
181
262
  print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/PICC/PICC_Vesdre.shp'))
182
263
  print(toys_dataset('Extract_part_array', 'extraction.vec'))
264
+ rs = toys_gpu_dataset('channel_w_archbridge_fully_man004')
wolfhece/wolf_array.py CHANGED
@@ -10496,7 +10496,16 @@ class WolfArray(Element_To_Draw, header_wolf):
10496
10496
  vmin:float=None, vmax:float=None,
10497
10497
  figsize:tuple=None,
10498
10498
  Walonmap:bool=False,
10499
- cat:str='IMAGERIE/ORTHO_2022_ETE',
10499
+ cat:Literal['IMAGERIE/ORTHO_1971', 'IMAGERIE/ORTHO_1994_2000', 'IMAGERIE/ORTHO_2006_2007', 'IMAGERIE/ORTHO_2009_2010',
10500
+ 'IMAGERIE/ORTHO_2012_2013', 'IMAGERIE/ORTHO_2015', 'IMAGERIE/ORTHO_2016',
10501
+ 'IMAGERIE/ORTHO_2017', 'IMAGERIE/ORTHO_2018', 'IMAGERIE/ORTHO_2019',
10502
+ 'IMAGERIE/ORTHO_2020', 'IMAGERIE/ORTHO_2021', 'IMAGERIE/ORTHO_2022_PRINTEMPS',
10503
+ 'IMAGERIE/ORTHO_2022_ETE', 'IMAGERIE/ORTHO_2023_ETE', 'IMAGERIE/ORTHO_LAST',
10504
+ 'orthoimage_coverage', 'orthoimage_coverage_2016', 'orthoimage_coverage_2017',
10505
+ 'orthoimage_coverage_2018', 'orthoimage_coverage_2019',
10506
+ 'orthoimage_coverage_2020', 'orthoimage_coverage_2021',
10507
+ 'orthoimage_coverage_2022', 'crossborder', 'crossborder_grey',
10508
+ 'overlay', 'topo', 'topo_grey'] = 'IMAGERIE/ORTHO_LAST',
10500
10509
  first_mask_data:bool=True,
10501
10510
  with_legend:bool=False,
10502
10511
  IGN:bool=False,
@@ -10548,6 +10557,19 @@ class WolfArray(Element_To_Draw, header_wolf):
10548
10557
  - `'IMAGERIE/ORTHO_2022_ETE'`
10549
10558
  - `'IMAGERIE/ORTHO_2023_ETE'`
10550
10559
  - `'IMAGERIE/ORTHO_LAST'`
10560
+ - 'orthoimage_coverage'
10561
+ - 'orthoimage_coverage_2016',
10562
+ - 'orthoimage_coverage_2017',
10563
+ - 'orthoimage_coverage_2018',
10564
+ - 'orthoimage_coverage_2019',
10565
+ - 'orthoimage_coverage_2020',
10566
+ - 'orthoimage_coverage_2021',
10567
+ - 'orthoimage_coverage_2022'
10568
+ - 'crossborder',
10569
+ - 'crossborder_grey',
10570
+ - 'overlay',
10571
+ - 'topo',
10572
+ - 'topo_grey'
10551
10573
  :type cat: str, optional (Default value = `'IMAGERIE/ORTHO_2022_ETE'`)
10552
10574
  :param first_mask_data: If True, applies the mask to the data before plotting. Default is True.
10553
10575
  :type first_mask_data: bool, optional (Default value = True)
@@ -10557,6 +10579,17 @@ class WolfArray(Element_To_Draw, header_wolf):
10557
10579
  :rtype: tuple
10558
10580
  """
10559
10581
 
10582
+ available_Walonmap = ['IMAGERIE/ORTHO_1971', 'IMAGERIE/ORTHO_1994_2000', 'IMAGERIE/ORTHO_2006_2007', 'IMAGERIE/ORTHO_2009_2010',
10583
+ 'IMAGERIE/ORTHO_2012_2013', 'IMAGERIE/ORTHO_2015', 'IMAGERIE/ORTHO_2016',
10584
+ 'IMAGERIE/ORTHO_2017', 'IMAGERIE/ORTHO_2018', 'IMAGERIE/ORTHO_2019',
10585
+ 'IMAGERIE/ORTHO_2020', 'IMAGERIE/ORTHO_2021', 'IMAGERIE/ORTHO_2022_PRINTEMPS',
10586
+ 'IMAGERIE/ORTHO_2022_ETE', 'IMAGERIE/ORTHO_2023_ETE', 'IMAGERIE/ORTHO_LAST']
10587
+ available_IGN = ['orthoimage_coverage', 'orthoimage_coverage_2016', 'orthoimage_coverage_2017',
10588
+ 'orthoimage_coverage_2018', 'orthoimage_coverage_2019',
10589
+ 'orthoimage_coverage_2020', 'orthoimage_coverage_2021',
10590
+ 'orthoimage_coverage_2022']
10591
+ available_Cartoweb = ['crossborder', 'crossborder_grey', 'overlay', 'topo', 'topo_grey']
10592
+
10560
10593
  if first_mask_data:
10561
10594
  self.mask_data(self.nullvalue)
10562
10595
 
@@ -10572,75 +10605,91 @@ class WolfArray(Element_To_Draw, header_wolf):
10572
10605
  from .PyWMS import getWalonmap
10573
10606
  from PIL import Image
10574
10607
 
10575
- try:
10576
- bounds = self.get_bounds()
10608
+ if cat not in available_Walonmap:
10609
+ logging.error(_('The category {} is not available in WalOnMap').format(cat))
10610
+ logging.error(_('Available categories are: {}').format(', '.join(available_Walonmap)))
10611
+ else:
10612
+ try:
10613
+ bounds = self.get_bounds()
10577
10614
 
10578
- scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10615
+ scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10579
10616
 
10580
- if scale_xovery > 1.:
10581
- # x is larger than y
10582
- w = 2000
10583
- h = int(2000 / scale_xovery)
10584
- else:
10585
- # y is larger than x
10586
- h = 2000
10587
- w = int(2000 * scale_xovery)
10617
+ if scale_xovery > 1.:
10618
+ # x is larger than y
10619
+ w = 2000
10620
+ h = int(2000 / scale_xovery)
10621
+ else:
10622
+ # y is larger than x
10623
+ h = 2000
10624
+ w = int(2000 * scale_xovery)
10625
+
10626
+ IO_image = getWalonmap(cat, bounds[0][0], bounds[1][0],
10627
+ bounds[0][1], bounds[1][1],
10628
+ w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10588
10629
 
10589
- IO_image = getWalonmap(cat, bounds[0][0], bounds[1][0],
10590
- bounds[0][1], bounds[1][1],
10591
- w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10630
+ image = Image.open(IO_image)
10592
10631
 
10593
- image = Image.open(IO_image)
10632
+ ax.imshow(image.transpose(Image.Transpose.FLIP_TOP_BOTTOM), extent=(bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]), alpha=1, origin='lower')
10633
+ except Exception as e:
10634
+ logging.error(_('Error while fetching the map image from WalOnMap'))
10635
+ logging.error(e)
10594
10636
 
10595
- ax.imshow(image.transpose(Image.Transpose.FLIP_TOP_BOTTOM), extent=(bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]), alpha=1, origin='lower')
10596
- except Exception as e:
10597
- logging.error(_('Error while fetching the map image from WalOnMap'))
10598
- logging.error(e)
10599
10637
  elif IGN:
10600
10638
  from .PyWMS import getNGI
10601
10639
  from PIL import Image
10602
- try:
10603
- bounds = self.get_bounds()
10604
- scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10605
- if scale_xovery > 1.:
10606
- # x is larger than y
10607
- w = 2000
10608
- h = int(2000 / scale_xovery)
10609
- else:
10610
- # y is larger than x
10611
- h = 2000
10612
- w = int(2000 * scale_xovery)
10613
- IO_image = getNGI(cat, bounds[0][0], bounds[1][0],
10614
- bounds[0][1], bounds[1][1],
10615
- w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10616
- image = Image.open(IO_image)
10617
- ax.imshow(image.transpose(Image.Transpose.FLIP_TOP_BOTTOM), extent=(bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]), alpha=1, origin='lower')
10618
- except Exception as e:
10619
- logging.error(_('Error while fetching the map image from IGN'))
10620
- logging.error(e)
10640
+
10641
+ if cat not in available_IGN:
10642
+ logging.error(_('The category {} is not available in IGN').format(cat))
10643
+ logging.error(_('Available categories are: {}').format(', '.join(available_IGN)))
10644
+
10645
+ else:
10646
+ try:
10647
+ bounds = self.get_bounds()
10648
+ scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10649
+ if scale_xovery > 1.:
10650
+ # x is larger than y
10651
+ w = 2000
10652
+ h = int(2000 / scale_xovery)
10653
+ else:
10654
+ # y is larger than x
10655
+ h = 2000
10656
+ w = int(2000 * scale_xovery)
10657
+ IO_image = getNGI(cat, bounds[0][0], bounds[1][0],
10658
+ bounds[0][1], bounds[1][1],
10659
+ w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10660
+ image = Image.open(IO_image)
10661
+ ax.imshow(image.transpose(Image.Transpose.FLIP_TOP_BOTTOM), extent=(bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]), alpha=1, origin='lower')
10662
+ except Exception as e:
10663
+ logging.error(_('Error while fetching the map image from IGN'))
10664
+ logging.error(e)
10621
10665
 
10622
10666
  elif Cartoweb:
10623
10667
  from .PyWMS import getCartoweb
10624
10668
  from PIL import Image
10625
- try:
10626
- bounds = self.get_bounds()
10627
- scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10628
- if scale_xovery > 1.:
10629
- # x is larger than y
10630
- w = 2000
10631
- h = int(2000 / scale_xovery)
10632
- else:
10633
- # y is larger than x
10634
- h = 2000
10635
- w = int(2000 * scale_xovery)
10636
- IO_image = getCartoweb(cat, bounds[0][0], bounds[1][0],
10637
- bounds[0][1], bounds[1][1],
10638
- w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10639
- image = Image.open(IO_image)
10640
- ax.imshow(image.transpose(Image.Transpose.FLIP_TOP_BOTTOM), extent=(bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]), alpha=1, origin='lower')
10641
- except Exception as e:
10642
- logging.error(_('Error while fetching the map image from Cartoweb'))
10643
- logging.error(e)
10669
+
10670
+ if cat not in available_Cartoweb:
10671
+ logging.error(_('The category {} is not available in Cartoweb').format(cat))
10672
+ logging.error(_('Available categories are: {}').format(', '.join(available_Cartoweb)))
10673
+ else:
10674
+ try:
10675
+ bounds = self.get_bounds()
10676
+ scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10677
+ if scale_xovery > 1.:
10678
+ # x is larger than y
10679
+ w = 2000
10680
+ h = int(2000 / scale_xovery)
10681
+ else:
10682
+ # y is larger than x
10683
+ h = 2000
10684
+ w = int(2000 * scale_xovery)
10685
+ IO_image = getCartoweb(cat, bounds[0][0], bounds[1][0],
10686
+ bounds[0][1], bounds[1][1],
10687
+ w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10688
+ image = Image.open(IO_image)
10689
+ ax.imshow(image.transpose(Image.Transpose.FLIP_TOP_BOTTOM), extent=(bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]), alpha=1, origin='lower')
10690
+ except Exception as e:
10691
+ logging.error(_('Error while fetching the map image from Cartoweb'))
10692
+ logging.error(e)
10644
10693
 
10645
10694
  if vmin is None and vmax is not None:
10646
10695
  vmin = self.mypal.values[0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wolfhece
3
- Version: 2.2.31
3
+ Version: 2.2.33
4
4
  Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
5
5
  Project-URL: Homepage, https://uee.uliege.be/hece
6
6
  Project-URL: Issues, https://uee.uliege.be/hece
@@ -17,16 +17,16 @@ wolfhece/PyParams.py,sha256=BgTAwxxq831rYEq_KLcFBX_upjiSUpVtfoQnCxCNWUI,100443
17
17
  wolfhece/PyPictures.py,sha256=m1kY0saW6Y9Q0bDCo47lW6XxDkBrbQG-Fd8uVn8G5ic,2514
18
18
  wolfhece/PyTranslate.py,sha256=4appkmNeHHZLFmUtaA_k5_5QL-5ymxnbVN4R2OblmtE,622
19
19
  wolfhece/PyVertex.py,sha256=a56oY1NB45QnwARg96Tbnq-z-mhZKFkYOkFOO1lNtlk,51056
20
- wolfhece/PyVertexvectors.py,sha256=MXoqgHVRMvpUOngqpErwT68JwUJo9FhEl1H4HB10-Zk,352574
20
+ wolfhece/PyVertexvectors.py,sha256=ljKJJuo1M9_RVryZiWKJZ8kB_4CuRZ1pOMeT8UeA6rM,353394
21
21
  wolfhece/PyWMS.py,sha256=XcSlav5icct2UwV7K2r7vpxa5rKZWiHkp732lI94HFI,31534
22
22
  wolfhece/RatingCurve.py,sha256=bUjIrQjvIjkD4V-z8bZmA6pe1ILtYNM0-3fT6YUY1RU,22498
23
23
  wolfhece/RatingCurveData.py,sha256=5UvnIm89BwqjnEbLCcY3CA8WoFd_xHJbooNy62fX5iY,57660
24
24
  wolfhece/RatingCurve_xml.py,sha256=cUjReVMHFKtakA2wVey5zz6lCgHlSr72y7ZfswZDvTM,33891
25
25
  wolfhece/ReadDataDCENN.py,sha256=vm-I4YMryvRldjXTvRYEUCxZsjb_tM7U9yj6OaPyD0k,1538
26
- wolfhece/Results2DGPU.py,sha256=GTu7PMuwfH-xH8J7sVr6zq2CTkGKF24fG1ujEW62PtM,31598
26
+ wolfhece/Results2DGPU.py,sha256=ljMEKHGMbmIAZE6UmMmYDMFqFAwjzxxVUmZdHHb6aME,32106
27
27
  wolfhece/__init__.py,sha256=EnpZ2yDEXueP7GAKV0uA2vAwMiZFyBjDAFcL5Y7LzbM,1850
28
28
  wolfhece/_add_path.py,sha256=mAyu85CQHk0KgUI6ZizweeQiw1Gdyea9OEjGLC6lLA4,916
29
- wolfhece/analyze_poly.py,sha256=gJlQZ0vwDG_N98eMDtUsLng9kKu-HlJ8a4xER9ubfDc,54527
29
+ wolfhece/analyze_poly.py,sha256=2uNdnRy828jR-aFNg9fx-8aHqXuRAg-hNQpvQ3g2qL8,60837
30
30
  wolfhece/analyze_vect.py,sha256=3lkMwaQ4KRddBVRvlP9PcM66wZwwC0eCmypP91AW-os,6015
31
31
  wolfhece/cli.py,sha256=h1tSMHALiftktreyugKcjbASXfpJUm9UYMeVxR-MtG4,6424
32
32
  wolfhece/color_constants.py,sha256=Snc5RX11Ydi756EkBp_83C7DiAQ_Z1aHD9jFIBsosAU,37121
@@ -51,7 +51,7 @@ wolfhece/pidcontroller.py,sha256=PHYenOdzfyPK2pXAhyRolCxMSMRd2AFza0eVMafpPHk,520
51
51
  wolfhece/pyGui1D.py,sha256=9g7OS3YiKsqy--6y0cBD7x2gaqTTYFXWkxImpgnTA20,121937
52
52
  wolfhece/pybridges.py,sha256=bFAqjL4ColeJtwvyCPGQ8VllWoq1RbVWXxFrdfrvqm8,65954
53
53
  wolfhece/pydike.py,sha256=dRb6qGkqoTXjf107KcajcIk1F_FuMPaOZLSwixT3dgA,11196
54
- wolfhece/pydownloader.py,sha256=7vcxzllphhQcH0nEI2NwX-HC0bKhOVpDkODq54oFMbU,7136
54
+ wolfhece/pydownloader.py,sha256=sf8E_R_VgKG7TQJpW0Di3Obyp4d8WhIdfNBGRjsa738,10351
55
55
  wolfhece/pylogging.py,sha256=4TI8hgBB65z-zpvU5Rfa2jkPXPhJaqXjHVPwbcdzTNc,4528
56
56
  wolfhece/pypolygons_scen.py,sha256=NWaNeK0RSUeOkgukeogK9FLmQiDjGZ9yhqs9208fojM,46237
57
57
  wolfhece/pyshields.py,sha256=KMtUO5kD0lisKnJD1NsDz-qaY5DpFcmS4O3WkXtUSmo,27898
@@ -61,7 +61,7 @@ wolfhece/rain_SPWMI.py,sha256=qCfcmF7LajloOaCwnTrrSMzyME03YyilmRUOqrPrv3U,13846
61
61
  wolfhece/textpillow.py,sha256=map7HsGYML_o5NHRdFg2s_TVQed_lDnpYNDv27MM0Vw,14130
62
62
  wolfhece/tools2d_dll.py,sha256=TfvvmyZUqEZIH0uHwUCJf0bdmCks_AiidDt23Unsp5w,13550
63
63
  wolfhece/tools_mpl.py,sha256=gQ3Jg1iuZiecmMqa5Eli2ZLSkttu68VXL8YmMDBaEYU,564
64
- wolfhece/wolf_array.py,sha256=jin9_ntHASNcqMx0CPYFHMEIw-LaF6UnousSaQx3AxU,523441
64
+ wolfhece/wolf_array.py,sha256=_di7NkNjiaKAO5FLqUgxr8XFoAdnOC5B-oLMpf_g270,526959
65
65
  wolfhece/wolf_hist.py,sha256=fTEb60Q4TEwobdZsRU4CFXAId1eOKdWAqF8lnF1xEWc,3590
66
66
  wolfhece/wolf_texture.py,sha256=f4psYah1vqyeQjXz2O46d6qeKuv_Lzowk39O9Fmh_2g,20969
67
67
  wolfhece/wolf_tiles.py,sha256=v-HohqaWuMYdn75XLnA22dlloAG90iwnIqrgnB0ASQ4,10488
@@ -89,7 +89,7 @@ wolfhece/apps/curvedigitizer.py,sha256=lEJJwgAfulrrWQc-U6ij6sj59hWN3SZl4Yu1kQxVz
89
89
  wolfhece/apps/hydrometry.py,sha256=lhhJsFeb4zGL4bNQTs0co85OQ_6ssL1Oy0OUJCzhfYE,656
90
90
  wolfhece/apps/isocurrent.py,sha256=dagmGR8ja9QQ1gwz_8fU-N052hIw-W0mWGVkzLu6C7I,4247
91
91
  wolfhece/apps/splashscreen.py,sha256=EdGDN9NhudIiP7c3gVqj7dp4MWFB8ySizM_tpMnsgpE,3091
92
- wolfhece/apps/version.py,sha256=5D9bE5dzDLfYPyBmgVoMOincHBhGAqYJzByZrRcBiy8,388
92
+ wolfhece/apps/version.py,sha256=1i-0asUH6zmMJgbSbFf4H99faPoXlxUxEtZ2Ap3WZ74,388
93
93
  wolfhece/apps/wolf.py,sha256=mRnjYsUu4KIsRuamdQWAINFMuwN4eJgMo9erG-hkZ70,729
94
94
  wolfhece/apps/wolf2D.py,sha256=4z_OPQ3IgaLtjexjMKX9ppvqEYyjFLt1hcfFABy3-jU,703
95
95
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -308,8 +308,8 @@ wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=u4C7CXe_bUyGKx7c_Bi0x9
308
308
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=ORy7fz4dcp691qKzaOZHrRLZ0uXNhL-LIHxmpDGL6BI,5007
309
309
  wolfhece/wintab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
310
310
  wolfhece/wintab/wintab.py,sha256=8A-JNONV6ujgsgG3lM5Uw-pVgglPATwKs86oBzzljoc,7179
311
- wolfhece-2.2.31.dist-info/METADATA,sha256=FCE-JySySzwE8OSrK7O7_8IIPOg9RBfBVDS8sPiXfek,2729
312
- wolfhece-2.2.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
313
- wolfhece-2.2.31.dist-info/entry_points.txt,sha256=Jr187pyvA3EeJiQLjZK9yo6mJX7IAn6ygZU9T8qF_gQ,658
314
- wolfhece-2.2.31.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
315
- wolfhece-2.2.31.dist-info/RECORD,,
311
+ wolfhece-2.2.33.dist-info/METADATA,sha256=e7XIIwS1G_1LrlL2gk4Ao3ljTeGKT8afnrJE6ugVjow,2729
312
+ wolfhece-2.2.33.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
313
+ wolfhece-2.2.33.dist-info/entry_points.txt,sha256=Jr187pyvA3EeJiQLjZK9yo6mJX7IAn6ygZU9T8qF_gQ,658
314
+ wolfhece-2.2.33.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
315
+ wolfhece-2.2.33.dist-info/RECORD,,