Severn_02: Calibration of a GR4J semi-distributed model network"

knitr::opts_chunk$set(
  comment = "#>",
  fig.width = 6,
  fig.asp = 0.68,
  out.width = "70%",
  fig.align = "center"
)

airGRiwrm automates the execution of airGR semi-distributed models. The steps for running or calibrating the model are the same as the ones of 'airGR'.

Load library

library(airGRiwrm)

Preparation of function inputs

To run a model, as for airGR, the functions of the airGRiwrm package (e.g. the models, calibration and criteria calculation functions) require data and options with specific formats.

To facilitate the use of the package, there are several functions dedicated to the creation of these objects:

GRiwrmInputsModel object

The method used for producing the GRiwrmInputsModel object is detailed in the vignette "V01_Structure_SD_model" of the package. The following code chunk resumes all the steps of this vignette:

data(Severn)
nodes <- Severn$BasinsInfo[, c("gauge_id", "downstream_id", "distance_downstream", "area")]
nodes$model <- "RunModel_GR4J"
griwrm <- CreateGRiwrm(nodes, list(id = "gauge_id", down = "downstream_id", length = "distance_downstream"))
BasinsObs <- Severn$BasinsObs
DatesR <- BasinsObs[[1]]$DatesR
PrecipTot <- cbind(sapply(BasinsObs, function(x) {x$precipitation}))
PotEvapTot <- cbind(sapply(BasinsObs, function(x) {x$peti}))
Qobs <- cbind(sapply(BasinsObs, function(x) {x$discharge_spec}))
Precip <- ConvertMeteoSD(griwrm, PrecipTot)
PotEvap <- ConvertMeteoSD(griwrm, PotEvapTot)
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap)
str(InputsModel)

GRiwrmRunOptions object

The CreateRunOptions() function allows to prepare the options required for the RunModel() function.

The user must at least define the following arguments:

Below, we define a one-year warm up period and we start the run period just after the warm up period.

IndPeriod_Run <- seq(
  which(InputsModel[[1]]$DatesR == (InputsModel[[1]]$DatesR[1] + 365*24*60*60)), # Set aside warm-up period
  length(InputsModel[[1]]$DatesR) # Until the end of the time series
)
IndPeriod_WarmUp <- seq(1, IndPeriod_Run[1] - 1)

Arguments of the CreateRunOptions function for airGRiwrm are the same as for the function in airGR and are copied for each node running a rainfall-runoff model.

RunOptions <- CreateRunOptions(
  InputsModel,
  IndPeriod_WarmUp = IndPeriod_WarmUp,
  IndPeriod_Run = IndPeriod_Run
)

GRiwrmInputsCrit object

The CreateInputsCrit() function allows to prepare the input in order to calculate a criterion. We use composed criterion with a parameter regularization based on @delavenneRegularizationApproachImprove2019.

It needs the following arguments:

InputsCrit <- CreateInputsCrit(
  InputsModel = InputsModel,
  FUN_CRIT = ErrorCrit_KGE2,
  RunOptions = RunOptions,
  Obs = Qobs[IndPeriod_Run, ],
  AprioriIds = c(
      "54057" = "54032",
      "54032" = "54001",
      "54001" = "54095"
  ),
  transfo = "sqrt",
  k = 0.15
)
str(InputsCrit)

GRiwrmCalibOptions object

Before using the automatic calibration tool, the user needs to prepare the calibration options with the CreateCalibOptions() function. The GRiwrmInputsModel argument contains all the necessary information:

CalibOptions <- CreateCalibOptions(InputsModel)

Calibration

The airGR calibration process is applied on each node of the GRiwrm network from upstream nodes to downstream nodes.

OutputsCalib <- suppressWarnings(
  Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions))

Run the model with the optimized model parameters

OutputsModels <- RunModel(
  InputsModel,
  RunOptions = RunOptions,
  Param = extractParam(OutputsCalib)
)

Plot the results for each basin

plot(OutputsModels, Qobs = Qobs[IndPeriod_Run,])

The resulting flows of each node in m3/s are directly available and can be plotted with these commands:

Qm3s <- attr(OutputsModels, "Qm3s")
plot(Qm3s[1:150,])


Try the airGRiwrm package in your browser

Any scripts or data that you put into this service are public.

airGRiwrm documentation built on Sept. 23, 2024, 1:08 a.m.