Lumped Model Run

To run the HBV lumped model inside Hapi you need to prepare the meteorological inputs (rainfall, temperature and potential evapotranspiration), HBV parameters, and the HBV model (you can load Bergström, 1992 version of HBV from Hapi )

  • First load the prepared lumped version of the HBV module inside Hapi, the triangular routing function and the wrapper function that runs the lumped model RUN.

1import Hapi.rrm.hbv_bergestrom92 as HBVLumped
2from Hapi.run import Run
3from Hapi.catchment import Catchment
4from Hapi.rrm.routing import Routing
  • read the meteorological data, data has be in the form of numpy array with the following order [rainfall, ET, Temp, Tm], ET is the potential evapotranspiration, Temp is the temperature (C), and Tm is the long term monthly average temperature.

1Parameterpath = Comp + "/data/lumped/Coello_Lumped2021-03-08_muskingum.txt"
2MeteoDataPath = Comp + "/data/lumped/meteo_data-MSWEP.csv"
3
4### meteorological data
5start = "2009-01-01"
6end = "2011-12-31"
7name = "Coello"
8Coello = Catchment(name, start, end)
9Coello.readLumpedInputs(MeteoDataPath)
  • Meteorological data

1start = "2009-01-01"
2end = "2011-12-31"
3name = "Coello"
4Coello = Catchment(name, start, end)
5Coello.readLumpedInputs(MeteoDataPath)
  • Lumped model

    prepare the initial conditions, cathcment area and the lumped model.

1# catchment area
2AreaCoeff = 1530
3# [Snow pack, Soil moisture, Upper zone, Lower Zone, Water content]
4InitialCond = [0,10,10,10,0]
5
6Coello.readLumpedModel(HBVLumped, AreaCoeff, InitialCond)
  • Load the pre-estimated parameters

    snow option (if you want to simulate snow accumulation and snow melt or not)

1Snow = 0 # no snow subroutine
2# if routing using Maxbas True, if Muskingum False
3Coello.readParameters(Parameterpath, Snow)
  • Prepare the routing options.

1# RoutingFn = Routing.TriangularRouting2
2RoutingFn = Routing.Muskingum_V
3Route = 1
  • now all the data required for the model are prepared in the right form, now you can call the runLumped wrapper to initiate the calculation

1Run.runLumped(Coello, Route, RoutingFn)

to calculate some metrics for the quality assessment of the calculate discharge the performancecriteria contains some metrics like RMSE, NSE, KGE and WB , you need to load it, a measured time series of doscharge for the same period of the simulation is also needed for the comparison.

all methods in performancecriteria takes two numpy arrays of the same length and return real number.

To plot the calculated and measured discharge import matplotlib

1gaugei = 0
2plotstart = "2009-01-01"
3plotend = "2011-12-31"
4Coello.plotHydrograph(plotstart, plotend, gaugei, Title= "Lumped Model")
5
6
7.. image:: /img/lumpedmodel.png
8:width: 400pt
  • To save the results

1StartDate = "2009-01-01"
2EndDate = "2010-04-20"
3
4Path = SaveTo + "Results-Lumped-Model" + str(dt.datetime.now())[0:10] + ".txt"
5Coello.saveResults(Result=5, StartDate=StartDate, EndDate=EndDate, Path=Path)