Commit 5d411323 authored by Dorchies David's avatar Dorchies David
Browse files

feat(RunOptions): add IniStates argument for a list of initial states

Refs #48
parent 2ab52a85
#' @param IniStates (optional) [numeric] object or [list] of [numeric] object of class \emph{IniStates}, see [airGR::CreateIniStates] for details
#' @rdname CreateRunOptions #' @rdname CreateRunOptions
#' @export #' @export
CreateRunOptions.GRiwrmInputsModel <- function(InputsModel, ...) { CreateRunOptions.GRiwrmInputsModel <- function(InputsModel, IniStates = NULL, ...) {
RunOptions <- list() RunOptions <- list()
class(RunOptions) <- append(class(RunOptions), "GRiwrmRunOptions") class(RunOptions) <- append(class(RunOptions), "GRiwrmRunOptions")
for(InputsModelBasin in InputsModel) { for(id in names(InputsModel)) {
RunOptions[[InputsModelBasin$id]] <- CreateRunOptions(InputsModel = InputsModelBasin, ...) RunOptions[[id]] <- CreateRunOptions(InputsModel = InputsModel[[id]], IniStates = IniStates[[id]], ...)
} }
return(RunOptions) return(RunOptions)
} }
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
#' #'
#' @details See [airGR::CreateRunOptions] documentation for a complete list of arguments. #' @details See [airGR::CreateRunOptions] documentation for a complete list of arguments.
#' #'
#' If `InputsModel` argument is a \emph{GRiwrmInputsModel} object, `IniStates` must be a list of [numeric] object of class \emph{IniStates} with one item per modelled 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.
#' #'
#' @return Depending on the class of `InputsModel` argument (respectively `InputsModel` and `GRiwrmInputsModel` object), the returned value is respectively: #' @return Depending on the class of `InputsModel` argument (respectively \emph{InputsModel} and \emph{GRiwrmInputsModel} object), the returned value is respectively:
#' - a `RunOptions` object (See [airGR::CreateRunOptions]) #' - a `RunOptions` object (See [airGR::CreateRunOptions])
#' - a `GRiwrmRunOptions` object which is a [list] of `RunOptions` object with one item per modelled sub-catchment #' - a `GRiwrmRunOptions` object which is a [list] of `RunOptions` object with one item per modelled sub-catchment
#' #'
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
\alias{CreateRunOptions} \alias{CreateRunOptions}
\title{Creation of the CalibOptions object} \title{Creation of the CalibOptions object}
\usage{ \usage{
\method{CreateRunOptions}{GRiwrmInputsModel}(InputsModel, ...) \method{CreateRunOptions}{GRiwrmInputsModel}(InputsModel, IniStates = NULL, ...)
\method{CreateRunOptions}{InputsModel}(InputsModel, ...) \method{CreateRunOptions}{InputsModel}(InputsModel, ...)
...@@ -16,10 +16,12 @@ CreateRunOptions(InputsModel, ...) ...@@ -16,10 +16,12 @@ CreateRunOptions(InputsModel, ...)
\arguments{ \arguments{
\item{InputsModel}{object of class \emph{InputsModel} or \emph{GRiwrmInputsModel}. See \link{CreateInputsModel} for details} \item{InputsModel}{object of class \emph{InputsModel} or \emph{GRiwrmInputsModel}. See \link{CreateInputsModel} for details}
\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{...}{arguments passed to \link[airGR:CreateRunOptions]{airGR::CreateRunOptions}, see details}
} }
\value{ \value{
Depending on the class of \code{InputsModel} argument (respectively \code{InputsModel} and \code{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{ \itemize{
\item a \code{RunOptions} object (See \link[airGR:CreateRunOptions]{airGR::CreateRunOptions}) \item a \code{RunOptions} object (See \link[airGR:CreateRunOptions]{airGR::CreateRunOptions})
\item a \code{GRiwrmRunOptions} object which is a \link{list} of \code{RunOptions} object with one item per modelled sub-catchment \item a \code{GRiwrmRunOptions} object which is a \link{list} of \code{RunOptions} object with one item per modelled sub-catchment
...@@ -31,6 +33,8 @@ This function can be used either for a catchment (with an \emph{InputsModel} obj ...@@ -31,6 +33,8 @@ This function can be used either for a catchment (with an \emph{InputsModel} obj
\details{ \details{
See \link[airGR:CreateRunOptions]{airGR::CreateRunOptions} documentation for a complete list of arguments. 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 modelled 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{ \examples{
......
Markdown is supported
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