CreateIniStates.Rd 6.32 KB
Newer Older
1
2
3
4
5
6
7
\encoding{UTF-8}


\name{CreateIniStates}
\alias{CreateIniStates}


8
\title{Creation of the IniStates object possibly required by the CreateRunOptions functions}
9
10
11


\usage{
12
CreateIniStates(FUN_MOD, InputsModel, IsHyst = FALSE,
13
  ProdStore = 350, RoutStore = 90, ExpStore = NULL,
14
15
  UH1 = NULL, UH2 = NULL,
  GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
16
  GthrCemaNeigeLayers = NULL, GlocmaxCemaNeigeLayers = NULL,
17
18
19
20
21
22
23
  verbose = TRUE)
}


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

24
\item{InputsModel}{[object of class \code{InputsModel}] see \code{\link{CreateInputsModel}} for details}
25

26
27
\item{IsHyst}{[boolean] boolean indicating if the hysteresis version of CemaNeige is used. See details}

28
\item{ProdStore}{[numeric] production store level [mm]}
29

30
\item{RoutStore}{[numeric] routing store level [mm]}
31

32
\item{ExpStore}{(optional) [numeric] series of exponential store level (negative) [mm] for the GR6J model}
33

34
\item{UH1}{(optional) [numeric] unit hydrograph 1 levels [mm]}
35

36
\item{UH2}{(optional) [numeric] unit hydrograph 2 levels [mm]}
37

38
\item{GCemaNeigeLayers}{(optional) [numeric] snow pack [mm], possibly used to create the CemaNeige model initial state}
39

40
\item{eTGCemaNeigeLayers}{(optional) [numeric] snow pack thermal state [°C], possibly used to create the CemaNeige model initial state}
41

42
\item{GthrCemaNeigeLayers}{(optional) [numeric] melt threshold [mm], possibly used to create the CemaNeige model initial state in case the linear hysteresis version is used}
43

44
\item{GlocmaxCemaNeigeLayers}{(optional) [numeric] local melt threshold for hysteresis [mm], possibly used to create the CemaNeige model initial state in case the linear hysteresis version is used}
45

46
\item{verbose}{(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = \code{TRUE}}
47
48
49
50
51

}


\value{
52
[list] object of class \code{IniStates} containing the initial model internal states; it always includes the following:
53
54
55
56
57
  \tabular{ll}{
    \emph{$Store          } \tab [numeric] list of store levels (\emph{$Prod}, \emph{$Rout} and \emph{$Exp}) \cr
    \emph{$UH             } \tab [numeric] list of unit hydrographs levels (\emph{$UH1} and \emph{$UH2}) \cr
    \emph{$CemaNeigeLayers} \tab [numeric] list of CemaNeige variables (\emph{$G} and \emph{$eTG})
  }
58
59
60
61
}


\description{
62
Creation of the \emph{IniStates} object possibly required by the \code{\link{CreateRunOptions}} function.
63
64
65
}

\details{
66
20 numeric values are required for UH1 and 40 numeric values are required for UH2 if GR4J, GR5J or GR6J are used (respectively 20*24 and 40*24 for the hourly model GR4H).Please note that depending on the X4 parameter value that will be provided when running the model, not all the values may be used (only the first int(X4)+1 values are used for UH1 and the first 2*int(X4)+1 for UH2). \cr
67
\code{GCemaNeigeLayers} and \code{eTGCemaNeigeLayers} require each numeric values as many as given in \code{\link{CreateInputsModel}} with the \code{NLayersargument}. \code{eTGCemaNeigeLayers} values can be negatives.\cr
68
69
The structure of the object of class \code{IniStates} returned is always exactly the same for all models (except for the unit hydrographs levels that contain more values with GR4H), even if some states do nt exist (e.g. \emph{$UH$UH1} for GR2M).  \cr
If CemaNeige is not used, \emph{$CemaNeigeLayers$G} and \emph{$CemaNeigeLayers$eTG} are set to \code{NA}. \cr
70
71

Nota: the \code{StateEnd} objects from the outputs of \code{RunModel*} functions already respect the format given by the \code{CreateIniStates} function. 
72
73
74
75
76
77
78
79
80
81
82
83
84
85
}


\examples{
library(airGR)

## loading catchment data
data(L0123001)

## preparation of the InputsModel object
InputsModel <- CreateInputsModel(FUN_MOD = RunModel_GR4J, DatesR = BasinObs$DatesR, 
                                 Precip = BasinObs$P, PotEvap = BasinObs$E)

## run period selection
86
87
Ind_Run <- seq(which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1990-01-01"), 
               which(format(BasinObs$DatesR, format = "\%Y-\%m-\%d")=="1999-12-31"))
88
89


90
### preparation of the IniStates object with low values of ProdStore and RoutStore
91
IniStates <- CreateIniStates(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel,
92
                             ProdStore = 0, RoutStore = 0, ExpStore = NULL,
93
94
                             UH1 = c(0.52, 0.54, 0.15, rep(0, 17)),
                             UH2 = c(0.057, 0.042, 0.015, 0.005, rep(0, 36)),
95
96
                             GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
                             GthrCemaNeigeLayers = NULL, GlocmaxCemaNeigeLayers = NULL)
97
98
99
str(IniStates)  

## preparation of the RunOptions object
100
101
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel,
                               IndPeriod_WarmUp = 0L,
102
                               IndPeriod_Run = Ind_Run, IniStates = IniStates)
103
104
                               
## simulation
105
106
107
Param <- c(X1 = 257.238, X2 = 1.012, X3 = 88.235, X4 = 2.208)
OutputsModel <- RunModel_GR4J(InputsModel = InputsModel,
                              RunOptions = RunOptions, Param = Param)
108
109
110
111
112
113
114
115
116
117

## results preview
plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run])                               
  
  
### preparation of the IniStates object with high values of ProdStore and RoutStore
IniStates <- CreateIniStates(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel,
                             ProdStore = 450, RoutStore = 100, ExpStore = NULL,
                             UH1 = c(0.52, 0.54, 0.15, rep(0, 17)),
                             UH2 = c(0.057, 0.042, 0.015, 0.005, rep(0, 36)),
118
119
                             GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
                             GthrCemaNeigeLayers = NULL, GlocmaxCemaNeigeLayers = NULL)
120
121
122
123
124
125
126
127
str(IniStates)  

## preparation of the RunOptions object
RunOptions <- CreateRunOptions(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel,
                               IndPeriod_WarmUp = 0L,
                               IndPeriod_Run = Ind_Run, IniStates = IniStates)
                               
## simulation
128
129
130
Param <- c(X1 = 257.238, X2 = 1.012, X3 = 88.235, X4 = 2.208)
OutputsModel <- RunModel_GR4J(InputsModel = InputsModel,
                              RunOptions = RunOptions, Param = Param)
131
132
133

## results preview
plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run]) 
134
135
136
137
138
139
140
141
142
143
144
}


\author{
Olivier Delaigue
}


\seealso{
\code{\link{CreateRunOptions}}
}