wolfhece 2.2.38__py3-none-any.whl → 2.2.39__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/Coordinates_operations.py +5 -0
- wolfhece/GraphNotebook.py +72 -1
- wolfhece/GraphProfile.py +1 -1
- wolfhece/MulticriteriAnalysis.py +1579 -0
- wolfhece/PandasGrid.py +62 -1
- wolfhece/PyCrosssections.py +194 -43
- wolfhece/PyDraw.py +891 -73
- wolfhece/PyGui.py +913 -72
- wolfhece/PyGuiHydrology.py +528 -74
- wolfhece/PyPalette.py +26 -4
- wolfhece/PyParams.py +33 -0
- wolfhece/PyPictures.py +2 -2
- wolfhece/PyVertex.py +25 -0
- wolfhece/PyVertexvectors.py +94 -28
- wolfhece/PyWMS.py +52 -36
- wolfhece/acceptability/acceptability.py +15 -8
- wolfhece/acceptability/acceptability_gui.py +507 -360
- wolfhece/acceptability/func.py +80 -183
- wolfhece/apps/version.py +1 -1
- wolfhece/compare_series.py +480 -0
- wolfhece/drawing_obj.py +12 -1
- wolfhece/hydrology/Catchment.py +228 -162
- wolfhece/hydrology/Internal_variables.py +43 -2
- wolfhece/hydrology/Models_characteristics.py +69 -67
- wolfhece/hydrology/Optimisation.py +893 -182
- wolfhece/hydrology/PyWatershed.py +267 -165
- wolfhece/hydrology/SubBasin.py +185 -140
- wolfhece/hydrology/cst_exchanges.py +76 -1
- wolfhece/hydrology/forcedexchanges.py +413 -49
- wolfhece/hydrology/read.py +65 -5
- wolfhece/hydrometry/kiwis.py +14 -7
- wolfhece/insyde_be/INBE_func.py +746 -0
- wolfhece/insyde_be/INBE_gui.py +1776 -0
- wolfhece/insyde_be/__init__.py +3 -0
- wolfhece/interpolating_raster.py +366 -0
- wolfhece/irm_alaro.py +1457 -0
- wolfhece/irm_qdf.py +889 -57
- wolfhece/lifewatch.py +6 -3
- wolfhece/picc.py +124 -8
- wolfhece/pyLandUseFlanders.py +146 -0
- wolfhece/pydownloader.py +2 -1
- wolfhece/pywalous.py +225 -31
- wolfhece/toolshydrology_dll.py +149 -0
- wolfhece/wolf_array.py +63 -25
- {wolfhece-2.2.38.dist-info → wolfhece-2.2.39.dist-info}/METADATA +3 -1
- {wolfhece-2.2.38.dist-info → wolfhece-2.2.39.dist-info}/RECORD +49 -40
- {wolfhece-2.2.38.dist-info → wolfhece-2.2.39.dist-info}/WHEEL +0 -0
- {wolfhece-2.2.38.dist-info → wolfhece-2.2.39.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.2.38.dist-info → wolfhece-2.2.39.dist-info}/top_level.txt +0 -0
wolfhece/hydrology/SubBasin.py
CHANGED
@@ -28,6 +28,7 @@ from dbfread import DBF
|
|
28
28
|
import ctypes as ct
|
29
29
|
import pandas as pd
|
30
30
|
from pathlib import Path
|
31
|
+
import ctypes as ct
|
31
32
|
|
32
33
|
from ..PyTranslate import _
|
33
34
|
from . import plot_hydrology as ph
|
@@ -80,7 +81,8 @@ class SubBasin:
|
|
80
81
|
# myHydro[i][1] : interflow
|
81
82
|
# myHydro[i][2] : baseflow
|
82
83
|
# @unit $[\si{m}^3/\si{s}}]$
|
83
|
-
myHydro:np.ndarray # [
|
84
|
+
myHydro:np.ndarray # [mm/h] Fortran-like array that is pointed to by ptr_q_all with Fortran DLL (old version in [m^3/s])
|
85
|
+
iv_saved:np.ndarray # [mm/h] or [mm] or [-] depending on the variable
|
84
86
|
|
85
87
|
intletsObj:dict
|
86
88
|
inlets:np.ndarray
|
@@ -123,7 +125,8 @@ class SubBasin:
|
|
123
125
|
peakTime:datetime.datetime # datetime of the peak for total outflow -> time delay is already applied
|
124
126
|
|
125
127
|
# Hello!
|
126
|
-
ptr_q_all:
|
128
|
+
ptr_q_all:ct._Pointer|None # Pointer to Fortran for the result matrix
|
129
|
+
ptr_iv_saved:ct._Pointer|None # Pointer to Fortran for the saved internal variables
|
127
130
|
|
128
131
|
transferParam:Wolf_Param # Parameter file with the type of transfer applied -> e.g. timeDelay
|
129
132
|
|
@@ -171,7 +174,8 @@ class SubBasin:
|
|
171
174
|
# myHydro[i][1] : interflow
|
172
175
|
# myHydro[i][2] : baseflow
|
173
176
|
# @unit $[\si{m}^3/\si{s}}]$
|
174
|
-
self.myHydro =
|
177
|
+
self.myHydro = np.empty((0,0),dtype=ct.c_double, order='F') # [mm/h] hydrograph of the subbasin (old version in [m^3/s]) (potentially with Fortran pointer to ptr_q_all)
|
178
|
+
self.saved_iv = np.empty((0,0),dtype=ct.c_double, order='F') # [mm/h] or [mm] or [-] depending on the variable (potentially with Fortran pointer to ptr_iv_saved)
|
175
179
|
|
176
180
|
self.intletsObj = {}
|
177
181
|
self.inlets = None
|
@@ -216,6 +220,7 @@ class SubBasin:
|
|
216
220
|
|
217
221
|
# Hello!
|
218
222
|
self.ptr_q_all = None
|
223
|
+
self.ptr_iv_saved = None
|
219
224
|
|
220
225
|
# version of the Python WOLFHydro
|
221
226
|
self._version = version
|
@@ -225,10 +230,12 @@ class SubBasin:
|
|
225
230
|
# Load all the hydrographs of the sub-basins
|
226
231
|
if(self.model==cst.measures or self.model==cst.compare_opti):
|
227
232
|
readHydro=False
|
233
|
+
|
228
234
|
# Get the main characteristics of the subbasin. If the hydro can be read, so be the main characteristics
|
229
235
|
if(readHydro):
|
230
236
|
self.read_myMainCharacteristics(_workingDir)
|
231
237
|
self.init_timeDelay()
|
238
|
+
|
232
239
|
if(readHydro):
|
233
240
|
timeTest, self.myHydro = self.get_hydro(self.iDSorted, _workingDir, tzDelta=datetime.timedelta(hours=self.tz))
|
234
241
|
if(self.time is None):
|
@@ -1012,6 +1019,10 @@ class SubBasin:
|
|
1012
1019
|
print("ERROR: Expecting only 1 file name for UH model!")
|
1013
1020
|
sys.exit()
|
1014
1021
|
|
1022
|
+
if not Path(fileName).exists():
|
1023
|
+
logging.error("The file " + fileName + " does not exist!")
|
1024
|
+
return None, None
|
1025
|
+
|
1015
1026
|
with open(fileName, newline = '') as fileID:
|
1016
1027
|
data_reader = csv.reader(fileID, delimiter='\t')
|
1017
1028
|
list_data = []
|
@@ -1244,7 +1255,7 @@ class SubBasin:
|
|
1244
1255
|
# Real hydrograph
|
1245
1256
|
self._outFlow[nameOutFlow]["Net"] = self.inlets + tmpHydro
|
1246
1257
|
elif(self.model==cst.tom_VHM or self.model==cst.tom_2layers_linIF or self.model==cst.tom_2layers_UH or
|
1247
|
-
self.model==cst.tom_HBV
|
1258
|
+
self.model==cst.tom_HBV or self.model==cst.tom_SAC_SMA or self.model==cst.tom_NAM or self.model==cst.tom_SAC_SMA_LROF):
|
1248
1259
|
tmpOutFlow = np.sum(self.myHydro,1)*self.surfaceDrained/3.6
|
1249
1260
|
|
1250
1261
|
# Raw hydrograph
|
@@ -1260,7 +1271,6 @@ class SubBasin:
|
|
1260
1271
|
# self.outFlow[i] = self.inlets[i] + np.sum(self.myHydro[i])
|
1261
1272
|
|
1262
1273
|
|
1263
|
-
|
1264
1274
|
def sum_inlets(self):
|
1265
1275
|
""" Sum all the inlet hydrographs of a subbasin. Return an array of zeros otherwise.
|
1266
1276
|
|
@@ -1281,10 +1291,11 @@ class SubBasin:
|
|
1281
1291
|
self.inlets += curObj.get_outFlow(typeOutFlow="Net", whichOutFlow=nameInlet, lag=deltaTr)
|
1282
1292
|
self.inletsRaw += curObj.get_outFlow(typeOutFlow="Raw", whichOutFlow=nameInlet, lag=deltaTr)
|
1283
1293
|
else:
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1294
|
+
if self.myHydro is not None:
|
1295
|
+
self.inlets = np.zeros(len(self.myHydro), dtype=ct.c_double, order='F')
|
1296
|
+
self.inletsRaw = np.zeros(len(self.myHydro), dtype=ct.c_double, order='F')
|
1297
|
+
else:
|
1298
|
+
logging.error("ERROR: No hydrograph computed for this subbasin!")
|
1288
1299
|
|
1289
1300
|
|
1290
1301
|
def add_rain(self, workingDir, fileName=None, tzDelta=datetime.timedelta(hours=0)):
|
@@ -1298,6 +1309,10 @@ class SubBasin:
|
|
1298
1309
|
if(fileName is None):
|
1299
1310
|
fileName = 'Subbasin_'+str(self.iDSorted)+'/simul_lumped_rain.txt'
|
1300
1311
|
|
1312
|
+
if not Path(os.path.join(workingDir,fileName)).exists():
|
1313
|
+
logging.error("The file " + os.path.join(workingDir,fileName) + " does not exist!")
|
1314
|
+
return None
|
1315
|
+
|
1301
1316
|
with open(os.path.join(workingDir,fileName), newline = '') as fileID2:
|
1302
1317
|
data_reader = csv.reader(fileID2, delimiter='\t')
|
1303
1318
|
list_data = []
|
@@ -1552,7 +1567,7 @@ class SubBasin:
|
|
1552
1567
|
"""
|
1553
1568
|
|
1554
1569
|
if(self.model==cst.tom_UH or self.model==cst.tom_2layers_linIF or self.model==cst.tom_2layers_UH or self.model==cst.tom_GR4 or
|
1555
|
-
self.model==cst.tom_HBV
|
1570
|
+
self.model==cst.tom_HBV or self.model==cst.tom_SAC_SMA or self.model==cst.tom_NAM or self.model==cst.tom_SAC_SMA_LROF):
|
1556
1571
|
# x = self.time/3600.0
|
1557
1572
|
if(axis=="Hours"):
|
1558
1573
|
x = (self.time[:]-self.time[0])/3600.0
|
@@ -1771,7 +1786,8 @@ class SubBasin:
|
|
1771
1786
|
y[:,i] = self.myHydro[:,i]*self.surfaceDrained/3.6
|
1772
1787
|
tmpSum += self.myHydro[:,i]*self.surfaceDrained/3.6
|
1773
1788
|
y[:,-1] = tmpSum
|
1774
|
-
elif(self.model==cst.tom_GR4 or self.model==cst.tom_HBV
|
1789
|
+
elif(self.model==cst.tom_GR4 or self.model==cst.tom_HBV or
|
1790
|
+
self.model==cst.tom_SAC_SMA or self.model==cst.tom_NAM or self.model==cst.tom_SAC_SMA_LROF):
|
1775
1791
|
y[:,0] = self.myHydro[:,0]*self.surfaceDrained/3.6
|
1776
1792
|
else:
|
1777
1793
|
print("ERROR: this model was not implemented yet!")
|
@@ -1984,7 +2000,7 @@ class SubBasin:
|
|
1984
2000
|
# y = np.zeros((len(self.outFlow)-lastElement,nbElements))
|
1985
2001
|
y = []
|
1986
2002
|
if(self.model==cst.tom_UH or self.model==cst.tom_2layers_linIF or self.model==cst.tom_2layers_UH or
|
1987
|
-
cst.tom_GR4 or cst.tom_HBV or cst.tom_SAC_SMA or cst.tom_NAM):
|
2003
|
+
cst.tom_GR4 or cst.tom_HBV or cst.tom_SAC_SMA or cst.tom_NAM or self.model==cst.tom_SAC_SMA_LROF):
|
1988
2004
|
if(withDelay):
|
1989
2005
|
# y[:,0] = self.outFlow[:-1]
|
1990
2006
|
y.append(myOutFlow[:])
|
@@ -2053,7 +2069,7 @@ class SubBasin:
|
|
2053
2069
|
# y_titles.append("Total")
|
2054
2070
|
y_titles.append(_('Débits simulés'))
|
2055
2071
|
elif(self.model==cst.tom_UH or self.model==cst.tom_2layers_linIF or self.model==cst.tom_2layers_UH or
|
2056
|
-
self.model==cst.tom_HBV or self.model==cst.tom_SAC_SMA or self.model==cst.tom_NAM):
|
2072
|
+
self.model==cst.tom_HBV or self.model==cst.tom_SAC_SMA or self.model==cst.tom_NAM, self.model==cst.tom_SAC_SMA_LROF):
|
2057
2073
|
if(ylabel==[]):
|
2058
2074
|
y_titles.append(_('Débits simulés'))
|
2059
2075
|
# y_titles.append('Avec reconstruction Qout B. Vesdre')
|
@@ -2200,127 +2216,138 @@ class SubBasin:
|
|
2200
2216
|
fileName = fileNameList[0]
|
2201
2217
|
fileNameHydro = fileNameList[1]
|
2202
2218
|
|
2203
|
-
|
2204
|
-
|
2205
|
-
list_data = []
|
2206
|
-
i=0
|
2207
|
-
for raw in data_reader:
|
2208
|
-
if i>0:
|
2209
|
-
list_data.append(raw)
|
2210
|
-
i += 1
|
2219
|
+
filename = Path(workingDir) / fileName
|
2220
|
+
if filename.exists():
|
2211
2221
|
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
|
2236
|
-
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
2241
|
-
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2222
|
+
with open(filename, newline = '') as fileID2:
|
2223
|
+
data_reader = csv.reader(fileID2, delimiter='\t')
|
2224
|
+
list_data = []
|
2225
|
+
i=0
|
2226
|
+
for raw in data_reader:
|
2227
|
+
if i>0:
|
2228
|
+
list_data.append(raw)
|
2229
|
+
i += 1
|
2230
|
+
|
2231
|
+
tmp = ''
|
2232
|
+
for i in range(len(list_data)):
|
2233
|
+
if(list_data[i][0][:4]=="Area"):
|
2234
|
+
tmp = list_data[i][0].split()
|
2235
|
+
self.surfaceDrained = float(tmp[1].split("[")[0])
|
2236
|
+
self.mainCharactDict["Area"] = {}
|
2237
|
+
self.mainCharactDict["Area"]["value"] = self.surfaceDrained
|
2238
|
+
self.mainCharactDict["Area"]["unit"] = "["+tmp[1].split("[")[1]
|
2239
|
+
elif(list_data[i][0][:9]=="Perimeter"):
|
2240
|
+
tmp = list_data[i][0].split()
|
2241
|
+
self.mainCharactDict["Perimeter"] = {}
|
2242
|
+
self.mainCharactDict["Perimeter"]["value"] = float(tmp[1].split("[")[0])
|
2243
|
+
self.mainCharactDict["Perimeter"]["unit"] = "["+tmp[1].split("[")[1]
|
2244
|
+
elif(list_data[i][0][:13]=="Average slope"):
|
2245
|
+
tmp = list_data[i][0].split()
|
2246
|
+
self.mainCharactDict["Average slope"] = {}
|
2247
|
+
self.mainCharactDict["Average slope"]["value"] = float(tmp[2].split("[")[0])
|
2248
|
+
self.mainCharactDict["Average slope"]["unit"] = "["+tmp[2].split("[")[1]
|
2249
|
+
elif(list_data[i][0][:35]=="Compactness coefficient (Gravelius)"):
|
2250
|
+
tmp = list_data[i][0].split()
|
2251
|
+
self.mainCharactDict["Compactness coefficient (Gravelius)"] = {}
|
2252
|
+
self.mainCharactDict["Compactness coefficient (Gravelius)"]["value"] = float(tmp[3].split("[")[0])
|
2253
|
+
self.mainCharactDict["Compactness coefficient (Gravelius)"]["unit"] = "[-]"
|
2254
|
+
elif(list_data[i][0][:12]=="Max lag time"):
|
2255
|
+
tmp = list_data[i][0].split()
|
2256
|
+
self.mainCharactDict["Max lag time"] = {}
|
2257
|
+
self.mainCharactDict["Max lag time"]["value"] = float(tmp[3].split("[")[0])
|
2258
|
+
self.mainCharactDict["Max lag time"]["unit"] = "["+tmp[3].split("[")[1]
|
2259
|
+
elif(list_data[i][0][:12] == "Min lag time"):
|
2260
|
+
tmp = list_data[i][0].split()
|
2261
|
+
self.timeDelay = float(tmp[3].split("[")[0])
|
2262
|
+
self.mainCharactDict["Min lag time"] = {}
|
2263
|
+
self.mainCharactDict["Min lag time"]["value"] = float(tmp[3].split("[")[0])
|
2264
|
+
self.mainCharactDict["Min lag time"]["unit"] = "["+tmp[3].split("[")[1]
|
2265
|
+
elif(list_data[i][0][:12]=="Max altitude"):
|
2266
|
+
tmp = list_data[i][0].split()
|
2267
|
+
self.mainCharactDict["Max altitude"] = {}
|
2268
|
+
self.mainCharactDict["Max altitude"]["value"] = float(tmp[2].split("[")[0])
|
2269
|
+
self.mainCharactDict["Max altitude"]["unit"] = "["+tmp[2].split("[")[1]
|
2270
|
+
elif(list_data[i][0][:12]=="Min altitude"):
|
2271
|
+
tmp = list_data[i][0].split()
|
2272
|
+
self.mainCharactDict["Min altitude"] = {}
|
2273
|
+
self.mainCharactDict["Min altitude"]["value"] = float(tmp[2].split("[")[0])
|
2274
|
+
self.mainCharactDict["Min altitude"]["unit"] = "["+tmp[2].split("[")[1]
|
2275
|
+
elif(list_data[i][0][:21]=="Fraction of landuse n"):
|
2276
|
+
tmp = list_data[i][0].split()
|
2277
|
+
self.mainCharactDict["Fraction of landuse n "+tmp[4]] = {}
|
2278
|
+
self.mainCharactDict["Fraction of landuse n "+tmp[4]]["value"] = float(tmp[5].split("[")[0])
|
2279
|
+
self.mainCharactDict["Fraction of landuse n "+tmp[4]]["unit"] = "["+tmp[5].split("[")[1]
|
2280
|
+
else:
|
2281
|
+
logging.error(f"File {filename} does not exist. Cannot read averaged characteristics.")
|
2261
2282
|
|
2262
2283
|
|
2263
2284
|
data_reader = None
|
2264
2285
|
list_data = []
|
2265
2286
|
# fileName = "/Subbasin_" + str(self.iDSorted) + "/" + "simul_subbasin.avrg_caractWholeHydroSubBasin"
|
2266
|
-
with open(os.path.join(workingDir,fileNameHydro), newline = '') as fileID2:
|
2267
|
-
data_reader = csv.reader(fileID2, delimiter='\t')
|
2268
|
-
list_data = []
|
2269
|
-
i=0
|
2270
|
-
for raw in data_reader:
|
2271
|
-
if i>0:
|
2272
|
-
list_data.append(raw)
|
2273
|
-
i += 1
|
2274
2287
|
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2288
|
+
fileNameHydro = Path(workingDir) / fileNameHydro
|
2289
|
+
if fileNameHydro.exists():
|
2290
|
+
with open(fileNameHydro, newline = '') as fileID2:
|
2291
|
+
data_reader = csv.reader(fileID2, delimiter='\t')
|
2292
|
+
list_data = []
|
2293
|
+
i=0
|
2294
|
+
for raw in data_reader:
|
2295
|
+
if i>0:
|
2296
|
+
list_data.append(raw)
|
2297
|
+
i += 1
|
2298
|
+
|
2299
|
+
tmp = ''
|
2300
|
+
for i in range(len(list_data)):
|
2301
|
+
if(list_data[i][0][:4]=="Area"):
|
2302
|
+
tmp = list_data[i][0].split()
|
2303
|
+
self.surfaceDrainedHydro = float(tmp[1].split("[")[0])
|
2304
|
+
self.mainCharactDictWholeHydro["Area"] = {}
|
2305
|
+
self.mainCharactDictWholeHydro["Area"]["value"] = self.surfaceDrainedHydro
|
2306
|
+
self.mainCharactDictWholeHydro["Area"]["unit"] = "["+tmp[1].split("[")[1]
|
2307
|
+
elif(list_data[i][0][:9]=="Perimeter"):
|
2308
|
+
tmp = list_data[i][0].split()
|
2309
|
+
self.mainCharactDictWholeHydro["Perimeter"] = {}
|
2310
|
+
self.mainCharactDictWholeHydro["Perimeter"]["value"] = float(tmp[1].split("[")[0])
|
2311
|
+
self.mainCharactDictWholeHydro["Perimeter"]["unit"] = "["+tmp[1].split("[")[1]
|
2312
|
+
elif(list_data[i][0][:13]=="Average slope"):
|
2313
|
+
tmp = list_data[i][0].split()
|
2314
|
+
self.mainCharactDictWholeHydro["Average slope"] = {}
|
2315
|
+
self.mainCharactDictWholeHydro["Average slope"]["value"] = float(tmp[2].split("[")[0])
|
2316
|
+
self.mainCharactDictWholeHydro["Average slope"]["unit"] = "["+tmp[2].split("[")[1]
|
2317
|
+
elif(list_data[i][0][:35]=="Compactness coefficient (Gravelius)"):
|
2318
|
+
tmp = list_data[i][0].split()
|
2319
|
+
self.mainCharactDictWholeHydro["Compactness coefficient (Gravelius)"] = {}
|
2320
|
+
self.mainCharactDictWholeHydro["Compactness coefficient (Gravelius)"]["value"] = float(tmp[3].split("[")[0])
|
2321
|
+
self.mainCharactDictWholeHydro["Compactness coefficient (Gravelius)"]["unit"] = "[-]"
|
2322
|
+
elif(list_data[i][0][:12]=="Max lag time"):
|
2323
|
+
tmp = list_data[i][0].split()
|
2324
|
+
self.mainCharactDictWholeHydro["Max lag time"] = {}
|
2325
|
+
self.mainCharactDictWholeHydro["Max lag time"]["value"] = float(tmp[3].split("[")[0])
|
2326
|
+
self.mainCharactDictWholeHydro["Max lag time"]["unit"] = "["+tmp[3].split("[")[1]
|
2327
|
+
elif(list_data[i][0][:12] == "Min lag time"):
|
2328
|
+
tmp = list_data[i][0].split()
|
2329
|
+
self.timeDelay = float(tmp[3].split("[")[0])
|
2330
|
+
self.mainCharactDictWholeHydro["Min lag time"] = {}
|
2331
|
+
self.mainCharactDictWholeHydro["Min lag time"]["value"] = float(tmp[3].split("[")[0])
|
2332
|
+
self.mainCharactDictWholeHydro["Min lag time"]["unit"] = "["+tmp[3].split("[")[1]
|
2333
|
+
elif(list_data[i][0][:12]=="Max altitude"):
|
2334
|
+
tmp = list_data[i][0].split()
|
2335
|
+
self.mainCharactDictWholeHydro["Max altitude"] = {}
|
2336
|
+
self.mainCharactDictWholeHydro["Max altitude"]["value"] = float(tmp[2].split("[")[0])
|
2337
|
+
self.mainCharactDictWholeHydro["Max altitude"]["unit"] = "["+tmp[2].split("[")[1]
|
2338
|
+
elif(list_data[i][0][:12]=="Min altitude"):
|
2339
|
+
tmp = list_data[i][0].split()
|
2340
|
+
self.mainCharactDictWholeHydro["Min altitude"] = {}
|
2341
|
+
self.mainCharactDictWholeHydro["Min altitude"]["value"] = float(tmp[2].split("[")[0])
|
2342
|
+
self.mainCharactDictWholeHydro["Min altitude"]["unit"] = "["+tmp[2].split("[")[1]
|
2343
|
+
elif(list_data[i][0][:21]=="Fraction of landuse n"):
|
2344
|
+
tmp = list_data[i][0].split()
|
2345
|
+
self.mainCharactDictWholeHydro["Fraction of landuse n "+tmp[4]] = {}
|
2346
|
+
self.mainCharactDictWholeHydro["Fraction of landuse n "+tmp[4]]["value"] = float(tmp[5].split("[")[0])
|
2347
|
+
self.mainCharactDictWholeHydro["Fraction of landuse n "+tmp[4]]["unit"] = "["+tmp[5].split("[")[1]
|
2348
|
+
|
2349
|
+
else:
|
2350
|
+
logging.error(f"File {fileNameHydro} does not exist. Cannot read averaged characteristics of the whole hydro subbasin.")
|
2324
2351
|
|
2325
2352
|
|
2326
2353
|
def get_flood(self, path='', check_coherence=False):
|
@@ -2921,13 +2948,15 @@ class SubBasin:
|
|
2921
2948
|
# It will then fill the given or not dict of landuse with a name property
|
2922
2949
|
def get_landuse_index_transform_default(self, landuseDict:dict={}) -> dict:
|
2923
2950
|
|
2924
|
-
if landuseDict
|
2951
|
+
if landuseDict is None:
|
2925
2952
|
landuseDict = {}
|
2926
2953
|
|
2927
2954
|
for key in cst.DEFAULT_LANDUSE:
|
2928
2955
|
if not key in landuseDict:
|
2929
2956
|
landuseDict[key] = {}
|
2930
2957
|
landuseDict[key]["name"] = cst.DEFAULT_LANDUSE[key]
|
2958
|
+
landuseDict[key]["surface"] = 0.0
|
2959
|
+
landuseDict[key]["unit"] = "[-]"
|
2931
2960
|
|
2932
2961
|
return landuseDict
|
2933
2962
|
|
@@ -2966,6 +2995,8 @@ class SubBasin:
|
|
2966
2995
|
if not key in landuseDict:
|
2967
2996
|
landuseDict[key] = {}
|
2968
2997
|
landuseDict[key]["name"] = line[1].strip()
|
2998
|
+
landuseDict[key]["surface"] = 0.0
|
2999
|
+
landuseDict[key]["unit"] = "[-]"
|
2969
3000
|
|
2970
3001
|
return landuseDict
|
2971
3002
|
|
@@ -2986,13 +3017,19 @@ class SubBasin:
|
|
2986
3017
|
# Get the names of all landuses
|
2987
3018
|
landuseDict = {}
|
2988
3019
|
landuseDict = self.get_landuse_index_transform(landuse_index_transform, landuseDict=landuseDict)
|
2989
|
-
if landuseDict
|
3020
|
+
if landuseDict is None:
|
2990
3021
|
landuseDict = self.get_landuse_index_transform_default(landuseDict=landuseDict)
|
2991
3022
|
|
2992
3023
|
# Get the surfaces and units of all landuses
|
2993
3024
|
for key in landuseDict:
|
2994
|
-
|
2995
|
-
|
3025
|
+
associated_key = "Fraction of landuse n "+str(key)
|
3026
|
+
if associated_key in avrgDict:
|
3027
|
+
# If the lanuse type is not present, it will be set to 0.0
|
3028
|
+
landuseDict[key]["surface"] = avrgDict[associated_key]["value"]
|
3029
|
+
landuseDict[key]["unit"] = avrgDict[associated_key]["unit"]
|
3030
|
+
else:
|
3031
|
+
landuseDict[key]["surface"] = 0.0
|
3032
|
+
landuseDict[key]["unit"] = "[-]"
|
2996
3033
|
|
2997
3034
|
if toSave:
|
2998
3035
|
if onlySub:
|
@@ -3024,9 +3061,9 @@ class SubBasin:
|
|
3024
3061
|
# Creation of data and legend
|
3025
3062
|
data = []
|
3026
3063
|
names = []
|
3027
|
-
for
|
3028
|
-
data.append(
|
3029
|
-
names.append(
|
3064
|
+
for landuse in landuseDict.values():
|
3065
|
+
data.append(landuse["surface"])
|
3066
|
+
names.append(landuse["name"])
|
3030
3067
|
|
3031
3068
|
# Creation of colors
|
3032
3069
|
colorDict = {}
|
@@ -3069,7 +3106,7 @@ class SubBasin:
|
|
3069
3106
|
|
3070
3107
|
def change_version(self, newVersion=None):
|
3071
3108
|
|
3072
|
-
if newVersion
|
3109
|
+
if newVersion is None:
|
3073
3110
|
self._version = float(cst.VERSION_WOLFHYDRO)
|
3074
3111
|
elif type(newVersion) == str:
|
3075
3112
|
self._version = float(newVersion)
|
@@ -3300,7 +3337,7 @@ class SubBasin:
|
|
3300
3337
|
# elif self.model == cst.tom_2layers_linIF:
|
3301
3338
|
# self.activate_all_iv_2layers()
|
3302
3339
|
cur_dir = os.path.join(self.fileNameRead, "Subbasin_"+str(self.iDSorted))
|
3303
|
-
|
3340
|
+
mc.MODELS_VAR[self.model].deactivate_all(directory=cur_dir, prefix_file='simul')
|
3304
3341
|
mc.MODELS_VAR[self.model].activate_all(directory=cur_dir, prefix_file='simul', type_of_var=iv.FINAL_OUT_VAR)
|
3305
3342
|
mc.MODELS_VAR[self.model].activate_all(directory=cur_dir, prefix_file='simul', type_of_var=iv.IV_VAR)
|
3306
3343
|
|
@@ -3716,7 +3753,7 @@ class SubBasin:
|
|
3716
3753
|
Returns:
|
3717
3754
|
- dict: A dictionary containing the summary of the fractions of the current module.
|
3718
3755
|
"""
|
3719
|
-
|
3756
|
+
print(f"Computing flow fractions for station :{self.name}")
|
3720
3757
|
if all_f == {}:
|
3721
3758
|
cur_dir = os.path.join(self.fileNameRead, "Subbasin_"+str(self.iDSorted))
|
3722
3759
|
all_qin = mc.MODELS_VAR[self.model].get_all_iv_timeseries(directory=cur_dir,
|
@@ -3725,8 +3762,16 @@ class SubBasin:
|
|
3725
3762
|
prefix_file='simul', type_of_var=iv.DEFAULT_VAR)
|
3726
3763
|
all_f.update(all_qin)
|
3727
3764
|
|
3728
|
-
q_simul = self.
|
3729
|
-
|
3765
|
+
q_simul = self.get_myHydro(unit='mm/h')
|
3766
|
+
for key, val in all_f.items():
|
3767
|
+
if len(val) != len(q_simul):
|
3768
|
+
logging.warning(f"Length of {key} does not match with the length of the simulated flow!")
|
3769
|
+
continue
|
3770
|
+
# all_r = {"%"+key: val/q_simul * 100.0 for key, val in all_f.items()}
|
3771
|
+
all_r = {
|
3772
|
+
f"%{key}": np.where(np.isfinite(val / q_simul), (val / q_simul) * 100.0, np.nan)
|
3773
|
+
for key, val in all_f.items()
|
3774
|
+
}
|
3730
3775
|
|
3731
3776
|
return self._operation_on_ts(all_r, summary=summary, interval=interval)
|
3732
3777
|
|
@@ -3749,7 +3794,7 @@ class SubBasin:
|
|
3749
3794
|
all_iv = mc.MODELS_VAR[self.model].get_all_iv_timeseries(directory=cur_dir,
|
3750
3795
|
prefix_file='simul', type_of_var=iv.IV_VAR)
|
3751
3796
|
if max_params != {}:
|
3752
|
-
out_dict = {key: all_iv[key]/cur_max for key, cur_max in max_params.items()}
|
3797
|
+
out_dict = {key: all_iv[key]/cur_max*100 for key, cur_max in max_params.items()}
|
3753
3798
|
else:
|
3754
3799
|
out_dict = all_iv
|
3755
3800
|
|