@@ -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):
5763def 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):
649686fromConvolution = []
650687fromCropheatunit = ['CROP_HEAT_UNIT' ,'' ]
651688toCropheatunit = ['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
653694anyCompartment = list (set ().union (
654695 fromPrecip ,toPrecip ,fromCanevp ,toCanevp ,fromSoilevap ,toSoilevap ,
0 commit comments