The error happened when exp <- lonlat_prec_st
was used instead of exp <- lonlat_prec
. The difference is due to that the first object has var dimension. I think this should be corrected since the function needs to allow flexibility in margin dimensions (dimensions not used in the calculation).
The error is the following: when lonlat_prec is used, the variable iorder
is a vector, whereas lonlat_prec_st is used, iorder it's a named list. The modification allows the function to work in both cases. These lines are in charge of reordering the array dimensions.
library(CSTools)
load("/esarchive/scratch/erifarov/git/cstools/data/lonlat_temp_st.rda")
`exp <- lonlat_prec_st`
ilon <- which(exp$coords$lon %in% 5:12)
ilat <- which(exp$coords$lat %in% 40:47)
exp$data <- exp$data[, , , , , ilat, ilon, drop = FALSE]
names(dim(exp$data)) <- names(dim(lonlat_prec_st$data))
exp$coords$lon <- exp$coords$lon[ilon]
exp$coords$lat <- exp$coords$lat[ilat]
downscaled <- RainFARM(exp$data, exp$coords$lon, exp$coords$lat,
nf = 20, kmin = 1, nens = 3,
time_dim = c("member", "ftime"))