Chunking problem when the dimension is reshaped
Reported by @cchou, the chunking has problems over the dimension that is merged and split. the example code is below:
# obs
path.obs <- '/esarchive/recon/ecmwf/era5/monthly_mean/$var$_f1h-r1440x721cds/$var$_$date$.nc'
y1 <- 1981; y2 <- 1984
sdate <- paste0(y1:y2, "07", '01')
var <- 'prlr'
# manually create the dates for obs
dates.obs <- c(paste0(y1:y2, "07", '15'),
paste0(y1:y2, "08", '15'),
paste0(y1:y2, "09", '15'))
# convert to the form required by Start()
time.obs <- as.POSIXct(dates.obs, "%Y%m%d",
origin = paste0(y1,'-', "07"), tz = 'UTC')
dim(time.obs) <- c('sdate' = y2 - y1 + 1, 'time' = 3)
obs <- Start(data = path.obs,
var = var,
date = unique(format(time.obs, '%Y%m')),
time = values(time.obs),
lat = indices(1:2),
lat_reorder = Sort(),
lon = indices(1:2),
lon_reorder = CircularSort(0, 360),
time_across = 'date',
merge_across_dims = TRUE,
split_multiselected_dims = TRUE,
synonims = list(lon = c('lon', 'longitude'),
lat = c('lat', 'latitude')),
return_vars = list(lon = NULL,
lat = NULL,
time = 'date'),
retrieve = FALSE)
fun <- function (obs) {
return(obs)
}
step <- Step(fun, target_dims = list(obs = 'sdate'), output_dims = list(obs = 'sdate'))
wf <- AddStep(obs, step)
res <- Compute(wf, chunks = list(time = 3))