Calibration.Rd 4.25 KB
Newer Older
Delaigue Olivier's avatar
Delaigue Olivier committed
1
2
3
\encoding{UTF-8}
\name{Calibration}
\alias{Calibration}
4
\title{Calibration algorithm which optimises the error criterion selected as objective function using the provided functions}
Delaigue Olivier's avatar
Delaigue Olivier committed
5
6
\usage{
Calibration(InputsModel, RunOptions, InputsCrit, CalibOptions, FUN_MOD,
7
  FUN_CRIT, FUN_CALIB = Calibration_Michel, FUN_TRANSFO = NULL,
8
  verbose = TRUE)
Delaigue Olivier's avatar
Delaigue Olivier committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
}
\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)}

23
\item{FUN_CALIB}{(optional) [function] calibration algorithm function (e.g. Calibration_Michel), default=Calibration_Michel}
Delaigue Olivier's avatar
Delaigue Olivier committed
24
25
26

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

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

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

## calibration period selection
45
46
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
47
48

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

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

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

## calibration
60
61
62
63
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
64
65
66

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

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

## efficiency criterion: Nash-Sutcliffe Efficiency
74
75
76
77
78
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
79
80

## efficiency criterion: Kling-Gupta Efficiency
81
82
83
84
85
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
86
87
88
89
90
91
92


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