Commit a71e00a3 authored by David's avatar David
Browse files

fix: CreateRunOptions debug

Refs #107
Showing with 28 additions and 21 deletions
+28 -21
......@@ -32,25 +32,24 @@ CreateRunOptions <- function(x, ...) {
#' @rdname CreateRunOptions
#' @export
CreateRunOptions.InputsModel <- function(x, ...) {
hasFUN_MOD <- "FUN_MOD" %in% names(list(...))
if (!hasFUN_MOD && !is.null(x$FUN_MOD)) {
CreateRunOptions(x,
FUN_MOD = x$FUN_MOD,
...)
} else if (hasFUN_MOD){
# Temporary fix waiting for resolution of HYCAR-Hydro/airgr#167
if (identical(match.fun(x$FUN_MOD), RunModel_Lag)) {
dots <- list(...)
dots$InputsModel <- x
dots$IniStates <- CreateIniStates(RunModel_Lag, x)
do.call(airGR::CreateRunOptions, dots)
dots <- list(...)
dots$InputsModel <- x
# Add FUN_MOD in parameters if carried by InputsModel
if (!"FUN_MOD" %in% names(dots)) {
if(!is.null(x$FUN_MOD)) {
dots$FUN_MOD <- x$FUN_MOD
} else {
# End of temporary fix HYCAR-Hydro/airgr#167
airGR::CreateRunOptions(InputsModel = x, ...)
stop(" The parameter `FUN_MOD` must be defined")
}
} else {
stop(" The parameter `FUN_MOD` must be defined")
}
# Temporary fix waiting for resolution of HYCAR-Hydro/airgr#167
if (identical(match.fun(dots$FUN_MOD), RunModel_Lag)) {
dots$IniStates <- CreateIniStates(RunModel_Lag, x)
}
# End of temporary fix HYCAR-Hydro/airgr#167
do.call(airGR::CreateRunOptions, dots)
}
#' @rdname CreateRunOptions
......
......@@ -15,9 +15,9 @@ CreateRunOptions(x, ...)
\method{CreateRunOptions}{InputsModel}(x, ...)
\method{CreateRunOptions}{character}(x, ...)
\method{CreateRunOptions}{character}(x, InputsModel, ...)
\method{CreateRunOptions}{`function`}(x, ...)
\method{CreateRunOptions}{`function`}(x, InputsModel, ...)
}
\arguments{
\item{x}{For a single catchment, it can be an object of class \emph{InputsModel} or a \link{function} or a \link{character} corresponding to \code{FUN_MOD} (compliant with \strong{airGR} call). For a network, it should be an object of class \emph{GRiwrmInputsModel}. See \link{CreateInputsModel} for details}
......@@ -25,9 +25,15 @@ CreateRunOptions(x, ...)
\item{IniStates}{(optional) \link{numeric} object or \link{list} of \link{numeric} object of class \emph{IniStates}, see \link[airGR:CreateIniStates]{airGR::CreateIniStates} for details}
\item{...}{arguments passed to \link[airGR:CreateRunOptions]{airGR::CreateRunOptions}, see details}
\item{InputsModel}{object of class \emph{InputsModel} (only used to be consistent
with the original \link[airGR:CreateRunOptions]{airGR::CreateRunOptions} which has \code{FUN_MOD} as first
parameter)
see \link[airGR:CreateInputsModel]{airGR::CreateInputsModel} for details}
}
\value{
Depending on the class of \code{InputsModel} argument (respectively \emph{InputsModel} and \emph{GRiwrmInputsModel} object), the returned value is respectively:
Depending on the class of \code{InputsModel} argument (respectively
\emph{InputsModel} and \emph{GRiwrmInputsModel} object), the returned value is respectively:
\itemize{
\item a \code{RunOptions} object (See \link[airGR:CreateRunOptions]{airGR::CreateRunOptions})
\item a \code{GRiwrmRunOptions} object which is a \link{list} of \code{RunOptions} objects with one item per modeled sub-catchment
......@@ -39,9 +45,11 @@ This function can be used either for a catchment (with an \emph{InputsModel} obj
\details{
See \link[airGR:CreateRunOptions]{airGR::CreateRunOptions} documentation for a complete list of arguments.
If \code{InputsModel} argument is a \emph{GRiwrmInputsModel} object, \code{IniStates} must be a list of \link{numeric} object of class \emph{IniStates} with one item per modeled sub-catchment.
If \code{x} argument is a \emph{GRiwrmInputsModel} object, \code{IniStates} must be a
list of \link{numeric} object of class \emph{IniStates} with one item per modeled sub-catchment.
With a \emph{GRiwrmInputsModel} object, all arguments are applied on each sub-catchments of the network.
With a \emph{GRiwrmInputsModel} object, all arguments are applied on each
sub-catchments of the network.
}
\examples{
###################################################################
......
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