wolfhece 2.1.94__py3-none-any.whl → 2.1.95__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 = 1
8
- self.patch = 94
8
+ self.patch = 95
9
9
 
10
10
  def __str__(self):
11
11
 
@@ -49,6 +49,14 @@ try:
49
49
  except:
50
50
  logging.error(_('WOLFGPU not installed !'))
51
51
 
52
+ # *****************
53
+ # ACCEPTED PREFIX
54
+ # *****************
55
+ # bath_*.tif
56
+ # mann_*.tif
57
+ # infil_*.tif
58
+
59
+ ACCEPTED_PREFIX = ['bath_', 'mann_', 'infil_']
52
60
 
53
61
  def delete_folder(pth:Path):
54
62
  for sub in pth.iterdir():
@@ -410,6 +418,48 @@ class Config_Manager_2D_GPU:
410
418
  _flatten(self.configs, self._flat_configs)
411
419
 
412
420
 
421
+ def check_prefix(self, list_tif:list[Path]) -> bool:
422
+ """ Check if all files have the right prefix """
423
+
424
+ logging.info(_('Checking if prefix of all files are right...\n'))
425
+
426
+ logging.info(_('Number of tif files : {}'.format(len(list_tif))))
427
+
428
+ standard_files = ['bathymetry.tif', 'manning.tif', 'infiltration.tif', 'h.tif', 'qx.tif', 'qy.tif']
429
+
430
+ log = ''
431
+ for curtif in list_tif:
432
+
433
+ if curtif.name.lower() in standard_files:
434
+ # No need to test the prefix
435
+ break
436
+
437
+ # test if the prefix is in the accepted prefix
438
+ if not any([curtif.name.lower().startswith(curprefix) for curprefix in ACCEPTED_PREFIX]):
439
+ loclog = _('Bad prefix for {} !'.format(curtif.name)) + '\n'
440
+
441
+ tests = ['man_', 'mnn_', 'ann_', 'mamn_', 'mannn_']
442
+ for test in tests:
443
+ if curtif.name.lower().startswith(test):
444
+ loclog += _('Did you mean "mann_" ?') + '\n'
445
+ break
446
+
447
+ tests = ['bath_', 'bth_', 'ath_', 'bat_', 'bathymetry_']
448
+ for test in tests:
449
+ if curtif.name.lower().startswith(test):
450
+ loclog += _('Did you mean "bath_" ?') + '\n'
451
+ break
452
+
453
+ tests = ['infil_', 'infl_', 'nfil_', 'ifil_', 'infiltration_']
454
+ for test in tests:
455
+ if curtif.name.lower().startswith(test):
456
+ loclog += _('Did you mean "infil_" ?') + '\n'
457
+ break
458
+
459
+ logging.warning(loclog)
460
+
461
+ return loclog
462
+
413
463
  def check_consistency(self) -> str:
414
464
  """
415
465
  Check consistency of all files
@@ -657,10 +707,9 @@ class Config_Manager_2D_GPU:
657
707
 
658
708
  return curdict
659
709
 
660
- def _select_tif_partname(self, curdict:dict, tifstr:Literal['bath', 'mann']):
661
- """ Select tif files with a 'str' in their name """
662
-
663
- tif_list = [curtif for curtif in curdict[GPU_2D_file_extensions.TIF.value] if tifstr in curtif.name]
710
+ def _select_tif_partname(self, curdict:dict, tifstr:Literal['bath_', 'mann_', 'infil_']):
711
+ """ Select tif files with a 'str' as name's prefix """
712
+ tif_list = [curtif for curtif in curdict[GPU_2D_file_extensions.TIF.value] if curtif.name.lower().startswith(tifstr)]
664
713
 
665
714
  return tif_list
666
715
 
@@ -671,9 +720,9 @@ class Config_Manager_2D_GPU:
671
720
  curdicts = self.get_dicts(curtree)
672
721
 
673
722
  # tous les fichiers tif -> list of lists
674
- all_tif_bath = [self._select_tif_partname(curdict, 'bath') for curdict in curdicts]
675
- all_tif_mann = [self._select_tif_partname(curdict, 'mann') for curdict in curdicts]
676
- all_tif_infil = [self._select_tif_partname(curdict, 'infil') for curdict in curdicts]
723
+ all_tif_bath = [self._select_tif_partname(curdict, 'bath_') for curdict in curdicts]
724
+ all_tif_mann = [self._select_tif_partname(curdict, 'mann_') for curdict in curdicts]
725
+ all_tif_infil = [self._select_tif_partname(curdict, 'infil_') for curdict in curdicts]
677
726
 
678
727
  # flatten list of lists
679
728
  all_tif_bath = [curel for curlist in all_tif_bath if len(curlist)>0 for curel in curlist]
@@ -702,9 +751,9 @@ class Config_Manager_2D_GPU:
702
751
  curdicts = self.get_dicts(curtree)
703
752
 
704
753
  # tous les fichiers tif -> list of lists
705
- all_tif_bath = [self._select_tif_partname(curdict, 'bath') for curdict in curdicts]
706
- all_tif_mann = [self._select_tif_partname(curdict, 'mann') for curdict in curdicts]
707
- all_tif_infil = [self._select_tif_partname(curdict, 'infil') for curdict in curdicts]
754
+ all_tif_bath = [self._select_tif_partname(curdict, 'bath_') for curdict in curdicts]
755
+ all_tif_mann = [self._select_tif_partname(curdict, 'mann_') for curdict in curdicts]
756
+ all_tif_infil = [self._select_tif_partname(curdict, 'infil_') for curdict in curdicts]
708
757
 
709
758
  # flatten list of lists
710
759
  all_tif_bath = [curel for curlist in all_tif_bath if len(curlist)>0 for curel in curlist]
@@ -719,10 +768,10 @@ class Config_Manager_2D_GPU:
719
768
 
720
769
  def create_vec(self,
721
770
  from_path:Path,
722
- which:Literal['bath', 'mann', 'infil'] = 'bath') -> Zones:
771
+ which:Literal['bath_', 'mann_', 'infil_'] = 'bath_') -> Zones:
723
772
  """ Create a vec file from a path """
724
773
 
725
- assert which in ['bath', 'mann', 'infil']
774
+ assert which in ACCEPTED_PREFIX, _('Bad prefix !')
726
775
 
727
776
  curtree = self.get_tree(from_path)
728
777
  curdicts = self.get_dicts(curtree)
@@ -1342,6 +1391,10 @@ class UI_Manager_2D_GPU():
1342
1391
  self._create_vec.Bind(wx.EVT_BUTTON,self.oncreatevec)
1343
1392
  self._create_vec.SetToolTip(_('Create a .vecz file (with contour and global bounds) from all bathymetry and manning .tif files\nBe sure that all files are right named !\n\n - bathymetry must contain "bath"\n - manning must contain "mann"\n - infiltration must contain "infil"'))
1344
1393
 
1394
+ self._check_prefix = wx.Button(self._frame,label = _('Check prefix (tif files)'))
1395
+ self._check_prefix.Bind(wx.EVT_BUTTON,self.oncheck_prefix)
1396
+ self._check_prefix.SetToolTip(_('Check prefix of .tif files\n\n - bath_*.tif\n - mann_*.tif\n - infil_*.tif\n\nThe prefix must be "bath_", "mann_" and "infil_"'))
1397
+
1345
1398
  self._checkconsistency = wx.Button(self._frame,label = _('Check consistency'))
1346
1399
  self._checkconsistency.Bind(wx.EVT_BUTTON,self.oncheck_consistency)
1347
1400
  self._checkconsistency.SetToolTip(_('Check consistency of the scenario\n\n - bathymetry.tif\n - manning.tif\n - infiltration.tif\n - hydrographs\n - initial conditions\n - boundary conditions\n - scripts'))
@@ -1393,6 +1446,7 @@ class UI_Manager_2D_GPU():
1393
1446
  sizer_buttons.Add(self._create_void_scripts,1,wx.EXPAND)
1394
1447
  sizer_buttons.Add(self._create_vrt,1,wx.EXPAND)
1395
1448
  sizer_buttons.Add(self._translate_vrt,1,wx.EXPAND)
1449
+ sizer_buttons.Add(self._check_prefix,1,wx.EXPAND)
1396
1450
  sizer_buttons.Add(self._checkconsistency,1,wx.EXPAND)
1397
1451
  sizer_buttons.Add(self._create_vec,1,wx.EXPAND)
1398
1452
  sizer_buttons.Add(self.listsims,1,wx.EXPAND)
@@ -1548,12 +1602,41 @@ class UI_Manager_2D_GPU():
1548
1602
  """ Traduction d'un fichier vrt en tif """
1549
1603
 
1550
1604
  logging.info(_('Translating vrt to tif ...'))
1551
- mydata = self._treelist.GetItemData(self._selected_item)
1605
+ if self._selected_item is None or self._selected_item == self._treelist.GetRootItem():
1606
+ logging.info(_('No item selected ! -- using root item'))
1607
+ with wx.MessageDialog(None, _('No item selected ! -- using root item'), _('Warning'), wx.OK | wx.CANCEL | wx.ICON_WARNING) as dlg:
1608
+ ret = dlg.ShowModal()
1609
+ if ret != wx.ID_OK:
1610
+ return
1611
+ mydata = self._parent.configs
1612
+ else:
1613
+ mydata = self._treelist.GetItemData(self._selected_item)
1552
1614
 
1553
1615
  # création du fichier vrt
1554
1616
  self._parent.translate_vrt2tif(mydata['path'])
1555
1617
  logging.info(_('... done !'))
1556
1618
 
1619
+ def oncheck_prefix(self,e:wx.MouseEvent):
1620
+ """ Vérification des préfixes des fichiers tif """
1621
+
1622
+ logging.info(_('Checking prefix ...'))
1623
+ if self._selected_item is None or self._selected_item == self._treelist.GetRootItem():
1624
+ logging.info(_('No item selected ! -- using root item'))
1625
+ with wx.MessageDialog(None, _('No item selected ! -- using root item'), _('Warning'), wx.OK | wx.CANCEL | wx.ICON_WARNING) as dlg:
1626
+ ret = dlg.ShowModal()
1627
+ if ret != wx.ID_OK:
1628
+ return
1629
+ mydata = self._parent.configs
1630
+ else:
1631
+ mydata = self._treelist.GetItemData(self._selected_item)
1632
+
1633
+ # création du fichier vrt
1634
+ log = self._parent.check_prefix(mydata['.tif']+mydata['.tiff'])
1635
+ if log =='':
1636
+ self._txtctrl.WriteText(_("All is fine !"))
1637
+ else:
1638
+ self._txtctrl.WriteText(log)
1639
+
1557
1640
  def oncheck_consistency(self,e:wx.MouseEvent):
1558
1641
  """ Vérification de la cohérence des fichiers """
1559
1642
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wolfhece
3
- Version: 2.1.94
3
+ Version: 2.1.95
4
4
  Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
5
5
  License: Copyright (c) 2024 University of Liege. All rights reserved.
6
6
  Project-URL: Homepage, https://uee.uliege.be/hece
@@ -75,7 +75,7 @@ wolfhece/apps/curvedigitizer.py,sha256=Yps4bcayzbsz0AoVc_dkSk35dEhhn_esIBy1Ziefg
75
75
  wolfhece/apps/hydrometry.py,sha256=lhhJsFeb4zGL4bNQTs0co85OQ_6ssL1Oy0OUJCzhfYE,656
76
76
  wolfhece/apps/isocurrent.py,sha256=dagmGR8ja9QQ1gwz_8fU-N052hIw-W0mWGVkzLu6C7I,4247
77
77
  wolfhece/apps/splashscreen.py,sha256=SrustmIQeXnsiD-92OzjdGhBi-S7c_j-cSvuX4T6rtg,2929
78
- wolfhece/apps/version.py,sha256=rZi-X4W-8UB0KrenDxLV9h-lnAEpdduh_0hJNqjLsoY,388
78
+ wolfhece/apps/version.py,sha256=r2wcZoRV0_klAhBwCfmfnaBz0LnBxe3grPK6uuy4SXg,388
79
79
  wolfhece/apps/wolf.py,sha256=j_CgvsL8rwixbVvVD5Z0s7m7cHZ86gmFLojKGuetMls,729
80
80
  wolfhece/apps/wolf2D.py,sha256=4z_OPQ3IgaLtjexjMKX9ppvqEYyjFLt1hcfFABy3-jU,703
81
81
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -262,7 +262,7 @@ wolfhece/report/reporting.py,sha256=JUEXovx_S4jpYkJEBU0AC-1Qw2OkkWyV3VAp6iOfSHc,
262
262
  wolfhece/report/wolf_report.png,sha256=NoSV58LSwb-oxCcZScRiJno-kxDwRdm_bK-fiMsKJdA,592485
263
263
  wolfhece/scenario/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
264
264
  wolfhece/scenario/check_scenario.py,sha256=VVjtxfcLAgq_Pf8VSqRq6BJ-y4Zi24CntJpZWxAv3n8,5162
265
- wolfhece/scenario/config_manager.py,sha256=0B_ZtMkcbZRwzkXHwT6jSC3-Lq85P2oBiq1Qxjkfh2w,86869
265
+ wolfhece/scenario/config_manager.py,sha256=aQFqY2aDcKR5r7NIFqjcO1VJngajK_lOE1ZX5LVKKpc,90591
266
266
  wolfhece/scenario/imposebc_void.py,sha256=PqA_99hKcaqK5zsK6IRIc5Exgg3WVpgWU8xpwNL49zQ,5571
267
267
  wolfhece/scenario/update_void.py,sha256=ay8C_FxfXN627Hx46waaAO6F3ovYmOCTxseUumKAY7c,7474
268
268
  wolfhece/shaders/fragment_shader_texture.glsl,sha256=w6h8d5mJqFaGbao0LGmjRcFFdcEQ3ICIl9JpuT71K5k,177
@@ -285,8 +285,8 @@ wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=8PlMYrb_8jI8h9F0_EagpM
285
285
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=ORy7fz4dcp691qKzaOZHrRLZ0uXNhL-LIHxmpDGL6BI,5007
286
286
  wolfhece/wintab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
287
287
  wolfhece/wintab/wintab.py,sha256=8A-JNONV6ujgsgG3lM5Uw-pVgglPATwKs86oBzzljoc,7179
288
- wolfhece-2.1.94.dist-info/METADATA,sha256=7QKX23LbIgX7dd_Qxm_3o1ItJk0-1y0clPJ_xQP3wwU,2570
289
- wolfhece-2.1.94.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
290
- wolfhece-2.1.94.dist-info/entry_points.txt,sha256=ZZ-aSfbpdcmo-wo84lRFzBN7LaSnD1XRGSaAKVX-Gpc,522
291
- wolfhece-2.1.94.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
292
- wolfhece-2.1.94.dist-info/RECORD,,
288
+ wolfhece-2.1.95.dist-info/METADATA,sha256=ixt70owejkFtGci4s6dE8uW9md9MKv7CpX-pQj9mOv0,2570
289
+ wolfhece-2.1.95.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
290
+ wolfhece-2.1.95.dist-info/entry_points.txt,sha256=ZZ-aSfbpdcmo-wo84lRFzBN7LaSnD1XRGSaAKVX-Gpc,522
291
+ wolfhece-2.1.95.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
292
+ wolfhece-2.1.95.dist-info/RECORD,,