Skip to content

Commit

Permalink
Merge pull request #26 from SticsRPacks/add-comment-param_values
Browse files Browse the repository at this point in the history
Warn that param_values is not effective for intercrops + warn in case no results are required
  • Loading branch information
sbuis authored Jul 16, 2024
2 parents b8df390 + 24d7143 commit 8c474f5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/stics_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#' 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.
#' WARNING: up to now, for intercrop situations, plant parameter(s) defined in
#' param_values is(are) only associated to the main crop.
#'
#' @param situation (optional) vector of situations (USMs) names for which
#' results must be returned. Results for all simulated situations are returned
Expand Down Expand Up @@ -168,6 +170,11 @@ stics_wrapper <- function(model_options,
# Check the available USMs
avail_sit <- list.dirs(data_dir, full.names = TRUE, recursive = FALSE)

# Warning in case sit_var_dates_mask is empty (may occur in case obs is empty ...)
if (!is.null(sit_var_dates_mask) && length(sit_var_dates_mask)==0) {
warning("sit_var_dates_mask is empty, not any results will be returned by stics_wrapper.")
}

## Checking existing files
files_exist <- file.exists(file.path(avail_sit, "new_travail.usm"))
avail_sit <- basename(avail_sit)[files_exist]
Expand Down Expand Up @@ -542,7 +549,8 @@ stics_wrapper <- function(model_options,
}

if (length(res$sim_list) == 0) {
warning("Stics simulations failed for all USMs!!!")
warning(paste("stics_wrapper will not return simulated results:",
"either Stics simulations failed for all USMs or no results were required (e.g. sit_var_dates_mask empty)."))
res$sim_list <- NULL
} else {
# Add the attribute cropr_simulation for using CroPlotR package
Expand Down

0 comments on commit 8c474f5

Please sign in to comment.