Hi @cdelgado
You mentioned that Subset() has problems with drop = T
. I did some tests and got the following errors. Can you confirm if these are the errors you found?
dat1 <- array(1:20, dim = c(dat = 1, lat = 2, lon = 10))
# case 1
Subset(dat1, c('lon'), list(2), drop = TRUE)
Error in names(metadata[["dim"]]) <- dim_names :
attempt to set an attribute on NULL
# case 2
Subset(dat1, c('dat', 'lat', 'lon'), list(1, 1, 2), drop = 'selected')
Error in attributes(subset) <- metadata :
length-0 dimension vector is invalid
The problem happened when the output dimension length is 1 only. For example, case 1 above should have [lat = 2], and case 2 should have [1].
The bug is fixed in this branch. I've done as many tests as I can to make sure it works well. If you wanna try, you can source("https://earth.bsc.es/gitlab/es/ClimProjDiags/-/raw/develop-Subset_dropT/R/Subset.R")
. Let me know if it solves the bug you found, thanks!
Cheers,
An-Chi