Skip to content

Commit 0d2f1f5

Browse files
committed
Implement split and lateralflush
1 parent 186a590 commit 0d2f1f5

12 files changed

Lines changed: 238 additions & 180 deletions

File tree

qraven/modules/hydrologicproc.py

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ def addprocess(self):
88

99
combo_proc = QComboBox()
1010
combo_alg = QComboBox()
11-
combo_from = QComboBox()
11+
combo_from = QComboBox()
12+
combo_from2 = QComboBox()
13+
combo_from2.setEnabled(False)
1214
combo_to = QComboBox()
13-
15+
combo_to2 = QComboBox()
16+
combo_to2.setEnabled(False)
17+
1418
chk_isconditional = QCheckBox()
1519

1620
combo_basedtype = QComboBox()
@@ -34,14 +38,16 @@ def addprocess(self):
3438
table.setCellWidget(currentRow, 0, combo_proc) #Sets the new combobox in the first column and in the new row
3539
table.setCellWidget(currentRow, 1, combo_alg)
3640
table.setCellWidget(currentRow, 2, combo_from)
37-
table.setCellWidget(currentRow, 3, combo_to)
38-
table.setCellWidget(currentRow, 4, chk_isconditional)
39-
table.setCellWidget(currentRow, 5, combo_basedtype)
40-
table.setCellWidget(currentRow, 6, combo_comparison)
41-
table.setCellWidget(currentRow, 7, txt_hrutype)
42-
table.setCellWidget(currentRow, 8, chk_mixingrate)
43-
table.setCellWidget(currentRow, 9, spin_pct)
44-
table.setCellWidget(currentRow, 10, chk_interbasin)
41+
table.setCellWidget(currentRow, 3, combo_from2)
42+
table.setCellWidget(currentRow, 4, combo_to)
43+
table.setCellWidget(currentRow, 5, combo_to2)
44+
table.setCellWidget(currentRow, 6, chk_isconditional)
45+
table.setCellWidget(currentRow, 7, combo_basedtype)
46+
table.setCellWidget(currentRow, 8, combo_comparison)
47+
table.setCellWidget(currentRow, 9, txt_hrutype)
48+
table.setCellWidget(currentRow, 10, chk_mixingrate)
49+
table.setCellWidget(currentRow, 11, spin_pct)
50+
table.setCellWidget(currentRow, 12, chk_interbasin)
4551

4652
table.resizeColumnsToContents() #Resizes the width of the column automatically
4753
combo_proc.currentIndexChanged.connect(lambda:setProcAlg(self,currentRow)) #Updates the algorithm combobox if the process changes
@@ -57,14 +63,17 @@ def removeprocess(self):
5763
def setProcAlg(self,row):
5864
#print('Went into the algs')
5965
table = self.dlg.table_hydroprocess
66+
6067
combo_proc = table.cellWidget(row, 0)
6168
combo_alg = table.cellWidget(row, 1) #Sets the new combobox in the first column and in the new row
62-
combo_from = table.cellWidget(row, 2)
63-
combo_to = table.cellWidget(row, 3)
64-
chk_mixingrate = table.cellWidget(row, 8)
65-
spin_pct = table.cellWidget(row, 9)
66-
chk_interbasin = table.cellWidget(row, 10)
69+
combo_from2 = table.cellWidget(row, 3)
70+
combo_to2 = table.cellWidget(row, 5)
71+
chk_mixingrate = table.cellWidget(row, 10)
72+
spin_pct = table.cellWidget(row, 11)
73+
chk_interbasin = table.cellWidget(row, 12)
6774

75+
combo_from2.setEnabled(False)
76+
combo_to2.setEnabled(False)
6877
combo_alg.setEnabled(True)
6978
spin_pct.setEnabled(False)
7079
chk_interbasin.setChecked(False)
@@ -75,6 +84,8 @@ def setProcAlg(self,row):
7584
# index = self.dlg.table_hydroprocess.indexAt(currentWidget.pos())
7685
# widgetRow = index.row()
7786
combo_alg.clear()
87+
combo_from2.clear()
88+
combo_to2.clear()
7889
combo_alg.addItem('')
7990

8091
# if isinstance(currentWidget, QComboBox):
@@ -142,11 +153,14 @@ def setProcAlg(self,row):
142153
elif selectedProc == 'Abstraction':
143154
combo_alg.addItems(abstractionAlg)
144155
elif selectedProc == 'Split':
156+
combo_to2.setEnabled(True)
145157
combo_alg.addItems(splitAlg)
146158
chk_mixingrate.setEnabled(True)
147159
elif selectedProc == 'Convolve':
148160
combo_alg.addItems(convolutionAlg)
149161
elif selectedProc == 'LateralFlush':
162+
combo_from2.setEnabled(True)
163+
combo_to2.setEnabled(True)
150164
combo_alg.addItems(lateralflushAlg)
151165
elif selectedProc == 'LateralEquilibrate':
152166
combo_alg.addItems(lateralequilibrateAlg)
@@ -235,9 +249,13 @@ def setStorage(self,selectedProc, row):
235249
combo_proc = table.cellWidget(row, 0)
236250
combo_alg = table.cellWidget(row, 1)
237251
combo_from = table.cellWidget(row, 2)
238-
combo_to = table.cellWidget(row, 3)
252+
combo_from2 = table.cellWidget(row,3)
253+
combo_to = table.cellWidget(row, 4)
254+
combo_to2 = table.cellWidget(row,5)
239255
combo_from.clear()
240256
combo_to.clear()
257+
combo_from2.clear()
258+
combo_to2.clear()
241259

242260

243261

@@ -393,9 +411,24 @@ def setStorage(self,selectedProc, row):
393411
#toredirectflow = self.dlg.table_hydroprocess.cellWidget(widgetRow-1,3).currentText()
394412
combo_from.addItems(tmpanyCompartment)
395413
combo_to.addItems(tmpanyCompartment)
396-
elif selectedProc == 'Flush' or selectedProc == "Overflow" or selectedProc == 'Split' or selectedProc == 'LateralFlush' or selectedProc == 'LateralEquilibrate':
414+
elif selectedProc == 'LateralFlush':
415+
hrugroups = [x.strip() for x in self.dlg.txt_defhru.toPlainText().split(',')]
416+
combo_from2.addItem('')
417+
combo_to2.addItem('')
418+
combo_from2.addItems(statevariables)
419+
combo_to2.addItems(statevariables)
420+
if hrugroups[0] !='':
421+
combo_from.addItems(hrugroups)
422+
combo_to.addItems(hrugroups)
423+
else:
424+
combo_from.addItem('HRUs undefined')
425+
combo_to.addItem('HRUs undefined')
426+
427+
elif selectedProc == 'Flush' or selectedProc == "Overflow" or selectedProc == 'Split' or selectedProc == 'LateralEquilibrate':
397428
if selectedProc == 'LateralEquilibrate':
398429
tmpanyCompartment.append('AllHRUs')
430+
elif selectedProc == 'Split':
431+
combo_to2.addItems(tmpanyCompartment)
399432
combo_from.addItems(tmpanyCompartment)
400433
combo_to.addItems(tmpanyCompartment)
401434
# table.setCellWidget(row, 2, combo_from) #Set the combobox for the from compartment
@@ -410,10 +443,10 @@ def enableConditionalProc(self,row):
410443

411444
table = self.dlg.table_hydroprocess
412445

413-
chk_isConditional = table.cellWidget(row, 4)
414-
combo_basedtype = table.cellWidget(row, 5)
415-
combo_comparison = table.cellWidget(row, 6)
416-
txt_hrutype = table.cellWidget(row, 7)
446+
chk_isConditional = table.cellWidget(row, 6)
447+
combo_basedtype = table.cellWidget(row, 7)
448+
combo_comparison = table.cellWidget(row, 8)
449+
txt_hrutype = table.cellWidget(row, 9)
417450

418451
combo_basedtype.clear()
419452
combo_comparison.clear()
@@ -435,8 +468,8 @@ def enableMixingRate(self, row):
435468
# currentWidget = self.dlg.sender()
436469
# index = self.dlg.table_hydroprocess.indexAt(currentWidget.pos())
437470
# widgetRow = index.row()
438-
chk_mixingrate = table.cellWidget(row, 8)
439-
spin_pct = table.cellWidget(row, 9)
471+
chk_mixingrate = table.cellWidget(row, 10)
472+
spin_pct = table.cellWidget(row, 11)
440473

441474
spin_pct.setSingleStep(0.1)
442475
spin_pct.setMaximum(1.0)
@@ -460,22 +493,26 @@ def getHydroProcess(self):
460493
for col in range(cols):
461494
currentWidget = table.cellWidget(row,col)
462495
if isinstance(currentWidget, QComboBox):
463-
processesList.append(currentWidget.currentText())
496+
if col == 3:
497+
if currentWidget.currentText() != '': #It is lateralflush and requires "To" keyword
498+
processesList.append(currentWidget.currentText()+' To ')
499+
else:
500+
processesList.append(currentWidget.currentText())
464501
elif isinstance(currentWidget, QCheckBox):
465502
if currentWidget.isChecked():
466-
if col == 4:
503+
if col == 6:
467504
processesList.append('condTrue') #The checkbox is Conditional
468-
elif col == 8:
469-
processesList.append('mixTrue') #The checkbox is Mixing rate
470505
elif col == 10:
506+
processesList.append('mixTrue') #The checkbox is Mixing rate
507+
elif col == 12:
471508
#processesList.append('interbasinTrue') #The checkbox is Interbasin
472509
processesList.insert(-5,'interbasinTrue')
473510
else:
474511
processesList.append('False')
475512
elif isinstance(currentWidget, QLineEdit):
476513
processesList.append(currentWidget.text().upper())
477514
elif isinstance(currentWidget, QDoubleSpinBox):
478-
if table.cellWidget(row,8).isChecked() or table.cellWidget(row,0).currentText() == 'LateralEquilibrate':
515+
if table.cellWidget(row,10).isChecked() or table.cellWidget(row,0).currentText() == 'LateralEquilibrate':
479516
#processesList.append("{:.1f}".format(currentWidget.value()))
480517
processesList.insert(-5,"{:.1f}".format(currentWidget.value()))
481518
else:
@@ -649,6 +686,10 @@ def getHydroProcess(self):
649686
fromConvolution = []
650687
fromCropheatunit = ['CROP_HEAT_UNIT','']
651688
toCropheatunit = ['CROP_HEAT_UNIT','']
689+
statevariables = ['SURFACE_WATER','ATMOSPHERE','ATMOS_PRECIP','PONDED_WATER','SOIL','GROUNDWATER',
690+
'CANOPY','CANOPY_SNOW','TRUNK','ROOT','DEPRESSION','WETLAND','LAKE_STORAGE','SNOW',
691+
'SNOW_LIQ','GLACIER','GLACIER_ICE']
692+
statevariables.sort()
652693

653694
anyCompartment = list(set().union(
654695
fromPrecip,toPrecip,fromCanevp,toCanevp,fromSoilevap,toSoilevap,

qraven/modules/templates/awbm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def loadAwbm(self):
3030
combo_alg.setCurrentText("PRECIP_RAVEN")
3131
combo_from = table.cellWidget(0,2)
3232
combo_from.setCurrentText("ATMOS_PRECIP")
33-
combo_to = table.cellWidget(0,3)
33+
combo_to = table.cellWidget(0,4)
3434
combo_to.setCurrentText("MULTIPLE")
3535

3636
combo_proc = table.cellWidget(1,0)
@@ -39,7 +39,7 @@ def loadAwbm(self):
3939
combo_alg.setCurrentText("SNOBAL_SIMPLE_MELT")
4040
combo_from = table.cellWidget(1,2)
4141
combo_from.setCurrentText("SNOW")
42-
combo_to = table.cellWidget(1,3)
42+
combo_to = table.cellWidget(1,4)
4343
combo_to.setCurrentText("PONDED_WATER")
4444

4545
combo_proc = table.cellWidget(2,0)
@@ -48,7 +48,7 @@ def loadAwbm(self):
4848
combo_alg.setCurrentText("INF_AWBM")
4949
combo_from = table.cellWidget(2,2)
5050
combo_from.setCurrentText("PONDED_WATER")
51-
combo_to = table.cellWidget(2,3)
51+
combo_to = table.cellWidget(2,4)
5252
combo_to.setCurrentText("MULTIPLE")
5353

5454
combo_proc = table.cellWidget(3,0)
@@ -57,7 +57,7 @@ def loadAwbm(self):
5757
combo_alg.setCurrentText("SOILEVAP_AWBM")
5858
combo_from = table.cellWidget(3,2)
5959
combo_from.setCurrentText("MULTIPLE")
60-
combo_to = table.cellWidget(3,3)
60+
combo_to = table.cellWidget(3,4)
6161
combo_to.setCurrentText("ATMOSPHERE")
6262

6363
combo_proc = table.cellWidget(4,0)
@@ -66,7 +66,7 @@ def loadAwbm(self):
6666
combo_alg.setCurrentText("BASE_LINEAR")
6767
combo_from = table.cellWidget(4,2)
6868
combo_from.setCurrentText("SOIL[3]")
69-
combo_to = table.cellWidget(4,3)
69+
combo_to = table.cellWidget(4,4)
7070
combo_to.setCurrentText("SURFACE_WATER")
7171

7272

qraven/modules/templates/canshield.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def loadCanshield(self):
3131
combo_alg.setCurrentText("FREEZE_DEGREE_DAY")
3232
combo_from = table.cellWidget(0,2)
3333
combo_from.setCurrentText("SNOW_LIQ")
34-
combo_to = table.cellWidget(0,3)
34+
combo_to = table.cellWidget(0,4)
3535
combo_to.setCurrentText("SNOW")
3636

3737
combo_proc = table.cellWidget(1,0)
@@ -40,7 +40,7 @@ def loadCanshield(self):
4040
combo_alg.setCurrentText("PRECIP_RAVEN")
4141
combo_from = table.cellWidget(1,2)
4242
combo_from.setCurrentText("ATMOS_PRECIP")
43-
combo_to = table.cellWidget(1,3)
43+
combo_to = table.cellWidget(1,4)
4444
combo_to.setCurrentText("MULTIPLE")
4545

4646
combo_proc = table.cellWidget(2,0)
@@ -49,7 +49,7 @@ def loadCanshield(self):
4949
combo_alg.setCurrentText("CANEVP_MAXIMUM")
5050
combo_from = table.cellWidget(2,2)
5151
combo_from.setCurrentText("CANOPY")
52-
combo_to = table.cellWidget(2,3)
52+
combo_to = table.cellWidget(2,4)
5353
combo_to.setCurrentText("ATMOSPHERE")
5454

5555
combo_proc = table.cellWidget(3,0)
@@ -58,7 +58,7 @@ def loadCanshield(self):
5858
combo_alg.setCurrentText("SUBLIM_MAXIMUM")
5959
combo_from = table.cellWidget(3,2)
6060
combo_from.setCurrentText("CANOPY_SNOW")
61-
combo_to = table.cellWidget(3,3)
61+
combo_to = table.cellWidget(3,4)
6262
combo_to.setCurrentText("ATMOSPHERE")
6363

6464
combo_proc = table.cellWidget(4,0)
@@ -67,7 +67,7 @@ def loadCanshield(self):
6767
combo_alg.setCurrentText("SNOBAL_TWO_LAYER")
6868
combo_from = table.cellWidget(4,2)
6969
combo_from.setCurrentText("MULTIPLE")
70-
combo_to = table.cellWidget(4,3)
70+
combo_to = table.cellWidget(4,4)
7171
combo_to.setCurrentText("MULTIPLE")
7272

7373
combo_proc = table.cellWidget(5,0)
@@ -76,7 +76,7 @@ def loadCanshield(self):
7676
combo_alg.setCurrentText("ABST_FILL")
7777
combo_from = table.cellWidget(5,2)
7878
combo_from.setCurrentText("PONDED_WATER")
79-
combo_to = table.cellWidget(5,3)
79+
combo_to = table.cellWidget(5,4)
8080
combo_to.setCurrentText("DEPRESSION")
8181

8282
combo_proc = table.cellWidget(6,0)
@@ -85,7 +85,7 @@ def loadCanshield(self):
8585
combo_alg.setCurrentText("OPEN_WATER_EVAP")
8686
combo_from = table.cellWidget(6,2)
8787
combo_from.setCurrentText("DEPRESSION")
88-
combo_to = table.cellWidget(6,3)
88+
combo_to = table.cellWidget(6,4)
8989
combo_to.setCurrentText("ATMOSPHERE")
9090

9191
combo_proc = table.cellWidget(7,0)
@@ -94,7 +94,7 @@ def loadCanshield(self):
9494
combo_alg.setCurrentText("INF_HBV")
9595
combo_from = table.cellWidget(7,2)
9696
combo_from.setCurrentText("PONDED_WATER")
97-
combo_to = table.cellWidget(7,3)
97+
combo_to = table.cellWidget(7,4)
9898
combo_to.setCurrentText("MULTIPLE")
9999

100100
combo_proc = table.cellWidget(8,0)
@@ -103,7 +103,7 @@ def loadCanshield(self):
103103
combo_alg.setCurrentText("LAKEREL_LINEAR")
104104
combo_from = table.cellWidget(8,2)
105105
combo_from.setCurrentText("LAKE_STORAGE")
106-
combo_to = table.cellWidget(8,3)
106+
combo_to = table.cellWidget(8,4)
107107
combo_to.setCurrentText("SURFACE_WATER")
108108

109109
combo_proc = table.cellWidget(9,0)
@@ -112,7 +112,7 @@ def loadCanshield(self):
112112
combo_alg.setCurrentText("SOILEVAP_ROOT")
113113
combo_from = table.cellWidget(9,2)
114114
combo_from.setCurrentText("SOIL[0]")
115-
combo_to = table.cellWidget(9,3)
115+
combo_to = table.cellWidget(9,4)
116116
combo_to.setCurrentText("ATMOSPHERE")
117117

118118
combo_proc = table.cellWidget(10,0)
@@ -121,7 +121,7 @@ def loadCanshield(self):
121121
combo_alg.setCurrentText("PERC_GAWSER_CONSTRAIN")
122122
combo_from = table.cellWidget(10,2)
123123
combo_from.setCurrentText("SOIL[0]")
124-
combo_to = table.cellWidget(10,3)
124+
combo_to = table.cellWidget(10,4)
125125
combo_to.setCurrentText("SOIL[1]")
126126

127127
combo_proc = table.cellWidget(11,0)
@@ -130,7 +130,7 @@ def loadCanshield(self):
130130
combo_alg.setCurrentText("PERC_GAWSER_CONSTRAIN")
131131
combo_from = table.cellWidget(11,2)
132132
combo_from.setCurrentText("SOIL[1]")
133-
combo_to = table.cellWidget(11,3)
133+
combo_to = table.cellWidget(11,4)
134134
combo_to.setCurrentText("SOIL[2]")
135135

136136
combo_proc = table.cellWidget(12,0)
@@ -139,7 +139,7 @@ def loadCanshield(self):
139139
combo_alg.setCurrentText("BASE_THRESH_POWER")
140140
combo_from = table.cellWidget(12,2)
141141
combo_from.setCurrentText("SOIL[0]")
142-
combo_to = table.cellWidget(12,3)
142+
combo_to = table.cellWidget(12,4)
143143
combo_to.setCurrentText("SURFACE_WATER")
144144

145145
combo_proc = table.cellWidget(13,0)
@@ -148,7 +148,7 @@ def loadCanshield(self):
148148
combo_alg.setCurrentText("BASE_THRESH_POWER")
149149
combo_from = table.cellWidget(13,2)
150150
combo_from.setCurrentText("SOIL[1]")
151-
combo_to = table.cellWidget(13,3)
151+
combo_to = table.cellWidget(13,4)
152152
combo_to.setCurrentText("SURFACE_WATER")
153153

154154
combo_proc = table.cellWidget(14,0)
@@ -157,7 +157,7 @@ def loadCanshield(self):
157157
combo_alg.setCurrentText("BASE_THRESH_POWER")
158158
combo_from = table.cellWidget(14,2)
159159
combo_from.setCurrentText("SOIL[2]")
160-
combo_to = table.cellWidget(14,3)
160+
combo_to = table.cellWidget(14,4)
161161
combo_to.setCurrentText("SURFACE_WATER")
162162

163163
table.resizeColumnsToContents() #Resizes the width of the column automatically

0 commit comments

Comments
 (0)