This is some progress of multiple steps. It is just one idea, but there may be many ways to build this development. Here is a script and you can see the planned structure.
repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/tas_f6h/$var$_$sdate$.nc"
var <- 'tas'
sdate <- c('20170101', '20170201')
data <- Start(dat = repos,
var = var,
sdate = c('20170101'), #, '20170401'),
ensemble = 'all', #indices(1),
time = 'all', #indices(1),
latitude = indices(1:50), #'all',
longitude = indices(1:100), #'all',
return_vars = list(time = c('sdate'),
longitude = NULL, latitude = NULL),
retrieve = FALSE
)
# fun1: add noise to time
fun1 <- function(x) {
# [time]
x + rnorm(length(x))
}
# fun2: average over ensemble
fun2 <- function(x) {
# [ensemble]
mean(x)
}
step1 <- Step(fun1, target_dims = c('time'),
output_dims = c('time'))
step2 <- Step(fun2, target_dims = c('ensemble'),
output_dims = NULL)
wf <- AddStep(inputs = data, step_fun = list(step_a = step1, step_b = step2))
#NOT WORKING YET
res <- Compute(wf,
chunks = list(step_a = list(ensemble = 2),
step_b = list(time = 2)))