wolfhece 2.1.12__py3-none-any.whl → 2.1.14__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 CHANGED
@@ -191,7 +191,7 @@ class DragdropFileTarget(wx.FileDropTarget):
191
191
  id = id + '_1'
192
192
 
193
193
  try:
194
- newobj = Zones(filename=name)
194
+ newobj = Zones(filename=name, parent=self.window)
195
195
  self.window.add_object('vector', newobj = newobj, id = id)
196
196
  except:
197
197
  logging.error(_('Error while loading vector : ') + name)
@@ -203,7 +203,7 @@ class DragdropFileTarget(wx.FileDropTarget):
203
203
  id = id + '_1'
204
204
 
205
205
  try:
206
- newobj = cloud_vertices(fname=name)
206
+ newobj = cloud_vertices(fname=name, mapviewer=self.window)
207
207
  self.window.add_object('cloud', newobj = newobj, id = id)
208
208
  except:
209
209
  logging.error(_('Error while loading cloud : ') + name)
@@ -380,6 +380,12 @@ class WolfMapViewer(wx.Frame):
380
380
 
381
381
  self.filemenu.AppendSeparator()
382
382
 
383
+ # SIMULATION Hydrologique
384
+
385
+ hydrol = self.filemenu.Append(wx.ID_ANY, _('Open hydrological model'), _('Hydrological simulation'))
386
+
387
+ self.filemenu.AppendSeparator()
388
+
383
389
  # MULTIVIEWER
384
390
 
385
391
  compareitem = self.filemenu.Append(wx.ID_ANY, _('Set comparison'), _('Set comparison'))
@@ -665,6 +671,13 @@ class WolfMapViewer(wx.Frame):
665
671
  self._wxlogging = value
666
672
 
667
673
 
674
+ def open_hydrological_model(self):
675
+ """ Open a hydrological model """
676
+
677
+ from .PyGui import HydrologyModel
678
+
679
+ newview = HydrologyModel(splash = False)
680
+
668
681
  def create_2D_MB_model(self):
669
682
  """ Create a 2D model """
670
683
 
@@ -1168,6 +1181,76 @@ class WolfMapViewer(wx.Frame):
1168
1181
  elif itemlabel ==_("Create video..."):
1169
1182
  if self.active_res2d is not None:
1170
1183
  self.create_video()
1184
+
1185
+ elif itemlabel == _("Setup cache..."):
1186
+
1187
+ if self.active_res2d is None:
1188
+ logging.warning(_('No active 2D result !'))
1189
+ return
1190
+
1191
+ dlg = wx.MessageDialog(None, _('Cache only water depth results ?'), style=wx.YES_NO)
1192
+ ret = dlg.ShowModal()
1193
+ if ret == wx.ID_NO:
1194
+ only_h = False
1195
+ else:
1196
+ only_h = True
1197
+ dlg.Destroy()
1198
+
1199
+ dlg = wx.MessageDialog(None, _('Cache all results ?'), style=wx.YES_NO)
1200
+ ret = dlg.ShowModal()
1201
+ if ret == wx.ID_NO:
1202
+
1203
+ dlg_start = wx.SingleChoiceDialog(None, _('Choosing the start index'),
1204
+ _('Choices'),
1205
+ [str(cur) for cur in range(1,self.active_res2d.get_nbresults()+1)])
1206
+ ret = dlg_start.ShowModal()
1207
+ if ret == wx.ID_CANCEL:
1208
+ dlg_start.Destroy()
1209
+ return
1210
+
1211
+ start_idx = int(dlg_start.GetStringSelection())
1212
+ dlg_start.Destroy()
1213
+
1214
+ dlg_end = wx.SingleChoiceDialog(None, _('Choosing the end index'),
1215
+ _('Choices'),
1216
+ [str(cur) for cur in range(start_idx + 1,self.active_res2d.get_nbresults()+1)])
1217
+
1218
+ ret = dlg_end.ShowModal()
1219
+ if ret == wx.ID_CANCEL:
1220
+ dlg_end.Destroy()
1221
+ return
1222
+
1223
+ dlg_end.Destroy()
1224
+
1225
+ end_idx = int(dlg_end.GetStringSelection())
1226
+
1227
+ logging.info(_('Caching from {} to {} - Be patient !').format(start_idx, end_idx))
1228
+ self.active_res2d.setup_cache(start_idx = start_idx-1, end_idx = end_idx-1, only_h=only_h)
1229
+ logging.info(_('Caching done !'))
1230
+ else:
1231
+ logging.info(_('Caching all results - Be patient !'))
1232
+ self.active_res2d.setup_cache(only_h=only_h)
1233
+ logging.info(_('Caching done !'))
1234
+
1235
+ dlg.Destroy()
1236
+
1237
+ elif itemlabel == _("Clear cache..."):
1238
+
1239
+ if self.active_res2d is None:
1240
+ logging.warning(_('No active 2D result !'))
1241
+ return
1242
+
1243
+ self.active_res2d.clear_cache()
1244
+ logging.info(_('Cache cleared !'))
1245
+
1246
+ elif itemlabel == _("Show tiles..."):
1247
+
1248
+ if self.active_res2d is None:
1249
+ logging.warning(_('No active 2D result !'))
1250
+ return
1251
+
1252
+ self.active_res2d.show_tiles()
1253
+
1171
1254
 
1172
1255
  def menu_2dgpu(self):
1173
1256
 
@@ -2094,8 +2177,8 @@ class WolfMapViewer(wx.Frame):
2094
2177
  return
2095
2178
 
2096
2179
  if fn=='':
2097
- dlg = wx.FileDialog(patent = None,
2098
- messaghe = _('Choose file name'),
2180
+ dlg = wx.FileDialog(parent = None,
2181
+ message = _('Choose file name'),
2099
2182
  wildcard = 'AVI video file (*.avi)|*.avi',
2100
2183
  style = wx.FD_SAVE)
2101
2184
  ret = dlg.ShowModal()
@@ -2175,6 +2258,12 @@ class WolfMapViewer(wx.Frame):
2175
2258
  interval = int(dlg.GetValue())
2176
2259
  dlg.Destroy()
2177
2260
 
2261
+ self.read_one_result(start_step)
2262
+
2263
+ for curmodel in self.iterator_over_objects(draw_type.RES2D):
2264
+ curmodel: Wolfresults_2D
2265
+ curmodel.step_interval_results = interval
2266
+
2178
2267
  for idx in tqdm(range(start_step, end_step, interval)):
2179
2268
 
2180
2269
  image = Image.frombytes('RGB', fig.canvas.get_width_height(),fig.canvas.tostring_rgb())
@@ -2189,6 +2278,11 @@ class WolfMapViewer(wx.Frame):
2189
2278
  ax=ax[0],
2190
2279
  title=_('Current time {:0>8} s'.format(el_time)))
2191
2280
 
2281
+ for curmodel in self.iterator_over_objects(draw_type.RES2D):
2282
+ curmodel: Wolfresults_2D
2283
+ curmodel.step_interval_results = 1
2284
+
2285
+
2192
2286
  def get_canvas_as_image(self) -> Image.Image:
2193
2287
  """
2194
2288
  Récupère la fenêtre OpenGL sous forme d'image
@@ -4008,8 +4102,15 @@ class WolfMapViewer(wx.Frame):
4008
4102
  elif unknown == _('Head'):
4009
4103
  unknown = 'head'
4010
4104
 
4011
- fig, ax = self.active_res2d.plot_h(self.active_res2d.SelectionData.myselection,
4012
- unknown, toshow=True)
4105
+ figax = None
4106
+ for curblock in self.active_res2d.myblocks.values():
4107
+ if curblock.SelectionData.nb > 0:
4108
+
4109
+ figax = self.active_res2d.plot_h(curblock.SelectionData.myselection,
4110
+ unknown, toshow=False, figax=figax)
4111
+ if figax is not None:
4112
+ fig, ax = figax
4113
+ fig.show()
4013
4114
 
4014
4115
  elif itemlabel == _("Plot stats unknown (inside active vector)..."):
4015
4116
 
@@ -4379,75 +4480,6 @@ class WolfMapViewer(wx.Frame):
4379
4480
  # if self.active_res2d is not None:
4380
4481
  # self.create_video()
4381
4482
 
4382
- elif itemlabel == _("Setup cache..."):
4383
-
4384
- if self.active_res2d is None:
4385
- logging.warning(_('No active 2D result !'))
4386
- return
4387
-
4388
- dlg = wx.MessageDialog(None, _('Cache only water depth results ?'), style=wx.YES_NO)
4389
- ret = dlg.ShowModal()
4390
- if ret == wx.ID_NO:
4391
- only_h = False
4392
- else:
4393
- only_h = True
4394
- dlg.Destroy()
4395
-
4396
- dlg = wx.MessageDialog(None, _('Cache all results ?'), style=wx.YES_NO)
4397
- ret = dlg.ShowModal()
4398
- if ret == wx.ID_NO:
4399
-
4400
- dlg_start = wx.SingleChoiceDialog(None, _('Choosing the start index'),
4401
- _('Choices'),
4402
- [str(cur) for cur in range(1,self.active_res2d.get_nbresults()+1)])
4403
- ret = dlg_start.ShowModal()
4404
- if ret == wx.ID_CANCEL:
4405
- dlg_start.Destroy()
4406
- return
4407
-
4408
- start_idx = int(dlg_start.GetStringSelection())
4409
- dlg_start.Destroy()
4410
-
4411
- dlg_end = wx.SingleChoiceDialog(None, _('Choosing the end index'),
4412
- _('Choices'),
4413
- [str(cur) for cur in range(start_idx + 1,self.active_res2d.get_nbresults()+1)])
4414
-
4415
- ret = dlg_end.ShowModal()
4416
- if ret == wx.ID_CANCEL:
4417
- dlg_end.Destroy()
4418
- return
4419
-
4420
- dlg_end.Destroy()
4421
-
4422
- end_idx = int(dlg_end.GetStringSelection())
4423
-
4424
- logging.info(_('Caching from {} to {} - Be patient !').format(start_idx, end_idx))
4425
- self.active_res2d.setup_cache(start_idx = start_idx-1, end_idx = end_idx-1, only_h=only_h)
4426
- logging.info(_('Caching done !'))
4427
- else:
4428
- logging.info(_('Caching all results - Be patient !'))
4429
- self.active_res2d.setup_cache(only_h=only_h)
4430
- logging.info(_('Caching done !'))
4431
-
4432
- dlg.Destroy()
4433
-
4434
- elif itemlabel == _("Clear cache..."):
4435
-
4436
- if self.active_res2d is None:
4437
- logging.warning(_('No active 2D result !'))
4438
- return
4439
-
4440
- self.active_res2d.clear_cache()
4441
- logging.info(_('Cache cleared !'))
4442
-
4443
- elif itemlabel == _("Show tiles..."):
4444
-
4445
- if self.active_res2d is None:
4446
- logging.warning(_('No active 2D result !'))
4447
- return
4448
-
4449
- self.active_res2d.show_tiles()
4450
-
4451
4483
  elif itemlabel == _("Manage banks..."):
4452
4484
  if self.active_vector is None:
4453
4485
  msg = _('Active vector is None\nPlease activate the one desired')
@@ -4712,6 +4744,10 @@ class WolfMapViewer(wx.Frame):
4712
4744
 
4713
4745
  self.create_2D_MB_model()
4714
4746
 
4747
+ elif itemlabel == _('Open hydrological model'):
4748
+
4749
+ self.open_hydrological_model()
4750
+
4715
4751
  elif itemlabel == _('Check headers'):
4716
4752
 
4717
4753
  self.check_2D_MB_headers()
wolfhece/PyGui.py CHANGED
@@ -276,19 +276,32 @@ class HydrologyModel(GenMapManager):
276
276
  ('_encode.sub','Coded index SubB [-]')]}
277
277
 
278
278
 
279
- self.files_hydrology_vectors={'Characteristic_maps':[('.delimit.vec','Watershed')],
279
+ self.files_hydrology_vectors={'Characteristic_vectors':[('.delimit.vec','Watershed')],
280
280
  'Whole_basin':[('Rain_basin_geom.vec','Rain geom'),
281
281
  ('Evap_basin_geom.vec','Evapotranspiration geom')]}
282
282
 
283
283
  for curfile in self.files_hydrology_array['Characteristic_maps']:
284
284
  curext=curfile[0]
285
- curidx=curfile[1]
285
+ curidx=curfile[1]
286
286
  self.mapviewer.add_object(which='array',filename=self.mydircharact+curext,id=curidx,ToCheck=False)
287
287
 
288
- for curfile in self.files_hydrology_vectors['Characteristic_maps']:
288
+
289
+ for curfile in self.files_hydrology_vectors['Characteristic_vectors']:
289
290
  curext=curfile[0]
290
291
  curidx=curfile[1]
291
- self.mapviewer.add_object(which='vector',filename=self.mydircharact+curext,id=curidx,ToCheck=False)
292
+
293
+ delimit = Zones(filename=self.mydircharact+curext, mapviewer=self.mapviewer, parent = self.mapviewer)
294
+
295
+ for idx, cur_zone in enumerate(delimit.myzones):
296
+ cur_sub = self.mycatchment.get_subBasin(idx+1)
297
+ cur_zone.myname = cur_sub.name
298
+ cur_vect = cur_zone.myvectors[0]
299
+ cur_vect.set_legend_to_centroid(cur_sub.name + ' - ' + str(cur_sub.iDSorted), visible=True)
300
+ cur_vect.myprop.legendfontsize = 12
301
+
302
+ delimit.reset_listogl()
303
+
304
+ self.mapviewer.add_object(which='vector',newobj = delimit, id=curidx, ToCheck=True)
292
305
 
293
306
  for curfile in self.files_hydrology_vectors['Whole_basin']:
294
307
  curext=curfile[0]
@@ -297,7 +310,17 @@ class HydrologyModel(GenMapManager):
297
310
  self.mapviewer.add_object(which='vector',filename=self.mydirwhole+curext,id=curidx,ToCheck=False)
298
311
 
299
312
  self.mapviewer.add_object(which='vector',newobj=self.myexchanges.mysegs,id='Forced exchanges',ToCheck=False)
313
+
314
+ zones_RT = self.mycatchment.get_retentionbasin_zones()
315
+ zones_RT.parent = self
316
+ self.mapviewer.add_object(which='vector',newobj=zones_RT,id='Anthropic links',ToCheck=False)
317
+
300
318
  self.mapviewer.add_object(which='cloud',newobj=self.mycatchment.subBasinCloud,id='Local outlets',ToCheck=False)
319
+ self.mapviewer.add_object(which='cloud',newobj=self.mycatchment.retentionBasinCloud,id='Anthropic inlets/outlets',ToCheck=False)
320
+
321
+ self.mycatchment.subBasinCloud.set_mapviewer(self.mapviewer)
322
+ self.mycatchment.retentionBasinCloud.set_mapviewer(self.mapviewer)
323
+
301
324
  self.mapviewer.add_object(which='cloud',newobj=self.myexchanges.mycloudup,id='Up nodes',ToCheck=False)
302
325
  self.mapviewer.add_object(which='cloud',newobj=self.myexchanges.myclouddown,id='Down nodes',ToCheck=False)
303
326
 
wolfhece/PyParams.py CHANGED
@@ -1064,7 +1064,7 @@ class Wolf_Param(wx.Frame):
1064
1064
  logging.debug("String type will be conserved! -- {}".format(value_param))
1065
1065
 
1066
1066
  if type(value_param) != int:
1067
- logging.warning("Parameters -- EnumProperty -- Value {} is not an integer".format(value_param))
1067
+ logging.warning("Parameters -- EnumProperty -- Value {} is not an integer in file : {}".format(value_param, self.filename))
1068
1068
  logging.debug("EnumProperty value must be an integer")
1069
1069
 
1070
1070
  page.Append(pg.EnumProperty(label= param_name, name= locname, labels= list_keys, values= list_values, value= int(value_param)))
@@ -2523,7 +2523,12 @@ class zone:
2523
2523
 
2524
2524
  :param prep: True = préparation des listes OpenGL ; False = affichage direct
2525
2525
  """
2526
+
2526
2527
  if prep:
2528
+ if len(self.myvectors) == 0:
2529
+ logging.warning(_('No vector in zone -- {}').format(self.myname))
2530
+ return
2531
+
2527
2532
  try:
2528
2533
  if self.idgllist==-99999:
2529
2534
  self.idgllist = glGenLists(1)
@@ -2540,6 +2545,10 @@ class zone:
2540
2545
  except:
2541
2546
  logging.error(_('OpenGL error in zone.plot'))
2542
2547
  else:
2548
+ if len(self.myvectors) == 0:
2549
+ logging.warning(_('No vector in zone -- {}').format(self.myname))
2550
+ return
2551
+
2543
2552
  if self.idgllist!=-99999:
2544
2553
  glCallList(self.idgllist)
2545
2554
  else:
@@ -4811,6 +4820,10 @@ class Zones(wx.Frame, Element_To_Draw):
4811
4820
  return expended_items
4812
4821
 
4813
4822
  def restore_tree_state(tree:TreeListCtrl, expended_items):
4823
+
4824
+ if len(expanded)==0:
4825
+ # Nothing to do
4826
+ return
4814
4827
 
4815
4828
  root = tree.GetRootItem()
4816
4829
 
@@ -5837,6 +5850,7 @@ class Zones(wx.Frame, Element_To_Draw):
5837
5850
 
5838
5851
  Pousse la même information dans l'objet parent s'il existe
5839
5852
  """
5853
+
5840
5854
  if self.wx_exists:
5841
5855
  self.active_zone = object
5842
5856
 
wolfhece/Results2DGPU.py CHANGED
@@ -237,6 +237,10 @@ class wolfres2DGPU(Wolfresults_2D):
237
237
  try:
238
238
  curblock.top.dx = params["parameters"]["dx"]
239
239
  curblock.top.dy = params["parameters"]["dy"]
240
+
241
+ curblock.dx = curblock.top.dx
242
+ curblock.dy = curblock.top.dy
243
+
240
244
  except:
241
245
  logging.error(_('No spatial resolution (dx,dy) in parameters.json -- Results will not be shown in viewer'))
242
246
  return -1
@@ -244,6 +248,10 @@ class wolfres2DGPU(Wolfresults_2D):
244
248
  try:
245
249
  curblock.top.origx = params["parameters"]["base_coord_x"]
246
250
  curblock.top.origy = params["parameters"]["base_coord_y"]
251
+
252
+ curblock.origx = curblock.top.origx
253
+ curblock.origy = curblock.top.origy
254
+
247
255
  except:
248
256
  logging.error(_('No spatial position (base_coord_x,base_coord_y) in parameters.json -- Results will not be spatially based'))
249
257
  return -2
@@ -406,12 +414,12 @@ class wolfres2DGPU(Wolfresults_2D):
406
414
  self.current_result = self._sanitize_result_step(self.current_result)
407
415
  self.read_oneresult(self.current_result)
408
416
 
409
- def read_next(self):
410
- """
411
- Lecture du pas suivant
412
- """
413
- self.current_result+=1
414
- self._update_result_view()
417
+ # def read_next(self):
418
+ # """
419
+ # Lecture du pas suivant
420
+ # """
421
+ # self.current_result+= self._step_interval
422
+ # self._update_result_view()
415
423
 
416
424
  def get_times_steps(self, nb:int = None):
417
425
  """
@@ -441,12 +449,12 @@ class wolfres2DGPU(Wolfresults_2D):
441
449
  else:
442
450
  return self.times, self.timesteps
443
451
 
444
- def read_previous(self):
445
- """
446
- Lecture du pas suivant
447
- """
448
- self.current_result -= 1
449
- self._update_result_view()
452
+ # def read_previous(self):
453
+ # """
454
+ # Lecture du pas suivant
455
+ # """
456
+ # self.current_result -= self._step_interval
457
+ # self._update_result_view()
450
458
 
451
459
  def get_cached_h(self, idx):
452
460
  """ Return cached water depth according to WOLF convention """
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 1
8
- self.patch = 12
8
+ self.patch = 14
9
9
 
10
10
  def __str__(self):
11
11
 
wolfhece/fonts/arial.ttf CHANGED
Binary file
@@ -53,10 +53,9 @@ class Catchment:
53
53
  _version:float # version of the wolfHydro python code. Useful for identifying the file versions to read and how to interpret them
54
54
  charact_watrshd:Watershed # Watershed object containing the most useful properties of the arrays in Characteristics maps
55
55
  subBasinCloud:cloud_vertices # cloud of points containing the true coordinates (used in simulation) of all subbasin outlets
56
+ retentionBasinCloud:cloud_vertices # cloud of points containing the true coordinates (used in simulation) of all retention basins
56
57
  iP_Cloud:cloud_vertices # cloud of points containing the given coordinates (given in param files) of all subbasin outlets
57
58
 
58
- subBasinDict:dict[int:SubBasin]
59
-
60
59
  catchmentDict:dict[Union[str, int], Union[SubBasin, RetentionBasin]] # dictionnary containing all the elements of the catchment
61
60
  subBasinDict:dict[int, SubBasin] # dictionnary containing all the subbasins
62
61
 
@@ -85,6 +84,10 @@ class Catchment:
85
84
  self.subBasinCloud.myprop.color=getIfromRGB((255,131,250))
86
85
  self.subBasinCloud.myprop.filled=True
87
86
 
87
+ self.retentionBasinCloud=cloud_vertices()
88
+ self.retentionBasinCloud.myprop.color=getIfromRGB((0,131,255))
89
+ self.retentionBasinCloud.myprop.filled=True
90
+
88
91
  self.iP_Cloud=cloud_vertices()
89
92
  self.iP_Cloud.myprop.color=getIfromRGB((255,131,250))
90
93
  self.iP_Cloud.myprop.filled=True
@@ -194,7 +197,7 @@ class Catchment:
194
197
  # self.topo_wolf_array = WolfArray(self.workingDir + "Characteristic_maps/Drainage_basin.b")
195
198
  # self.topo_wolf_array = WolfArray(self.workingDir + "Characteristic_maps/Drainage_basin.b2")
196
199
  self.time_wolf_array = WolfArray(os.path.join(self.workingDir,"Characteristic_maps/Drainage_basin.time"))
197
- self.charact_watrshd = Watershed(self.workingDir)
200
+ self.charact_watrshd = Watershed(self.workingDir, dir_mnt_subpixels=self.paramsInput[('Sub-pixeling', 'Directory')])
198
201
  self.set_eff_outlet_coord()
199
202
 
200
203
  # time array:
@@ -221,6 +224,8 @@ class Catchment:
221
224
  # Iterate through the Input params dictionnary
222
225
  self.create_ObjectsInCatchment()
223
226
 
227
+ self.charact_watrshd.set_names_subbasins([(cur.iDSorted, cur.name) for cur in self.subBasinDict.values()])
228
+
224
229
  # self.add_hyetoToDict()
225
230
 
226
231
 
@@ -323,8 +328,27 @@ class Catchment:
323
328
  if(self.plotAllSub):
324
329
  self.plot_allSub()
325
330
 
331
+ # self.charact_watrshd.impose_sorted_index_subbasins([cur.iDSorted for cur in self.subBasinDict.values()])
326
332
 
333
+ self._fill_cloud_retentionbasin()
334
+
335
+ def get_subBasin(self, id_sorted_or_name:int | str) -> SubBasin:
336
+ """
337
+ This method returns the subbasin object associated with the sorted id or name given in argument.
338
+
339
+ The sorted id is the one given by the Fortran code.
340
+ """
327
341
 
342
+ if isinstance(id_sorted_or_name, str):
343
+ for cursub in self.subBasinDict.values():
344
+ if(cursub.name.lower() == id_sorted_or_name.lower()):
345
+ return cursub
346
+
347
+ elif isinstance(id_sorted_or_name, int):
348
+ for cursub in self.subBasinDict.values():
349
+ if(cursub.iDSorted == id_sorted_or_name):
350
+ return cursub
351
+ return None
328
352
 
329
353
 
330
354
  def get_time(self):
@@ -565,6 +589,7 @@ class Catchment:
565
589
  self.junctionNamesDict[self.paramsTopology.myparams[element]["outlet "+str(iOutlet+1)][key_Param.VALUE]] = element
566
590
 
567
591
  self.retentionBasinDict[element] = RetentionBasin(self.dateBegin, self.dateEnd, self.deltaT, self.time, idBasin, nameBasin, typeOfRB, self.paramsRB.myparams, _tz=self.tz, _outletNames=myOutletsNames, _workingDir=self.workingDir)
592
+
568
593
  # Save the RB in the RB dictionnary into the global Catchment dictionnary
569
594
  self.catchmentDict[element] = self.retentionBasinDict[element]
570
595
 
@@ -573,6 +598,25 @@ class Catchment:
573
598
  print("ERROR: This type of junction is unknown. Please check the topo postprocess file")
574
599
  sys.exit()
575
600
 
601
+ def _fill_cloud_retentionbasin(self):
602
+ """ This procedure fills the cloud of the retention basin with the vertices of the retention basin and its inlets. """
603
+
604
+ for curRT in self.retentionBasinDict.values():
605
+ curRT:RetentionBasin
606
+ self.retentionBasinCloud.add_vertex(wolfvertex(curRT.x,curRT.y))
607
+ inlet_coords = curRT.get_inletCoords()
608
+ for cur_inlet in inlet_coords:
609
+ self.retentionBasinCloud.add_vertex(wolfvertex(cur_inlet[0],cur_inlet[1]))
610
+
611
+ def get_retentionbasin_zones(self)-> Zones:
612
+ """ This method returns a Zones instance of the retention basins. """
613
+
614
+ zones = Zones()
615
+ for curRB in self.retentionBasinDict.values():
616
+ curRB:RetentionBasin
617
+ zones.add_zone(curRB.get_zone(), forceparent=True)
618
+
619
+ return zones
576
620
 
577
621
 
578
622
  def link_objects(self):
@@ -1367,7 +1411,7 @@ class Catchment:
1367
1411
  excelData[0].append(self.topologyDict[level][curBasin].x)
1368
1412
  excelData[1].append(self.topologyDict[level][curBasin].y)
1369
1413
  for curChar in self.topologyDict[level][curBasin].mainCharactDict:
1370
- excelData[iChar].append(self.topologyDict[level][curBasin].mainCharactDict[curChar][key_Param.VALUE])
1414
+ excelData[iChar].append(self.topologyDict[level][curBasin].mainCharactDict[curChar]["value"])
1371
1415
  iChar += 1
1372
1416
  iBasin += 1
1373
1417
 
@@ -1416,10 +1460,10 @@ class Catchment:
1416
1460
  endFileName = "rain.hyeto"
1417
1461
  for element in self.hyetoDict['Ordered To Nb']:
1418
1462
  nbToRead = self.hyetoDict['Ordered To Nb'][element]
1419
- fileName = os.path.join(beginFileName, nbToRead, endFileName)
1463
+ fileName = os.path.join(beginFileName, nbToRead+ endFileName)
1420
1464
  isOk, fileName = check_path(fileName, applyCWD=True)
1421
1465
  if isOk<0:
1422
- print("WARNING: could not find any dbf file! ")
1466
+ # print("WARNING: could not find any dbf file! ")
1423
1467
  time_mod.sleep(.5)
1424
1468
  return
1425
1469
  [time, rain] = self.get_hyeto(fileName)
@@ -1803,6 +1847,46 @@ class Catchment:
1803
1847
  # paramsInput.ApplytoMemory(None)
1804
1848
  paramsInput.SavetoFile(None)
1805
1849
 
1850
+
1851
+ def _correct_Umax_from_old_model(self, adapt_with_rain:bool=True):
1852
+ fileName = "simul_soil.param"
1853
+ which="Umax"
1854
+
1855
+ for iBasin in range(1,len(self.subBasinDict)+1):
1856
+ myBasin = self.subBasinDict[iBasin]
1857
+ dirID = myBasin.iDSorted
1858
+
1859
+ fileToModif = os.path.join(self.workingDir, "Subbasin_" + str(dirID), fileName)
1860
+
1861
+ paramsInput = Wolf_Param(to_read=False,toShow=False)
1862
+ paramsInput.ReadFile(fileToModif)
1863
+
1864
+ if adapt_with_rain:
1865
+ myInterval = paramsInput.get_param("Distributed production model parameters", "Time span soil", default_value=0.0)
1866
+ if myInterval==0.0:
1867
+ nbIntervals = len(myBasin.myRain)-1
1868
+ else:
1869
+ nbIntervals = math.floor(myInterval/myBasin.deltaT)
1870
+ kernel = np.ones(nbIntervals)
1871
+ volRain = np.convolve(myBasin.myRain, kernel)*myBasin.deltaT/3600.0
1872
+ maxRain = np.max(volRain)
1873
+ else:
1874
+ maxRain = paramsInput.get_param("Distributed production model parameters", "Umax")
1875
+ if maxRain==0.0:
1876
+ logging.warning("The Umax is not adapted with the rain and its value is 0.0. It might be better to put 'adapt_with_rain' to True.")
1877
+
1878
+ k = paramsInput.get_param("Horton parameters", "k", default_value=0.0)
1879
+ if k==0.0:
1880
+ continue
1881
+
1882
+ U_max = maxRain/k
1883
+
1884
+ paramsInput.change_param("Distributed production model parameters", which, U_max)
1885
+ paramsInput.change_param("Horton parameters", "k", 0.0)
1886
+
1887
+ # paramsInput.ApplytoMemory(None)
1888
+ paramsInput.SavetoFile(None)
1889
+
1806
1890
 
1807
1891
 
1808
1892
  def plot_all_diff_cumulRain_with_lagtime(self, interval, lagTime, selection_by_iD=[], graph_title="", show=True, writeDir="", lawNetRain=0, netRainParams={}):
@@ -1856,7 +1940,7 @@ class Catchment:
1856
1940
  directory = self.paramsInput.get_param("Measuring stations SPW", "Directory")
1857
1941
  isOk, directory = check_path(directory, self.workingDir)
1858
1942
  if isOk<0:
1859
- print("ERROR : measuring station data path not present! ")
1943
+ logging.error(_("ERROR : measuring station data path not present! "))
1860
1944
  fileName = os.path.join(directory, self.paramsInput.get_param("Measuring stations SPW", "Filename"))
1861
1945
 
1862
1946
 
@@ -1869,7 +1953,7 @@ class Catchment:
1869
1953
  for raw in data_reader:
1870
1954
  list_data.append(raw)
1871
1955
  else:
1872
- print("ERROR : measuring station data file not present! ")
1956
+ logging.error(_("ERROR : measuring station data file not present! "))
1873
1957
  return
1874
1958
 
1875
1959
  # Building dictionnary