wolfhece 2.2.20__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.
Files changed (58) hide show
  1. wolfhece/PyDraw.py +127 -0
  2. wolfhece/__init__.py +1 -0
  3. wolfhece/_add_path.py +9 -0
  4. wolfhece/apps/check_install.py +6 -6
  5. wolfhece/apps/splashscreen.py +1 -1
  6. wolfhece/apps/version.py +1 -1
  7. wolfhece/cli.py +96 -1
  8. wolfhece/hydrology/Optimisation.py +30 -25
  9. wolfhece/report/pdf.py +55 -0
  10. wolfhece/report/simplesimgpu.py +1409 -0
  11. wolfhece/tools2d_dll.py +7 -2
  12. wolfhece/wolf_array.py +23 -5
  13. wolfhece/wolf_hist.py +21 -16
  14. wolfhece/wolfresults_2D.py +0 -24
  15. {wolfhece-2.2.20.dist-info → wolfhece-2.2.23.dist-info}/METADATA +3 -1
  16. {wolfhece-2.2.20.dist-info → wolfhece-2.2.23.dist-info}/RECORD +19 -56
  17. {wolfhece-2.2.20.dist-info → wolfhece-2.2.23.dist-info}/entry_points.txt +3 -0
  18. wolfhece/libs/GL/gl.h +0 -1044
  19. wolfhece/libs/GL/glaux.h +0 -272
  20. wolfhece/libs/GL/glcorearb.h +0 -3597
  21. wolfhece/libs/GL/glext.h +0 -11771
  22. wolfhece/libs/GL/glu.h +0 -255
  23. wolfhece/libs/GL/glxext.h +0 -926
  24. wolfhece/libs/GL/wglext.h +0 -840
  25. wolfhece/libs/MSVCP140.dll +0 -0
  26. wolfhece/libs/WolfDll.dll +0 -0
  27. wolfhece/libs/Wolf_tools.dll +0 -0
  28. wolfhece/libs/api-ms-win-crt-heap-l1-1-0.dll +0 -0
  29. wolfhece/libs/api-ms-win-crt-math-l1-1-0.dll +0 -0
  30. wolfhece/libs/api-ms-win-crt-runtime-l1-1-0.dll +0 -0
  31. wolfhece/libs/fribidi-0.dll +0 -0
  32. wolfhece/libs/get_infos.cp310-win_amd64.pyd +0 -0
  33. wolfhece/libs/get_infos.cp311-win_amd64.pyd +0 -0
  34. wolfhece/libs/get_infos.cp312-win_amd64.pyd +0 -0
  35. wolfhece/libs/get_infos.cp313-win_amd64.pyd +0 -0
  36. wolfhece/libs/glu32.dll +0 -0
  37. wolfhece/libs/hdf5.dll +0 -0
  38. wolfhece/libs/hdf5_hl.dll +0 -0
  39. wolfhece/libs/libcurl.dll +0 -0
  40. wolfhece/libs/libpardiso600-WIN-X86-64.dll +0 -0
  41. wolfhece/libs/libraqm.dll +0 -0
  42. wolfhece/libs/msvcr100.dll +0 -0
  43. wolfhece/libs/netcdf.dll +0 -0
  44. wolfhece/libs/paho-mqtt3cs.dll +0 -0
  45. wolfhece/libs/vcomp100.dll +0 -0
  46. wolfhece/libs/vcruntime140.dll +0 -0
  47. wolfhece/libs/vcruntime140_1.dll +0 -0
  48. wolfhece/libs/verify_wolf.cp310-win_amd64.pyd +0 -0
  49. wolfhece/libs/verify_wolf.cp311-win_amd64.pyd +0 -0
  50. wolfhece/libs/verify_wolf.cp312-win_amd64.pyd +0 -0
  51. wolfhece/libs/verify_wolf.cp313-win_amd64.pyd +0 -0
  52. wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
  53. wolfhece/libs/wolfogl.cp311-win_amd64.pyd +0 -0
  54. wolfhece/libs/wolfogl.cp312-win_amd64.pyd +0 -0
  55. wolfhece/libs/wolfogl.cp313-win_amd64.pyd +0 -0
  56. wolfhece/libs/zlib1.dll +0 -0
  57. {wolfhece-2.2.20.dist-info → wolfhece-2.2.23.dist-info}/WHEEL +0 -0
  58. {wolfhece-2.2.20.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:
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:
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(';')
@@ -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
- # try:
41
- # from ..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'
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
@@ -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 ..libs import wolfogl
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
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 2
8
- self.patch = 20
8
+ self.patch = 23
9
9
 
10
10
  def __str__(self):
11
11
 
wolfhece/cli.py CHANGED
@@ -15,7 +15,8 @@ def check():
15
15
 
16
16
  def license():
17
17
  """ Main wolf application : License """
18
- from .libs.wolfogl import request_license
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
- self.pathDll = Path(os.path.dirname(__file__)).parent
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
- def _get_punctual_reservoir_fractions(self, eval_date:datetime.datetime,
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
wolfhece/report/pdf.py ADDED
@@ -0,0 +1,55 @@
1
+ """ WX Frame displaying a PDF file """
2
+ import wx
3
+ import wx.lib.sized_controls as sc
4
+ from wx.lib.pdfviewer import pdfViewer, pdfButtonPanel
5
+
6
+ from pathlib import Path
7
+
8
+ class PDFViewer(sc.SizedFrame):
9
+
10
+ def __init__(self, parent, **kwargs):
11
+ """ Initialize the PDF Viewer Frame """
12
+ super(PDFViewer, self).__init__(parent, **kwargs)
13
+
14
+ paneCont = self.GetContentsPane()
15
+ self.buttonpanel = pdfButtonPanel(paneCont, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0)
16
+ self.buttonpanel.SetSizerProps(expand=True)
17
+
18
+ self.viewer:pdfViewer
19
+ self.viewer = pdfViewer(paneCont, wx.ID_ANY, wx.DefaultPosition,
20
+ wx.DefaultSize,
21
+ wx.HSCROLL|wx.VSCROLL|wx.SUNKEN_BORDER)
22
+
23
+ self.viewer.SetSizerProps(expand=True, proportion=1)
24
+
25
+ # introduce buttonpanel and viewer to each other
26
+ self.buttonpanel.viewer = self.viewer
27
+ self.viewer.buttonpanel = self.buttonpanel
28
+
29
+ icon = wx.Icon()
30
+ icon_path = Path(__file__).parent.parent / "apps/wolf_logo2.bmp"
31
+ icon.CopyFromBitmap(wx.Bitmap(str(icon_path), wx.BITMAP_TYPE_ANY))
32
+ self.SetIcon(icon)
33
+
34
+
35
+ def load_pdf(self, pdf_path:str):
36
+ """ Load a PDF file into the viewer """
37
+
38
+ if not Path(pdf_path).exists():
39
+ wx.MessageBox("PDF file does not exist.", "Error", wx.OK | wx.ICON_ERROR)
40
+ return
41
+
42
+ try:
43
+ self.viewer.LoadFile(str(pdf_path))
44
+ except Exception as e:
45
+ wx.MessageBox("Failed to load PDF file.", "Error", wx.OK | wx.ICON_ERROR)
46
+
47
+ if __name__ == '__main__':
48
+ import wx.lib.mixins.inspection as WIT
49
+ app = WIT.InspectableApp(redirect=False)
50
+
51
+ pdfV = PDFViewer(None)
52
+ pdfV.load_pdf(Path(__file__).parent.parent.parent /'tests' / 'data' / 'pdf' / "dummy.pdf") # Change to your PDF file path
53
+ pdfV.Show()
54
+
55
+ app.MainLoop()