An error occurred while loading the file. Please try again.
-
Dorchies David authored
- Add functions for reading and writing data from and to the model - Add doSupervision which process the regulation for one (or more ?) time steps - Add method RunModel for Supervisor (change first argument of RunModel to `x` - Improve documentation Refs #19
118b310c
#' RunModel function for GRiwrmInputsModel object
#'
#' @param x object of class \emph{GRiwrmInputsModel}, see \code{[CreateInputsModel.GRiwrm]} for details.
#' @param RunOptions object of class \emph{GRiwrmRunOptions}, see \code{[CreateRunOptions.GRiwrm]} for details.
#' @param Param list of parameter. The list item names are the IDs of the sub-basins. Each item is a vector of numerical parameters.
#' @param ... Mandatory for S3 method signature function compatibility with generic.
#'
#' @return \emph{GRiwrmOutputsModel} object which is a list of \emph{OutputsModel} objects (See \code{\link[airGR]{RunModel}}) for each node of the semi-distributed model.
#' @export
RunModel.GRiwrmInputsModel <- function(x, RunOptions, Param, ...) {
message("RunModel.GRiwrmInputsModel")
# Run runoff model for each sub-basin
OutputsModel <- lapply(X = x, FUN = function(IM) {
RunModel.GR(IM,
RunOptions = RunOptions[[IM$id]],
Param = Param[[IM$id]])
})
class(OutputsModel) <- append(class(OutputsModel), "GRiwrmOutputsModel")
# Loop over sub-basin using SD model
for(id in getSD_Ids(x)) {
IM <- x[[id]]
message("RunModel.GRiwrmInputsModel: Treating sub-basin ", id, "...")
# Update x$Qupstream with simulated upstream flows
if(any(IM$UpstreamIsRunoff)) {
IM <- UpdateQsimUpstream(IM, RunOptions[[id]]$IndPeriod_Run, OutputsModel)
}
# Run the SD model for the sub-basin
OutputsModel[[id]] <- RunModel.SD(
IM,
RunOptions = RunOptions[[id]],
Param = Param[[id]],
OutputsModel[[id]]
)
}
return(OutputsModel)
}