This function uses Stics directly through a system call, can force Stics input parameters with values given in arguments.

stics_wrapper(
  model_options,
  param_values = NULL,
  situation = NULL,
  var = NULL,
  dates = NULL,
  sit_var_dates_mask = NULL,
  sit_names = lifecycle::deprecated(),
  var_names = lifecycle::deprecated()
)

Arguments

model_options

List containing any information needed by the model. In the case of Stics: javastics (or/and stics_exe) and workspace the path of the directory containing the Stics input data for each USM (one folder per USM where Stics input files are stored in txt format). See stics_wrapper_options() for more information.

param_values

(optional) a named vector or a tibble that contains values of Stics input parameters to use in the simulations. Should have one named column per parameter. An optional column named situation containing the name of the situations (USMs for Stics) allows to define different values of the parameters for different situations. If param_values is not provided, the simulations will be performed using the parameters values defined in the Stics input files referenced in model_options argument.

situation

(optional) vector of situations (USMs) names for which results must be returned. Results for all simulated situations are returned if not provided.

var

(optional) vector of variables names for which results must be returned. If not provided, it returns the results for all simulated variables that were already listed in the var.mod (i.e. from the last simulation).

dates

(optional) vector of dates (POSIXct) for which results must be returned. Results for all dates simulated are returned if not provided. If required dates varies between situations, use sit_var_dates_mask argument

sit_var_dates_mask

(optional) List of situations: a named list containing a mask for variables and dates for which simulated values should be returned. Typically a list containing the observations to which simulations should be compared as provided by SticsRFiles::get_obs

sit_names

[Deprecated] sit_names is no longer supported, use situation instead.

var_names

[Deprecated] var_names is no longer supported, use var instead.

Value

A list containing simulated values (sim_list: a list of tibbles (one element per situation) and an error code (error) indicating if at least one simulation ended with an error.

See also

stics_wrapper_options() for more information on how to provide model_options.

Examples

if (FALSE) {

# Specifying the JavaStics folder
javastics <- "/path/to/JavaSTICS/folder"

# Setting the input data folder path, root directory of the usms directories
data_path <- "/path/to/usms/subdirs/root"

# Setting the mandatory simulations options
sim_options <- stics_wrapper_options(
  javastics = javastics,
  workspace = data_path
)

# Running all the usms that have a corresponding input folder in data_path
results <- stics_wrapper(sim_options)

# Running a sublist of usm
usms_list <- c("wheat", "pea", "maize")
results <- stics_wrapper(sim_options, situation = usms_list)

# Applying a single parameter values vector for the sublist of usms
param_values <- c(0.002, 50)
names(param_values) <- c("dlaimax", "durvieF")
results <- stics_wrapper(
  model_options = sim_options,
  situation = usms_list, param_values = param_values
)

# Applying different values of the parameters for the usms
# Let's run usm wheat with c(dlaimax=0.001, durvieF=50),
# usm pea with c(dlaimax=0.001, durvieF=60),
# and usm maize with c(dlaimax=0.001, durvieF=70)
param_values <- data.frame(
  Situation = c("wheat", "pea", "maize"),
  dlaimax = c(0.001, 0.001, 0.001),
  durvieF = c(50, 60, 70)
)
results <- stics_wrapper(
  model_options = sim_options,
  param_values = param_values, situation = c("wheat", "pea", "maize")
)
}