Include a warning in Subset
Hi @aho,
There is an inconsistency with the Subset function. It happens when the data array has an attribute called 'dimensions' and they are ordered differently than actual dimensions of the array. This is due to line 51 where this attribute is evaluated before checking the names(dim(data))
. Then, for this case, the output data subset mixes the dimensions incorrectly.
It is not a big deal, but I think this line could be removed and replaced directly with dim_names <- names(dim(data))
. I found the error when using Load where there is this attribute called 'dimensions' which is created additionally. Do you think it is something that could be changed?
Here there is an example of the code where you can see the error:
library(ClimProjDiags)
library(s2dv)
data <- array(1:217560, dim = c(dataset = 1, sdate = 12, lon = 37, lat = 35, member = 2, ftime = 7))
attr(data, 'dimensions') <- names(dim(data))
dimnames <- names(dim(data))
data <- Reorder(data, sort(dimnames))
datas_subset <- Subset(data, along = 'dataset', 1, drop = 'selected')
dim(datas_subset)
# sdate lon lat member ftime
# 7 35 37 2 12
# wrong dimensions
Thank you,
Eva