wolfhece 2.2.18__py3-none-any.whl → 2.2.23__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 +128 -1
- wolfhece/PyVertexvectors.py +42 -4
- wolfhece/Results2DGPU.py +11 -2
- wolfhece/__init__.py +15 -1
- wolfhece/_add_path.py +9 -0
- wolfhece/apps/check_install.py +6 -6
- wolfhece/apps/splashscreen.py +1 -1
- wolfhece/apps/version.py +1 -1
- wolfhece/assets/tree.py +0 -0
- wolfhece/cli.py +96 -1
- wolfhece/hydrology/Optimisation.py +30 -25
- wolfhece/mesh2d/cst_2D_boundary_conditions.py +1 -1
- wolfhece/mesh2d/simple_2d.py +94 -69
- wolfhece/report/pdf.py +55 -0
- wolfhece/report/simplesimgpu.py +1409 -0
- wolfhece/scenario/config_manager.py +13 -0
- wolfhece/tools2d_dll.py +7 -2
- wolfhece/wolf_array.py +47 -6
- wolfhece/wolf_hist.py +21 -16
- wolfhece/wolfresults_2D.py +8 -24
- {wolfhece-2.2.18.dist-info → wolfhece-2.2.23.dist-info}/METADATA +3 -1
- {wolfhece-2.2.18.dist-info → wolfhece-2.2.23.dist-info}/RECORD +25 -61
- {wolfhece-2.2.18.dist-info → wolfhece-2.2.23.dist-info}/WHEEL +1 -1
- {wolfhece-2.2.18.dist-info → wolfhece-2.2.23.dist-info}/entry_points.txt +3 -0
- wolfhece/libs/GL/gl.h +0 -1044
- wolfhece/libs/GL/glaux.h +0 -272
- wolfhece/libs/GL/glcorearb.h +0 -3597
- wolfhece/libs/GL/glext.h +0 -11771
- wolfhece/libs/GL/glu.h +0 -255
- wolfhece/libs/GL/glxext.h +0 -926
- wolfhece/libs/GL/wglext.h +0 -840
- wolfhece/libs/MSVCP140.dll +0 -0
- wolfhece/libs/WolfDll.dll +0 -0
- wolfhece/libs/Wolf_tools.dll +0 -0
- wolfhece/libs/api-ms-win-crt-heap-l1-1-0.dll +0 -0
- wolfhece/libs/api-ms-win-crt-math-l1-1-0.dll +0 -0
- wolfhece/libs/api-ms-win-crt-runtime-l1-1-0.dll +0 -0
- wolfhece/libs/fribidi-0.dll +0 -0
- wolfhece/libs/get_infos.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/get_infos.cp311-win_amd64.pyd +0 -0
- wolfhece/libs/get_infos.cp312-win_amd64.pyd +0 -0
- wolfhece/libs/get_infos.cp313-win_amd64.pyd +0 -0
- wolfhece/libs/glu32.dll +0 -0
- wolfhece/libs/hdf5.dll +0 -0
- wolfhece/libs/hdf5_hl.dll +0 -0
- wolfhece/libs/libcurl.dll +0 -0
- wolfhece/libs/libpardiso600-WIN-X86-64.dll +0 -0
- wolfhece/libs/libraqm.dll +0 -0
- wolfhece/libs/msvcr100.dll +0 -0
- wolfhece/libs/netcdf.dll +0 -0
- wolfhece/libs/paho-mqtt3cs.dll +0 -0
- wolfhece/libs/vcomp100.dll +0 -0
- wolfhece/libs/vcruntime140.dll +0 -0
- wolfhece/libs/vcruntime140_1.dll +0 -0
- wolfhece/libs/verify_wolf.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/verify_wolf.cp311-win_amd64.pyd +0 -0
- wolfhece/libs/verify_wolf.cp312-win_amd64.pyd +0 -0
- wolfhece/libs/verify_wolf.cp313-win_amd64.pyd +0 -0
- wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/wolfogl.cp311-win_amd64.pyd +0 -0
- wolfhece/libs/wolfogl.cp312-win_amd64.pyd +0 -0
- wolfhece/libs/wolfogl.cp313-win_amd64.pyd +0 -0
- wolfhece/libs/zlib1.dll +0 -0
- {wolfhece-2.2.18.dist-info → wolfhece-2.2.23.dist-info}/top_level.txt +0 -0
wolfhece/PyDraw.py
CHANGED
@@ -2287,6 +2287,7 @@ class WolfMapViewer(wx.Frame):
|
|
2287
2287
|
self.analyzeplot = wx.Menu()
|
2288
2288
|
self.analyzeexport = wx.Menu()
|
2289
2289
|
self.analyzeinpaint = wx.Menu()
|
2290
|
+
self.analyzesimsheet = wx.Menu()
|
2290
2291
|
|
2291
2292
|
plotvect = self.analyzeplot.Append(wx.ID_ANY, _("Plot active vector..."),
|
2292
2293
|
_("Plot the active vector and linked arrays"))
|
@@ -2299,6 +2300,17 @@ class WolfMapViewer(wx.Frame):
|
|
2299
2300
|
self.analyzemenu.Append(wx.ID_ANY,_('Export...'), self.analyzeexport)
|
2300
2301
|
self.analyzemenu.Append(wx.ID_ANY,_('Inpaint...'), self.analyzeinpaint)
|
2301
2302
|
|
2303
|
+
self.analyzemenu.AppendSeparator()
|
2304
|
+
|
2305
|
+
self.analyzemenu.Append(wx.ID_ANY,_('Report...'), self.analyzesimsheet)
|
2306
|
+
|
2307
|
+
self.analyzesimsheet.Append(wx.ID_ANY, _("Active simulation..."), _("Generate a summary PDF report for the active simulation"))
|
2308
|
+
self.analyzesimsheet.Append(wx.ID_ANY, _("All checked simulations..."), _("Generate a summary PDF report for all checked simulations"))
|
2309
|
+
self.analyzesimsheet.Append(wx.ID_ANY, _("All simulations in directory..."), _("Generate a summary PDF report for all simulations in the current directory"))
|
2310
|
+
self.analyzesimsheet.AppendSeparator()
|
2311
|
+
self.analyzesimsheet.Append(wx.ID_ANY, _("Compare checked simulations..."), _("Generate a summary PDF report for all the loaded simulations"))
|
2312
|
+
self.analyzesimsheet.Append(wx.ID_ANY, _("Compare all simulations in a directory..."), _("Generate a summary PDF report for all the simulations in a directory"))
|
2313
|
+
|
2302
2314
|
|
2303
2315
|
self.analyzeinpaint.Append(wx.ID_ANY, _("Inpaint active array..."), _("Inpaint active array"))
|
2304
2316
|
self.analyzeinpaint.Append(wx.ID_ANY, _("Inpaint waterlevel..."), _("Inpaint a waterlevel result array based on sepcified dem and dtm data"))
|
@@ -8301,6 +8313,121 @@ class WolfMapViewer(wx.Frame):
|
|
8301
8313
|
elif itemlabel == _("Load and apply mask (nap)..."):
|
8302
8314
|
self.loadnap_and_apply()
|
8303
8315
|
|
8316
|
+
elif itemlabel == _("Active simulation..."):
|
8317
|
+
if self.active_res2d is None:
|
8318
|
+
logging.warning(_('No active simulation !'))
|
8319
|
+
return
|
8320
|
+
|
8321
|
+
from .report.simplesimgpu import SimpleSimGPU_Report_wx
|
8322
|
+
|
8323
|
+
if isinstance(self.active_res2d, wolfres2DGPU):
|
8324
|
+
newsheet = SimpleSimGPU_Report_wx(Path(self.active_res2d.filename).parent, size=(800, 600))
|
8325
|
+
newsheet.Show()
|
8326
|
+
else:
|
8327
|
+
logging.warning(_('Active simulation is not a GPU simulation - Not yet implemented for CPU simulations !'))
|
8328
|
+
|
8329
|
+
elif itemlabel == _("All checked simulations..."):
|
8330
|
+
|
8331
|
+
sims = self.get_list_keys(draw_type.RES2D, checked_state=True)
|
8332
|
+
if len(sims) == 0:
|
8333
|
+
logging.warning(_('No checked simulation !'))
|
8334
|
+
return
|
8335
|
+
|
8336
|
+
from .report.simplesimgpu import SimpleSimGPU_Report_wx
|
8337
|
+
|
8338
|
+
for curkey in sims:
|
8339
|
+
curmodel = self.get_obj_from_id(curkey, draw_type.RES2D)
|
8340
|
+
if isinstance(curmodel, wolfres2DGPU):
|
8341
|
+
newsheet = SimpleSimGPU_Report_wx(Path(curmodel.filename).parent, size=(800, 600))
|
8342
|
+
newsheet.Show()
|
8343
|
+
else:
|
8344
|
+
logging.warning(_('Simulation {} is not a GPU simulation - Not yet implemented for CPU simulations !').format(curmodel.idx))
|
8345
|
+
|
8346
|
+
elif itemlabel == _("All simulations in directory..."):
|
8347
|
+
dlg = wx.DirDialog(None, _('Choose the directory containing the simulations'), style=wx.DD_DEFAULT_STYLE)
|
8348
|
+
ret = dlg.ShowModal()
|
8349
|
+
if ret == wx.ID_CANCEL:
|
8350
|
+
dlg.Destroy()
|
8351
|
+
return
|
8352
|
+
directory = Path(dlg.GetPath())
|
8353
|
+
dlg.Destroy()
|
8354
|
+
if not directory.exists():
|
8355
|
+
logging.error(_('Directory {} does not exist !').format(directory))
|
8356
|
+
wx.MessageBox(_('Directory {} does not exist !').format(directory), _('Error'), wx.OK | wx.ICON_ERROR)
|
8357
|
+
return
|
8358
|
+
if not directory.is_dir():
|
8359
|
+
logging.error(_('Path {} is not a directory !').format(directory))
|
8360
|
+
wx.MessageBox(_('Path {} is not a directory !').format(directory), _('Error'), wx.OK | wx.ICON_ERROR)
|
8361
|
+
return
|
8362
|
+
from .report.simplesimgpu import SimpleSimGPU_Reports_wx
|
8363
|
+
|
8364
|
+
|
8365
|
+
# check if we want to show all wx reports
|
8366
|
+
dlg = wx.MessageDialog(None, _('Do you want to show all reports ?'), _('Show all reports'), style=wx.YES_NO | wx.YES_DEFAULT)
|
8367
|
+
ret = dlg.ShowModal()
|
8368
|
+
dlg.Destroy()
|
8369
|
+
|
8370
|
+
newsheets = SimpleSimGPU_Reports_wx(directory, show = ret == wx.ID_YES, size=(800, 600))
|
8371
|
+
|
8372
|
+
elif itemlabel == _("Compare checked simulations..."):
|
8373
|
+
|
8374
|
+
sims = self.get_list_keys(draw_type.RES2D, checked_state=True)
|
8375
|
+
if len(sims) == 0:
|
8376
|
+
logging.warning(_('No checked simulation !'))
|
8377
|
+
return
|
8378
|
+
|
8379
|
+
elif len(sims) == 1:
|
8380
|
+
logging.warning(_('Only one checked simulation - Nothing to compare !'))
|
8381
|
+
return
|
8382
|
+
|
8383
|
+
from .report.simplesimgpu import SimpleSimGPU_Report_Compare_wx
|
8384
|
+
|
8385
|
+
sims = [self.get_obj_from_id(curkey, draw_type.RES2D) for curkey in sims]
|
8386
|
+
# conserve only GPU simulations
|
8387
|
+
sims = [Path(curmodel.filename) for curmodel in sims if isinstance(curmodel, wolfres2DGPU)]
|
8388
|
+
|
8389
|
+
# take parent if "simul_gpu_results" in sims
|
8390
|
+
sims = [sim.parent for sim in sims if 'simul_gpu_results' in str(sim)]
|
8391
|
+
|
8392
|
+
if len(sims) == 0:
|
8393
|
+
logging.warning(_('No GPU simulation to compare !'))
|
8394
|
+
return
|
8395
|
+
elif len(sims) == 1:
|
8396
|
+
logging.warning(_('Only one GPU simulation - Nothing to compare !'))
|
8397
|
+
return
|
8398
|
+
elif len(sims) > 1:
|
8399
|
+
try:
|
8400
|
+
newsheet = SimpleSimGPU_Report_Compare_wx(sims, size=(800, 600))
|
8401
|
+
newsheet.Show()
|
8402
|
+
except Exception as e:
|
8403
|
+
logging.error(_('Error in comparing simulations\n{}'.format(e)))
|
8404
|
+
|
8405
|
+
elif itemlabel == _("Compare all simulations in a directory..."):
|
8406
|
+
|
8407
|
+
dlg = wx.DirDialog(None, _('Choose the directory containing the simulations'), style=wx.DD_DEFAULT_STYLE)
|
8408
|
+
ret = dlg.ShowModal()
|
8409
|
+
if ret == wx.ID_CANCEL:
|
8410
|
+
dlg.Destroy()
|
8411
|
+
return
|
8412
|
+
|
8413
|
+
directory = Path(dlg.GetPath())
|
8414
|
+
dlg.Destroy()
|
8415
|
+
|
8416
|
+
if not directory.exists():
|
8417
|
+
logging.error(_('Directory {} does not exist !').format(directory))
|
8418
|
+
wx.MessageBox(_('Directory {} does not exist !').format(directory), _('Error'), wx.OK | wx.ICON_ERROR)
|
8419
|
+
return
|
8420
|
+
if not directory.is_dir():
|
8421
|
+
logging.error(_('Path {} is not a directory !').format(directory))
|
8422
|
+
wx.MessageBox(_('Path {} is not a directory !').format(directory), _('Error'), wx.OK | wx.ICON_ERROR)
|
8423
|
+
return
|
8424
|
+
from .report.simplesimgpu import SimpleSimGPU_Report_Compare_wx
|
8425
|
+
try:
|
8426
|
+
newsheet = SimpleSimGPU_Report_Compare_wx(directory, size= (800,600))
|
8427
|
+
newsheet.Show()
|
8428
|
+
except Exception as e:
|
8429
|
+
logging.error(_('Error in comparing simulations in directory\n{}'.format(e)))
|
8430
|
+
|
8304
8431
|
elif itemlabel == _("Inpaint active array..."):
|
8305
8432
|
|
8306
8433
|
if self.active_array is None:
|
@@ -13209,7 +13336,7 @@ class WolfMapViewer(wx.Frame):
|
|
13209
13336
|
width, height = self.canvas.GetSize()
|
13210
13337
|
|
13211
13338
|
if iwidth == 0 or iheight == 0:
|
13212
|
-
logging.
|
13339
|
+
logging.warning(_('Width or height of the canvas is null -- Please check the "findminmax" routine in "Autoscale" !'))
|
13213
13340
|
iwidth = 1
|
13214
13341
|
iheight = 1
|
13215
13342
|
|
wolfhece/PyVertexvectors.py
CHANGED
@@ -1124,9 +1124,9 @@ if :\n \
|
|
1124
1124
|
self.myprops[('Move','Delta Y')] = 0.
|
1125
1125
|
|
1126
1126
|
self.parent.update_lengths()
|
1127
|
-
self.myprops[( 'Geometry','Length 2D')] = self.parent.length2D
|
1128
|
-
self.myprops[( 'Geometry','Length 3D')] = self.parent.length3D
|
1129
|
-
self.myprops[( 'Geometry','Surface')] = self.parent.area
|
1127
|
+
self.myprops[( 'Geometry','Length 2D')] = self.parent.length2D if self.parent.length2D is not None else 0.
|
1128
|
+
self.myprops[( 'Geometry','Length 3D')] = self.parent.length3D if self.parent.length3D is not None else 0.
|
1129
|
+
self.myprops[( 'Geometry','Surface')] = self.parent.area if self.parent.area is not None else 0.
|
1130
1130
|
|
1131
1131
|
self.myprops.Populate()
|
1132
1132
|
class vector:
|
@@ -6811,6 +6811,10 @@ class Zones(wx.Frame, Element_To_Draw):
|
|
6811
6811
|
self.sascending.SetToolTip(_("Check whether the vertices of the activated vector are ordered according to increasing 's' defined as 2D geometric distance \n If needed, invert some positions and return information to the user"))
|
6812
6812
|
self.sascending.Bind(wx.EVT_BUTTON,self.Onsascending)
|
6813
6813
|
|
6814
|
+
self._btn_buffer = wx.Button(self,label=_('Buffer'))
|
6815
|
+
self._btn_buffer.SetToolTip(_("Create a buffer around the currently activated vector\nThe buffer replaces the current vector"))
|
6816
|
+
self._btn_buffer.Bind(wx.EVT_BUTTON,self.Onbuffer)
|
6817
|
+
|
6814
6818
|
self.insertvertices = wx.Button(self,label=_('Insert'))
|
6815
6819
|
self.insertvertices.SetToolTip(_("Insert new vertex into the currently active vector from mouse clicks \n The new vertex is inserted along the nearest segment \n\n Keyboard 'Return' to stop the action ! "))
|
6816
6820
|
self.insertvertices.Bind(wx.EVT_BUTTON,self.Oninsert)
|
@@ -6929,8 +6933,11 @@ class Zones(wx.Frame, Element_To_Draw):
|
|
6929
6933
|
box_s.Add(self.getxyfromsz,1,wx.EXPAND) # Added
|
6930
6934
|
|
6931
6935
|
boxright.Add(self.interpxyz,0,wx.EXPAND)
|
6932
|
-
boxright.Add(self.sascending,0,wx.EXPAND)
|
6933
6936
|
|
6937
|
+
_sizer_ascbuffer = wx.BoxSizer(wx.HORIZONTAL)
|
6938
|
+
_sizer_ascbuffer.Add(self.sascending,1,wx.EXPAND)
|
6939
|
+
_sizer_ascbuffer.Add(self._btn_buffer,1,wx.EXPAND)
|
6940
|
+
boxright.Add(_sizer_ascbuffer,0,wx.EXPAND)
|
6934
6941
|
|
6935
6942
|
sizer_values_surface = wx.BoxSizer(wx.HORIZONTAL)
|
6936
6943
|
self.butgetval = wx.Button(self,label=_('Get values'))
|
@@ -7491,6 +7498,37 @@ class Zones(wx.Frame, Element_To_Draw):
|
|
7491
7498
|
dlg.ShowModal()
|
7492
7499
|
dlg.Destroy()
|
7493
7500
|
|
7501
|
+
def Onbuffer(self, e:wx.MouseEvent):
|
7502
|
+
""" Create a buffer around the currently activated vector.
|
7503
|
+
The buffer replaces the active vector in the same zone."""
|
7504
|
+
|
7505
|
+
if self.wx_exists:
|
7506
|
+
if self.verify_activevec():
|
7507
|
+
return
|
7508
|
+
|
7509
|
+
dlg = wx.TextEntryDialog(None, _('Buffer distance ?'), value='5.0')
|
7510
|
+
ret = dlg.ShowModal()
|
7511
|
+
dist = dlg.GetValue()
|
7512
|
+
dlg.Destroy()
|
7513
|
+
try:
|
7514
|
+
dist = float(dist)
|
7515
|
+
except:
|
7516
|
+
logging.warning(_('Bad value -- Retry !'))
|
7517
|
+
return
|
7518
|
+
if dist <= 0:
|
7519
|
+
logging.warning(_('Buffer distance must be > 0 -- Retry !'))
|
7520
|
+
return
|
7521
|
+
|
7522
|
+
if self.active_vector.nbvertices == 1:
|
7523
|
+
self.active_vector.myvertices = self.active_vector.myvertices * 3
|
7524
|
+
logging.warning(_('The active vector has only one vertex. It will be duplicated to create a buffer.'))
|
7525
|
+
if self.active_vector.nbvertices == 2:
|
7526
|
+
self.active_vector.myvertices = self.active_vector.myvertices + [self.active_vector.myvertices[0]]
|
7527
|
+
logging.warning(_('The active vector has only two vertices. The first one will be duplicated to create a buffer.'))
|
7528
|
+
|
7529
|
+
self.active_vector.buffer(dist)
|
7530
|
+
self.active_vector._reset_listogl()
|
7531
|
+
|
7494
7532
|
def Onmodify(self, event:wx.MouseEvent):
|
7495
7533
|
"""
|
7496
7534
|
Permet la modification interactive de vertex dans le vector actif
|
wolfhece/Results2DGPU.py
CHANGED
@@ -186,6 +186,7 @@ class wolfres2DGPU(Wolfresults_2D):
|
|
186
186
|
self._cache = None
|
187
187
|
|
188
188
|
def __getstate__(self):
|
189
|
+
""" Get state for pickle """
|
189
190
|
dct= super().__getstate__()
|
190
191
|
|
191
192
|
to_pop = ['_result_store', '_cache']
|
@@ -193,17 +194,25 @@ class wolfres2DGPU(Wolfresults_2D):
|
|
193
194
|
if key in dct:
|
194
195
|
dct.pop(key)
|
195
196
|
|
196
|
-
dct['isGPU'] = True
|
197
|
+
dct['isGPU'] = True # Indicate that this is a GPU result --> to avoid confusion with CPU results and loading phase "_loader", "_post_loader"
|
197
198
|
|
198
199
|
return dct
|
199
200
|
|
200
201
|
def __setstate__(self, dct):
|
201
|
-
|
202
|
+
""" Set state from a dictionary from pickle """
|
202
203
|
super().__setstate__(dct)
|
203
204
|
|
204
205
|
self._loader(self.filename)
|
205
206
|
self._post_loader()
|
206
207
|
|
208
|
+
if len(dct['myblocks']) > 0:
|
209
|
+
self.myblocks = dct['myblocks']
|
210
|
+
self.head_blocks = dct['head_blocks']
|
211
|
+
self.loaded_rough = dct['loaded_rough']
|
212
|
+
self.current_result = dct['current_result']
|
213
|
+
self.loaded = dct['loaded']
|
214
|
+
self._nap = dct['_nap']
|
215
|
+
|
207
216
|
self._result_store = None
|
208
217
|
self._cache = None
|
209
218
|
self.setup_store(self._result_store)
|
wolfhece/__init__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from . import _add_path
|
2
|
+
from .libs import *
|
2
3
|
from .PyTranslate import _
|
3
4
|
|
4
5
|
try:
|
@@ -11,5 +12,18 @@ except ImportError as e:
|
|
11
12
|
raise Exception(_('Error importing GDAL library\nPlease ensure GDAL is installed and the Python bindings are available\n\ngdal wheels can be found at https://github.com/cgohlke/geospatial-wheels'))
|
12
13
|
|
13
14
|
from .apps.version import WolfVersion
|
15
|
+
from packaging.version import Version
|
14
16
|
|
15
|
-
__version__ = WolfVersion().get_version()
|
17
|
+
__version__ = WolfVersion().get_version()
|
18
|
+
|
19
|
+
def is_enough(version: str) -> bool:
|
20
|
+
"""
|
21
|
+
Compare the current version of WolfHece to a given version string.
|
22
|
+
|
23
|
+
Args:
|
24
|
+
version (str): The version string to compare against.
|
25
|
+
|
26
|
+
Returns:
|
27
|
+
bool: True if the current version is greater than or equal to the given version, False otherwise.
|
28
|
+
"""
|
29
|
+
return Version(__version__) >= Version(version)
|
wolfhece/_add_path.py
CHANGED
@@ -3,6 +3,11 @@ import os.path
|
|
3
3
|
import sys
|
4
4
|
import platform
|
5
5
|
|
6
|
+
try:
|
7
|
+
import wolf_libs
|
8
|
+
except ImportError:
|
9
|
+
print("wolf_libs not found. Please install the wolf-libs package -- pip install wolf-libs.")
|
10
|
+
sys.exit(1)
|
6
11
|
|
7
12
|
def _add_path():
|
8
13
|
_root_dir = os.path.dirname(os.path.realpath(__file__))
|
@@ -10,6 +15,10 @@ def _add_path():
|
|
10
15
|
# manual specify list of dll directories, with paths relative to _root_dir
|
11
16
|
_dll_dirs = ['libs', 'shaders']
|
12
17
|
|
18
|
+
# add wolf_libs path to __dll_dirs
|
19
|
+
if wolf_libs.__path__:
|
20
|
+
_dll_dirs.insert(0, os.path.join(wolf_libs.__path__[0]))
|
21
|
+
|
13
22
|
if platform.system() == 'Windows':
|
14
23
|
os.environ.setdefault('PATH', '')
|
15
24
|
paths = os.environ['PATH'].split(';')
|
wolfhece/apps/check_install.py
CHANGED
@@ -37,12 +37,12 @@ def main():
|
|
37
37
|
else:
|
38
38
|
ret += 'WolfGPU not installed\n Please install WolfGPU if needed\n\n'
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
try:
|
41
|
+
from wolf_libs import wolfpy
|
42
|
+
ret += 'Wolfpy accessible\n\n'
|
43
|
+
except ImportError as e:
|
44
|
+
ret += 'Wolfpy not accessible\n\n'
|
45
|
+
ret += 'Error : ' + str(e) + '\n\n'
|
46
46
|
|
47
47
|
try:
|
48
48
|
from ..PyGui import MapManager
|
wolfhece/apps/splashscreen.py
CHANGED
@@ -23,7 +23,7 @@ import time
|
|
23
23
|
from wx.adv import SplashScreen as SplashScreen,SPLASH_CENTRE_ON_SCREEN,SPLASH_TIMEOUT,Sound
|
24
24
|
|
25
25
|
try:
|
26
|
-
from
|
26
|
+
from wolf_libs import wolfogl
|
27
27
|
except ImportError:
|
28
28
|
print("** WolfOGL not found **")
|
29
29
|
print("Without WolfOGL, the application will not work !")
|
wolfhece/apps/version.py
CHANGED
wolfhece/assets/tree.py
ADDED
File without changes
|
wolfhece/cli.py
CHANGED
@@ -15,7 +15,8 @@ def check():
|
|
15
15
|
|
16
16
|
def license():
|
17
17
|
""" Main wolf application : License """
|
18
|
-
from .
|
18
|
+
from wolf_libs.wolfogl import request_license
|
19
|
+
|
19
20
|
from pathlib import Path
|
20
21
|
|
21
22
|
if Path(__file__).parent / 'license' / 'wolf.lic':
|
@@ -76,6 +77,100 @@ def hydro():
|
|
76
77
|
from .apps.wolfhydro import main
|
77
78
|
main()
|
78
79
|
|
80
|
+
def report_gpu():
|
81
|
+
""" Application for generating GPU simulation reports """
|
82
|
+
from .report.simplesimgpu import SimpleSimGPU_Report
|
83
|
+
|
84
|
+
# récupère l'argument de la ligne de commande
|
85
|
+
from pathlib import Path
|
86
|
+
import sys
|
87
|
+
n = len(sys.argv)
|
88
|
+
|
89
|
+
if n == 3:
|
90
|
+
outpath = Path(sys.argv[2])
|
91
|
+
mydir = Path(sys.argv[1])
|
92
|
+
elif n == 2:
|
93
|
+
outpath = Path('.')
|
94
|
+
mydir = Path(sys.argv[1])
|
95
|
+
else:
|
96
|
+
print('Usage: wolf_report_gpu <directory> or wolf_report_gpu <directory> <directory_out>')
|
97
|
+
|
98
|
+
if n in [2, 3]:
|
99
|
+
if mydir.exists():
|
100
|
+
report = SimpleSimGPU_Report(mydir)
|
101
|
+
report.create_report()
|
102
|
+
report.save_report(outpath / (mydir.name + '_report.pdf'))
|
103
|
+
else:
|
104
|
+
print('Directory not found')
|
105
|
+
else:
|
106
|
+
print('Usage: wolf_report_gpu <directory>')
|
107
|
+
|
108
|
+
def reports_gpu():
|
109
|
+
""" Application for generating GPU simulation reports """
|
110
|
+
from .report.simplesimgpu import SimpleSimGPU_Report
|
111
|
+
|
112
|
+
# récupère l'argument de la ligne de commande
|
113
|
+
from pathlib import Path
|
114
|
+
import glob
|
115
|
+
import sys
|
116
|
+
n = len(sys.argv)
|
117
|
+
|
118
|
+
if n == 3:
|
119
|
+
outpath = Path(sys.argv[2])
|
120
|
+
mydir = Path(sys.argv[1])
|
121
|
+
elif n == 2:
|
122
|
+
mydir = Path(sys.argv[1])
|
123
|
+
outpath = Path('.')
|
124
|
+
else:
|
125
|
+
print('Usage: wolf_reports_gpu <directory> or wolf_reports_gpu <directory> <directory_out>')
|
126
|
+
|
127
|
+
if n in [2, 3]:
|
128
|
+
if mydir.exists():
|
129
|
+
# find all sims in the directory
|
130
|
+
sim_dirs = Path(mydir).rglob('parameters.json')
|
131
|
+
sim_dirs = [Path(d).parent for d in sim_dirs]
|
132
|
+
if not sim_dirs:
|
133
|
+
print('No simulation directories found in {}'.format(mydir))
|
134
|
+
return
|
135
|
+
# create a report for each simulation
|
136
|
+
for sim_dir in sim_dirs:
|
137
|
+
print('Creating report for {}'.format(sim_dir))
|
138
|
+
report = SimpleSimGPU_Report(sim_dir)
|
139
|
+
report.create_report()
|
140
|
+
report.save_report(outpath / (sim_dir.name + '_report.pdf'))
|
141
|
+
else:
|
142
|
+
print('Directory not found')
|
143
|
+
|
144
|
+
def report_compare():
|
145
|
+
""" Application for comparing GPU simulation reports """
|
146
|
+
from .report.simplesimgpu import SimpleSimGPU_Report_Compare
|
147
|
+
|
148
|
+
# récupère l'argument de la ligne de commande
|
149
|
+
from pathlib import Path
|
150
|
+
import sys
|
151
|
+
n = len(sys.argv)
|
152
|
+
if n == 2:
|
153
|
+
mydir = Path(sys.argv[1])
|
154
|
+
if mydir.exists():
|
155
|
+
report = SimpleSimGPU_Report_Compare(mydir)
|
156
|
+
report.create_report()
|
157
|
+
report.save_report(mydir.name + '_report_compare.pdf')
|
158
|
+
else:
|
159
|
+
print('Directory not found')
|
160
|
+
elif n > 2:
|
161
|
+
files = [Path(f) for f in sys.argv[1:]]
|
162
|
+
if all(f.exists() for f in files):
|
163
|
+
report = SimpleSimGPU_Report_Compare(files)
|
164
|
+
report.create_report()
|
165
|
+
report.save_report('report_compare.pdf')
|
166
|
+
else:
|
167
|
+
for f in files:
|
168
|
+
if not f.exists():
|
169
|
+
print('File {} not found'.format(f))
|
170
|
+
else:
|
171
|
+
print('Usage: wolf_report_compare <directory> or wolf_report_compare <file1> <file2> ...')
|
172
|
+
|
173
|
+
|
79
174
|
def compare():
|
80
175
|
""" Application for comparing 2D arrays """
|
81
176
|
from .apps.wolfcompare2Darrays import main
|
@@ -19,6 +19,8 @@ from matplotlib.backends.backend_wxagg import (
|
|
19
19
|
import shutil
|
20
20
|
import ctypes as ct
|
21
21
|
|
22
|
+
|
23
|
+
import wolf_libs
|
22
24
|
from .PostProcessHydrology import PostProcessHydrology
|
23
25
|
from .Catchment import *
|
24
26
|
from .Comparison import *
|
@@ -148,7 +150,10 @@ class Optimisation(wx.Frame):
|
|
148
150
|
self.myParams = {}
|
149
151
|
self.myParamsPy = {}
|
150
152
|
self.nbParams = 0
|
151
|
-
|
153
|
+
|
154
|
+
#self.pathDll = Path(os.path.dirname(__file__)).parent
|
155
|
+
# point to the wolf_libs package directory
|
156
|
+
self.pathDll = wolf_libs.__path__[0]
|
152
157
|
|
153
158
|
self.callBack_proc = {}
|
154
159
|
self.callBack_ptr = {}
|
@@ -234,8 +239,8 @@ class Optimisation(wx.Frame):
|
|
234
239
|
self.Bind(wx.EVT_MENU, self.launch_models_propertie_with_Nash, testEquiFinClick)
|
235
240
|
plotEquiFinClick = toolMenu.Append(wx.ID_ANY, 'Plot analysis with Nash')
|
236
241
|
self.Bind(wx.EVT_MENU, self.plot_model_analysis, plotEquiFinClick)
|
237
|
-
|
238
|
-
|
242
|
+
|
243
|
+
|
239
244
|
|
240
245
|
# Creation of the Lauch Menu
|
241
246
|
launchMenu = wx.Menu()
|
@@ -2021,7 +2026,7 @@ class Optimisation(wx.Frame):
|
|
2021
2026
|
myGroup = myModelDict[int(myType)]["Group"][iFile]
|
2022
2027
|
myKey = myModelDict[int(myType)]["Key"][iFile]
|
2023
2028
|
self.write_one_opti_param(filePath, fileName, myGroup, myKey, params[i], convers_factor=convFact[iFile])
|
2024
|
-
else:
|
2029
|
+
else:
|
2025
2030
|
self.curParams_vec_F[i] = params[i]
|
2026
2031
|
self.update_timeDelay(i+1)
|
2027
2032
|
refCatch.save_timeDelays([self.myParams[i+1]["junction_name"]])
|
@@ -2676,10 +2681,10 @@ class Optimisation(wx.Frame):
|
|
2676
2681
|
logging.info("The equifinality test is finished!")
|
2677
2682
|
|
2678
2683
|
|
2679
|
-
def get_best_params(self, stationOut:str,
|
2684
|
+
def get_best_params(self, stationOut:str,
|
2680
2685
|
criterion:str="Nash", quantile:float=0.99, std:float=0.05, eps:float=0.2, rmv_near_max=1e-4, nb_rand_close:int=10,
|
2681
2686
|
objective_fct:bool= True, apply_clustering:bool=False, objective_weight:float=1.0):
|
2682
|
-
from sklearn.cluster import DBSCAN
|
2687
|
+
from sklearn.cluster import DBSCAN
|
2683
2688
|
"""
|
2684
2689
|
Get the best parameters for a given station.
|
2685
2690
|
|
@@ -2832,10 +2837,10 @@ class Optimisation(wx.Frame):
|
|
2832
2837
|
return None
|
2833
2838
|
cur_fracts = curBasin.get_volume_fractions(interval=intervals)
|
2834
2839
|
return cur_fracts
|
2835
|
-
|
2836
|
-
def _get_flow_fractions(self, idLauncher:int=0, stationOut:str="",
|
2840
|
+
|
2841
|
+
def _get_flow_fractions(self, idLauncher:int=0, stationOut:str="",
|
2837
2842
|
intervals:list[tuple[datetime.datetime, datetime.datetime]]=[]) -> dict[list[str], list[float]]:
|
2838
|
-
|
2843
|
+
|
2839
2844
|
curCatch:Catchment = self.myCases[idLauncher].refCatchment
|
2840
2845
|
cur_key = curCatch.get_key_catchmentDict(stationOut)
|
2841
2846
|
curBasin: SubBasin = curCatch.catchmentDict[cur_key]
|
@@ -2844,11 +2849,11 @@ class Optimisation(wx.Frame):
|
|
2844
2849
|
return None
|
2845
2850
|
cur_fracts = curBasin.get_flow_fractions(interval=intervals, summary="mean")
|
2846
2851
|
return cur_fracts
|
2847
|
-
|
2848
2852
|
|
2849
|
-
|
2853
|
+
|
2854
|
+
def _get_punctual_reservoir_fractions(self, eval_date:datetime.datetime,
|
2850
2855
|
idLauncher:int=0, stationOut:str="") -> dict[list[str], list[float]]:
|
2851
|
-
|
2856
|
+
|
2852
2857
|
curCatch:Catchment = self.myCases[idLauncher].refCatchment
|
2853
2858
|
cur_key = curCatch.get_key_catchmentDict(stationOut)
|
2854
2859
|
curBasin: SubBasin = curCatch.catchmentDict[cur_key]
|
@@ -2856,7 +2861,7 @@ class Optimisation(wx.Frame):
|
|
2856
2861
|
logging.warning("The current module is not a SubBasin object!")
|
2857
2862
|
return None
|
2858
2863
|
linked_params = mc.MODELS_VAR[curBasin.model].get_all_linked_params()
|
2859
|
-
i_params = self._get_key_from_type_all_parameters(list(linked_params.values()))
|
2864
|
+
i_params = self._get_key_from_type_all_parameters(list(linked_params.values()))
|
2860
2865
|
max_params = {var_name: self.myParams[i_params[param_id]]["value"] for var_name, param_id in linked_params.items()}
|
2861
2866
|
cur_fracts = curBasin.get_iv_fractions_one_date(max_params=max_params, eval_date=eval_date)
|
2862
2867
|
return cur_fracts
|
@@ -3021,7 +3026,7 @@ class Optimisation(wx.Frame):
|
|
3021
3026
|
cur_columns = [col for col in df.columns if cur_prop in col.replace(" ", "")]
|
3022
3027
|
if cur_columns != []:
|
3023
3028
|
corr_prop = cur_columns[0]
|
3024
|
-
ax.scatter(df.loc[:,corr_prop], df.loc[:,y_label], s=0.5, c=cur_color,
|
3029
|
+
ax.scatter(df.loc[:,corr_prop], df.loc[:,y_label], s=0.5, c=cur_color,
|
3025
3030
|
marker='o', label=cur_prop, alpha=0.4)
|
3026
3031
|
ax.set_xlabel("% of the rain [-]")
|
3027
3032
|
ax.set_ylabel(y_label+" [-]")
|
@@ -3049,10 +3054,10 @@ class Optimisation(wx.Frame):
|
|
3049
3054
|
ax.set_title("Peak analysis : "+stationOut)
|
3050
3055
|
ax.legend()
|
3051
3056
|
fig.savefig(os.path.join(self.workingDir, "Equifinality_peaks_ratio_"+stationOut+".png"))
|
3052
|
-
|
3057
|
+
|
3053
3058
|
else:
|
3054
3059
|
logging.error("The file "+filename+" does not exist!")
|
3055
|
-
|
3060
|
+
|
3056
3061
|
plt.show()
|
3057
3062
|
|
3058
3063
|
|
@@ -3212,7 +3217,7 @@ class Optimisation(wx.Frame):
|
|
3212
3217
|
|
3213
3218
|
# FIXME : this function has been dashed off -> functionnal but not well written!!
|
3214
3219
|
# TODO : to improve !!!!!!
|
3215
|
-
def launch_models_propertie_with_Nash(self, event, idLauncher:int=0, idOpti:int=1, quantile_Nash:float=0.01, std_Nash:float=0.03, clustering_Nash:bool=True,
|
3220
|
+
def launch_models_propertie_with_Nash(self, event, idLauncher:int=0, idOpti:int=1, quantile_Nash:float=0.01, std_Nash:float=0.03, clustering_Nash:bool=True,
|
3216
3221
|
save_every:int=100, restart_from_file:bool=True):
|
3217
3222
|
"""
|
3218
3223
|
Analyse the properties of the model and compare them with the Nash coefficient.
|
@@ -3232,11 +3237,11 @@ class Optimisation(wx.Frame):
|
|
3232
3237
|
if onlyOwnSub is None:
|
3233
3238
|
onlyOwnSub = False
|
3234
3239
|
doneList = []
|
3235
|
-
previousLevel = 1
|
3240
|
+
previousLevel = 1
|
3236
3241
|
# Collect sort and save the compare stations
|
3237
3242
|
self.set_compare_stations(idLauncher=idLauncher)
|
3238
3243
|
sortJct = self.myStations
|
3239
|
-
# Get the initial number of intervals
|
3244
|
+
# Get the initial number of intervals
|
3240
3245
|
# -> these can evolve according to the measurement available at each station
|
3241
3246
|
is_ok = self._save_opti_intervals()
|
3242
3247
|
all_intervals = self.all_intervals
|
@@ -3268,14 +3273,14 @@ class Optimisation(wx.Frame):
|
|
3268
3273
|
# Reload the useful modules
|
3269
3274
|
self.reload_hydro(idCompar=0, fromStation=stationOut, lastLevel=previousLevel, updateAll=True)
|
3270
3275
|
## =======
|
3271
|
-
## Init
|
3276
|
+
## Init
|
3272
3277
|
## =======
|
3273
3278
|
self.init_optimizer(idOpti)
|
3274
3279
|
self.associate_ptr(None, idOpti=idOpti)
|
3275
3280
|
# Get the best parameters to test
|
3276
3281
|
all_params = self.get_best_params(stationOut=stationOut, quantile=quantile_Nash, std=std_Nash, rmv_near_max=1e-4, apply_clustering=clustering_Nash)
|
3277
3282
|
## =======
|
3278
|
-
## Compute
|
3283
|
+
## Compute
|
3279
3284
|
## =======
|
3280
3285
|
all_frac = []
|
3281
3286
|
# Check if the excel file already exists and load it to check if some parameters have already been tested
|
@@ -3307,7 +3312,7 @@ class Optimisation(wx.Frame):
|
|
3307
3312
|
cur_all_frac = (list(cur_p)
|
3308
3313
|
+ cur_timeDelays
|
3309
3314
|
+ list(frac_flow_dict.values())
|
3310
|
-
+ list(init_iv.values())
|
3315
|
+
+ list(init_iv.values())
|
3311
3316
|
+ [p_excess, max_sim_obs, cur_obj])
|
3312
3317
|
all_frac.append(cur_all_frac)
|
3313
3318
|
# Periodically save the evaluations in case of trouble
|
@@ -3364,14 +3369,14 @@ class Optimisation(wx.Frame):
|
|
3364
3369
|
# FIXME : it might be better to pass the myParams to the CaseOpti object instead to allow parallelisation
|
3365
3370
|
def _build_type_to_key_index(self) -> dict[int, int]:
|
3366
3371
|
return {param["type"]: i for i, param in self.myParams.items()}
|
3367
|
-
|
3372
|
+
|
3368
3373
|
def _get_key_from_type_all_parameters(self, list_type_param: list[int]) -> dict[int | None]:
|
3369
3374
|
type_to_key = self._build_type_to_key_index()
|
3370
3375
|
return {cur_key: type_to_key.get(cur_key) for cur_key in list_type_param}
|
3371
3376
|
|
3372
3377
|
def _get_key_from_type_parameter(self, type_param:int) -> int:
|
3373
3378
|
return next((i for i, param in self.myParams.items() if param["type"] == type_param), None)
|
3374
|
-
|
3379
|
+
|
3375
3380
|
|
3376
3381
|
def make_nd_array(self, c_pointer, shape, dtype=np.float64, order='C', own_data=True,readonly=False):
|
3377
3382
|
arr_size = np.prod(shape[:]) * np.dtype(dtype).itemsize
|
@@ -3417,5 +3422,5 @@ class Optimisation(wx.Frame):
|
|
3417
3422
|
# Remove the parameters that have already been tested
|
3418
3423
|
new_params = np.array([el for el in all_params if ~np.any(np.all(np.isclose(all_params_tested, el[:-1], atol=1e-6), axis=1))])
|
3419
3424
|
return all_data_tested, new_params
|
3420
|
-
|
3425
|
+
|
3421
3426
|
return [], all_params
|
@@ -30,7 +30,7 @@ class BCType_2D_GPU(Enum):
|
|
30
30
|
""" Boundary conditions for 2D simulations with wolfgpu """
|
31
31
|
|
32
32
|
# The numbers match the numbers in Wolf's simulations parameters.
|
33
|
-
|
33
|
+
H = (1,_('Water level [m]'))
|
34
34
|
QX = (2,_('Flow rate along X [m²/s]'))
|
35
35
|
QY = (3,_('Flow rate along Y [m²/s]'))
|
36
36
|
NONE = (4,_('None'))
|