From af60836e3bab0343d0a8ee06d482988d2497477c Mon Sep 17 00:00:00 2001 From: Samuel Buis Date: Tue, 16 Jul 2024 14:29:47 +0200 Subject: [PATCH 1/2] Added comment on param_values (warn that not effective for intercrops) --- R/stics_wrapper.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/stics_wrapper.R b/R/stics_wrapper.R index 92a372b..031e4aa 100644 --- a/R/stics_wrapper.R +++ b/R/stics_wrapper.R @@ -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 From 24d71439b3f982b91f7b10519b98ca053d0af9a9 Mon Sep 17 00:00:00 2001 From: Samuel Buis Date: Tue, 16 Jul 2024 14:30:31 +0200 Subject: [PATCH 2/2] Added warning in case not results are returned due to sit_var_dates_mask empty but not null --- R/stics_wrapper.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/stics_wrapper.R b/R/stics_wrapper.R index 031e4aa..bb21e78 100644 --- a/R/stics_wrapper.R +++ b/R/stics_wrapper.R @@ -170,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] @@ -544,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