wolfhece 2.1.129__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.
- wolfhece/PyDraw.py +109 -46
- wolfhece/PyGui.py +3 -0
- wolfhece/PyGuiHydrology.py +24 -24
- wolfhece/PyPalette.py +27 -11
- wolfhece/Results2DGPU.py +17 -0
- wolfhece/acceptability/acceptability_gui.py +29 -18
- wolfhece/acceptability/func.py +23 -21
- wolfhece/apps/version.py +2 -2
- wolfhece/eikonal.py +1 -1
- wolfhece/hydrology/Catchment.py +2 -2
- wolfhece/hydrology/Comparison.py +26 -28
- wolfhece/hydrology/plot_hydrology.py +2 -2
- wolfhece/lagrangian/particle_system_ui.py +1 -1
- wolfhece/lagrangian/particles.py +1 -1
- wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
- wolfhece/lazviewer/vfuncsdir/vfuncs.cp310-win_amd64.pyd +0 -0
- wolfhece/lazviewer/viewer/viewer.exe +0 -0
- wolfhece/lazviewer/viewer/viewer_np1_23_5.exe +0 -0
- wolfhece/libs/Wolf_tools.dll +0 -0
- wolfhece/libs/get_infos.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/verify_wolf.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
- wolfhece/tools2d_dll.py +359 -0
- wolfhece/wolf_array.py +3 -2
- wolfhece/wolfresults_2D.py +162 -33
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.1.dist-info}/METADATA +14 -9
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.1.dist-info}/RECORD +30 -28
- wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.1.dist-info}/WHEEL +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.1.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.129.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 = (
|
1736
|
-
self.mouseup
|
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
|
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
|
-
|
3022
|
-
|
3023
|
-
|
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
|
-
|
3027
|
+
danger_maps = self.active_res2d.danger_map_multiprocess(start_step-1, end_step-1, every, _callback)
|
3026
3028
|
|
3027
|
-
|
3028
|
-
|
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.
|
4515
|
-
self.canvas.Bind(wx.EVT_RIGHT_DCLICK, self.
|
4516
|
-
self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.
|
4517
|
-
self.canvas.Bind(wx.EVT_LEFT_DOWN, self.
|
4518
|
-
self.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.
|
4519
|
-
self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.
|
4520
|
-
self.canvas.Bind(wx.EVT_RIGHT_UP, self.
|
4521
|
-
self.canvas.Bind(wx.EVT_MOTION, self.
|
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.
|
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
|
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
|
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
|
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
|
11464
|
+
def On_Right_Double_Clicks(self, e):
|
11461
11465
|
self._endactions()
|
11462
11466
|
|
11463
|
-
def
|
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
|
-
|
11473
|
-
|
11474
|
-
|
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
|
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
|
-
|
11500
|
-
|
11501
|
-
|
11502
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
|
wolfhece/PyGuiHydrology.py
CHANGED
@@ -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
|
280
|
-
|
279
|
+
def On_Mouse_Right_Down(self, e: wx.MouseEvent):
|
280
|
+
|
281
281
|
# Call the parent event handler
|
282
|
-
super().
|
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
|
-
|
688
|
+
if self.nb > 1:
|
689
|
+
|
690
|
+
dval = self.values[-1]-self.values[0]
|
675
691
|
|
676
|
-
|
692
|
+
normval = np.ones([len(self.values)])
|
677
693
|
|
678
|
-
|
679
|
-
|
694
|
+
if dval > 0.:
|
695
|
+
normval = (self.values-self.values[0])/(self.values[-1]-self.values[0])
|
680
696
|
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
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
|
-
|
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/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
|
@@ -7,34 +7,32 @@ Copyright (c) 2025 University of Liege. All rights reserved.
|
|
7
7
|
This script and its content are protected by copyright law. Unauthorized
|
8
8
|
copying or distribution of this file, via any medium, is strictly prohibited.
|
9
9
|
"""
|
10
|
-
from .acceptability import Base_data_creation, Database_to_raster, Vulnerability, Acceptability
|
11
|
-
from .acceptability import steps_base_data_creation, steps_vulnerability, steps_acceptability
|
12
|
-
from .func import Accept_Manager
|
13
|
-
from ..wolf_array import WolfArray, header_wolf
|
14
|
-
from ..scenario.config_manager import Config_Manager_2D_GPU
|
15
|
-
from ..PyDraw import WolfMapViewer, draw_type
|
16
|
-
from ..Results2DGPU import wolfres2DGPU
|
17
|
-
from ..PyGui import MapManager
|
18
|
-
|
19
10
|
import wx
|
20
|
-
import
|
11
|
+
import numpy as np
|
21
12
|
import logging
|
22
13
|
import subprocess
|
23
|
-
import matplotlib
|
24
14
|
import shutil
|
25
15
|
import os
|
26
16
|
import geopandas as gpd
|
17
|
+
import pandas as pd
|
27
18
|
import matplotlib.pyplot as plt
|
28
19
|
from matplotlib.figure import Figure
|
29
20
|
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
|
30
21
|
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar2Wx
|
31
22
|
from pathlib import Path
|
32
23
|
from scipy.ndimage import label
|
33
|
-
import pandas as pd
|
34
24
|
from gettext import gettext as _
|
35
25
|
import rasterio
|
36
26
|
from shapely.geometry import Polygon
|
37
|
-
|
27
|
+
|
28
|
+
from .acceptability import Base_data_creation, Database_to_raster, Vulnerability, Acceptability
|
29
|
+
from .acceptability import steps_base_data_creation, steps_vulnerability, steps_acceptability
|
30
|
+
from .func import Accept_Manager
|
31
|
+
from ..wolf_array import WolfArray, header_wolf
|
32
|
+
from ..scenario.config_manager import Config_Manager_2D_GPU
|
33
|
+
from ..PyDraw import WolfMapViewer, draw_type
|
34
|
+
from ..Results2DGPU import wolfres2DGPU
|
35
|
+
from ..PyGui import MapManager
|
38
36
|
|
39
37
|
def nullvalue_for_hole(WA):
|
40
38
|
"""
|
@@ -710,7 +708,7 @@ class AcceptabilityGui(wx.Frame):
|
|
710
708
|
dlg.ShowModal()
|
711
709
|
return
|
712
710
|
else :
|
713
|
-
if (self._manager._study_area
|
711
|
+
if (self._manager._study_area is None) or (self._manager._scenario is None):
|
714
712
|
logging.error(f"No study area and/or scenario selected, no check of TEMP and OUTPUT.")
|
715
713
|
with wx.MessageDialog(self, f"INPUT is well structured, but TEMP and OUTPUT have not been checked because there is no study area and scenario selected.", "Checking", wx.OK | wx.ICON_INFORMATION) as dlg:
|
716
714
|
dlg.ShowModal()
|
@@ -1075,7 +1073,8 @@ class AcceptabilityGui(wx.Frame):
|
|
1075
1073
|
return
|
1076
1074
|
|
1077
1075
|
def OnInterpolation(self,e):
|
1078
|
-
"""Interpolates the last extracted time steps present in
|
1076
|
+
"""Interpolates the last extracted time steps present in
|
1077
|
+
LAST_STEP_EXTRACTED using the fast marching
|
1079
1078
|
interpolation routine holes.exe, by creating a batch file
|
1080
1079
|
while performing multiple checks on the required input files."""
|
1081
1080
|
if not hasattr(self, 'file_paths'):
|
@@ -1121,7 +1120,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1121
1120
|
D = file_path
|
1122
1121
|
else:
|
1123
1122
|
C = file_path
|
1124
|
-
if D
|
1123
|
+
if D is None:
|
1125
1124
|
logging.info("DEM (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and CANNOT include the word 'mask'")
|
1126
1125
|
with wx.MessageDialog(self,
|
1127
1126
|
f"DEM (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and CANNOT include the word 'mask'",
|
@@ -1130,7 +1129,7 @@ class AcceptabilityGui(wx.Frame):
|
|
1130
1129
|
dlg.ShowModal()
|
1131
1130
|
return
|
1132
1131
|
|
1133
|
-
if C
|
1132
|
+
if C is None:
|
1134
1133
|
logging.info("DEM mask (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and MUST include the word 'mask'")
|
1135
1134
|
with wx.MessageDialog(self,
|
1136
1135
|
f"DEM mask (.bin) not found in DEM_FILES. The file must begins by 'MNT_' and MUST include the word 'mask'",
|
@@ -1189,7 +1188,19 @@ class AcceptabilityGui(wx.Frame):
|
|
1189
1188
|
|
1190
1189
|
empty_folder(self._manager.IN_SA_INTERP)
|
1191
1190
|
path_bat_file = os.path.join(self._manager.IN_SCEN_DIR, "process_files.bat")
|
1192
|
-
|
1191
|
+
|
1192
|
+
if True:
|
1193
|
+
# FORTRAN HOLES.EXE
|
1194
|
+
subprocess.run([path_bat_file], check=True)
|
1195
|
+
else:
|
1196
|
+
#Python eikonal model
|
1197
|
+
from ..eikonal import inpaint_array, inpaint_waterlevel
|
1198
|
+
for a, b in zip(A, B):
|
1199
|
+
in_wa = WolfArray(a)
|
1200
|
+
mask_wa = WolfArray(C)
|
1201
|
+
dem_wa = WolfArray(D)
|
1202
|
+
inpaint_array(in_wa.array, mask_wa.array, dem_wa.array, avoid_last=1)
|
1203
|
+
in_wa.write_all(b)
|
1193
1204
|
|
1194
1205
|
renamed_files = []
|
1195
1206
|
path_fichier=self._manager.IN_SA_INTERP
|