wolfhece 2.2.32__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/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 = 32
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')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wolfhece
3
- Version: 2.2.32
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,13 +17,13 @@ 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
29
  wolfhece/analyze_poly.py,sha256=2uNdnRy828jR-aFNg9fx-8aHqXuRAg-hNQpvQ3g2qL8,60837
@@ -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
@@ -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=YFwBEBJyNYr5L7c5L4vBndUtZOBO27tL7NJgOCGDkW0,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.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,,
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,,