Skip to content

Commit

Permalink
Added warning in case not results are returned due to sit_var_dates_m…
Browse files Browse the repository at this point in the history
…ask empty but not null
  • Loading branch information
sbuis committed Jul 16, 2024
1 parent af60836 commit 24d7143
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion R/stics_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 24d7143

Please sign in to comment.