Skip to contents

Creation of an InputsModel object for an airGRiwrm network

Usage

# S3 method for class 'GRiwrm'
CreateInputsModel(
  x,
  DatesR,
  Precip = NULL,
  PotEvap = NULL,
  Qinf = NULL,
  Qobs = NULL,
  Qmin = NULL,
  Qrelease = NULL,
  PrecipScale = TRUE,
  TempMean = NULL,
  TempMin = NULL,
  TempMax = NULL,
  ZInputs = NULL,
  HypsoData = NULL,
  NLayers = 5,
  IsHyst = FALSE,
  FUN_REGUL = NULL,
  ...
)

Arguments

x

GRiwrm object containing diagram of the semi-distributed model (See CreateGRiwrm)

DatesR

POSIXt vector of dates

Precip

(optional) matrix or data.frame of numeric containing precipitation in [mm per time step]. Column names correspond to node IDs

PotEvap

(optional) matrix or data.frame of numeric containing potential evaporation [mm per time step]. Column names correspond to node IDs

Qinf

(optional) matrix or data.frame of numeric containing observed flows. It must be provided only for nodes of type "Direct injection" and "Diversion". See CreateGRiwrm for details about these node types. Unit is [mm per time step] for nodes with an area, and [m³ per time step] for nodes with area=NA. Column names correspond to node IDs. Negative flows are abstracted from the model and positive flows are injected to the model

Qobs

(deprecated) use Qinf instead

Qmin

(optional) matrix or data.frame of numeric containing minimum flows that must be provided downstream of a node with a Diversion [m³ per time step]. Default is zero. Column names correspond to node IDs

Qrelease

(optional) matrix or data.frame of numeric containing targeted release flows by nodes using the RunModel_Reservoir model [m³ per time step]. Column names correspond to node IDs

PrecipScale

(optional) logical vector 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). Column names correspond to node IDs

TempMean

(optional) matrix or data.frame of time series of mean air temperature [°C], required to create the CemaNeige module inputs. Column names correspond to node IDs

TempMin

(optional) matrix or data.frame of time series of minimum air temperature [°C], possibly used to create the CemaNeige module inputs. Column names correspond to node IDs

TempMax

(optional) matrix or data.frame of time series of maximum air temperature [°C], possibly used to create the CemaNeige module inputs. Column names correspond to node IDs

ZInputs

(optional) numeric vector giving the mean elevation of the Precip and Temp series (before extrapolation) [m], possibly used to create the CemaNeige module input. Column names correspond to node IDs

HypsoData

(optional) matrix or data.frame containing 101 numeric rows: min, q01 to q99 and max of catchment elevation distribution [m], if not defined a single elevation is used for CemaNeige. Column names correspond to node IDs

NLayers

(optional) numeric vector (integer) giving the number of elevation layers requested [-], required to create CemaNeige module inputs, default=5. Column names correspond to node IDs

IsHyst

logical indicating if the hysteresis version of CemaNeige is used. See details of airGR::CreateRunOptions().

FUN_REGUL

list of functions for local regulation (See details)

...

used for compatibility with S3 methods

Value

A GRiwrmInputsModel object which is a list of InputsModel objects created by airGR::CreateInputsModel() with one item per modeled sub-catchment.

Details

Meteorological data are needed for the nodes of the network that represent a catchment simulated by a rainfall-runoff model. Instead of airGR::CreateInputsModel() that has numeric vector as time series inputs, this function uses matrix or data.frame with the id of the sub-catchments as column names. For single values (ZInputs or NLayers), the function requires named vector with the id of the sub-catchment as name item. If an argument is optional, only the column or the named item has to be provided.

See airGR::CreateInputsModel() documentation for details concerning each argument

The number of rows of Precip, PotEvap, Qinf, Qmin, Qrelease, TempMean, TempMin, TempMax must be the same as the length of DatesR (each row corresponds to a time step defined in DatesR).

For various examples of use see topics RunModel.GRiwrmInputsModel(), RunModel_Reservoir(), and RunModel.Supervisor().

For example of use of Direct Injection nodes, see vignettes "V03_Open-loop_influenced_flow" and "V04_Closed-loop_regulated_withdrawal".

For example of use of Diversion nodes, see example in RunModel.GRiwrmInputsModel() topic and vignette "V06_Modelling_regulated_diversion".

The FUN_REGUL parameter

FUN_REGUL argument is a named list of functions that modify the node InputsModel before sending it to the node's model. This feature is useful for modifying data such as InputsModel$Qdiv or InputsModel$Qrelease giving simulated flows already available from upstream nodes. Each item of the list has a name corresponding to the node on which the function is applied. Each function must follow this interface: function(InputsModel, RunOptions, OutputsModel, env) where the arguments are:

  • InputsModel, the InputsModel object of the current node

  • RunOptions, the RunOptions object of the current node

  • OutputsModel, the GRiwrmOutputsModel object of the upstream and sibling nodes that have been already computed when the computation of the current node occurs

  • env, the environment of the RunModel.GRiwrmInputsModel() function

The functions embedded in FUN_REGUL should all return the argument InputsModel after calculation.

Examples

# Loading catchment data
data(Severn)

# Creating catchment network
nodes <- Severn$BasinsInfo[, c("gauge_id", "downstream_id", "distance_downstream", "area")]
nodes$model <- "RunModel_GR4J"
rename_columns <- list(id = "gauge_id",
                       down = "downstream_id",
                       length = "distance_downstream")
griwrm <- CreateGRiwrm(nodes, rename_columns)
griwrm
#>      id  down length    area         model donor
#> 4 54095 54001     42 3722.68 RunModel_GR4J 54095
#> 5 54002 54057     43 2207.95 RunModel_GR4J 54002
#> 6 54029 54032     32 1483.65 RunModel_GR4J 54029
#> 3 54001 54032     45 4329.90 RunModel_GR4J 54001
#> 2 54032 54057     15 6864.88 RunModel_GR4J 54032
#> 1 54057  <NA>     NA 9885.46 RunModel_GR4J 54057

# Preparation of InputsModel object
BasinsObs <- Severn$BasinsObs
DatesR <- BasinsObs[[1]]$DatesR
PrecipTot <- cbind(sapply(BasinsObs, function(x) {x$precipitation}))
PotEvapTot <- cbind(sapply(BasinsObs, function(x) {x$peti}))
Qobs <- cbind(sapply(BasinsObs, function(x) {x$discharge_spec}))
Precip <- ConvertMeteoSD(griwrm, PrecipTot)
PotEvap <- ConvertMeteoSD(griwrm, PotEvapTot)
InputsModel <- CreateInputsModel(griwrm, DatesR, Precip, PotEvap)
#> CreateInputsModel.GRiwrm: Processing sub-basin 54095...
#> CreateInputsModel.GRiwrm: Processing sub-basin 54002...
#> CreateInputsModel.GRiwrm: Processing sub-basin 54029...
#> CreateInputsModel.GRiwrm: Processing sub-basin 54001...
#> CreateInputsModel.GRiwrm: Processing sub-basin 54032...
#> CreateInputsModel.GRiwrm: Processing sub-basin 54057...