Learn R Programming

airGR (version 1.7.6)

CreateInputsModel: Creation of the InputsModel object required to the RunModel functions

Description

Creation of the InputsModel object required to the RunModel* functions.

Usage

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 InputsModel [(x, i)

Value

[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

Arguments

FUN_MOD

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

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 = TRUE (the mean of the precipitation is kept to the original value)

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 = TRUE

Qupstream

(optional) [numerical matrix] time series of upstream flows (catchment average), its unit is defined by the QupstrUnit parameter, required to create the SD model inputs. See details

LengthHydro

(optional) [numeric] real giving the distance between the downstream outlet and each upstream inlet of the sub-catchment [km], required to create the SD model inputs . See details

BasinAreas

(optional) [numeric] real giving the area of each upstream sub-catchment [km2] and the area of the downstream sub-catchment in the last item, required to create the SD model inputs . See details

QupstrUnit

(optional) [character] unit of the flow in the argument Qupstream, available units are: "mm" for mm/time-step (default), "m3" for m3/time-step, "m3/s" and "l/s". See details

x

[InputsModel] object of class InputsModel

i

[integer] of the indices to subset a time series or [character] names of the elements to extract

Author

Laurent Coron

Details

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 semi-distributed (SD) model should provide valid Qupstream, LengthHydro, and BasinAreas arguments. Each upstream sub-catchment 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 sub-catchment. Upstream flows that are not related to a sub-catchment 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.

See Also

RunModel, CreateRunOptions, CreateInputsCrit, CreateCalibOptions, DataAltiExtrapolation_Valery

Examples

Run this code
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 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: Nash-Sutcliffe Efficiency
InputsCrit  <- CreateInputsCrit(FUN_CRIT = ErrorCrit_NSE, InputsModel = InputsModel,
                                RunOptions = RunOptions, Obs = BasinObs$Qmm[Ind_Run])
OutputsCrit <- ErrorCrit_NSE(InputsCrit = InputsCrit, OutputsModel = OutputsModel)

Run the code above in your browser using DataLab