CreateIniStates: Creation of the IniStates object possibly required by the...

View source: R/CreateIniStates.R

CreateIniStatesR Documentation

Creation of the IniStates object possibly required by the CreateRunOptions functions

Description

Creation of the IniStates object possibly required by the CreateRunOptions function.

Usage

CreateIniStates(FUN_MOD, InputsModel,
                IsHyst = FALSE, IsIntStore = FALSE,
                ProdStore = 350, RoutStore = 90,
                ExpStore = NULL, IntStore = NULL,
                UH1 = NULL, UH2 = NULL,
                GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
                GthrCemaNeigeLayers = NULL, GlocmaxCemaNeigeLayers = NULL,
                SD = NULL, verbose = TRUE)

Arguments

FUN_MOD

[function] hydrological model function (e.g. RunModel_GR4J, RunModel_CemaNeigeGR4J)

InputsModel

[object of class InputsModel] see CreateInputsModel for details

IsHyst

[boolean] boolean indicating if the hysteresis version of CemaNeige is used. See details

IsIntStore

[boolean] boolean indicating if the interception store is used in GR5H. See details

ProdStore

[numeric] production store level [mm] for all GR models except GR1A

RoutStore

[numeric] routing store level [mm] for all GR models except GR1A

ExpStore

(optional) [numeric] series of exponential store level (negative) [mm] for the GR6J model

IntStore

(optional) [numeric] series of rainfall neutralisation or interception store level [mm] for the GR5H model

UH1

(optional) [numeric] unit hydrograph 1 levels [mm]

UH2

(optional) [numeric] unit hydrograph 2 levels [mm]

GCemaNeigeLayers

(optional) [numeric] snow pack [mm], possibly used to create the CemaNeige model initial state

eTGCemaNeigeLayers

(optional) [numeric] snow pack thermal state [°C], possibly used to create the CemaNeige model initial state

GthrCemaNeigeLayers

(optional) [numeric] melt threshold [mm], possibly used to create the CemaNeige model initial state in case the Linear Hysteresis version is used

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

SD

(optional) [list] of [numeric] states of delayed upstream flows for semi-distributed models, the nature of the state and the unit depend on the model and the unit of the upstream flow

verbose

(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = TRUE

Details

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 models GR4H and GR5H). 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).
GCemaNeigeLayers and eTGCemaNeigeLayers require each numeric values as many as given in CreateInputsModel with the NLayers argument. eTGCemaNeigeLayers values can be negative.
The structure of the object of class IniStates returned is always exactly the same for all models (except for the unit hydrographs levels that contain more values with GR4H and GR5H), even if some states do not exist (e.g. $UH$UH1 for GR2M).
If CemaNeige is not used, $CemaNeigeLayers$G, $CemaNeigeLayers$eTG $CemaNeigeLayers$GthrCemaNeigeLayers and $CemaNeigeLayers$GlocmaxCemaNeigeLayers are set to NA.

Nota: the StateEnd objects from the outputs of RunModel* functions already respect the format given by the CreateIniStates function.

Value

[list] object of class IniStates containing the initial model internal states; it always includes the following:

$Store [numeric] list of store levels ($Prod, $Rout and $Exp)
$UH [numeric] list of unit hydrographs levels ($UH1 and $UH2)
$CemaNeigeLayers [numeric] list of CemaNeige variables ($G, $eTG, $GthrCemaNeigeLayers and $GlocmaxCemaNeigeLayers)

Author(s)

Olivier Delaigue

See Also

CreateRunOptions

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
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"))


### preparation of the IniStates object with low values of ProdStore and RoutStore
IniStates <- CreateIniStates(FUN_MOD = RunModel_GR4J, InputsModel = InputsModel,
                             ProdStore = 0, RoutStore = 0, 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)),
                             GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
                             GthrCemaNeigeLayers = NULL, GlocmaxCemaNeigeLayers = NULL)
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
Param <- c(X1 = 257.238, X2 = 1.012, X3 = 88.235, X4 = 2.208)
OutputsModel <- RunModel_GR4J(InputsModel = InputsModel,
                              RunOptions = RunOptions, Param = Param)

## 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)),
                             GCemaNeigeLayers = NULL, eTGCemaNeigeLayers = NULL,
                             GthrCemaNeigeLayers = NULL, GlocmaxCemaNeigeLayers = NULL)
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
Param <- c(X1 = 257.238, X2 = 1.012, X3 = 88.235, X4 = 2.208)
OutputsModel <- RunModel_GR4J(InputsModel = InputsModel,
                              RunOptions = RunOptions, Param = Param)

## results preview
plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run])

airGR documentation built on Oct. 26, 2023, 9:07 a.m.