wolfhece 2.0.23__py3-none-any.whl → 2.0.25__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.
@@ -102,7 +102,7 @@ class RetentionBasin():
102
102
  # Init of the object allowing to determine the outlet flux
103
103
  tmpCounter = 0
104
104
  for element in _dictRB:
105
- if(_dictRB[element]['from']['value'] == self.iD):
105
+ if(_dictRB[element]['from'][key_Param.VALUE] == self.iD):
106
106
  if(tmpCounter>0):
107
107
  print("ERROR: the same RB associated to two different caracteristics. Please check the RetentionBasin.postPro file.")
108
108
  sys.exit()
@@ -122,28 +122,28 @@ class RetentionBasin():
122
122
  if(myAnswer=="Y" or myAnswer=="y"):
123
123
  isOk = True
124
124
  self.dictRB['type'] = {}
125
- self.dictRB['type']['value'] = ""
125
+ self.dictRB['type'][key_Param.VALUE] = ""
126
126
  elif(myAnswer=="N" or myAnswer=="n"):
127
127
  sys.exit()
128
128
  else:
129
129
  self.dictRB['type'] = {}
130
- self.dictRB['type']['value'] = ""
130
+ self.dictRB['type'][key_Param.VALUE] = ""
131
131
 
132
132
 
133
133
 
134
- self.type = self.dictRB['type']['value']
134
+ self.type = self.dictRB['type'][key_Param.VALUE]
135
135
  if('stagnant height' in self.dictRB):
136
- self.hStagn = float(self.dictRB['stagnant height']['value'])
136
+ self.hStagn = float(self.dictRB['stagnant height'][key_Param.VALUE])
137
137
  if(self.type == 'HighwayRB'):
138
- self.surface = float(self.dictRB['surface']['value'])
139
- self.hBank = float(self.dictRB['height 2']['value'])
138
+ self.surface = float(self.dictRB['surface'][key_Param.VALUE])
139
+ self.hBank = float(self.dictRB['height 2'][key_Param.VALUE])
140
140
  self.volume = self.surface * self.hBank
141
141
  elif(self.type == 'RobiernuRB'):
142
- self.volume = float(self.dictRB['volume']['value'])
142
+ self.volume = float(self.dictRB['volume'][key_Param.VALUE])
143
143
  elif(self.type == 'OrbaisRB'):
144
- self.volume = float(self.dictRB['volume']['value'])
144
+ self.volume = float(self.dictRB['volume'][key_Param.VALUE])
145
145
  try:
146
- zvFile = self.dictRB['Z-V file']['value']
146
+ zvFile = self.dictRB['Z-V file'][key_Param.VALUE]
147
147
  except:
148
148
  zvFile = ""
149
149
  if(zvFile!=""):
@@ -156,12 +156,12 @@ class RetentionBasin():
156
156
  # print("ERROR: Not implemented yet!")
157
157
  # sys.exit()
158
158
  elif(self.type == 'ForcedDam'):
159
- self.volume = float(self.dictRB['volume']['value'])
160
- self.hi = float(self.dictRB['initial height']['value'])
159
+ self.volume = float(self.dictRB['volume'][key_Param.VALUE])
160
+ self.hi = float(self.dictRB['initial height'][key_Param.VALUE])
161
161
  self.vi = self.h_to_volume(self.hi)
162
162
 
163
163
  try:
164
- zvFile = self.dictRB['Z-V file']['value']
164
+ zvFile = self.dictRB['Z-V file'][key_Param.VALUE]
165
165
  except:
166
166
  zvFile = ""
167
167
  if(zvFile!=""):
@@ -174,11 +174,11 @@ class RetentionBasin():
174
174
  self.read_zv(os.path.join(self.fileNameRead,zvFile))
175
175
 
176
176
  if("time delay" in self.dictRB):
177
- self.timeDelay = float(self.dictRB["time delay"]["value"])
177
+ self.timeDelay = float(self.dictRB["time delay"][key_Param.VALUE])
178
178
  elif(self.type == "HelleRB"):
179
- self.volume = float(self.dictRB['volume']['value'])
179
+ self.volume = float(self.dictRB['volume'][key_Param.VALUE])
180
180
  try:
181
- zvFile = self.dictRB['Z-V file']['value']
181
+ zvFile = self.dictRB['Z-V file'][key_Param.VALUE]
182
182
  isOk, zvFile = check_path(zvFile, self.fileNameRead, applyCWD=True)
183
183
  if isOk<0:
184
184
  print("ERROR : Problem in the Z-V file!")
@@ -194,13 +194,13 @@ class RetentionBasin():
194
194
 
195
195
 
196
196
  if ("initial height" in self.dictRB):
197
- self.hi = float(self.dictRB['initial height']['value'])
197
+ self.hi = float(self.dictRB['initial height'][key_Param.VALUE])
198
198
  self.vi = self.h_to_volume(self.hi)
199
199
 
200
200
  if("time delay" in self.dictRB):
201
- self.timeDelay = float(self.dictRB["time delay"]["value"])
201
+ self.timeDelay = float(self.dictRB["time delay"][key_Param.VALUE])
202
202
 
203
- # Creation of Outlet object
203
+ # Creation of Outlet object
204
204
  self.outletObj = Outlet(self.dictRB, _workingDir=self.fileNameRead, time=self.time)
205
205
  self.qLim = Dumping(self.dictRB)
206
206
 
@@ -223,7 +223,7 @@ class RetentionBasin():
223
223
  self.intletsObj[name] = toPoint
224
224
 
225
225
  if("time delay from module" in self.dictRB):
226
- nameModule = self.dictRB["time delay from module"]['value']
226
+ nameModule = self.dictRB["time delay from module"][key_Param.VALUE]
227
227
  if(toPoint.iD == nameModule):
228
228
  self.timeDelay = toPoint.timeDelay
229
229
  self.x = toPoint.x
@@ -250,7 +250,7 @@ class RetentionBasin():
250
250
  self._outFlow[name]["delta time"] = deltaTime
251
251
 
252
252
  if("time delay from module" in self.dictRB):
253
- nameModule = self.dictRB["time delay from module"]['value']
253
+ nameModule = self.dictRB["time delay from module"][key_Param.VALUE]
254
254
  if(toPoint.iD == nameModule):
255
255
  self.timeDelay = toPoint.timeDelay
256
256
  self.x = toPoint.x
@@ -262,7 +262,7 @@ class RetentionBasin():
262
262
  self.directFluxObj[name] = toPoint
263
263
 
264
264
  if("time delay from module" in self.dictRB):
265
- nameModule = self.dictRB["time delay from module"]['value']
265
+ nameModule = self.dictRB["time delay from module"][key_Param.VALUE]
266
266
  if(toPoint.iD == nameModule):
267
267
  self.timeDelay = toPoint.timeDelay
268
268
  self.x = toPoint.x
@@ -1332,7 +1332,7 @@ class RetentionBasin():
1332
1332
  self.timeDelayObj = None
1333
1333
 
1334
1334
  if("time delay from module" in self.dictRB):
1335
- nameModule = self.dictRB["time delay from module"]['value']
1335
+ nameModule = self.dictRB["time delay from module"][key_Param.VALUE]
1336
1336
  else:
1337
1337
  return timeDelay
1338
1338
 
@@ -2272,22 +2272,23 @@ class SubBasin:
2272
2272
 
2273
2273
  if method == -1 :
2274
2274
  # detect the method on the params files -> TO DO
2275
- myMethod = int(wolf_If.myparams["Distributed production model parameters"]["Type of infiltration"]["value"])
2275
+ myMethod = int(wolf_If.get_param("Distributed production model parameters","Type of infiltration"))
2276
2276
 
2277
2277
 
2278
2278
  if(myMethod==cst.tom_infil_Horton):
2279
2279
  myParams = []
2280
- myParams.append(float(wolf_If.myparams["Horton parameters"]["F0"]["value"]))
2281
- myParams.append(float(wolf_If.myparams["Horton parameters"]["Fc"]["value"]))
2282
- myParams.append(float(wolf_If.myparams["Horton parameters"]["k"]["value"]))
2280
+ myParams.append(float(wolf_If.get_param("Horton parameters","F0")))
2281
+ myParams.append(float(wolf_If.get_param("Horton parameters","Fc")))
2282
+ myParams.append(float(wolf_If.get_param("Horton parameters","k")))
2283
+
2283
2284
 
2284
- uMax = float(wolf_If.myparams["Distributed production model parameters"]["Umax"]["value"])
2285
+ uMax = float(wolf_If.get_param("Distributed production model parameters","Umax"))
2285
2286
  p = self.myRain[:]
2286
2287
  nb_timesteps = len(p)
2287
2288
 
2288
- timeLag = float(wolf_If.myparams["Distributed production model parameters"]["Time lag"]["value"])
2289
+ timeLag = float(wolf_If.get_param("Distributed production model parameters","Time lag"))
2289
2290
  try:
2290
- timeSpan = float(wolf_If.myparams["Distributed production model parameters"]["Time span soil"]["value"])
2291
+ timeSpan = float(wolf_If.get_param("Distributed production model parameters","Time span soil"))
2291
2292
  nbIntervals = math.ceil(timeSpan/self.deltaT)
2292
2293
  except:
2293
2294
  nbIntervals = len(self.myRain)
@@ -1,4 +1,4 @@
1
- from ..vfuncs import vfuncs
1
+ from ..vfuncsdir import vfuncs
2
2
  from scipy.spatial import kdtree
3
3
  import numpy as np
4
4
  import copy
Binary file
@@ -7,7 +7,8 @@ import numpy as np
7
7
  import subprocess
8
8
 
9
9
  from ..PyTranslate import _
10
- from ..wolfresults_2D import wolf2dprev,Wolfresults_2D
10
+ from ..wolfresults_2D import Wolfresults_2D
11
+ from .wolf2dprev import prev_infiltration
11
12
  from ..wolf_array import WolfArray
12
13
 
13
14
  CHECK_EXT=['.top', '.frot']
@@ -313,7 +314,7 @@ class config_manager_2D:
313
314
  nameitem = self.treelist.GetItemText(myitem).lower()
314
315
 
315
316
  if nameitem=='fil':
316
- mydata:wolf2dprev.prev_infiltration
317
+ mydata:prev_infiltration
317
318
  txt = _('Number of zones : {} \n'.format(mydata.nb_zones))
318
319
  for i in range(1,mydata.nb_zones+1):
319
320
  txt += _('Q zone {} : {} \n'.format(i,mydata.my_Q[0][i]))
@@ -381,7 +382,7 @@ class config_manager_2D:
381
382
  name = self._find_sim(keyname)
382
383
  if name is not None:
383
384
  curdict['genfile'] = name
384
- curdict['fil'] = wolf2dprev.prev_infiltration(None,name)
385
+ curdict['fil'] = prev_infiltration(None,name)
385
386
  curdict['fil'].read_file()
386
387
 
387
388
  def _find_sim(self,wd):
@@ -42,7 +42,18 @@ PREV_READ_TXT = 1
42
42
  PREV_READ_FINE = 2
43
43
  PREV_READ_MB = 3
44
44
 
45
-
45
+ def find_sep(line:str):
46
+ if ',' in line:
47
+ return ','
48
+ elif ' ' in line:
49
+ return ' '
50
+ elif '\t' in line:
51
+ return '\t'
52
+ elif ';' in line:
53
+ return ';'
54
+ else:
55
+ logging.error(f"Unrecognized separator in line {line}")
56
+ return None
46
57
 
47
58
  class prev_parameters_blocks:
48
59
  """ #> Paramètres de calcul propres aux blocs
@@ -1677,9 +1688,12 @@ class prev_boundary_conditions():
1677
1688
  pass
1678
1689
 
1679
1690
  def read_file(self, lines: list, orient):
1680
- """#> lecture du fichier de paramètres"""
1691
+ """ Lecture du fichier de paramètres"""
1692
+
1681
1693
  for curline in lines:
1682
- tmp = curline.split(',')
1694
+
1695
+ tmp = curline.split(find_sep(curline))
1696
+
1683
1697
  i = int(tmp[0])
1684
1698
  j = int(tmp[1])
1685
1699
  ntype = int(tmp[2])
@@ -1708,7 +1722,7 @@ class prev_boundary_conditions():
1708
1722
  # Strong boundary conditions are not vectors.
1709
1723
  pass
1710
1724
  else:
1711
- raise Exception(f"Unrecognized orientation {orient}")
1725
+ logging.error(f"Unrecognized orientation {orient}")
1712
1726
 
1713
1727
  def get_xy(self, i, j, orient, aswolf=False):
1714
1728
 
@@ -2388,20 +2402,15 @@ class prev_infiltration():
2388
2402
 
2389
2403
  if self.nb_steps > 0:
2390
2404
 
2391
- if ',' in lines[1]:
2392
- sep = ','
2393
- elif '\t' in lines[1]:
2394
- sep = '\t'
2395
- elif ';' in lines[1]:
2396
- sep = ';'
2397
- else:
2405
+ sep = find_sep(lines[1])
2406
+
2407
+ if sep is None:
2398
2408
  logging.error(_("Values in the '.fil' file are not separated by comma, semi-comma or tabulation -- Check your file -- Continuing with zero values"))
2399
2409
  self.my_Q = np.zerons((self.nb_steps, self.nb_zones))
2400
2410
  return
2401
-
2402
- locarray = [[float(val) for val in lines[i].strip().split(sep)[:self.nb_zones + 1]] for i in
2403
- range(1, len(lines))]
2404
- self.my_Q = np.asarray(locarray)
2411
+ else:
2412
+ locarray = [[float(val) for val in lines[i].strip().split(sep)[:self.nb_zones + 1]] for i in range(1, len(lines))]
2413
+ self.my_Q = np.asarray(locarray)
2405
2414
 
2406
2415
  def read_array(self):
2407
2416
  """lecture de la matrice d'infiltration"""
@@ -2487,8 +2496,8 @@ class prev_suxsuy():
2487
2496
  with open(self.filenamesuy, 'r') as f:
2488
2497
  linesY = f.read().splitlines()
2489
2498
 
2490
- linesX = [np.float64(curline.split(',')) for curline in linesX]
2491
- linesY = [np.float64(curline.split(',')) for curline in linesY]
2499
+ linesX = [np.float64(curline.split(find_sep(curline))) for curline in linesX]
2500
+ linesY = [np.float64(curline.split(find_sep(curline))) for curline in linesY]
2492
2501
 
2493
2502
  myparams: prev_parameters_simul
2494
2503
  myparams = self.parent.myparam
@@ -2666,7 +2675,7 @@ class bloc_file():
2666
2675
  lines = f.read().splitlines()
2667
2676
 
2668
2677
  # #lecture du nombre de blocs et de la taille maximale du contour
2669
- tmpline = lines[0].split(',')
2678
+ tmpline = lines[0].split(find_sep(lines[0]))
2670
2679
  self.nb_blocks = int(tmpline[0])
2671
2680
  self.max_size_cont = int(tmpline[1])
2672
2681
 
@@ -2689,7 +2698,7 @@ class bloc_file():
2689
2698
  decal = 2
2690
2699
  if self.interior:
2691
2700
  for i in range(decal, nb + decal):
2692
- tmpline = lines[i].split(',')
2701
+ tmpline = lines[i].split(find_sep(lines[i]))
2693
2702
  # FIXME no *dx, *dy ??? I think it's i,j : cell coordinates
2694
2703
  x = float(tmpline[0]) + trlx
2695
2704
  y = float(tmpline[1]) + trly
@@ -2702,7 +2711,7 @@ class bloc_file():
2702
2711
  external_border.add_vertex(curvert)
2703
2712
  else:
2704
2713
  for i in range(decal, nb + decal):
2705
- tmpline = lines[i].split(',')
2714
+ tmpline = lines[i].split(find_sep(lines[i]))
2706
2715
  x = float(tmpline[0]) + trlx
2707
2716
  y = float(tmpline[1]) + trly
2708
2717
  curvert = wolfvertex(x, y)
@@ -2728,7 +2737,7 @@ class bloc_file():
2728
2737
 
2729
2738
  # lecture des tailles de maille pour tous les blocs
2730
2739
  for i in range(self.nb_blocks):
2731
- tmp = lines[decal].split(',')
2740
+ tmp = lines[decal].split(find_sep(lines[decal]))
2732
2741
  self.my_blocks[i].dx = float(tmp[0])
2733
2742
  self.my_blocks[i].dy = float(tmp[1])
2734
2743
  decal += 1
@@ -2921,7 +2930,7 @@ class bloc_extent:
2921
2930
 
2922
2931
  ##lecture des données
2923
2932
  for i in range(self.nb):
2924
- tmp = lines[i + 1].split(',')
2933
+ tmp = lines[i + 1].split(find_sep(lines[i+1]))
2925
2934
 
2926
2935
  x = float(tmp[0]) + trlx
2927
2936
  y = float(tmp[1]) + trly
@@ -2933,10 +2942,10 @@ class bloc_extent:
2933
2942
  self.external_border.set_limits() # on retient les limites en cas de modifications
2934
2943
 
2935
2944
  ##emprise du bloc en accord avec le grid magnétique et l'extension de surface utile pour les relations de voisinage entre blocs
2936
- tmp = lines[self.nb + 1].split(',')
2945
+ tmp = lines[self.nb + 1].split(find_sep(lines[self.nb + 1]))
2937
2946
  self.xmin = float(tmp[0])
2938
2947
  self.xmax = float(tmp[1])
2939
- tmp = lines[self.nb + 2].split(',')
2948
+ tmp = lines[self.nb + 2].split(find_sep(lines[self.nb + 2]))
2940
2949
  self.ymin = float(tmp[0])
2941
2950
  self.ymax = float(tmp[1])
2942
2951
 
wolfhece/pybridges.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """
2
2
  Bridges manager
3
3
 
4
- @author : Pierre Archambeau
4
+ :author : Pierre Archambeau
5
5
 
6
6
  2023 - Liège University - HECE
7
7
  """
@@ -253,9 +253,8 @@ class Bridge(Zones):
253
253
  - chaque entrée est un dictionnaire dont la clé 'values' contient un dictionnaire pour chaque matrice du projet
254
254
  - chaque élément de ce sous-dictionnaire est un tuple contenant toutes les valeurs utiles
255
255
 
256
- ***
256
+
257
257
  ATTENTION : si linked_arrays est un dictionnaire, alors un niveau supérieur est ajouté sur base des clés de ce dictionnaire, dans ce cas, self.linked est un dict et non une liste
258
- ***
259
258
 
260
259
  """
261
260
  curzone = self.get_zone(zones_in_file.PARTS.value)
@@ -19,7 +19,7 @@ import matplotlib.pyplot as plt
19
19
  import types
20
20
 
21
21
  from ..PyTranslate import _
22
- from ..wolfresults_2D import wolf2dprev,Wolfresults_2D
22
+ from ..wolfresults_2D import Wolfresults_2D
23
23
  from ..wolf_array import WolfArray, header_wolf, WOLF_ARRAY_FULL_INTEGER
24
24
  from .check_scenario import check_file_update, check_file_bc, import_files
25
25
  from .update_void import create_new_file as update_void