CreateInputsCrit.Rd 5.86 KB
Newer Older
Delaigue Olivier's avatar
Delaigue Olivier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
\encoding{UTF-8}
\name{CreateInputsCrit}
\alias{CreateInputsCrit}
\title{Creation of the InputsCrit object required to the ErrorCrit functions}
\usage{
CreateInputsCrit(FUN_CRIT, InputsModel, RunOptions, Qobs, BoolCrit = NULL,
  transfo = "", Ind_zeroes = NULL, epsilon = NULL)
}
\arguments{
\item{FUN_CRIT}{[function] error criterion function (e.g. ErrorCrit_RMSE, ErrorCrit_NSE)}

\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}

16
\item{Qobs}{[numeric] series of observed discharges [mm/time step]}
Delaigue Olivier's avatar
Delaigue Olivier committed
17
18
19
20
21

\item{BoolCrit}{(optional) [boolean] boolean giving the time steps to consider in the computation (all time steps are consider by default)}

\item{transfo}{(optional) [character] name of the transformation (e.g. "", "sqrt", "log", "inv", "sort")}

22
\item{Ind_zeroes}{(optional) [numeric] indices of the time steps where zeroes are observed}
Delaigue Olivier's avatar
Delaigue Olivier committed
23
24
25
26
27
28

\item{epsilon}{(optional) [numeric] epsilon to add to all Qobs and Qsim if \emph{$Ind_zeroes} is not empty}
}
\value{
[list] object of class \emph{InputsCrit} containing the data required to evaluate the model outputs; it can include the following:
         \tabular{ll}{
29
30
         \emph{$BoolCrit  }  \tab   [boolean] boolean giving the time steps considered in the computation \cr
         \emph{$Qobs      }  \tab   [numeric] series of observed discharges [mm/time step] \cr
Delaigue Olivier's avatar
Delaigue Olivier committed
31
         \emph{$transfo   }  \tab   [character] name of the transformation (e.g. "", "sqrt", "log", "inv", "sort") \cr
32
         \emph{$Ind_zeroes}  \tab   [numeric] indices of the time steps where zeroes are observed \cr
Delaigue Olivier's avatar
Delaigue Olivier committed
33
34
35
36
37
38
39
         \emph{$epsilon   }  \tab   [numeric] epsilon to add to all Qobs and Qsim if \emph{$Ind_zeroes} is not empty \cr
         }
}
\description{
Creation of the InputsCrit object required to the ErrorCrit functions.
}
\details{
Delaigue Olivier's avatar
Delaigue Olivier committed
40
Users wanting to use FUN_CRIT functions that are not included in 
Delaigue Olivier's avatar
Delaigue Olivier committed
41
42
43
the package must create their own InputsCrit object accordingly.
}
\examples{
44
45
## loading catchment data
library(airGR)
Delaigue Olivier's avatar
Delaigue Olivier committed
46
47
48
data(L0123001)

## preparation of the InputsModel object
49
50
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, 
                                 Precip = BasinObs$P, PotEvap = BasinObs$E)
Delaigue Olivier's avatar
Delaigue Olivier committed
51
52

## run period selection
53
54
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
55
56

## preparation of the RunOptions object
57
58
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J,
                               InputsModel = InputsModel, IndPeriod_Run = Ind_Run)
Delaigue Olivier's avatar
Delaigue Olivier committed
59
60

## simulation
61
62
63
Param <- c(734.568, -0.840, 109.809, 1.971)
OutputsModel <- RunModel(InputsModel = InputsModel, RunOptions = RunOptions, 
                         Param = Param, FUN = RunModel_GR4J)
Delaigue Olivier's avatar
Delaigue Olivier committed
64
65

## efficiency criterion: Nash-Sutcliffe Efficiency
66
67
68
69
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
70
71
72

## efficiency criterion: Nash-Sutcliffe Efficiency on log-transformed flows
transfo <- "log"
73
74
75
76
77
78
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, 
                               RunOptions = RunOptions, Qobs = BasinObs$Qmm[Ind_Run],
                               transfo = transfo)
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: Nash-Sutcliffe Efficiency above a threshold (q75\%)
81
82
83
84
85
86
87
BoolCrit <- rep(TRUE, length(BasinObs$Qmm[Ind_Run])); 
BoolCrit[BasinObs$Qmm[Ind_Run]<quantile(BasinObs$Qmm[Ind_Run], 0.75, na.rm = TRUE)] <- FALSE
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel, 
                               RunOptions = RunOptions, Qobs = BasinObs$Qmm[Ind_Run],
                               BoolCrit = BoolCrit)
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
88
89

## efficiency criterion: Kling-Gupta Efficiency
90
91
92
93
94
95
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 = ""))
cat(paste("SubCrit  ", OutputsCrit$SubCritNames, "  ",
          round(OutputsCrit$SubCritValues, 4), "\\n", sep = ""))
Delaigue Olivier's avatar
Delaigue Olivier committed
96
97
98

## efficiency criterion: Kling-Gupta Efficiency below a threshold (q10\%) on log-trqansformed flows
transfo  <- "log"
99
100
101
102
103
104
105
106
107
BoolCrit <- rep(TRUE, length(BasinObs$Qmm[Ind_Run])); 
BoolCrit[BasinObs$Qmm[Ind_Run]>quantile(BasinObs$Qmm[Ind_Run], 0.10, na.rm = TRUE)] <- FALSE
InputsCrit <- CreateInputsCrit(FUN_CRIT = ErrorCrit_KGE,
                               InputsModel = InputsModel,RunOptions = RunOptions, 
                               Qobs = BasinObs$Qmm[Ind_Run], BoolCrit = BoolCrit, transfo = transfo)
OutputsCrit <- ErrorCrit_KGE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
cat(paste("  Crit  ", OutputsCrit$CritName, "  ", round(OutputsCrit$CritValue, 4), "\\n", sep = ""))
cat(paste("SubCrit  ", OutputsCrit$SubCritNames, "  ",
          round(OutputsCrit$SubCritValues, 4), "\\n", sep = ""))
Delaigue Olivier's avatar
Delaigue Olivier committed
108
109
110
111
112
113
114
115
116
117


}
\author{
Laurent Coron (June 2014)
}
\seealso{
\code{\link{RunModel}}, \code{\link{CreateInputsModel}}, \code{\link{CreateRunOptions}}, \code{\link{CreateCalibOptions}}
}