exp <- array(1:(2*3*4*5*6*4), 
 c(dataset = 1, member = 2, sdate = 3, ftime = 4, lat = 5, lon = 6, wt = 4))
obs <- array(1:(1*3*4*5*6*4),
 c(dataset = 1, member = 1, sdate = 3, ftime = 4, lat = 5, lon = 6, wt = 4))
source("/esarchive/scratch/nperez/git/cstools/R/CST_QuantileMapping.R")
library(multiApply)
library(qmap)
library(abind)
res <- QuantileMapping(exp, obs, sample_dims = c('member', 'ftime', 'sdate'))
res <- QuantileMapping(exp, obs, sample_dims = c('ftime'))
exp <- array(1:(93*22*53*3), c(time = 93, lat = 22, lon = 53, type = 3))
exp <- abind::abind(exp, array(NA, c(time = 6, lat = 22, lon = 53, type = 3)),
                    along = 1)
names(dim(exp)) <- c('time','lat','lon','type')
source("/esarchive/scratch/nperez/git/cstools/R/CST_SplitDim.R")
library(s2dverification)
exp <- SplitDim(exp, 'time', freq = 9, indices = NULL)
obs <- array(1:(9*22*53*3), c(time = 9, lat = 22, lon = 53, type = 3, index = 1))
res <- QuantileMapping(exp, obs, sample_dims = c('time', 'index'))
res <- QuantileMapping(exp, obs, sample_dims = c('time', 'index'), method='RQUANT')
new_exp <- CSTools::MergeDims(exp2, c('time', 'index'))
all(new_exp==exp, na.rm=T)



data <- array(1:100, c(x = 50, y = 2))
data[1:3, ] <- NA
data[5:7, ] <- NA
data[30:33,] <- NA
data[49:50,] <- NA

pos <- c(1:3, 5:7, 30:33)
dimdata <- dim(data)
xdim <- which(names(dimdata) == 'x')
dimdata[xdim] <- dimdata[xdim] + length(pos)
new <- array(NA, dimdata)



