wolfhece 2.2.30__py3-none-any.whl → 2.2.32__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.
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 = 30
8
+ self.patch = 32
9
9
 
10
10
  def __str__(self):
11
11
 
@@ -0,0 +1,182 @@
1
+ """
2
+ Author: HECE - University of Liege, Pierre Archambeau
3
+ Date: 2025
4
+
5
+ Copyright (c) 2025 University of Liege. All rights reserved.
6
+
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.
9
+ """
10
+
11
+
12
+ """ This module provides a downloader for the WOLFHECE dataset and other files freely available on the web. """
13
+
14
+ import re
15
+ import requests
16
+ import ftplib
17
+ from pathlib import Path
18
+ from enum import Enum
19
+ from typing import Union, Optional, List
20
+ from collections import namedtuple
21
+ import logging
22
+
23
+ class DownloadType(Enum):
24
+ """ Enum to define the type of download. """
25
+ HTTP = 'http'
26
+ HTTPS = 'https'
27
+ FTP = 'ftp'
28
+
29
+ class DownloadFiles(Enum):
30
+ """ Enum to define the files to download. """
31
+ WOLFARRAYS = ('bin', 'bin.txt')
32
+ TIFARRAYS = ('tif',)
33
+ TIFFARRAYS = ('tiff',)
34
+ SHPFILES = ('shp', 'dbf', 'shx', 'prj', 'cpg', 'sbn', 'sbx')
35
+ GPKGFILES = ('gpkg',)
36
+ VECFILES = ('vec', 'vec.extra')
37
+ VECZFILES = ('vecz', 'vecz.extra')
38
+ PROJECTFILES = ('proj',)
39
+
40
+ class DonwloadDirectories(Enum):
41
+ """ Enum to define the directories for downloads. """
42
+ GDBFILES = ('gdb',)
43
+
44
+
45
+ GITLAB_EXAMPLE = 'https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main'
46
+ DATADIR = Path(__file__).parent / 'data' / 'downloads'
47
+
48
+ def clean_url(url: str) -> str:
49
+ """ Clean the URL by removing any query parameters or fragments.
50
+
51
+ :param url: The URL to clean.
52
+ :type url: str
53
+ :return: The cleaned URL.
54
+ :rtype: str
55
+ """
56
+ # Remove query parameters and fragments
57
+ cleaned_url = re.sub(r'\?.*|#.*', '', url)
58
+ # Remove trailing slashes
59
+ cleaned_url = re.sub(r'/+$', '', cleaned_url)
60
+ # Remove any leading or trailing whitespace
61
+ cleaned_url = cleaned_url.strip()
62
+ # Ensure slashes are consistent
63
+ cleaned_url = re.sub(r'(?<!:)//+', '/', cleaned_url)
64
+ # Convert Backslashes to forward slashes
65
+ cleaned_url = cleaned_url.replace('\\', '/')
66
+ # Ensure the URL starts with http:// or https://
67
+ if not cleaned_url.startswith(('http://', 'https://', 'ftp://')):
68
+ raise ValueError(f"Invalid URL: {url}. Must start with http://, https://, or ftp://")
69
+ return cleaned_url.strip()
70
+
71
+ def download_file(url: str, destination: Union[str, Path] = None, download_type: DownloadType = DownloadType.HTTP, load_from_cache:bool = True) -> None:
72
+ """ Download a file from the specified URL to the destination path.
73
+
74
+ :param url: The URL of the file to download.
75
+ :param destination: The path where the file will be saved.
76
+ :param download_type: The type of download (HTTP, HTTPS, FTP).
77
+ :type url: str
78
+ :type destination: Union[str, Path]
79
+ :type download_type: DownloadType
80
+ :return: None
81
+ :raises requests.HTTPError: If the HTTP request fails.
82
+ """
83
+
84
+ url = str(url).strip()
85
+ # Clean the URL
86
+ url = clean_url(url)
87
+
88
+ if destination is None:
89
+ try:
90
+ destination = DATADIR / Path(url).parent.name / Path(url).name
91
+ except:
92
+ destination = DATADIR / Path(url).name
93
+ # create the directory if it does not exist
94
+ destination.parent.mkdir(parents=True, exist_ok=True)
95
+
96
+ suffix = Path(url).suffix.lower()
97
+ # remove point from the suffix for matching
98
+ if suffix.startswith('.'):
99
+ suffix = suffix[1:]
100
+
101
+ # Find the download type based on the URL suffix
102
+ for file_type_enum in DownloadFiles:
103
+ if suffix in file_type_enum.value:
104
+ file_type = file_type_enum
105
+ break
106
+
107
+ # Create a list of files to download based on the download type
108
+ # by replacing suffix in the url with the appropriate file extensions
109
+ to_download = []
110
+ to_destination = []
111
+ for ext in file_type.value:
112
+ if ext.startswith('.'):
113
+ ext = ext[1:]
114
+ to_download.append(url.replace(suffix, f'{ext}'))
115
+ to_destination.append(destination.with_suffix(f'.{ext}'))
116
+
117
+
118
+ if download_type == DownloadType.HTTP or download_type == DownloadType.HTTPS:
119
+
120
+ for url, destination in zip(to_download, to_destination):
121
+
122
+ if load_from_cache and destination.exists():
123
+ logging.info(f"File {destination} already exists. Skipping download.")
124
+ continue
125
+
126
+ if not url.startswith(('http://', 'https://')):
127
+ raise ValueError(f"Invalid URL: {url}. Must start with http:// or https://")
128
+
129
+ try:
130
+ response = requests.get(url)
131
+ response.raise_for_status()
132
+ with open(destination, 'wb') as file:
133
+ file.write(response.content)
134
+ except requests.HTTPError as e:
135
+ logging.error(f"HTTP error occurred while downloading {url}: {e}")
136
+
137
+ elif download_type == DownloadType.FTP:
138
+
139
+ for url, destination in zip(to_download, to_destination):
140
+
141
+ if load_from_cache and destination.exists():
142
+ logging.info(f"File {destination} already exists. Skipping download.")
143
+ continue
144
+
145
+ if not url.startswith('ftp://'):
146
+ raise ValueError(f"Invalid URL: {url}. Must start with ftp://")
147
+
148
+ try:
149
+ parsed_url = ftplib.parse_ftp_url(url)
150
+ with ftplib.FTP(parsed_url.hostname) as ftp:
151
+ ftp.login()
152
+ with open(destination, 'wb') as file:
153
+ ftp.retrbinary(f'RETR {parsed_url.path}', file.write)
154
+ except ftplib.all_errors as e:
155
+ logging.error(f"FTP error occurred while downloading {url}: {e}")
156
+ else:
157
+ raise ValueError(f"Unsupported download type: {download_type}")
158
+
159
+ return to_destination[0]
160
+
161
+ def toys_dataset(dir:str, file:str, load_from_cache:bool = True):
162
+ """ Download toy files from the WOLFHECE dataset.
163
+
164
+ :param dir: The directory where the file will be saved.
165
+ :param file: The name of the file to download.
166
+ :type dir: str
167
+ :type file: str
168
+ :return: The path to the downloaded file.
169
+ """
170
+ url = f"{GITLAB_EXAMPLE}/{dir}/{file}"
171
+ destination = DATADIR / dir / file
172
+ return download_file(url, destination, load_from_cache=load_from_cache)
173
+
174
+ if __name__ == "__main__":
175
+ # Example usage
176
+ print(download_file(r'https:\\gitlab.uliege.be\HECE\wolf_examples\-\raw\main\Extract_part_array\extraction.vec'))
177
+ print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/Extract_part_array/extraction.vec'))
178
+ print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/Extract_part_array/Array_vector.proj'))
179
+ print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/Array_Theux_Pepinster/mnt.bin'))
180
+ print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/Array_Theux_Pepinster/mnt.tif'))
181
+ print(download_file('https://gitlab.uliege.be/HECE/wolf_examples/-/raw/main/PICC/PICC_Vesdre.shp'))
182
+ print(toys_dataset('Extract_part_array', 'extraction.vec'))
@@ -25,7 +25,7 @@ from .drawing_obj import Element_To_Draw
25
25
  from .PyTranslate import _
26
26
  from .wolfresults_2D import views_2D, Wolfresults_2D
27
27
  from .Results2DGPU import wolfres2DGPU
28
- from .pybridges import stored_values_pos,stored_values_unk, parts_values, operators, stored_values_coords
28
+ from .pybridges import stored_values_pos, stored_values_unk, parts_values, operators, stored_values_coords
29
29
 
30
30
  from zipfile import ZIP_DEFLATED, ZipFile
31
31
 
@@ -48,8 +48,8 @@ class Extracting_Zones(Zones):
48
48
  def __init__(self, filename='', ox: float = 0, oy: float = 0, tx: float = 0, ty: float = 0, parent=None, is2D=True, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False) -> None:
49
49
  super().__init__(filename, ox, oy, tx, ty, parent, is2D, idx, plotted, mapviewer, need_for_wx)
50
50
 
51
- self.parts:dict = None
52
- self.linked:Union[dict, list] = None
51
+ self.parts:dict = None # Store the values inside the polygons - dict[dict] or dict[list]
52
+ self.linked:Union[dict, list] = None # Object from which the values are extracted - dict or list
53
53
 
54
54
  def cache_data(self, outputfile:str):
55
55
  """
@@ -163,14 +163,11 @@ class Extracting_Zones(Zones):
163
163
  locdict[cursim] = np.array([np.array([ tuple(lst1), np.array(lst2, dtype= np.int32)], dtype=object ) for lst1, lst2 in curnparray], dtype=object)
164
164
 
165
165
 
166
- def find_values_inside_parts(self, linked_arrays):
166
+ def find_values_inside_parts(self, linked_arrays: dict | list):
167
167
  """
168
- Récupère les valeurs à l'intérieur de la zone
168
+ Get values inside the polygons defined in the zones.
169
169
 
170
- Retour :
171
- - dictionnaire dont la clé est le nom (ou l'index) du polygone dans la zone --> parties centrale, amont ou aval
172
- - chaque entrée est un dictionnaire dont la clé 'values' contient un dictionnaire pour chaque matrice du projet
173
- - chaque élément de ce sous-dictionnaire est un tuple contenant toutes les valeurs utiles
170
+ :param linked_arrays: list or dict of arrys/simulations to link with the polygons.
174
171
 
175
172
  ***
176
173
  ATTENTION : si linked_arrays est un dictionnaire, alors un niveau supérieur est ajouté sur base des clés de ce dictionnaire, dans ce cas, self.linked est un dict et non une liste
@@ -179,6 +176,7 @@ class Extracting_Zones(Zones):
179
176
  """
180
177
  if isinstance(linked_arrays, dict):
181
178
 
179
+ self.linked = {}
182
180
  for curkey, curgroup in linked_arrays.items():
183
181
  self.linked[curkey] = [(curlink.idx, type(curlink)) for curlink in curgroup]
184
182
 
wolfhece/wolf_array.py CHANGED
@@ -111,6 +111,11 @@ except ImportError as e:
111
111
  print(e)
112
112
  raise Exception(_('Error importing modules'))
113
113
 
114
+ try:
115
+ from .pydownloader import download_file, toys_dataset
116
+ except ImportError as e:
117
+ raise Exception(_('Error importing pydownloader module'))
118
+
114
119
  WOLF_ARRAY_HILLSHAPE = -1
115
120
  WOLF_ARRAY_FULL_SINGLE = 1
116
121
  WOLF_ARRAY_FULL_DOUBLE = 2
@@ -5605,6 +5610,14 @@ class WolfArray(Element_To_Draw, header_wolf):
5605
5610
 
5606
5611
  if fname is not None:
5607
5612
 
5613
+ # check if fname is an url
5614
+ if str(fname).startswith('http:') or str(fname).startswith('https:'):
5615
+ try:
5616
+ fname = download_file(fname)
5617
+ except Exception as e:
5618
+ logging.error(_('Error while downloading file: %s') % e)
5619
+ return
5620
+
5608
5621
  self.filename = str(fname)
5609
5622
  logging.info(_('Loading file : %s') % self.filename)
5610
5623
  self.read_all()
@@ -6240,20 +6253,39 @@ class WolfArray(Element_To_Draw, header_wolf):
6240
6253
  if reset_plot:
6241
6254
  self.reset_plot()
6242
6255
 
6243
- def statistics(self, inside_polygon:vector | Polygon = None):
6256
+ def statistics(self, inside_polygon:vector | Polygon | np.ndarray = None) -> dict[str, float | np.ndarray]:
6244
6257
  """
6245
6258
  Statistics on Selected data or the whole array if no selection
6246
6259
 
6247
6260
  :param inside_polygon: vector or Polygon to select data inside the polygon
6248
6261
  :return: mean, std, median, sum, volume (sum*dx*dy), values
6262
+ :rtype: dict[str, float | np.ndarray]
6263
+
6264
+ Translated Keys are:
6265
+ - _('Mean'): mean value of the selected data
6266
+ - _('Std'): standard deviation of the selected data
6267
+ - _('Median'): median value of the selected data
6268
+ - _('Sum'): sum of the selected data
6269
+ - _('Volume'): volume of the selected data (sum * dx * dy)
6270
+ - _('Values'): values of the selected data as a numpy array
6249
6271
  """
6250
6272
 
6251
6273
  if inside_polygon is not None:
6252
- ij = self.get_ij_inside_polygon(inside_polygon)
6274
+ if isinstance(inside_polygon, vector | Polygon):
6275
+ ij = self.get_ij_inside_polygon(inside_polygon)
6276
+ elif isinstance(inside_polygon, np.ndarray):
6277
+ if inside_polygon.ndim == 2 and inside_polygon.shape[1] == 2:
6278
+ ij = self.get_ij_from_xy_array(inside_polygon)
6279
+ else:
6280
+ logging.error(_('Invalid shape for inside_polygon numpy array'))
6281
+ return {}
6282
+
6253
6283
  vals = self.array[ij[:,0], ij[:,1]]
6284
+
6254
6285
  elif self.SelectionData.nb == 0 or self.SelectionData.myselection == 'all':
6255
6286
  logging.info(_('No selection -- statistics on the whole array'))
6256
6287
  vals = self.array[~self.array.mask].ravel().data # all values
6288
+
6257
6289
  else:
6258
6290
  vals = self.SelectionData.get_values_sel()
6259
6291
 
@@ -8996,7 +9028,7 @@ class WolfArray(Element_To_Draw, header_wolf):
8996
9028
  C'est le cas notamment de Wolfresults_2D
8997
9029
  """
8998
9030
 
8999
- return self.get_values_insidepoly(myvect, usemask,getxy)
9031
+ return self.get_values_insidepoly(myvect, usemask, getxy)
9000
9032
 
9001
9033
  def get_all_values_underpoly(self, myvect: vector, usemask:bool=True, getxy:bool=False):
9002
9034
  """
@@ -10145,7 +10177,7 @@ class WolfArray(Element_To_Draw, header_wolf):
10145
10177
 
10146
10178
  return my_extr
10147
10179
 
10148
- def get_value(self, x:float, y:float, z:float=0., nullvalue:float=-99999):
10180
+ def get_value(self, x:float, y:float, z:float=0., nullvalue:float=-99999, convert_to_float:bool=True):
10149
10181
  """
10150
10182
  Return the value at given coordinates
10151
10183
 
@@ -10180,8 +10212,10 @@ class WolfArray(Element_To_Draw, header_wolf):
10180
10212
  else:
10181
10213
  value = nullvalue
10182
10214
 
10183
- #FIXME : forcing to convert to float is not a good idea
10184
- return float(value)
10215
+ if convert_to_float:
10216
+ return float(value)
10217
+ else:
10218
+ return value
10185
10219
 
10186
10220
  def get_xlim(self, window_x:float, window_y:float):
10187
10221
  """
@@ -10462,7 +10496,16 @@ class WolfArray(Element_To_Draw, header_wolf):
10462
10496
  vmin:float=None, vmax:float=None,
10463
10497
  figsize:tuple=None,
10464
10498
  Walonmap:bool=False,
10465
- 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',
10466
10509
  first_mask_data:bool=True,
10467
10510
  with_legend:bool=False,
10468
10511
  IGN:bool=False,
@@ -10514,6 +10557,19 @@ class WolfArray(Element_To_Draw, header_wolf):
10514
10557
  - `'IMAGERIE/ORTHO_2022_ETE'`
10515
10558
  - `'IMAGERIE/ORTHO_2023_ETE'`
10516
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'
10517
10573
  :type cat: str, optional (Default value = `'IMAGERIE/ORTHO_2022_ETE'`)
10518
10574
  :param first_mask_data: If True, applies the mask to the data before plotting. Default is True.
10519
10575
  :type first_mask_data: bool, optional (Default value = True)
@@ -10523,6 +10579,17 @@ class WolfArray(Element_To_Draw, header_wolf):
10523
10579
  :rtype: tuple
10524
10580
  """
10525
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
+
10526
10593
  if first_mask_data:
10527
10594
  self.mask_data(self.nullvalue)
10528
10595
 
@@ -10538,75 +10605,91 @@ class WolfArray(Element_To_Draw, header_wolf):
10538
10605
  from .PyWMS import getWalonmap
10539
10606
  from PIL import Image
10540
10607
 
10541
- try:
10542
- 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()
10543
10614
 
10544
- 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])
10545
10616
 
10546
- if scale_xovery > 1.:
10547
- # x is larger than y
10548
- w = 2000
10549
- h = int(2000 / scale_xovery)
10550
- else:
10551
- # y is larger than x
10552
- h = 2000
10553
- 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)
10554
10625
 
10555
- IO_image = getWalonmap(cat, bounds[0][0], bounds[1][0],
10556
- bounds[0][1], bounds[1][1],
10557
- w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
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
10558
10629
 
10559
- image = Image.open(IO_image)
10630
+ image = Image.open(IO_image)
10631
+
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)
10560
10636
 
10561
- 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')
10562
- except Exception as e:
10563
- logging.error(_('Error while fetching the map image from WalOnMap'))
10564
- logging.error(e)
10565
10637
  elif IGN:
10566
10638
  from .PyWMS import getNGI
10567
10639
  from PIL import Image
10568
- try:
10569
- bounds = self.get_bounds()
10570
- scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10571
- if scale_xovery > 1.:
10572
- # x is larger than y
10573
- w = 2000
10574
- h = int(2000 / scale_xovery)
10575
- else:
10576
- # y is larger than x
10577
- h = 2000
10578
- w = int(2000 * scale_xovery)
10579
- IO_image = getNGI(cat, bounds[0][0], bounds[1][0],
10580
- bounds[0][1], bounds[1][1],
10581
- w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10582
- image = Image.open(IO_image)
10583
- 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')
10584
- except Exception as e:
10585
- logging.error(_('Error while fetching the map image from IGN'))
10586
- 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)
10587
10665
 
10588
10666
  elif Cartoweb:
10589
10667
  from .PyWMS import getCartoweb
10590
10668
  from PIL import Image
10591
- try:
10592
- bounds = self.get_bounds()
10593
- scale_xovery = (bounds[0][1] - bounds[0][0]) / (bounds[1][1] - bounds[1][0])
10594
- if scale_xovery > 1.:
10595
- # x is larger than y
10596
- w = 2000
10597
- h = int(2000 / scale_xovery)
10598
- else:
10599
- # y is larger than x
10600
- h = 2000
10601
- w = int(2000 * scale_xovery)
10602
- IO_image = getCartoweb(cat, bounds[0][0], bounds[1][0],
10603
- bounds[0][1], bounds[1][1],
10604
- w=w, h=h, tofile=False) # w=self.nbx, h=self.nby
10605
- image = Image.open(IO_image)
10606
- 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')
10607
- except Exception as e:
10608
- logging.error(_('Error while fetching the map image from Cartoweb'))
10609
- 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)
10610
10693
 
10611
10694
  if vmin is None and vmax is not None:
10612
10695
  vmin = self.mypal.values[0]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wolfhece
3
- Version: 2.2.30
3
+ Version: 2.2.32
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,7 +17,7 @@ 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=-MIgo6-PVir2NxQn6RoOdpEkqfrJv8Ts6_FjEZqXJC4,351630
20
+ wolfhece/PyVertexvectors.py,sha256=MXoqgHVRMvpUOngqpErwT68JwUJo9FhEl1H4HB10-Zk,352574
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
@@ -26,7 +26,7 @@ wolfhece/ReadDataDCENN.py,sha256=vm-I4YMryvRldjXTvRYEUCxZsjb_tM7U9yj6OaPyD0k,153
26
26
  wolfhece/Results2DGPU.py,sha256=GTu7PMuwfH-xH8J7sVr6zq2CTkGKF24fG1ujEW62PtM,31598
27
27
  wolfhece/__init__.py,sha256=EnpZ2yDEXueP7GAKV0uA2vAwMiZFyBjDAFcL5Y7LzbM,1850
28
28
  wolfhece/_add_path.py,sha256=mAyu85CQHk0KgUI6ZizweeQiw1Gdyea9OEjGLC6lLA4,916
29
- wolfhece/analyze_poly.py,sha256=jsCUsd0ZJtTwSk5hekcXj8i0tGhH-WCfNkrBtPRJpCc,12715
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,8 +51,9 @@ 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
55
  wolfhece/pylogging.py,sha256=4TI8hgBB65z-zpvU5Rfa2jkPXPhJaqXjHVPwbcdzTNc,4528
55
- wolfhece/pypolygons_scen.py,sha256=dG4zyJL_t5wgDqRfe-OqSH-fnxUt-su1H-tM3K3wHnc,46339
56
+ wolfhece/pypolygons_scen.py,sha256=NWaNeK0RSUeOkgukeogK9FLmQiDjGZ9yhqs9208fojM,46237
56
57
  wolfhece/pyshields.py,sha256=KMtUO5kD0lisKnJD1NsDz-qaY5DpFcmS4O3WkXtUSmo,27898
57
58
  wolfhece/pyviews.py,sha256=zuZjWUptRDm1MTE1PN4Xj_qSITnojgDMG0LlFIBH3SE,13739
58
59
  wolfhece/pywalous.py,sha256=mWB7UxlYMIbPxNUDlONQEjcOOy9VSaRU9aYWZ5IFLu8,19164
@@ -60,7 +61,7 @@ wolfhece/rain_SPWMI.py,sha256=qCfcmF7LajloOaCwnTrrSMzyME03YyilmRUOqrPrv3U,13846
60
61
  wolfhece/textpillow.py,sha256=map7HsGYML_o5NHRdFg2s_TVQed_lDnpYNDv27MM0Vw,14130
61
62
  wolfhece/tools2d_dll.py,sha256=TfvvmyZUqEZIH0uHwUCJf0bdmCks_AiidDt23Unsp5w,13550
62
63
  wolfhece/tools_mpl.py,sha256=gQ3Jg1iuZiecmMqa5Eli2ZLSkttu68VXL8YmMDBaEYU,564
63
- wolfhece/wolf_array.py,sha256=15bCTr6nplKwGrkKR4vJR_NZCnhSZsoceUtV99Uy4C8,521981
64
+ wolfhece/wolf_array.py,sha256=_di7NkNjiaKAO5FLqUgxr8XFoAdnOC5B-oLMpf_g270,526959
64
65
  wolfhece/wolf_hist.py,sha256=fTEb60Q4TEwobdZsRU4CFXAId1eOKdWAqF8lnF1xEWc,3590
65
66
  wolfhece/wolf_texture.py,sha256=f4psYah1vqyeQjXz2O46d6qeKuv_Lzowk39O9Fmh_2g,20969
66
67
  wolfhece/wolf_tiles.py,sha256=v-HohqaWuMYdn75XLnA22dlloAG90iwnIqrgnB0ASQ4,10488
@@ -88,7 +89,7 @@ wolfhece/apps/curvedigitizer.py,sha256=lEJJwgAfulrrWQc-U6ij6sj59hWN3SZl4Yu1kQxVz
88
89
  wolfhece/apps/hydrometry.py,sha256=lhhJsFeb4zGL4bNQTs0co85OQ_6ssL1Oy0OUJCzhfYE,656
89
90
  wolfhece/apps/isocurrent.py,sha256=dagmGR8ja9QQ1gwz_8fU-N052hIw-W0mWGVkzLu6C7I,4247
90
91
  wolfhece/apps/splashscreen.py,sha256=EdGDN9NhudIiP7c3gVqj7dp4MWFB8ySizM_tpMnsgpE,3091
91
- wolfhece/apps/version.py,sha256=TbVLaOlu0bvthJf8mZ0I5HvlwlTNg4-IrIDSbM0cAAU,388
92
+ wolfhece/apps/version.py,sha256=YFwBEBJyNYr5L7c5L4vBndUtZOBO27tL7NJgOCGDkW0,388
92
93
  wolfhece/apps/wolf.py,sha256=mRnjYsUu4KIsRuamdQWAINFMuwN4eJgMo9erG-hkZ70,729
93
94
  wolfhece/apps/wolf2D.py,sha256=4z_OPQ3IgaLtjexjMKX9ppvqEYyjFLt1hcfFABy3-jU,703
94
95
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -307,8 +308,8 @@ wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=u4C7CXe_bUyGKx7c_Bi0x9
307
308
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=ORy7fz4dcp691qKzaOZHrRLZ0uXNhL-LIHxmpDGL6BI,5007
308
309
  wolfhece/wintab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
309
310
  wolfhece/wintab/wintab.py,sha256=8A-JNONV6ujgsgG3lM5Uw-pVgglPATwKs86oBzzljoc,7179
310
- wolfhece-2.2.30.dist-info/METADATA,sha256=6DgxvLnytFPLyQpPZ2b0ZoyBqOe-rb98b-jm6FTw9Os,2729
311
- wolfhece-2.2.30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
312
- wolfhece-2.2.30.dist-info/entry_points.txt,sha256=Jr187pyvA3EeJiQLjZK9yo6mJX7IAn6ygZU9T8qF_gQ,658
313
- wolfhece-2.2.30.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
314
- wolfhece-2.2.30.dist-info/RECORD,,
311
+ wolfhece-2.2.32.dist-info/METADATA,sha256=P-q8Ge4qvtiLISYIb4XbpDkwbCdh5KMPx-3k10Xr6qg,2729
312
+ wolfhece-2.2.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
313
+ wolfhece-2.2.32.dist-info/entry_points.txt,sha256=Jr187pyvA3EeJiQLjZK9yo6mJX7IAn6ygZU9T8qF_gQ,658
314
+ wolfhece-2.2.32.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
315
+ wolfhece-2.2.32.dist-info/RECORD,,