Calibration.Rd 4.45 KB
Newer Older
Delaigue Olivier's avatar
Delaigue Olivier committed
1
% Generated by roxygen2: do not edit by hand
Delaigue Olivier's avatar
Delaigue Olivier committed
2
3
4
5
% Please edit documentation in R/Calibration.R
\encoding{UTF-8}
\name{Calibration}
\alias{Calibration}
6
\title{Calibration algorithm which optimises the error criterion selected as objective function using the provided functions}
Delaigue Olivier's avatar
Delaigue Olivier committed
7
8
\usage{
Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD,
9
  FUN_CRIT, FUN_CALIB = Calibration_Michel, FUN_TRANSFO = NULL,
Delaigue Olivier's avatar
Delaigue Olivier committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  quiet = FALSE)
}
\arguments{
\item{InputsModel}{[object of class \emph{InputsModel}] see \code{\link{CreateInputsModel}} for details}

\item{RunOptions}{[object of class \emph{RunOptions}] see \code{\link{CreateRunOptions}} for details}

\item{InputsCrit}{[object of class \emph{InputsCrit}] see \code{\link{CreateInputsCrit}} for details}

\item{CalibOptions}{[object of class \emph{CalibOptions}] see \code{\link{CreateCalibOptions}} for details}

\item{FUN_MOD}{[function] hydrological model function (e.g. RunModel_GR4J, RunModel_CemaNeigeGR4J)}

\item{FUN_CRIT}{[function] error criterion function (e.g. ErrorCrit_RMSE, ErrorCrit_NSE)}

25
\item{FUN_CALIB}{(optional) [function] calibration algorithm function (e.g. Calibration_Michel, Calibration_optim), default=Calibration_Michel}
Delaigue Olivier's avatar
Delaigue Olivier committed
26
27
28
29
30
31

\item{FUN_TRANSFO}{(optional) [function] model parameters transformation function, if the FUN_MOD used is native in the package FUN_TRANSFO is automatically defined}

\item{quiet}{(optional) [boolean] boolean indicating if the function is run in quiet mode or not, default=FALSE}
}
\value{
32
[list] see \code{\link{Calibration_Michel}} or \code{\link{Calibration_optim}}
Delaigue Olivier's avatar
Delaigue Olivier committed
33
34
}
\description{
35
Calibration algorithm which optimises the error criterion selected as objective function using the provided functions. \cr
Delaigue Olivier's avatar
Delaigue Olivier committed
36
37
}
\examples{
38
39
## loading catchment data
library(airGR)
Delaigue Olivier's avatar
Delaigue Olivier committed
40
41
42
data(L0123001)

## preparation of InputsModel object
43
44
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, 
                                 Precip = BasinObs$P, PotEvap = BasinObs$E)
Delaigue Olivier's avatar
Delaigue Olivier committed
45
46

## calibration period selection
47
48
Ind_Run <- seq(which(format(BasinObs$DatesR, format = "\%d/\%m/\%Y \%H:\%M")=="01/01/1990 00:00"), 
               which(format(BasinObs$DatesR, format = "\%d/\%m/\%Y \%H:\%M")=="31/12/1999 00:00"))
Delaigue Olivier's avatar
Delaigue Olivier committed
49
50

## preparation of RunOptions object
51
52
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
                               InputsModel = InputsModel, IndPeriod_Run = Ind_Run)
Delaigue Olivier's avatar
Delaigue Olivier committed
53
54

## calibration criterion: preparation of the InputsCrit object
55
56
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, 
                               RunOptions = RunOptions, Qobs = BasinObs$Qmm[Ind_Run])
Delaigue Olivier's avatar
Delaigue Olivier committed
57
58

## preparation of CalibOptions object
59
CalibOptions <- CreateCalibOptions(FUN_MOD = RunModel_GR4J, FUN_CALIB = Calibration_Michel)
Delaigue Olivier's avatar
Delaigue Olivier committed
60
61

## calibration
62
63
64
65
OutputsCalib <- Calibration(InputsModel = InputsModel, RunOptions = RunOptions,
                            InputsCrit = InputsCrit,  CalibOptions = CalibOptions,
                            FUN_MOD = RunModel_GR4J, FUN_CRIT = ErrorCrit_NSE, 
                            FUN_CALIB = Calibration_Michel)
Delaigue Olivier's avatar
Delaigue Olivier committed
66
67
68

## simulation
Param <- OutputsCalib$ParamFinalR
69
70
OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions, 
                         Param = Param, FUN = RunModel_GR4J)
Delaigue Olivier's avatar
Delaigue Olivier committed
71
72

## results preview
73
plot_OutputsModel(OutputsModel = OutputsModel, Qobs = BasinObs$Qmm[Ind_Run])
Delaigue Olivier's avatar
Delaigue Olivier committed
74
75

## efficiency criterion: Nash-Sutcliffe Efficiency
76
77
78
79
80
InputsCrit  <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, 
                                RunOptions = RunOptions, Qobs = BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
cat(paste("  Crit  ", OutputsCrit$CritName, "  ",
          round(OutputsCrit$CritValue, 4), "\\n", sep = ""))
Delaigue Olivier's avatar
Delaigue Olivier committed
81
82

## efficiency criterion: Kling-Gupta Efficiency
83
84
85
86
87
InputsCrit  <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE, InputsModel = InputsModel, 
                                RunOptions = RunOptions, Qobs = BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
cat(paste("  Crit  ", OutputsCrit$CritName, "  ",
          round(OutputsCrit$CritValue, 4), "\\n", sep = ""))
Delaigue Olivier's avatar
Delaigue Olivier committed
88
89
90
91
92
93
94


}
\author{
Laurent Coron (June 2014)
}
\seealso{
95
\code{\link{Calibration_Michel}}, \code{\link{Calibration_optim}},
Delaigue Olivier's avatar
Delaigue Olivier committed
96
         \code{\link{RunModel}}, \code{\link{ErrorCrit}}, \code{\link{TransfoParam}},
Delaigue Olivier's avatar
Delaigue Olivier committed
97
         \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, 
Delaigue Olivier's avatar
Delaigue Olivier committed
98
99
100
         \code{\link{CreateInputsCrit}}, \code{\link{CreateCalibOptions}}.
}