Skip to content

Commit d6bbb6a

Browse files
authored
Merge pull request #50 from openstreams/glacier_params
Fix conversion of time-dependent glacier parameters and HBV time dependent parameters
2 parents b5a11f7 + df9bf44 commit d6bbb6a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

tests/test_wflow_hbv2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def testapirunhr(self):
6464
)
6565

6666
print("Checking water budget ....")
67-
self.assertAlmostEqual(0.0011249125109316083, my_data[:, 2].sum(), places=4)
67+
self.assertAlmostEqual(0.001239627579707303, my_data[:, 2].sum(), places=4)
6868

6969
my_data = np.genfromtxt(os.path.join(caseName, runId, "run.csv"), delimiter=",")
7070
print("Checking discharge ....")
71-
self.assertAlmostEqual(1671.0379650115967, my_data[:, 2].mean(), places=4)
71+
self.assertAlmostEqual(163.88664160221816, my_data[:, 2].mean(), places=4)
7272

7373
if __name__ == "__main__":
7474
unittest.main()

wflow/wflow_funcs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,15 @@ def glacierHBV(GlacierFrac,
532532
:ivar Temperature: Air temperature
533533
:ivar TT: Temperature threshold for ice melting
534534
:ivar Cfmax: Ice degree-day factor in mm/(°C/day)
535-
:ivar G_SIfrac: Fraction of the snow part turned into ice each timestep
535+
:ivar G_SIfrac: Fraction of the snow part turned into ice each daily timestep
536536
:ivar timestepsecs: Model timestep in seconds
537537
:ivar basetimestep: Model base timestep (86 400 seconds)
538538
539539
:returns: Snow,Snow2Glacier,GlacierStore,GlacierMelt,
540540
"""
541541

542542
#Fraction of the snow transformed into ice (HBV-light model)
543-
Snow2Glacier = G_SIfrac * Snow
543+
Snow2Glacier = G_SIfrac * (timestepsecs / basetimestep) * Snow
544544

545545
Snow2Glacier = pcr.ifthenelse(
546546
GlacierFrac > 0.0, Snow2Glacier, pcr.scalar(0.0)
@@ -554,7 +554,7 @@ def glacierHBV(GlacierFrac,
554554
GlacierStore = GlacierStore + Snow2Glacier
555555

556556
PotMelt = pcr.ifthenelse(
557-
Temperature > TT, Cfmax * (Temperature - TT), pcr.scalar(0.0)
557+
Temperature > TT, Cfmax * (timestepsecs / basetimestep) * (Temperature - TT), pcr.scalar(0.0)
558558
) # Potential snow melt, based on temperature
559559

560560
GlacierMelt = pcr.ifthenelse(

wflow/wflow_hbv.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -726,15 +726,15 @@ def initial(self):
726726
subcatch,
727727
self.Soil,
728728
0.02307,
729-
) # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR
729+
) * self.timestepsecs / self.basetimestep # Recession constant baseflow #K4=0.07; BASEFLOW:LINEARRESERVOIR
730730
if self.SetKquickFlow:
731731
self.KQuickFlow = self.readtblDefault(
732732
self.Dir + "/" + self.intbl + "/KQuickFlow.tbl",
733733
self.LandUse,
734734
subcatch,
735735
self.Soil,
736736
0.09880,
737-
) # recession rate at flow HQ #KHQ=0.2; OUTFLOWUPPERZONE_NONLINEARRESERVOIR
737+
) * self.timestepsecs / self.basetimestep # recession rate at flow HQ #KHQ=0.2; OUTFLOWUPPERZONE_NONLINEARRESERVOIR
738738
self.SUZ = self.readtblDefault(
739739
self.Dir + "/" + self.intbl + "/SUZ.tbl",
740740
self.LandUse,
@@ -748,22 +748,22 @@ def initial(self):
748748
subcatch,
749749
self.Soil,
750750
0.3,
751-
) # K0
751+
) * self.timestepsecs / self.basetimestep # K0
752752
else:
753753
self.KHQ = self.readtblDefault(
754754
self.Dir + "/" + self.intbl + "/KHQ.tbl",
755755
self.LandUse,
756756
subcatch,
757757
self.Soil,
758758
0.09880,
759-
) # recession rate at flow HQ #KHQ=0.2; OUTFLOWUPPERZONE_NONLINEARRESERVOIR
759+
) * self.timestepsecs / self.basetimestep # recession rate at flow HQ #KHQ=0.2; OUTFLOWUPPERZONE_NONLINEARRESERVOIR
760760
self.HQ = self.readtblDefault(
761761
self.Dir + "/" + self.intbl + "/HQ.tbl",
762762
self.LandUse,
763763
subcatch,
764764
self.Soil,
765765
3.27000,
766-
) # high flow rate HQ for which recession rate of upper reservoir is known #HQ=3.76;
766+
) * self.timestepsecs / self.basetimestep # high flow rate HQ for which recession rate of upper reservoir is known #HQ=3.76;
767767
self.AlphaNL = self.readtblDefault(
768768
self.Dir + "/" + self.intbl + "/AlphaNL.tbl",
769769
self.LandUse,
@@ -778,7 +778,7 @@ def initial(self):
778778
subcatch,
779779
self.Soil,
780780
0.4000,
781-
) # percolation from Upper to Lowerzone (mm/day)
781+
) * self.timestepsecs / self.basetimestep # percolation from Upper to Lowerzone (mm/day)
782782
self.CFR = self.readtblDefault(
783783
self.Dir + "/" + self.intbl + "/CFR.tbl",
784784
self.LandUse,
@@ -814,7 +814,7 @@ def initial(self):
814814
subcatch,
815815
self.Soil,
816816
2.0,
817-
) # maximum capillary rise from runoff response routine to soil moisture routine
817+
) * self.timestepsecs / self.basetimestep # maximum capillary rise from runoff response routine to soil moisture routine
818818
self.ICF = self.readtblDefault(
819819
self.Dir + "/" + self.intbl + "/ICF.tbl",
820820
self.LandUse,
@@ -871,7 +871,7 @@ def initial(self):
871871
subcatch,
872872
self.Soil,
873873
3.75653,
874-
)
874+
) * self.timestepsecs / self.basetimestep
875875
# WHC= 0.10000 # fraction of Snowvolume that can store water
876876
self.WHC = self.readtblDefault(
877877
self.Dir + "/" + self.intbl + "/WHC.tbl",

0 commit comments

Comments
 (0)