diff --git a/NAMESPACE b/NAMESPACE index d4e57ad55f6f3c6fd45a5032f39676d915a9a529..b69360fc294fbd17ec4a98a3391e06c9e4dfffc9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,4 @@ # Generated by roxygen2: do not edit by hand export(loadConfig) +export(set_initial_conditions) diff --git a/R/set_initial_conditions.R b/R/set_initial_conditions.R new file mode 100644 index 0000000000000000000000000000000000000000..84d671c0f5ec59182af15ae3699501234f8a2f58 --- /dev/null +++ b/R/set_initial_conditions.R @@ -0,0 +1,44 @@ +#' Import initial conditions +#' +#' Import initial conditions from a scenario/variant result calculation to a new scenario/variant. +#' +#' @param params [numeric], arguments passed to Edisic for importing initial conditions. See details +#' @param cfg +#' +#' @details `params` [numeric] vector of length 5. Each number correspond to: +#' +#' 1. number of the scenario from which import initial conditions +#' 1. number of the variant from which import initial conditions (Use "0" for no variant) +#' 1. Time in seconds of the initial conditions to import (Use "0" for a single permanent simulation with no time steps) +#' 1. number of the scenario where the initial conditions are exported to +#' 1. number of the variant where the initial conditions are exported to (Use "0" for no variant) +#' +#' @return +#' @export +#' +#' @examples +#' \dontrun{ +#' # Import initial conditions from the scenario #1 without variant at time 0s +#' # to the variant #1 in the scenario #1 +#' set_initial_conditions("1 0 0 1 1") +#' } +set_initial_conditions <- function(params, cfg = loadConfig()) { + if (!is.numeric(params) || length(params) != 5) { + stop("`params` should be a numeric of length 5") + } + sArgs <- paste(params, collapse = " ") + shell( + shQuote( + paste( + file.path(cfg$sic$path, cfg$sic$edisic), + shQuote(dirname(cfg$project$path), type = "cmd"), + "CI", + shQuote(basename(cfg$project$path), type = "cmd"), + sArgs + ), + type = "cmd2" + ), + wait = T, + translate = T + ) +} diff --git a/man/set_initial_conditions.Rd b/man/set_initial_conditions.Rd new file mode 100644 index 0000000000000000000000000000000000000000..a4449b7258e95a28cd18d8564047825f63e24d0a --- /dev/null +++ b/man/set_initial_conditions.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/set_initial_conditions.R +\name{set_initial_conditions} +\alias{set_initial_conditions} +\title{Import initial conditions} +\usage{ +set_initial_conditions(params, cfg = loadConfig()) +} +\arguments{ +\item{params}{\link{numeric}, arguments passed to Edisic for importing initial conditions. See details} + +\item{cfg}{} +} +\value{ + +} +\description{ +Import initial conditions from a scenario/variant result calculation to a new scenario/variant. +} +\details{ +\code{params} \link{numeric} vector of length 5. Each number correspond to: +\enumerate{ +\item number of the scenario from which import initial conditions +\item number of the variant from which import initial conditions (Use "0" for no variant) +\item Time in seconds of the initial conditions to import (Use "0" for a single permanent simulation with no time steps) +\item number of the scenario where the initial conditions are exported to +\item number of the variant where the initial conditions are exported to (Use "0" for no variant) +} +} +\examples{ +\dontrun{ +# Import initial conditions from the scenario #1 without variant at time 0s +# to the variant #1 in the scenario #1 +set_initial_conditions("1 0 0 1 1") +} +}