wolfhece 2.1.128__py3-none-any.whl → 2.2.1__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.
Files changed (44) hide show
  1. wolfhece/PyDraw.py +109 -46
  2. wolfhece/PyGui.py +3 -0
  3. wolfhece/PyGuiHydrology.py +24 -24
  4. wolfhece/PyPalette.py +27 -11
  5. wolfhece/PyParams.py +5 -1
  6. wolfhece/PyVertexvectors.py +52 -7
  7. wolfhece/Results2DGPU.py +17 -0
  8. wolfhece/acceptability/acceptability_gui.py +29 -18
  9. wolfhece/acceptability/func.py +23 -21
  10. wolfhece/apps/version.py +2 -2
  11. wolfhece/eikonal.py +1 -1
  12. wolfhece/hydrology/Catchment.py +113 -12
  13. wolfhece/hydrology/Comparison.py +54 -52
  14. wolfhece/hydrology/Optimisation.py +309 -178
  15. wolfhece/hydrology/PostProcessHydrology.py +6 -3
  16. wolfhece/hydrology/RetentionBasin.py +21 -14
  17. wolfhece/hydrology/SubBasin.py +128 -12
  18. wolfhece/hydrology/constant.py +3 -0
  19. wolfhece/hydrology/cst_exchanges.py +364 -38
  20. wolfhece/hydrology/plot_hydrology.py +34 -18
  21. wolfhece/hydrology/read.py +16 -6
  22. wolfhece/lagrangian/particle_system_ui.py +1 -1
  23. wolfhece/lagrangian/particles.py +1 -1
  24. wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
  25. wolfhece/lazviewer/vfuncsdir/vfuncs.cp310-win_amd64.pyd +0 -0
  26. wolfhece/lazviewer/viewer/viewer.exe +0 -0
  27. wolfhece/lazviewer/viewer/viewer_np1_23_5.exe +0 -0
  28. wolfhece/libs/WolfDll.dll +0 -0
  29. wolfhece/libs/Wolf_tools.dll +0 -0
  30. wolfhece/libs/get_infos.cp310-win_amd64.pyd +0 -0
  31. wolfhece/libs/verify_wolf.cp310-win_amd64.pyd +0 -0
  32. wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
  33. wolfhece/radar/wolfradar.py +75 -22
  34. wolfhece/shapes/__init__.py +0 -0
  35. wolfhece/shapes/circle.py +335 -0
  36. wolfhece/tools2d_dll.py +359 -0
  37. wolfhece/wolf_array.py +3 -2
  38. wolfhece/wolfresults_2D.py +162 -33
  39. {wolfhece-2.1.128.dist-info → wolfhece-2.2.1.dist-info}/METADATA +15 -9
  40. {wolfhece-2.1.128.dist-info → wolfhece-2.2.1.dist-info}/RECORD +43 -39
  41. wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
  42. {wolfhece-2.1.128.dist-info → wolfhece-2.2.1.dist-info}/WHEEL +0 -0
  43. {wolfhece-2.1.128.dist-info → wolfhece-2.2.1.dist-info}/entry_points.txt +0 -0
  44. {wolfhece-2.1.128.dist-info → wolfhece-2.2.1.dist-info}/top_level.txt +0 -0
wolfhece/PyDraw.py CHANGED
@@ -1732,10 +1732,10 @@ class WolfMapViewer(wx.Frame):
1732
1732
  self.treewidth = 200 # largeur de la zone d'arbre "treelist"
1733
1733
 
1734
1734
  self.backcolor = wx.Colour(255, 255, 255) # couleur de fond
1735
- self.mousedown = (0., 0.) # position initiale du bouton position bas
1736
- self.mouseup = (0., 0.) # position initiale du bouton position haut
1735
+ self.mousedown = (-99999., -99999.) # position initiale du bouton position bas
1736
+ # self.mouseup = (-99999., -99999.) # position initiale du bouton position haut
1737
1737
  self.oneclick = True # détection d'un simple click ou d'un double-click
1738
- self.move = False # la souris est-elle en train de bouger?
1738
+ # self.move = False # la souris est-elle en train de bouger?
1739
1739
 
1740
1740
  self.linked = False
1741
1741
  self.link_shareopsvect = True
@@ -2553,6 +2553,7 @@ class WolfMapViewer(wx.Frame):
2553
2553
  self.menuwolf2d.AppendSeparator()
2554
2554
 
2555
2555
  self.menu2d_dangermap = self.menuwolf2d.Append(wx.ID_ANY, _("Danger map"), _("Compute the danger map"))
2556
+ # self.menu2d_dangermap_mp = self.menuwolf2d.Append(wx.ID_ANY, _("Danger map (multiprocess)"), _("Compute the danger map using multiprocessing -- Need to duplicate the model, the memory usage can be very high for large model"))
2556
2557
  self.menu2d_dangermaph = self.menuwolf2d.Append(wx.ID_ANY, _("Danger map - only h"), _("Compute the danger map - only waterdepth"))
2557
2558
 
2558
2559
  self.menuwolf2d.AppendSeparator()
@@ -2992,7 +2993,7 @@ class WolfMapViewer(wx.Frame):
2992
2993
 
2993
2994
  danger_map.write_all(Path(outdir) / 'danger_h.tif')
2994
2995
 
2995
- elif itemlabel == _("Danger map"):
2996
+ elif itemlabel in [_("Danger map"), _("Danger map (multiprocess)")]:
2996
2997
  if self.active_res2d is None:
2997
2998
  logging.warning(_('No active 2D result !'))
2998
2999
  return
@@ -3018,16 +3019,19 @@ class WolfMapViewer(wx.Frame):
3018
3019
 
3019
3020
  every = dlg.GetValue()
3020
3021
 
3021
- pgbar = wx.ProgressDialog(_('Danger map'), _('Danger map'), maximum = end_step-1, parent=self, style = wx.PD_APP_MODAL | wx.PD_AUTO_HIDE)
3022
- def _callback(id, msg):
3023
- pgbar.Update(id+1-start_step, msg)
3022
+ if itemlabel == _("Danger map"):
3023
+ pgbar = wx.ProgressDialog(_('Danger map'), _('Danger map'), maximum = end_step-1, parent=self, style = wx.PD_APP_MODAL | wx.PD_AUTO_HIDE)
3024
+ def _callback(id, msg):
3025
+ pgbar.Update(id+1-start_step, msg)
3024
3026
 
3025
- danger_maps = self.active_res2d.danger_map(start_step-1, end_step-1, every, _callback)
3027
+ danger_maps = self.active_res2d.danger_map_multiprocess(start_step-1, end_step-1, every, _callback)
3026
3028
 
3027
- pgbar.Hide()
3028
- pgbar.Destroy()
3029
+ pgbar.Hide()
3030
+ pgbar.Destroy()
3031
+ else:
3032
+ danger_maps = self.active_res2d.danger_map_multiprocess(start_step-1, end_step-1, every)
3029
3033
 
3030
- with wx.DirDialog(None, _('Choose a directory'), style=wx.DD_DEFAULT_STYLE) as dlg:
3034
+ with wx.DirDialog(None, _('Choose a directory to store results'), style=wx.DD_DEFAULT_STYLE) as dlg:
3031
3035
 
3032
3036
  if dlg.ShowModal() == wx.ID_CANCEL:
3033
3037
  return
@@ -4511,16 +4515,16 @@ class WolfMapViewer(wx.Frame):
4511
4515
 
4512
4516
  self.canvas.Bind(wx.EVT_CHAR_HOOK, self.OnHotKey)
4513
4517
 
4514
- self.canvas.Bind(wx.EVT_BUTTON, self.OnButton)
4515
- self.canvas.Bind(wx.EVT_RIGHT_DCLICK, self.OnRDClick)
4516
- self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.OnLDClick)
4517
- self.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnLDown)
4518
- self.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.OnLDown)
4519
- self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
4520
- self.canvas.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
4521
- self.canvas.Bind(wx.EVT_MOTION, self.OnMotion)
4518
+ self.canvas.Bind(wx.EVT_BUTTON, self.On_Mouse_Button)
4519
+ self.canvas.Bind(wx.EVT_RIGHT_DCLICK, self.On_Right_Double_Clicks)
4520
+ self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.On_Left_Double_Clicks)
4521
+ self.canvas.Bind(wx.EVT_LEFT_DOWN, self.On_Mouse_Left_Down)
4522
+ self.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.On_Mouse_Left_Down)
4523
+ self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.On_Mouse_Right_Down)
4524
+ self.canvas.Bind(wx.EVT_RIGHT_UP, self.On_Mouse_Right_Up)
4525
+ self.canvas.Bind(wx.EVT_MOTION, self.On_Mouse_Motion)
4522
4526
  self.canvas.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave)
4523
- self.canvas.Bind(wx.EVT_MOUSEWHEEL, self.OnButton)
4527
+ self.canvas.Bind(wx.EVT_MOUSEWHEEL, self.On_Mouse_Button)
4524
4528
 
4525
4529
  self.treelist.Bind(dataview.EVT_TREELIST_ITEM_CHECKED, self.OnCheckItem)
4526
4530
  self.treelist.Bind(dataview.EVT_TREELIST_ITEM_ACTIVATED, self.OnActivateTreeElem)
@@ -10936,7 +10940,7 @@ class WolfMapViewer(wx.Frame):
10936
10940
  self.myfigprof.cs_setter(mycross = self.active_cs, active_profile= self.active_profile, mapviewer = self)
10937
10941
 
10938
10942
 
10939
- def OnRightDown(self, e: wx.MouseEvent):
10943
+ def On_Mouse_Right_Down(self, e: wx.MouseEvent):
10940
10944
  """
10941
10945
  Event when the right button of the mouse is pressed.
10942
10946
 
@@ -11361,7 +11365,7 @@ class WolfMapViewer(wx.Frame):
11361
11365
  self.rightdown = (x, y)
11362
11366
 
11363
11367
 
11364
- def OnRightUp(self, e):
11368
+ def On_Mouse_Right_Up(self, e):
11365
11369
  pos = e.GetPosition()
11366
11370
  x, y = self.getXY(pos)
11367
11371
 
@@ -11389,7 +11393,7 @@ class WolfMapViewer(wx.Frame):
11389
11393
  except:
11390
11394
  pass
11391
11395
 
11392
- def OnButton(self, e: wx.MouseEvent):
11396
+ def On_Mouse_Button(self, e: wx.MouseEvent):
11393
11397
  d = e.GetWheelDelta()
11394
11398
  r = e.GetWheelRotation()
11395
11399
  a = e.GetWheelAxis()
@@ -11457,10 +11461,10 @@ class WolfMapViewer(wx.Frame):
11457
11461
  # will translate and rescale the map view so that it fits the window.
11458
11462
  self.setbounds()
11459
11463
 
11460
- def OnRDClick(self, e):
11464
+ def On_Right_Double_Clicks(self, e):
11461
11465
  self._endactions()
11462
11466
 
11463
- def OnLDClick(self, e:wx.MouseEvent):
11467
+ def On_Left_Double_Clicks(self, e:wx.MouseEvent):
11464
11468
  pos = e.GetPosition()
11465
11469
 
11466
11470
  ctrldown = e.ControlDown()
@@ -11469,9 +11473,12 @@ class WolfMapViewer(wx.Frame):
11469
11473
 
11470
11474
  x, y = self.getXY(pos)
11471
11475
 
11472
- self.mousex = self.mousedown[0]
11473
- self.mousey = self.mousedown[1]
11474
- # self.mousedown = (0., 0.)
11476
+ if self.mousedown[0] == -99999:
11477
+ # Manage the case when the user double click rapidly on the map
11478
+ # self.mousedown can not be set in On_Mouse_Left_Down
11479
+ self.mousedown = (x, y)
11480
+
11481
+ self.mousex, self.mousey = self.mousedown
11475
11482
  self.oneclick = False
11476
11483
  self.setbounds()
11477
11484
 
@@ -11493,13 +11500,14 @@ class WolfMapViewer(wx.Frame):
11493
11500
  if self.active_laz.viewer is not None:
11494
11501
  self.active_laz.force_view(self.mousex, self.mousey)
11495
11502
 
11496
- def OnLDown(self, e):
11503
+ def On_Mouse_Left_Down(self, e):
11504
+ """ Event when the left button of the mouse is pressed """
11497
11505
 
11498
- if not self.move:
11499
- pos = e.GetPosition()
11500
- x, y = self.getXY(pos)
11501
- self.mousedown = (x, y)
11502
- self.move=True
11506
+ # if not self.move:
11507
+ pos = e.GetPosition()
11508
+ x, y = self.getXY(pos)
11509
+ self.mousedown = (x, y)
11510
+ # self.move = True
11503
11511
 
11504
11512
  def _set_active_bc(self):
11505
11513
  """Search and activate BCManager according to active_array"""
@@ -11973,23 +11981,33 @@ class WolfMapViewer(wx.Frame):
11973
11981
  self.mytooltip.PopulateOnePage()
11974
11982
 
11975
11983
 
11976
- def OnMotion(self, e: wx.MouseEvent):
11984
+ def On_Mouse_Motion(self, e: wx.MouseEvent):
11977
11985
  """ Mouse move event """
11978
11986
 
11979
11987
  # Déplacement de la souris sur le canvas OpenGL
11980
- posframe = self.GetPosition()
11981
- pos = e.GetPosition()
11982
- x, y = self.getXY(pos)
11983
- altdown = e.AltDown()
11984
- shiftdown = e.ShiftDown()
11988
+ posframe = self.GetPosition() # Get the position of the frame -> useful to set the tooltip position
11989
+ pos = e.GetPosition() # Get the position of the mouse in the canvas
11990
+ x, y = self.getXY(pos) # Get the coordinates of the mouse in the map
11991
+ altdown = e.AltDown() # Alt key pressed
11992
+ shiftdown = e.ShiftDown() # Shift key pressed
11985
11993
 
11986
11994
  if e.LeftIsDown() or e.MiddleIsDown():
11995
+ # Left mouse button or middle mouse button is pressed
11996
+ #
11997
+ # Moving the map relative to the position where the mouse was clicked
11998
+ # the first time
11999
+
12000
+ if self.mousedown[0] == -99999: # only if the mouse was clicked before
12001
+ self.mousedown = [x, y]
12002
+
11987
12003
  self.mousex -= x - self.mousedown[0]
11988
12004
  self.mousey -= y - self.mousedown[1]
11989
12005
 
11990
- self.setbounds(False)
12006
+ self.setbounds(updatescale = False)
11991
12007
  return
12008
+
11992
12009
  elif e.RightIsDown():
12010
+ # Right mouse button is pressed
11993
12011
  if self.action == 'select bc':
11994
12012
  if self.active_vector is None:
11995
12013
 
@@ -12002,7 +12020,10 @@ class WolfMapViewer(wx.Frame):
12002
12020
  wolfvertex(x,self.rightdown[1]),
12003
12021
  wolfvertex(self.rightdown[0],self.rightdown[1])]
12004
12022
  else:
12005
- self.move=False
12023
+ # No mouse button is pressed
12024
+ # self.move=False
12025
+ self.mousedown = (-99999, -99999)
12026
+ # self.mouseup = (-99999, -99999)
12006
12027
 
12007
12028
  if self.action is not None:
12008
12029
 
@@ -12112,10 +12133,14 @@ class WolfMapViewer(wx.Frame):
12112
12133
 
12113
12134
  self.Paint()
12114
12135
 
12136
+ # Store the position of the mouse as last known position
12115
12137
  self._last_mouse_pos = (x,y,pos)
12138
+
12139
+ # Update the tooltip with the values of the active arrays and results at position x,y
12116
12140
  self._update_mytooltip()
12117
12141
 
12118
12142
  if e.ControlDown():
12143
+ # Control key is pressed, so the tooltip must be near the mouse position
12119
12144
  if self._oldpos_tooltip is None:
12120
12145
  # Store the position of the tooltip
12121
12146
  # Useful to restore it after CTRL is released
@@ -12165,6 +12190,7 @@ class WolfMapViewer(wx.Frame):
12165
12190
  # self.mytooltip.SetIcon(self.GetIcon()) # update icon
12166
12191
  self.mytooltip.SetWindowStyle(wx.DEFAULT_FRAME_STYLE) # | wx.STAY_ON_TOP) # on top, with Title bar
12167
12192
 
12193
+ #Force to show the tooltip --> useful when the tooltip was hidden by the user
12168
12194
  self.mytooltip.Show(True)
12169
12195
 
12170
12196
  e.Skip()
@@ -12383,6 +12409,16 @@ class WolfMapViewer(wx.Frame):
12383
12409
  """ Check for updates """
12384
12410
  from .apps.version import WolfVersion
12385
12411
  import requests
12412
+ import importlib.metadata
12413
+
12414
+ # check_gpu = False
12415
+ # try:
12416
+ # import wolfgpu
12417
+ # check_gpu = True
12418
+ # except:
12419
+ # pass
12420
+
12421
+ msg = ''
12386
12422
 
12387
12423
  current_version = str(WolfVersion())
12388
12424
  package_name = "wolfhece"
@@ -12391,15 +12427,42 @@ class WolfMapViewer(wx.Frame):
12391
12427
  available_version = requests.get(f"https://pypi.org/pypi/{package_name}/json").json()["info"]["version"]
12392
12428
 
12393
12429
  if available_version > current_version:
12394
- with wx.MessageDialog(None, _("A new version is available: {}\n\nYour version is {}\n\nIf you want to upgrade, 'pip install wolfhece --upgrade' from your Python environment.").format(available_version, current_version), _("Upgrade"), wx.OK | wx.ICON_INFORMATION) as dlg:
12395
- dlg.ShowModal()
12430
+ msg += _("A new version is available: {}\n\nYour version is {}\n\nIf you want to upgrade, 'pip install wolfhece --upgrade' from your Python environment.").format(available_version, current_version)
12396
12431
  else:
12397
- with wx.MessageDialog(None, _("You have the latest version."), _("Upgrade"), wx.OK | wx.ICON_INFORMATION) as dlg:
12398
- dlg.ShowModal()
12432
+ msg += _("You have the latest version.")
12399
12433
 
12400
12434
  except Exception as e:
12401
12435
  logging.error("Package not found on PyPI. -- {}".format(e))
12402
12436
 
12437
+ # if check_gpu:
12438
+ # # find the version
12439
+ # package_name = "wolfgpu"
12440
+ # current_version = importlib.metadata.version(package_name)
12441
+ # url_wolfgpu = "https://gitlab.uliege.be/api/v4/projects/4180/packages/pypi/simple/" #+ package_name
12442
+ # try:
12443
+ # response = requests.get(url_wolfgpu).json()
12444
+ # update_wolfgpu = False
12445
+ # #parcourir toutes le entrées et ne conserver que la version la plus récente
12446
+ # for one in response:
12447
+ # one["version"] > current_version
12448
+ # update_wolfgpu = True
12449
+
12450
+ # if update_wolfgpu:
12451
+ # msg += '\n'
12452
+ # msg += _("A new version of WolfGPU is available: {}.{}.{}, please update it.").format(current_version[0], current_version[1], current_version[2])
12453
+ # else:
12454
+ # msg += '\n'
12455
+ # msg+= _("You have the latest version of WolfGPU.")
12456
+
12457
+ # except Exception as e:
12458
+ # logging.error("Package not found on PyPI. -- {}".format(e))
12459
+
12460
+ msg+= '\n\n'
12461
+ msg+= _('If you use wolfgpu, please check the GPU version independently.')
12462
+
12463
+ with wx.MessageDialog(None, msg, _("Upgrade"), wx.OK | wx.ICON_INFORMATION) as dlg:
12464
+ dlg.ShowModal()
12465
+
12403
12466
  def print_shortcuts(self, inframe:bool = None):
12404
12467
  """ Print the list of shortcuts into logging """
12405
12468
 
wolfhece/PyGui.py CHANGED
@@ -3669,6 +3669,9 @@ class Wolf2DGPUModel(GenMapManager):
3669
3669
  self._append_magnetic_grid_to_prop()
3670
3670
 
3671
3671
  if self._sim.sim is not None:
3672
+ # FIXME : Not the right place -> check in SimpleSimulation
3673
+ self._wp.add_param(_('Scheme'), _('Time step strategy'), 2, Type_Param.Integer, jsonstr={"Values":{"Fixed time step":1,"Optimized time step":2}})
3674
+ self._wp.add_param(_('Infiltration'), _('Interpolation mode'), 0, Type_Param.Integer, jsonstr={"Values":{"None":0, "Linear":1}})
3672
3675
  self._sim.sim.add_to_wolfparam(self._wp)
3673
3676
  self._wp.Populate(sorted_groups=True)
3674
3677
 
@@ -129,7 +129,7 @@ class GuiHydrology(WolfMapViewer):
129
129
 
130
130
  def __init__(self, parent=None, title='WOLF Hydrological model - viewer', w=500, h=500, treewidth=200, wolfparent=None, wxlogging=None):
131
131
  """ Constructor
132
-
132
+
133
133
  :param parent: parent window - wx.Frame
134
134
  :param title: title of the window - str
135
135
  :param w: width of the window - int
@@ -140,8 +140,8 @@ class GuiHydrology(WolfMapViewer):
140
140
  :param wxlogging: logging instance -- PyGui.WolfLog
141
141
  """
142
142
 
143
- super(GuiHydrology, self).__init__(parent, title=title, w=w, h=h,
144
- treewidth=treewidth,
143
+ super(GuiHydrology, self).__init__(parent, title=title, w=w, h=h,
144
+ treewidth=treewidth,
145
145
  wolfparent=wolfparent,
146
146
  wxlogging=wxlogging)
147
147
 
@@ -197,7 +197,7 @@ class GuiHydrology(WolfMapViewer):
197
197
 
198
198
  if self.wolfparent is None:
199
199
  return None
200
-
200
+
201
201
  if self.wolfparent.mycatchment is None:
202
202
  return None
203
203
 
@@ -219,7 +219,7 @@ class GuiHydrology(WolfMapViewer):
219
219
  itemlabel = item.ItemLabel
220
220
 
221
221
  if itemlabel == _('Choose outlet'):
222
- myselect = selectpoint(title=_('Outlet'),
222
+ myselect = selectpoint(title=_('Outlet'),
223
223
  SPWstations=self.wolfparent.SPWstations,
224
224
  DCENNstations=self.wolfparent.DCENNstations)
225
225
  myselect.Show()
@@ -276,15 +276,15 @@ class GuiHydrology(WolfMapViewer):
276
276
  self.action = 'Select downstream rivers'
277
277
 
278
278
 
279
- def OnRightDown(self, e: wx.MouseEvent):
280
-
279
+ def On_Mouse_Right_Down(self, e: wx.MouseEvent):
280
+
281
281
  # Call the parent event handler
282
- super().OnRightDown(e)
282
+ super().On_Mouse_Right_Down(e)
283
283
 
284
284
  if self.action is None:
285
285
  logging.info(_('No action selected !'))
286
286
  return
287
-
287
+
288
288
  if self.action == '':
289
289
  logging.info(_('No action selected !'))
290
290
  return
@@ -305,7 +305,7 @@ class GuiHydrology(WolfMapViewer):
305
305
  return
306
306
 
307
307
  if 'Find upstream watershed' in self.action:
308
-
308
+
309
309
  starting_node = self.watershed.get_node_from_xy(x,y)
310
310
  up_vect = self.watershed.get_vector_from_upstream_node(starting_node, limit_to_sub='limit to sub' in self.action)
311
311
 
@@ -322,39 +322,39 @@ class GuiHydrology(WolfMapViewer):
322
322
 
323
323
  if self.active_array.Operations is not None:
324
324
  newzone = zone(name = str(starting_node.sub))
325
-
325
+
326
326
  self.active_array.Operations.show_structure_OpsVectors()
327
327
  self.active_array.Operations.myzones.add_zone(newzone, forceparent=True)
328
328
  newzone.add_vector(up_vect, forceparent=True)
329
329
 
330
330
  props_vec(up_vect)
331
-
331
+
332
332
  self.active_array.Operations.myzones.prep_listogl()
333
333
  self.active_array.Operations.myzones.fill_structure()
334
-
335
- self.Refresh()
334
+
335
+ self.Refresh()
336
336
  else:
337
337
  logging.warning(_('No operations frame in the active array!'))
338
-
338
+
339
339
  elif 'Select upstream watershed' in self.action:
340
-
340
+
341
341
  xy = self.watershed.get_xy_upstream_node(self.watershed.get_node_from_xy(x,y), limit_to_sub='limit to sub' in self.action)
342
- self.active_array.SelectionData.set_selection_from_list_xy(xy)
343
- self.Refresh()
342
+ self.active_array.SelectionData.set_selection_from_list_xy(xy)
343
+ self.Refresh()
344
344
 
345
345
  elif 'Select upstream rivers' in self.action:
346
346
 
347
- xy = self.watershed.get_xy_upstream_node(self.watershed.get_node_from_xy(x,y),
347
+ xy = self.watershed.get_xy_upstream_node(self.watershed.get_node_from_xy(x,y),
348
348
  limit_to_sub='limit to sub' in self.action,
349
349
  limit_to_river=True)
350
-
351
- self.active_array.SelectionData.set_selection_from_list_xy(xy)
352
- self.Refresh()
350
+
351
+ self.active_array.SelectionData.set_selection_from_list_xy(xy)
352
+ self.Refresh()
353
353
 
354
354
  elif 'Select downstream rivers' in self.action:
355
355
 
356
356
  xy = self.watershed.get_xy_downstream_node(self.watershed.get_node_from_xy(x,y))
357
- self.active_array.SelectionData.set_selection_from_list_xy(xy)
358
- self.Refresh()
357
+ self.active_array.SelectionData.set_selection_from_list_xy(xy)
358
+ self.Refresh()
359
359
 
360
360
 
wolfhece/PyPalette.py CHANGED
@@ -47,6 +47,8 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
47
47
  self.nseg = nseg
48
48
  self.automatic = True
49
49
  self.interval_cst = False
50
+ self.colors = np.zeros((self.nb, 4), dtype=np.float64)
51
+ self.values = np.zeros((self.nb), dtype=np.float64)
50
52
 
51
53
  self.wx_exists = wx.App.Get() is not None
52
54
 
@@ -57,6 +59,18 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
57
59
  LinearSegmentedColormap.__init__(self, 'wolf', {}, nseg)
58
60
  self.set_bounds()
59
61
 
62
+ def __getstate__(self):
63
+ """ Récupération de l'état de l'objet pour la sérialisation """
64
+ state = self.__dict__.copy()
65
+ return state
66
+
67
+ def __setstate__(self, state):
68
+ """ Récupération de l'état de l'objet pour la désérialisation """
69
+ self.__dict__.update(state)
70
+
71
+ # Reinitialize the LinearSegmentedColormap with the current state
72
+ self.fill_segmentdata()
73
+
60
74
  @property
61
75
  def colormin_uint8(self):
62
76
  return self.colormin.astype(np.uint8)*255
@@ -671,21 +685,23 @@ class wolfpalette(wx.Frame, LinearSegmentedColormap):
671
685
  self.colorsflt = self.colors.astype(float)/255.
672
686
  self.colorsuint8 = self.colors.astype(np.uint8)
673
687
 
674
- dval = self.values[-1]-self.values[0]
688
+ if self.nb > 1:
689
+
690
+ dval = self.values[-1]-self.values[0]
675
691
 
676
- normval = np.ones([len(self.values)])
692
+ normval = np.ones([len(self.values)])
677
693
 
678
- if dval > 0.:
679
- normval = (self.values-self.values[0])/(self.values[-1]-self.values[0])
694
+ if dval > 0.:
695
+ normval = (self.values-self.values[0])/(self.values[-1]-self.values[0])
680
696
 
681
- normval[0] = 0.
682
- normval[-1] = 1.
683
- segmentdata = {"red": np.column_stack([normval, self.colorsflt[:, 0], self.colorsflt[:, 0]]),
684
- "green": np.column_stack([normval, self.colorsflt[:, 1], self.colorsflt[:, 1]]),
685
- "blue": np.column_stack([normval, self.colorsflt[:, 2], self.colorsflt[:, 2]]),
686
- "alpha": np.column_stack([normval, self.colorsflt[:, 3], self.colorsflt[:, 3]])}
697
+ normval[0] = 0.
698
+ normval[-1] = 1.
699
+ segmentdata = {"red": np.column_stack([normval, self.colorsflt[:, 0], self.colorsflt[:, 0]]),
700
+ "green": np.column_stack([normval, self.colorsflt[:, 1], self.colorsflt[:, 1]]),
701
+ "blue": np.column_stack([normval, self.colorsflt[:, 2], self.colorsflt[:, 2]]),
702
+ "alpha": np.column_stack([normval, self.colorsflt[:, 3], self.colorsflt[:, 3]])}
687
703
 
688
- LinearSegmentedColormap.__init__(self, 'wolf', segmentdata, self.nseg)
704
+ LinearSegmentedColormap.__init__(self, 'wolf', segmentdata, self.nseg)
689
705
 
690
706
  def readfile(self, *args):
691
707
  """Lecture de la palette sur base d'un fichier WOLF .pal"""
wolfhece/PyParams.py CHANGED
@@ -1973,10 +1973,14 @@ class Wolf_Param(wx.Frame):
1973
1973
  elif not self.is_in_active(group, name) and self.is_in_default(group, name):
1974
1974
  # le paramètre est dans les paramètres par défaut mais pas dans les paramètres actifs --> on l'ajoute
1975
1975
  default_value = self.myparams_default[group][name]
1976
+ if key_Param.ADDED_JSON in default_value.keys():
1977
+ json = default_value[key_Param.ADDED_JSON]
1978
+ else:
1979
+ json = None
1976
1980
  self.add_param(group, name, value,
1977
1981
  default_value[key_Param.TYPE],
1978
1982
  comment=default_value[key_Param.COMMENT],
1979
- jsonstr=default_value[key_Param.ADDED_JSON],
1983
+ jsonstr=json,
1980
1984
  whichdict='Active')
1981
1985
  elif self.is_in_active(group, name):
1982
1986
  param = self.myparams[group][name]
@@ -7883,22 +7883,67 @@ class Zones(wx.Frame, Element_To_Draw):
7883
7883
 
7884
7884
  sz = []
7885
7885
 
7886
+ # Getting s values and Z values from the xls grid
7887
+ # s in column 4 and z in column 2
7888
+ # The first row is the header
7886
7889
  i = 0
7887
7890
  while self.xls.GetCellValue(i,4) != '':
7888
- sz.append((float(self.xls.GetCellValue(i,4)), float(self.xls.GetCellValue(i,2))))
7889
- i += 1
7891
+ s = self.xls.GetCellValue(i,4)
7892
+ z = self.xls.GetCellValue(i,2)
7893
+ try:
7894
+ s = float(s)
7895
+ except:
7896
+ logging.error(_('Error during update from sz support - check your s data and types (only float)'))
7897
+ return
7898
+
7899
+ try:
7900
+ if z == '':
7901
+ logging.warning(_('No z value -- setting to 0.0'))
7902
+ z = 0.0
7903
+ else:
7904
+ z = float(z)
7905
+ except:
7906
+ logging.error(_('Error during update from sz support - check your z data and types (only float)'))
7907
+ return
7908
+
7909
+ sz.append((s, z))
7910
+ i += 1
7911
+
7912
+ if len(sz) == 0:
7913
+ logging.warning(_('No data to update -- Please set s in column "s curvi" (5th) and z in column Z (3th)'))
7914
+ return
7890
7915
 
7891
7916
  logging.info(f'Number of points: {len(sz)}')
7892
7917
 
7893
7918
  vec_sz = np.array(sz)
7894
7919
 
7895
- self.update_from_sz_support(vec=self.active_vector, sz=vec_sz)
7920
+ memory_xyz = []
7921
+ i = 0
7922
+ while self.xls.GetCellValue(i,0) != '':
7923
+ memory_xyz.append((float(self.xls.GetCellValue(i,0)), float(self.xls.GetCellValue(i,1)), float(self.xls.GetCellValue(i,2))))
7924
+ i += 1
7896
7925
 
7897
- # update of the xls grid
7898
- for k in range(self.active_vector.nbvertices ):
7899
- self.xls.SetCellValue(k,0,str(self.active_vector.myvertices[k].x))
7900
- self.xls.SetCellValue(k,1,str(self.active_vector.myvertices[k].y))
7926
+ try:
7927
+ self.update_from_sz_support(vec=self.active_vector, sz=vec_sz)
7928
+
7929
+ # update of the xls grid
7930
+ for k in range(self.active_vector.nbvertices ):
7931
+ self.xls.SetCellValue(k,0,str(self.active_vector.myvertices[k].x))
7932
+ self.xls.SetCellValue(k,1,str(self.active_vector.myvertices[k].y))
7933
+ except:
7934
+ logging.error(_('Error during update from sz support - check your data'))
7935
+ logging.info(_('Resetting the active vector to its original state'))
7936
+
7937
+ self.active_vector.myvertices = []
7938
+ for cur in memory_xyz:
7939
+ self.active_vector.add_vertex(wolfvertex(cur[0], cur[1], cur[2]))
7940
+ self.active_vector._reset_listogl()
7941
+ self.active_vector.update_lengths()
7942
+ self.active_vector.find_minmax(True)
7901
7943
 
7944
+ for k in range(self.active_vector.nbvertices ):
7945
+ self.xls.SetCellValue(k,0,str(self.active_vector.myvertices[k].x))
7946
+ self.xls.SetCellValue(k,1,str(self.active_vector.myvertices[k].y))
7902
7947
 
7903
7948
  def update_from_sz_direction(self, xy1:np.ndarray, xy2:np.ndarray, sz:np.ndarray):
7904
7949
  """ Update the active vector from the sz values in the xls grid """
wolfhece/Results2DGPU.py CHANGED
@@ -185,6 +185,23 @@ class wolfres2DGPU(Wolfresults_2D):
185
185
 
186
186
  self._cache = None
187
187
 
188
+ def __getstate__(self):
189
+ dct= super().__getstate__()
190
+
191
+ to_pop = ['_result_store', '_cache']
192
+ for key in to_pop:
193
+ if key in dct:
194
+ dct.pop(key)
195
+
196
+ return dct
197
+
198
+ def __setstate__(self, dct):
199
+ super().__setstate__(dct)
200
+
201
+ self._result_store = None
202
+ self._cache = None
203
+ self.setup_store(self._result_store)
204
+
188
205
  def setup_store(self, store = None):
189
206
  """
190
207
  Setup results store