CST_Start() does not work for retrieve = FALSE: Add meaningful error message to as.s2dv_cube() and change the doc accordingly
Hi @abatalla
R and packages Version
R version is irrelevant CSTools 5.0.2
Summary
An external user (Simon Moulds) reports the following issue in CST_Start():
Hi Victoria,
I’m writing to report a possible bug (or at least undocumented behaviour) with CSTools. The issue relates to the CST_Start function. Here is a reproducible example:
library(CSTools)
library(startR)
data_path <- system.file('extdata', package = 'startR')
path_obs <- file.path(data_path, 'obs/monthly_mean/$var$/$var$_$sdate$.nc')
sdates <- c('200011', '200012')
## Fails:
data <- CST_Start(dat = path_obs, var = "tos", sdate = sdates, latitude = 'all', longitude = 'all', retrieve = FALSE)
## Works:
data <- CST_Start(dat = path_obs, var = "tos", sdate = sdates, latitude = 'all', longitude = 'all', retrieve = TRUE)
In othe words, if retrieve is FALSE then the function will fail because startR::Start returns a startR_cube object, whereas if retrieve = TRUE then startR::Start returns a startR_array object, which is successfully recognised by CST_Start.
In the CSTools docs there is at least one example use of CST_Start that supplies retrieve = FALSE.
Other Relevant Information
Already mentioned in !209 (comment 271759)
This error is actually coming from the as.s2dv_cube() function used within CST_Start() to transform the output of Start() into an s2dv_cube object. The example in CST_Start() should be changed and the documentation should be improved to reflect this. An meaningful error message can be added to as.s2dv_cube() when the object is of class startR_cube.
Victòria