There was a bug when the function was subsetting a coordinate with multiple dimensions. Example code:
library(StartR)
library(ClimProjDiags)
library(s2dv)
repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc"
repos2 <- "/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc"
data3 <- Start(dat = list(list(name = 'system4_m1', path = repos2),
list(name = 'system5_m1', path = repos)),
var = c('tas', 'sfcWind'),
sdate = '20170101',
ensemble = indices(1),
time = indices(1:3),
lat = indices(1:4),
lon = indices(1:4),
synonims = list(lat = c('lat', 'latitude'),
lon = c('lon', 'longitude')),
return_vars = list(time = 'sdate',
longitude = 'dat',
latitude = 'dat'),
metadata_dims = c('dat', 'var'),
retrieve = T
)
exp_start <- as.s2dv_cube(data3)
source("https://earth.bsc.es/gitlab/external/cstools/-/raw/master/R/CST_Subset.R")
exp_sub1 <- CST_Subset(exp_start,
along = c("dat", "lon", 'time', 'var'),
indices = list(1, 1:2, 1:2, 1),
dat_dim = 'dat',
var_dim = 'var',
drop = 'non-selected')
# Error in names(dim(l)) <- x.dims :
# 'names' attribute [2] must be the same length as the vector [1]
The error was found in function: .subset_with_attrs
. This was due to time coordinate having dimensions: sdate = 1, time = N.
Now, if the coordinate to subset has more than 1 dimension the function Subset is used directly. The changed part is in these lines and the same here.
@vagudets do you agree with this change?