wolfhece 2.1.100__py3-none-any.whl → 2.1.101__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.
@@ -8100,9 +8100,12 @@ class prev_infiltration():
8100
8100
 
8101
8101
  sequence, nb_zones = self._infiltrations_chronology.shape
8102
8102
  for zone in range(1,nb_zones):
8103
- ax.plot(self._infiltrations_chronology[:, 0], self._infiltrations_chronology[:, zone], label=f'Infil {zone}')
8103
+ ax.plot(self._infiltrations_chronology[:, 0], self._infiltrations_chronology[:, zone], label=f'Zone {zone}')
8104
8104
 
8105
+ ax.set_xlabel(_('Time [s]'))
8106
+ ax.set_ylabel(_('Infiltration [$m^3/s$]'))
8105
8107
  ax.legend()
8108
+ fig.tight_layout()
8106
8109
 
8107
8110
  if show:
8108
8111
  fig.show()
@@ -202,14 +202,15 @@ class Config_Manager_2D_GPU:
202
202
  Gestionnaire de configurations 2D - code GPU
203
203
  """
204
204
 
205
- def __init__(self, workingdir:str = '', mapviewer:WolfMapViewer = None) -> None:
205
+ def __init__(self, workingdir:str = '', mapviewer:WolfMapViewer = None, python_venv:Path = None) -> None:
206
206
  """
207
207
  Recherche de toutes les modélisation dans un répertoire et ses sous-répertoires
208
208
  """
209
209
  self.wx_exists = wx.App.Get() is not None
210
210
 
211
- self.workingdir = ''
212
- self.wolfcli = ''
211
+ self.workingdir:Path = None
212
+ self.wolfgpu:Path = None
213
+ self._py_env:Path = python_venv
213
214
 
214
215
  if workingdir == '':
215
216
  if self.wx_exists:
@@ -228,6 +229,7 @@ class Config_Manager_2D_GPU:
228
229
  logging.error(_('Directory does not exist !'))
229
230
  return
230
231
 
232
+ self.find_wolfgpu()
231
233
  self.workingdir = Path(workingdir)
232
234
  self.mapviewer = mapviewer
233
235
 
@@ -239,6 +241,33 @@ class Config_Manager_2D_GPU:
239
241
 
240
242
  self.load_data()
241
243
 
244
+ def find_wolfgpu(self):
245
+ """ Find the wolfgpu Path from wolfgpu package"""
246
+
247
+ import importlib.util
248
+ import sys
249
+
250
+ if self._py_env is None:
251
+ self._py_env = Path(sys.executable).parent
252
+
253
+ # Find wolfgpu.exe in script directory
254
+ candidate = self._py_env / 'wolfgpu.exe'
255
+
256
+ if candidate.exists():
257
+ self.wolfgpu = candidate
258
+ return
259
+
260
+ candidate = self._py_env / 'Scripts' / 'wolfgpu.exe'
261
+
262
+ if candidate.exists():
263
+ self.wolfgpu = candidate
264
+ return
265
+ else:
266
+ logging.error(_('WOLFGPU not found !'))
267
+ self.wolfgpu = None
268
+ self._py_env = None
269
+
270
+
242
271
  def _test_ui(self):
243
272
  """ Test if the UI is available """
244
273
 
@@ -1263,25 +1292,35 @@ class Config_Manager_2D_GPU:
1263
1292
  logging.info(cursim.check_errors())
1264
1293
  logging.info(_('Simulation {} created !'.format(curdir)))
1265
1294
 
1266
-
1267
1295
  with open(curdir / 'quickrun.bat', 'w', encoding='utf-8') as f:
1296
+ f.write("@echo off\n")
1297
+ f.write("\n")
1268
1298
  f.write(str(curdir.drive) + '\n')
1269
1299
  f.write('cd {}\n'.format(str(curdir.parent)))
1270
- f.write('wolfgpu -quickrun ' + str(curdir.name) + '\n')
1271
-
1272
- # f.write("from pathlib import Path\n")
1273
- # f.write("from wolfgpu.simple_simulation import SimpleSimulation\n")
1274
- # f.write("from wolfgpu.SimulationRunner import SimulationRunner\n")
1275
- # f.write("from wolfgpu.glsimulation import ResultsStore\n\n")
1276
- # f.write("def main():\n")
1277
- # f.write("\tsim = SimpleSimulation.load(Path(__file__).parent)\n")
1278
- # f.write("\tresult_store:ResultsStore = SimulationRunner.quick_run(sim, Path(__file__).parent)")
1279
- # f.write("\n\nif __name__ == '__main__':\n")
1280
- # f.write("\tmain()\n")
1300
+ f.write("\n")
1301
+ f.write("WOLFGPU_PARAMS=-quickrun " + str(curdir.name) + "\n")
1302
+ f.write("\n")
1303
+ f.write("where wolfgpu.exe\n")
1304
+ f.write("IF %ERRORLEVEL%==0 (\n")
1305
+ f.write("wolfgpu %WOLFGPU_PARAMS%\n")
1306
+ f.write("goto :end\n")
1307
+ f.write(")\n")
1308
+ f.write("\n")
1309
+ f.write("echo -------------------------------\n")
1310
+ f.write("echo ERROR !!!\n")
1311
+ f.write("echo -------------------------------\n")
1312
+ f.write("echo I can't find wolfgpu.exe.\n")
1313
+ f.write("echo It is normally installed in the 'Scripts' subdirectory of your python\n")
1314
+ f.write("echo directory (or environment).\n")
1315
+ f.write("echo This 'Scripts' subdirectory must be available on the PATH environment variable.\n")
1316
+ f.write("echo I am now going to try to run wolfgpu as a regular python module\n")
1317
+ f.write("echo -------------------------------\n")
1318
+ f.write("pause\n")
1319
+ f.write("python -m wolfgpu.cli %WOLFGPU_PARAMS%\n")
1320
+ f.write(":end\n")
1281
1321
 
1282
1322
  allsims.append(curdir / 'quickrun.bat')
1283
1323
 
1284
-
1285
1324
  logging.info(_('Simulation creation finished !'))
1286
1325
  logging.warning(_('Do not forget to update/set the boundary conditions if not set by scripts !'))
1287
1326
 
@@ -1303,10 +1342,24 @@ class Config_Manager_2D_GPU:
1303
1342
  with open(path, 'w', encoding='utf-8') as f:
1304
1343
  f.write(batch)
1305
1344
 
1345
+ if self.wolfgpu is None:
1346
+ logging.warning('****************************************************')
1347
+ logging.warning(_('Wolfgpu.exe not found !'))
1348
+ logging.warning(_('It is normally installed in the "Scripts" subdirectory of your python directory (or environment).'))
1349
+ logging.warning(_('This "Scripts" subdirectory must be available on the PATH environment variable.'))
1350
+ logging.warning('****************************************************')
1351
+ else:
1352
+ logging.info('****************************************************')
1353
+ logging.info(_('Wolfgpu.exe found in {}!').format(self.wolfgpu))
1354
+ logging.info(_('You can now run the simulations !'))
1355
+ logging.info(_('Do not forget to activate your Python virtual environment if you are using one !'))
1356
+ logging.info('****************************************************')
1357
+
1306
1358
  return batch
1307
1359
 
1308
1360
  def run_batch(self, batch:Path):
1309
1361
  """ run a batch file in a subprocess """
1362
+
1310
1363
  if not batch.exists():
1311
1364
  logging.error(_('Batch file {} does not exist !'.format(batch)))
1312
1365
  return
@@ -1763,9 +1816,33 @@ class UI_Manager_2D_GPU():
1763
1816
 
1764
1817
  log = self._parent.check_consistency()
1765
1818
  if log =='':
1766
- self._txtctrl.WriteText(_("All is fine !"))
1819
+ self._txtctrl.WriteText(_("All is fine !\n\n"))
1767
1820
  else:
1768
- self._txtctrl.WriteText(log)
1821
+ self._txtctrl.WriteText(log +"\n\n")
1822
+
1823
+ # Info on Python Environment and wolfgpu Path and version
1824
+ # -------------------------------------------------------
1825
+
1826
+ import sys
1827
+ # Python Environment
1828
+ self._txtctrl.write(_('Python Environment\n'))
1829
+ self._txtctrl.write('-------------------\n')
1830
+ self._txtctrl.write('Python version : {}\n'.format(sys.version))
1831
+ self._txtctrl.write('Python path : {}\n'.format(sys.executable))
1832
+ self._txtctrl.write('Python version info : {}\n'.format(sys.version_info))
1833
+
1834
+ # Test if wolfgpu.exe exists in script directory
1835
+ # wolfgpu Path and version
1836
+ self._txtctrl.write('\nWolfgpu Path and version\n')
1837
+ self._txtctrl.write('------------------------\n')
1838
+
1839
+ wolfgpu = self._parent.wolfgpu
1840
+ if wolfgpu.exists():
1841
+ self._txtctrl.write('Wolfgpu.exe found in : {}\n'.format(self._parent.wolfgpu.parent))
1842
+ else:
1843
+ self._txtctrl.write('Wolfgpu.exe not found !\n')
1844
+ self._parent.wolfgpu = None
1845
+
1769
1846
 
1770
1847
  def choice_hydrograph(self) -> list[int]:
1771
1848
 
@@ -1975,7 +2052,7 @@ class UI_Manager_2D_GPU():
1975
2052
  try:
1976
2053
  if curwp.Shown:
1977
2054
  cursim.from_wolfparam(curwp)
1978
- cursim.save_json()
2055
+ cursim._save_json()
1979
2056
  except Exception as e:
1980
2057
  self._wp[cursim] = None
1981
2058
  logging.debug(_('Error while saving parameters for simulation {}'.format(cursim.path.name)))
@@ -1989,7 +2066,7 @@ class UI_Manager_2D_GPU():
1989
2066
  try:
1990
2067
  if curwp.Shown:
1991
2068
  cursim.from_wolfparam(curwp)
1992
- cursim.save_json()
2069
+ cursim._save_json()
1993
2070
  except Exception as e:
1994
2071
  self._wp[cursim] = None
1995
2072
  logging.debug(_('Error while saving parameters for simulation {}'.format(cursim.path.name)))