CreateInputsModel.GRiwrm.Rd 2.80 KiB
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CreateInputsModel.GRiwrm.R
\name{CreateInputsModel.GRiwrm}
\alias{CreateInputsModel.GRiwrm}
\title{Create InputsModel object for a \strong{airGRiwrm} network}
\usage{
\method{CreateInputsModel}{GRiwrm}(x, DatesR, Precip, PotEvap, Qobs, ...)
}
\arguments{
\item{x}{GRiwrm object describing the diagram of the semi-distributed model, see \code{[GRiwrm]}.}

\item{DatesR}{Vector of POSIXt observation time steps.}

\item{Precip}{Matrix or data frame of numeric containing precipitation in mm. Column names correspond to node IDs.}

\item{PotEvap}{Matrix or data frame of numeric containing potential evaporation in mm. Column names correspond to node IDs.}

\item{Qobs}{Matrix or data frame of numeric containing potential observed flow in mm. Column names correspond to node IDs.}

\item{...}{further arguments passed to \link[airGR:CreateInputsModel]{airGR::CreateInputsModel}.}
}
\value{
GRiwrmInputsModel object equivalent to \strong{airGR} InputsModel object for a semi-distributed model (See \link[airGR:CreateInputsModel]{airGR::CreateInputsModel})
}
\description{
Create InputsModel object for a \strong{airGRiwrm} network
}
\examples{
#################################################################
# Run the `airGRRunModel_Lag` example in the GRiwrm fashion way #
#################################################################

# Run airGR RunModel_Lag example for harvesting necessary data
library(airGR)
example(RunModel_Lag)
# detach the package because airGR overwrite airGRiwrm functions here
detach("package:airGR")

# This example is a network of 2 nodes which can be describe like this:
db <- data.frame(id = c("Reservoir", "GaugingDown"),
                 length = c(LengthHydro, NA),
                 down = c("GaugingDown", NA),
                 area = c(NA, BasinInfo$BasinArea),
                 model = c(NA, "RunModel_GR4J"),
                 stringsAsFactors = FALSE)

# Create GRiwrm object from the data.frame
griwrm <- GRiwrm(db)
str(griwrm)

# Formatting observations for the hydrological models
# Each input data should be a matrix or a data.frame with the good id in the name of the column
Precip <- matrix(BasinObs$P, ncol = 1)
colnames(Precip) <- "GaugingDown"
PotEvap <- matrix(BasinObs$E, ncol = 1)
colnames(PotEvap) <- "GaugingDown"

# Observed flows are integrated now because we mix:
#  - flows that are directly injected in the model
#  - flows that could be used for the calibration of the hydrological models
Qobs = matrix(c(Qupstream, BasinObs$Qmm), ncol = 2)
colnames(Qobs) <- griwrm$id
str(Qobs)

InputsModels <- CreateInputsModel(griwrm,
                            DatesR = BasinObs$DatesR,
                            Precip = Precip,
                            PotEvap = PotEvap,
                            Qobs = Qobs)
str(InputsModels)

}