Commit 29c14599 authored by David's avatar David
Browse files

fix(docs): warnings

Refs #173
Showing with 29 additions and 25 deletions
+29 -25
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
#' #'
#' @details #' @details
#' `IndPeriod_Run` or `DatesR` must must be continuous periods starting the #' `IndPeriod_Run` or `DatesR` must must be continuous periods starting the
#' time step after the last simulation time step of `OutputsModel`. #' time step after the last simulation time step of the `GRiwrmOutputsModel`
#' object provided through the argument `x`.
#' #'
#' `Qinf`, `Qmin`, and `Qrelease` are used for overwriting the corresponding #' `Qinf`, `Qmin`, and `Qrelease` are used for overwriting the corresponding
#' arguments provided to [CreateInputsModel.GRiwrm] for the period to be simulated. #' arguments provided to [CreateInputsModel.GRiwrm] for the period to be simulated.
...@@ -14,7 +15,7 @@ ...@@ -14,7 +15,7 @@
#' `IndPeriod_Run` or `DatesR` lengths. #' `IndPeriod_Run` or `DatesR` lengths.
#' #'
#' @inheritParams getNextTimeSteps #' @inheritParams getNextTimeSteps
#' @inheritParams Calibration #' @inheritParams RunModel.GRiwrmInputsModel
#' @inheritParams airGR::CreateRunOptions #' @inheritParams airGR::CreateRunOptions
#' @param DatesR (optional) [POSIXt] vector of dates of period to be used for #' @param DatesR (optional) [POSIXt] vector of dates of period to be used for
#' the model run. See details #' the model run. See details
...@@ -30,24 +31,25 @@ ...@@ -30,24 +31,25 @@
#' @param Qrelease (optional) [matrix] or [data.frame] of [numeric] containing #' @param Qrelease (optional) [matrix] or [data.frame] of [numeric] containing
#' release flows by nodes using the model `RunModel_Reservoir` \[m3 per #' release flows by nodes using the model `RunModel_Reservoir` \[m3 per
#' time step\]. See details #' time step\]. See details
#' @param ... Further arguments for compatibility with S3 methods
#' #'
#' @inherit RunModel.GRiwrmInputsModel return #' @inherit RunModel.GRiwrmInputsModel return
#' @export #' @export
#' #'
RunModel.GRiwrmOutputsModel <- function(OutputsModel, RunModel.GRiwrmOutputsModel <- function(x,
InputsModel, InputsModel,
RunOptions, RunOptions,
IndPeriod_Run = which(InputsModel[[1]]$DatesR %in% DatesR), IndPeriod_Run = which(InputsModel[[1]]$DatesR %in% DatesR),
DatesR = getNextTimeSteps(OutputsModel), DatesR = getNextTimeSteps(x),
Qinf = NULL, Qinf = NULL,
Qrelease = NULL, Qrelease = NULL,
Qmin = NULL, Qmin = NULL,
...) { ...) {
stopifnot(inherits(OutputsModel, "GRiwrmOutputsModel"), stopifnot(inherits(x, "GRiwrmOutputsModel"),
inherits(InputsModel, "GRiwrmInputsModel"), inherits(InputsModel, "GRiwrmInputsModel"),
inherits(RunOptions, "GRiwrmRunOptions")) inherits(RunOptions, "GRiwrmRunOptions"))
# Check Run Period # Check Run Period
next_time_step <- getNextTimeSteps(OutputsModel) next_time_step <- getNextTimeSteps(x)
next_index <- which(InputsModel[[1]]$DatesR == next_time_step) next_index <- which(InputsModel[[1]]$DatesR == next_time_step)
if (IndPeriod_Run[1] != next_index) { if (IndPeriod_Run[1] != next_index) {
stop("`IndPeriod_Run` should have its first element equal to ", next_index) stop("`IndPeriod_Run` should have its first element equal to ", next_index)
...@@ -57,7 +59,7 @@ RunModel.GRiwrmOutputsModel <- function(OutputsModel, ...@@ -57,7 +59,7 @@ RunModel.GRiwrmOutputsModel <- function(OutputsModel,
for (id in names(RunOptions)) { for (id in names(RunOptions)) {
# Run model for the sub-basin and one time step # Run model for the sub-basin and one time step
RunOptions[[id]]$IniResLevels <- NULL RunOptions[[id]]$IniResLevels <- NULL
RunOptions[[id]]$IniStates <- serializeIniStates(OutputsModel[[id]]$StateEnd) RunOptions[[id]]$IniStates <- serializeIniStates(x[[id]]$StateEnd)
RunOptions[[id]]$IndPeriod_WarmUp <- 0L RunOptions[[id]]$IndPeriod_WarmUp <- 0L
RunOptions[[id]]$IndPeriod_Run <- IndPeriod_Run RunOptions[[id]]$IndPeriod_Run <- IndPeriod_Run
} }
...@@ -84,7 +86,7 @@ RunModel.GRiwrmOutputsModel <- function(OutputsModel, ...@@ -84,7 +86,7 @@ RunModel.GRiwrmOutputsModel <- function(OutputsModel,
if (inputArg == "Qrelease" && !InputsModel[[id]]$isReservoir) { if (inputArg == "Qrelease" && !InputsModel[[id]]$isReservoir) {
stop("The column ", id, " of the argument `Qrelease` does not refer to a Reservoir node") stop("The column ", id, " of the argument `Qrelease` does not refer to a Reservoir node")
} }
if (inputArg == "Qmin" && !InputsModel[[id]]$isDiversion) { if (inputArg == "Qmin" && !InputsModel[[id]]$hasDiversion) {
stop("The column ", id, " of the argument `Qmin` does not refer to a Diversion node") stop("The column ", id, " of the argument `Qmin` does not refer to a Diversion node")
} }
if (is.null(InputsModel[[id]][[inputArg]])) { if (is.null(InputsModel[[id]][[inputArg]])) {
...@@ -93,13 +95,13 @@ RunModel.GRiwrmOutputsModel <- function(OutputsModel, ...@@ -93,13 +95,13 @@ RunModel.GRiwrmOutputsModel <- function(OutputsModel,
InputsModel[[id]][[inputArg]][IndPeriod_Run] <- v InputsModel[[id]][[inputArg]][IndPeriod_Run] <- v
} }
if (inputArg == "Qinf") { if (inputArg == "Qinf") {
g <- attr(InputsModel, "GRiwrm")
if (is.null(InputsModel[[id]])) { if (is.null(InputsModel[[id]])) {
# Direct Injection # Direct Injection
g <- attr(InputsModel, "GRiwrm")
id_down <- g$down[g$id == id] id_down <- g$down[g$id == id]
InputsModel[[id_down]]$Qupstream[IndPeriod_Run, id] <- v InputsModel[[id_down]]$Qupstream[IndPeriod_Run, id] <- v
} else { } else {
if (!InputsModel[[id]]$isDiversion) { if (!InputsModel[[id]]$hasDiversion) {
stop("The column ", id, " of the argument `Qinf` does not refer to a DirectInjection or a Diversion node") stop("The column ", id, " of the argument `Qinf` does not refer to a DirectInjection or a Diversion node")
} }
InputsModel[[id]]$Qdiv[IndPeriod_Run] <- v InputsModel[[id]]$Qdiv[IndPeriod_Run] <- v
......
...@@ -93,7 +93,7 @@ calcOverAbstraction <- function(O, WarmUp) { ...@@ -93,7 +93,7 @@ calcOverAbstraction <- function(O, WarmUp) {
#' Get the next time steps date/time of a simulation #' Get the next time steps date/time of a simulation
#' #'
#' @param OutputsModel Object returned by [RunModel.GRiwrmInputsModel], #' @param x Object returned by [RunModel.GRiwrmInputsModel],
#' [RunModel.Supervisor], or [RunModel.GRiwrmOutputsModel] #' [RunModel.Supervisor], or [RunModel.GRiwrmOutputsModel]
#' @param TimeStep [integer] number of time steps to get after the end of the #' @param TimeStep [integer] number of time steps to get after the end of the
#' simulation #' simulation
...@@ -102,10 +102,10 @@ calcOverAbstraction <- function(O, WarmUp) { ...@@ -102,10 +102,10 @@ calcOverAbstraction <- function(O, WarmUp) {
#' the end of the simulation. #' the end of the simulation.
#' @export #' @export
#' #'
getNextTimeSteps <- function(OutputsModel, TimeStep = 1L) { getNextTimeSteps <- function(x, TimeStep = 1L) {
stopifnot(inherits(OutputsModel, "GRiwrmOutputsModel"), stopifnot(inherits(x, "GRiwrmOutputsModel"),
is.integer(TimeStep)) is.integer(TimeStep))
last_date <- dplyr::last(OutputsModel[[1]]$DatesR) last_date <- dplyr::last(x[[1]]$DatesR)
first_date <- last_date + attr(OutputsModel, "TimeStep") first_date <- last_date + attr(x, "TimeStep")
return(seq(first_date, length.out = TimeStep, by = attr(OutputsModel, "TimeStep"))) return(seq(first_date, length.out = TimeStep, by = attr(x, "TimeStep")))
} }
...@@ -5,24 +5,25 @@ ...@@ -5,24 +5,25 @@
\title{RunModel for hot restart after a previous simulation period} \title{RunModel for hot restart after a previous simulation period}
\usage{ \usage{
\method{RunModel}{GRiwrmOutputsModel}( \method{RunModel}{GRiwrmOutputsModel}(
OutputsModel, x,
InputsModel, InputsModel,
RunOptions, RunOptions,
IndPeriod_Run = which(InputsModel[[1]]$DatesR \%in\% DatesR), IndPeriod_Run = which(InputsModel[[1]]$DatesR \%in\% DatesR),
DatesR = getNextTimeSteps(OutputsModel), DatesR = getNextTimeSteps(x),
Qinf = NULL, Qinf = NULL,
Qrelease = NULL, Qrelease = NULL,
Qmin = NULL, Qmin = NULL,
merge_outputs = TRUE,
... ...
) )
} }
\arguments{ \arguments{
\item{OutputsModel}{Object returned by \link{RunModel.GRiwrmInputsModel}, \item{x}{Object returned by \link{RunModel.GRiwrmInputsModel},
\link{RunModel.Supervisor}, or \link{RunModel.GRiwrmOutputsModel}} \link{RunModel.Supervisor}, or \link{RunModel.GRiwrmOutputsModel}}
\item{InputsModel}{[object of class \emph{InputsModel} or \emph{GRiwrmInputsModel}] see \link{CreateInputsModel}} \item{InputsModel}{[object of class \emph{InputsModel}] see \code{\link[airGR]{CreateInputsModel}} for details}
\item{RunOptions}{[object of class \emph{RunOptions} or \emph{GRiwrmRunOptions}] see \link{CreateRunOptions}} \item{RunOptions}{[object of class \emph{GRiwrmRunOptions}] see \link{CreateRunOptions.GRiwrmInputsModel} for details}
\item{IndPeriod_Run}{[numeric] index of period to be used for the model run [-]. See details} \item{IndPeriod_Run}{[numeric] index of period to be used for the model run [-]. See details}
...@@ -44,7 +45,7 @@ minimum flows to let downstream of a node with a Diversion [m3 per ...@@ -44,7 +45,7 @@ minimum flows to let downstream of a node with a Diversion [m3 per
time step]. Default is zero. Column names correspond to node IDs. time step]. Default is zero. Column names correspond to node IDs.
See details} See details}
\item{...}{further arguments passed to \link[airGR:Calibration]{airGR::Calibration}, see details} \item{...}{Further arguments for compatibility with S3 methods}
} }
\value{ \value{
An object of class \emph{GRiwrmOutputsModel}. An object of class \emph{GRiwrmOutputsModel}.
...@@ -66,7 +67,8 @@ redefined for this new simulation period. ...@@ -66,7 +67,8 @@ redefined for this new simulation period.
} }
\details{ \details{
\code{IndPeriod_Run} or \code{DatesR} must must be continuous periods starting the \code{IndPeriod_Run} or \code{DatesR} must must be continuous periods starting the
time step after the last simulation time step of \code{OutputsModel}. time step after the last simulation time step of the \code{GRiwrmOutputsModel}
object provided through the argument \code{x}.
\code{Qinf}, \code{Qmin}, and \code{Qrelease} are used for overwriting the corresponding \code{Qinf}, \code{Qmin}, and \code{Qrelease} are used for overwriting the corresponding
arguments provided to \link{CreateInputsModel.GRiwrm} for the period to be simulated. arguments provided to \link{CreateInputsModel.GRiwrm} for the period to be simulated.
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
\alias{getNextTimeSteps} \alias{getNextTimeSteps}
\title{Get the next time steps date/time of a simulation} \title{Get the next time steps date/time of a simulation}
\usage{ \usage{
getNextTimeSteps(OutputsModel, TimeStep = 1L) getNextTimeSteps(x, TimeStep = 1L)
} }
\arguments{ \arguments{
\item{OutputsModel}{Object returned by \link{RunModel.GRiwrmInputsModel}, \item{x}{Object returned by \link{RunModel.GRiwrmInputsModel},
\link{RunModel.Supervisor}, or \link{RunModel.GRiwrmOutputsModel}} \link{RunModel.Supervisor}, or \link{RunModel.GRiwrmOutputsModel}}
\item{TimeStep}{\link{integer} number of time steps to get after the end of the \item{TimeStep}{\link{integer} number of time steps to get after the end of the
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment