View source: R/CreateInputsModel.R
CreateInputsModel  R Documentation 
Creation of the InputsModel object required to the RunModel*
functions.
CreateInputsModel(FUN_MOD, DatesR, Precip, PrecipScale = TRUE, PotEvap = NULL,
TempMean = NULL, TempMin = NULL, TempMax = NULL,
ZInputs = NULL, HypsoData = NULL, NLayers = 5,
Qupstream = NULL, LengthHydro = NULL, BasinAreas = NULL,
QupstrUnit = "mm", verbose = TRUE)
## S3 method for class 'InputsModel'
x[i]
FUN_MOD 
[function] hydrological model function (e.g. 
DatesR 
[POSIXt] vector of dates required to create the GR model and CemaNeige module inputs 
Precip 
[numeric] time series of total precipitation (catchment average) [mm/time step], required to create the GR model and CemaNeige module inputs 
PrecipScale 
(optional) [boolean] indicating if the mean of the precipitation interpolated on the elevation layers must be kept or not, required to create CemaNeige module inputs, default = 
PotEvap 
[numeric] time series of potential evapotranspiration (catchment average) [mm/time step], required to create the GR model inputs 
TempMean 
(optional) [numeric] time series of mean air temperature [°C], required to create the CemaNeige module inputs 
TempMin 
(optional) [numeric] time series of min air temperature [°C], possibly used to create the CemaNeige module inputs 
TempMax 
(optional) [numeric] time series of max air temperature [°C], possibly used to create the CemaNeige module inputs 
ZInputs 
(optional) [numeric] real giving the mean elevation of the Precip and Temp series (before extrapolation) [m], possibly used to create the CemaNeige module inputs 
HypsoData 
(optional) [numeric] vector of 101 reals: min, q01 to q99 and max of catchment elevation distribution [m], if not defined a single elevation is used for CemaNeige 
NLayers 
(optional) [numeric] integer giving the number of elevation layers requested [], required to create CemaNeige module inputs, default=5 
verbose 
(optional) [boolean] boolean indicating if the function is run in verbose mode or not, default = 
Qupstream 
(optional) [numerical matrix] time series of upstream flows (catchment average), its unit is defined by the 
LengthHydro 
(optional) [numeric] real giving the distance between the downstream outlet and each upstream inlet of the subcatchment [km], required to create the SD model inputs . See details 
BasinAreas 
(optional) [numeric] real giving the area of each upstream subcatchment [km2] and the area of the downstream subcatchment in the last item, required to create the SD model inputs . See details 
QupstrUnit 
(optional) [character] unit of the flow in the argument 
x 
[InputsModel] object of class InputsModel 
i 
[integer] of the indices to subset a time series or [character] names of the elements to extract 
Users wanting to use FUN_MOD
functions that are not included in
the package must create their own InputsModel object accordingly.
Please note that if CemaNeige is used, and ZInputs
is different than HypsoData
, then precipitation and temperature are interpolated with the DataAltiExtrapolation_Valery
function.
Users wanting to use a semidistributed (SD) model should provide valid Qupstream
, LengthHydro
, and BasinAreas
arguments. Each upstream subcatchment is described by an upstream flow time series (one column in Qupstream
matrix), a distance between the downstream outlet and the upstream inlet (one item in LengthHydro
) and an area (one item in BasinAreas
).
The order of the columns or of the items should be consistent for all these parameters.
BasinAreas
should contain one extra information (stored in the last item) which is the area of the downstream subcatchment.
Upstream flows that are not related to a subcatchment such as release or withdraw spots are identified by an area equal to NA
, and if unit="mm"
the upstream flow must be expressed in m3/time step instead of mm/time step which is not possible in absence of a related area.
Please note that the use of SD model requires to use the RunModel
function instead of RunModel_GR4J
or the other RunModel_*
functions.
[list] object of class InputsModel containing the data required to evaluate the model outputs; it can include the following:
$DatesR  [POSIXlt] vector of dates 
$Precip  [numeric] time series of total precipitation (catchment average) [mm/time step] 
$PotEvap  [numeric] time series of potential evapotranspiration (catchment average) [mm/time step], 
defined if FUN_MOD includes GR4H, GR5H, GR4J, GR5J, GR6J, GR2M or GR1A  
$LayerPrecip  [list] list of time series of precipitation (layer average) [mm/time step], 
defined if FUN_MOD includes CemaNeige 

$LayerTempMean  [list] list of time series of mean air temperature (layer average) [°C], 
defined if FUN_MOD includes CemaNeige 

$LayerFracSolidPrecip  [list] list of time series of solid precipitation fraction (layer average) [], 
defined if FUN_MOD includes CemaNeige 

Laurent Coron
RunModel
, CreateRunOptions
, CreateInputsCrit
,
CreateCalibOptions
, DataAltiExtrapolation_Valery
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")=="19900101"),
which(format(BasinObs$DatesR, format = "%Y%m%d")=="19991231"))
## preparation of the RunOptions object
RunOptions < CreateRunOptions(FUN_MOD = RunModel_GR4J,
InputsModel = InputsModel, IndPeriod_Run = Ind_Run)
## simulation
Param < c(X1 = 734.568, X2 = 0.840, X3 = 109.809, X4 = 1.971)
OutputsModel < RunModel(InputsModel = InputsModel,
RunOptions = RunOptions, Param = Param,
FUN_MOD = RunModel_GR4J)
## results preview
plot(OutputsModel, Qobs = BasinObs$Qmm[Ind_Run])
## efficiency criterion: NashSutcliffe Efficiency
InputsCrit < CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel,
RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
OutputsCrit < ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.