@@ -380,20 +380,19 @@ def initial(self):
380
380
# Here it becomes Outflow (x+dx) Q at the beginning of the computation step (t) for full section (instant)
381
381
# Used to calculated Inflow (x) from upstream pixels at the beginning of the computation step (t)
382
382
self .var .ChanQ = np .where (PrevDischarge == - 9999 , self .var .ChanQKin , PrevDischarge ) #np
383
- # Initialise channel discharge: cold start: equal to ChanQKin [m3/s]
383
+ # Initialise instantaneous channel discharge: cold start: equal to ChanQKin [m3/s]
384
384
385
385
# # cmcheck - deve diventare una variabile di stato
386
386
# PrevAvgDischarge = loadmap('DischargeMaps')
387
- # self.var.ChanQAvg = np.where(PrevAvgDischarge == -9999, maskinfo.in_zero(), PrevAvgDischarge) #np
387
+ # self.var.ChanQAvgDt = np.where(PrevAvgDischarge == -9999, maskinfo.in_zero(), PrevAvgDischarge) #np
388
388
# cmcheck - per adesso
389
389
self .var .ChanQAvgDt = maskinfo .in_zero ()
390
-
391
- # Average channel outflow (x+dx) from channels during previous model computation step (dt)
390
+ # Initialise average channel outflow (x+dx) from channels during previous model computation step (dt)
392
391
393
392
# cmcheck
394
393
ChanQAvgDtPcr = decompress (self .var .ChanQAvgDt ) # pcr
395
394
self .var .ChanQAvgInDt = compressArray (upstream (self .var .LddChan , ChanQAvgDtPcr ))
396
- # Average channel inflow (x) from channels for next model computation step (dt)
395
+ # Initialise average channel inflow (x) from channels for next model computation step (dt)
397
396
# Using LddChan here because we need all pixels upstream, kin and mct
398
397
399
398
@@ -706,21 +705,23 @@ def dynamic(self, NoRoutingExecuted):
706
705
# Outflow (x+dx) at time t beginning of calculation step (instant)
707
706
# This is used to calculate inflow from upstream cells
708
707
709
- # ChanM3KinStart = self.var.ChanM3Kin.copy()
708
+ ChanM3KinStart = self .var .ChanM3Kin .copy ()
710
709
# Channel storage at time t beginning of calculation step (instant)
711
710
712
711
ChanQKinOutEnd ,ChanM3KinEnd = self .KINRouting (ChanQKinOutStart ,SideflowChan )
713
712
# Outflow (x+dx) at time t+dt end of calculation step (instant)
714
713
# Channel storage at time t+dt end of calculation step (instant)
714
+ # This is in fact the same as the average outflow -> from some feature in kinematic routing function
715
715
716
716
# cmcheck
717
- self .var .ChanQAvgDt = (self .var .ChanQAvgInDt * self .var .DtRouting + SideflowChanM3 - ChanM3KinEnd + self .var .ChanM3 ) * self .var .InvDtRouting
717
+ # Calculate average outflow using water balance for channel grid cell over sub-routing step
718
+ self .var .ChanQAvgDt = (self .var .ChanQAvgInDt * self .var .DtRouting + SideflowChanM3 - ChanM3KinEnd + ChanM3KinStart ) * self .var .InvDtRouting
718
719
# if np.any(self.var.ChanQAvgDt < 0):
719
720
# print("At least one value is less than 0.")
720
721
self .var .ChanQAvgDt [self .var .ChanQAvgDt < 0 ] = 0
721
722
# Average outflow (x+dx) QAvg during routing step (average)
722
- # Qout_avg = Qin_avg -(Vend - Vini)
723
-
723
+ # Qout_avg = Qin_avg -(Vend - Vstart)/DtRouting
724
+ # Qin_avg = Qin_avg_channels + Qin_avg_sideflow
724
725
725
726
# updating variables for next routing step
726
727
self .var .ChanQKin = ChanQKinOutEnd .copy ()
@@ -735,15 +736,16 @@ def dynamic(self, NoRoutingExecuted):
735
736
# Channel storage V at the end of computation step t+dt for full section (instant)
736
737
# same as ChanM3KinEnd for Kinematic routing only
737
738
738
- # Update average channel inflow (x) Qavg for next step
739
- ChanQAvgInDt = decompress (self .var .ChanQAvgDt ) # pcr
740
- self .var .ChanQAvgInDt = compressArray (upstream (self .var .LddChan , ChanQAvgInDt ))
739
+ # Update average channel inflow (x) Qavg for next sub-routing step
740
+ ChanQAvgDtPcr = decompress (self .var .ChanQAvgDt ) # pcr
741
+ self .var .ChanQAvgInDt = compressArray (upstream (self .var .LddChan , ChanQAvgDtPcr ))
741
742
742
743
# self.var.sumDisDay += self.var.ChanQ
743
744
# # sum of total river outflow on model sub-step
744
745
745
746
self .var .sumDisDay += self .var .ChanQAvgDt
746
- # sum of average river outflow on model routing sub-step
747
+ # sum of average river outflow on routing sub-step
748
+ # used for calculating average discharge on model time step
747
749
748
750
749
751
# SPLIT ROUTING - no InitLisfllod
@@ -775,29 +777,27 @@ def dynamic(self, NoRoutingExecuted):
775
777
776
778
if not (option ['SplitRouting' ]):
777
779
# Kinematic routing
780
+ # This is calculated for every grid cell, including MCT grid cells
778
781
779
782
ChanQKinOutStart = self .var .ChanQ .copy ()
780
783
# Outflow (x+dx) Q at time t beginning of calculation step (instant)
784
+ # This is used to calculate inflow from upstream cells
781
785
782
786
ChanM3KinStart = self .var .ChanM3 .copy ()
783
-
784
- # ChanM3KinStart = self.var.ChanM3.copy()
785
- # Channel storage at time t (instant)
787
+ # Channel storage at time t beginning of calculation step (instant)
786
788
787
789
ChanQKinOutEnd ,ChanM3KinEnd = self .KINRouting (ChanQKinOutStart ,SideflowChan )
788
790
# Outflow at time t+dt end of calculation step (instant)
789
791
# Channel storage at time t+dt end of calculation step (instant)
790
-
792
+ # This is in fact the same as the average outflow -> from some feature in kinematic routing function
791
793
792
794
# cmcheck
793
-
794
- # cal average outflow discharge for channels during routing sub step dt
795
-
795
+ # Calculate average outflow using water balance for channel grid cell
796
796
ChanQKinAvgDt = (self .var .ChanQAvgInDt * self .var .DtRouting + SideflowChanM3 - ChanM3KinEnd + ChanM3KinStart ) * self .var .InvDtRouting
797
797
# if np.any(self.var.ChanQAvgDt < 0):
798
798
# print("At least one value is less than 0.")
799
799
ChanQKinAvgDt [ChanQKinAvgDt < 0 ] = 0
800
- # Average outflow (x+dx) QAvg during routing step (average)
800
+ # Average outflow (x+dx) QAvg during sub- routing step (average)
801
801
# Qout_avg = Qin_avg -(Vend - Vini)
802
802
803
803
@@ -822,7 +822,7 @@ def dynamic(self, NoRoutingExecuted):
822
822
# MCT routing
823
823
824
824
ChanQMCTOutStart = self .var .ChanQ .copy ()
825
- # Outflow (x+dx) at time t q10 (instant)
825
+ # Outflow (x+dx) at time t (instant) q10
826
826
827
827
# debug
828
828
# ChanQKinOutEnd[ChanQKinOutEnd != 0] = 0
@@ -832,7 +832,7 @@ def dynamic(self, NoRoutingExecuted):
832
832
# Channel storage at time t V00
833
833
834
834
ChanQMCTInStart = self .var .PrevQMCTin .copy ()
835
- # Inflow (x) at time t instant (instant)
835
+ # Inflow (x) at time t instant (instant) q00
836
836
# This is coming from upstream pixels
837
837
838
838
# calling MCT routing
@@ -842,10 +842,11 @@ def dynamic(self, NoRoutingExecuted):
842
842
# Channel storage at time t+dt end of calculation step (instant)
843
843
844
844
845
- # # update input (x) Q at t for next step (instant)
846
- # ChanQMCTStartPcr = decompress(ChanQMCTOutStart) # pcr
847
- # self.var.PrevQMCTin = compressArray(upstream(self.var.LddChan, ChanQMCTStartPcr ))
845
+ # # update input (x) Q at t for next step (instant) q10 -> q00
846
+ # ChanQMCTOutStartPcr = decompress(ChanQMCTOutStart) # pcr
847
+ # self.var.PrevQMCTin = compressArray(upstream(self.var.LddChan, ChanQMCTOutStartPcr ))
848
848
# # using LddChan here because we need to input from upstream pixels to include kinematic pixels
849
+ # update input (x) Q at t for next step (instant)
849
850
850
851
851
852
# Storing MCT Courant and Reynolds numbers for state files
@@ -855,6 +856,7 @@ def dynamic(self, NoRoutingExecuted):
855
856
# cmcheck
856
857
857
858
# calc average discharge outflow for MCT channels during routing sub step dt
859
+ # Calculate average outflow using water balance for MCT channel grid cell over sub-routing step
858
860
# ChanQMCTAvgDt = (self.var.ChanQAvgInDt * self.var.DtRouting + SideflowChanMCT * self.var.DtRouting - ChanM3MCTEnd + ChanM3MCTStart) * self.var.InvDtRouting
859
861
ChanQMCTAvgDt = np .where (self .var .IsChannelKinematic , 0. , (
860
862
self .var .ChanQAvgInDt * self .var .DtRouting + SideflowChanMCT * self .var .DtRouting - ChanM3MCTEnd + ChanM3MCTStart ) * self .var .InvDtRouting )
@@ -884,7 +886,6 @@ def dynamic(self, NoRoutingExecuted):
884
886
self .var .PrevQMCTin = compressArray (upstream (self .var .LddChan , ChanQMCTStartPcr ))
885
887
# using LddChan here because we need to input from upstream pixels to include kinematic pixels
886
888
887
-
888
889
# Update average channel inflow (x) Qavg for next step
889
890
ChanQAvgInDtPcr = decompress (self .var .ChanQAvgDt ) # pcr
890
891
self .var .ChanQAvgInDt = compressArray (upstream (self .var .LddChan , ChanQAvgInDtPcr ))
0 commit comments