Introduction

Introduction


Hydrological modeling packages in

  • topmodel
  • dynatopmodel
  • TUWmodel
  • Ecohydmod
  • hydromad (not on CRAN)
  • etc.

… and of course airGR & airGRteaching

Why these packages?


The models included are simple…

they can be coded from the publications so many versions in many languages exist.

Prone to code mistakes

Objectives of the packages:

  • the GR models development team controls the "official" version
  • modular functionalities
  • Fortran still used for the model cores (faster)
  • all other functions in R

airGR(teaching) Models & Tools

Models


GR hydrological models

Rainfall-runoff lumped models developed since the 90's at IRSTEA

  • annual: GR1A
  • month: GR2M
  • day: GR4J, GR5J, GR6J
  • hour: GR4H

Snow model

  • CemaNeige

Tools

Error criteria

  • RMSE
  • Nash-Sutcliffe
  • KGE
  • KGE'

Calibration algorithm

  • Housemade global then local optimisation

Dataset input

Dataset preparation


data.frame of 2 basins from 1985 to 2005

summary(dfObs)
##       Date                  P                  E         
##  Min.   :1985-01-01   Min.   : 0.00000   Min.   :0.0000  
##  1st Qu.:1990-01-01   1st Qu.: 0.04297   1st Qu.:0.4354  
##  Median :1995-01-01   Median : 0.90565   Median :1.0481  
##  Mean   :1995-01-01   Mean   : 3.28253   Mean   :1.2721  
##  3rd Qu.:2000-01-01   3rd Qu.: 4.19317   3rd Qu.:1.9221  
##  Max.   :2004-12-31   Max.   :63.58900   Max.   :5.7799  
##                                                          
##       Qmm                 T             Basin     
##  Min.   : 0.03988   Min.   :-13.668   12001:7305  
##  1st Qu.: 0.62357   1st Qu.:  4.254   50002:7305  
##  Median : 1.42465   Median :  7.986               
##  Mean   : 2.25734   Mean   :  7.814               
##  3rd Qu.: 2.76480   3rd Qu.: 11.480               
##  Max.   :38.97774   Max.   : 24.174               
##  NA's   :1

aiGRteaching

airGRteaching overview

Coding can be a hard task for some students

  • slows down the understanding of the concepts presented during courses
  • limited time to teach programming


airGRteaching contains only very basic functions

B12001 <- dfObs[dfObs$Basin == "12001", 
                c("Date", "P", "E", "Qmm", "T")]
PREP <- PrepGR(ObsDF = B12001, 
               HydroModel = "GR4J", CemaNeige = TRUE)

airGRteaching graphical functions


dyplot(): dynamic chart to explore data

dyplot(PREP)

airGRteaching calibration


Model calibration on a given period, with the KGE' criterion

CAL <- CalGR(PrepGR = PREP, CalCrit = "KGE2",
             WupPer = c("1989-01-01", "1989-12-31"), 
             CalPer = c("1990-01-01", "1993-12-31"))
## Grid-Screening in progress (0% 20% 40% 60% 80% 100%)
##   Screening completed (729 runs)
##       Param =  432.681 ,   -0.020 ,   20.697 ,    1.417 ,    0.002 ,    4.961
##       Crit KGE'[Q]      = 0.8025
## Steepest-descent local search in progress
##   Calibration completed (36 iterations, 1138 runs)
##       Param =  320.368 ,    0.405 ,   35.589 ,    1.191 ,    0.002 ,    4.589
##       Crit KGE'[Q]      = 0.8518

airGRteaching calibration


Plotting calibration process

plot(CAL, which = "iter")

airGRteaching calibration


Plotting performances

plot(CAL, which = "perf")

airGRteaching simulation


To check if the calibration is correct, we can perform an evaluation on an independent period (Klemes split-sample test)

SIM <- SimGR(PrepGR = PREP, CalGR = CAL, EffCrit = "KGE2",
             WupPer = c("1993-01-01", "1993-12-31"),
             SimPer = c("1994-01-01", "1998-12-31"))
## Crit. KGE'[Q] = 0.8679
##  SubCrit. KGE'[Q] cor(sim, obs, "pearson") = 0.8941 
##  SubCrit. KGE'[Q] cv(sim)/cv(obs)          = 1.0469 
##  SubCrit. KGE'[Q] mean(sim)/mean(obs)      = 0.9365

airGRteaching simulation


Plotting the resulting discharge time series

dyplot(SIM)

airGRteaching Shiny interface


List of 2 basins data.frame

colSelect <- c("Date", "P", "E", "Qmm", "T")
listObs <- list(B12001 = dfObs[dfObs$Basin == "12001", colSelect],
                B50002 = dfObs[dfObs$Basin == "50002", colSelect])


Launching the Shiny interface for 2 basins

ShinyGR(ObsDF = listObs,
        SimPer = list(c("1994-01-01", "1998-12-31"),
                      c("1994-01-01", "1998-12-31")))


Only daily models available

Possibility to put the GUI on the Web with a Shiny server

airGR

airGR overview



airGR allows for more advanced or systematic tests

Use of:

  • bootstrap technique for calibration
  • additional calibration algorithms

Possibility to set:

  • some model parameters
  • initial reservoir levels
  • internal states
  • etc.

Tutorial

https://webgr.irstea.fr/airGR-website

Options

Use of optimisation algorithms from other R packages

See the "V02.1_param_optim" vignette for implementation

optDE <- DEoptim::DEoptim(fn = OptimGR4J,
                          lower = lowerGR4J, upper = upperGR4J)
optPSO <- hydroPSO::hydroPSO(fn = OptimGR4J,
                             lower = lowerGR4J, upper = upperGR4J)

Conclusion

Final words


airGRteaching can be used to:

  • play with the models parameters or understand the models components
  • help someone very bad at coding to make hydrological modeling


airGR can be used to:

  • make more advanced hydrological modeling
  • plug the rainfall-runoff models with your own tools

License: GPL-2

Coron, L., Thirel, G., Delaigue, O., Perrin, C., Andréassian, V., 2017: The Suite of Lumped GR Hydrological Models in an R package, Environmental Modelling & Software, 94, 166-171, DOI: 10.1016/j.envsoft.2017.05.002.

Contact: airGR@irstea.fr