Start(): "object 'indices_chunk' not found" when splitting multiselected dimension that is across files
Hi me,
Summary
When using split_multiselected_dims = TRUE
to split a multiselected inner dimension that is defined across a file dimension, Start() raises an error upon calling the internal function rebuild_array_merge_split()
because one of the function parameters, indices_chunk
, is passed onto the function but has not been defined.
Error in rebuild_array_merge_split(data_array = data_array_tmp, metadata = metadata_tmp, :
object 'indices_chunk' not found
In !258 (merged) I have attempted a "fix" which is to provide an empty vector indices_chunk <- c()
in the case that it is not defined and that seems to solve the problem and passes the unit tests. However, I do not fully understand the issue so I'm not sure if this solution might cause problems in the future.
Example
library(startR)
library(abind)
library(lubridate)
library(multiApply)
freq <- "daily_mean"
hcst.path <- paste0("/esarchive/exp/ecmwf/system51c3s/", freq, "/$var_dir$/$var$_$syear$.nc")
var_dir <- "tas_f6h"
var <- "tas"
sdates <- c("19990601", "20000601", "20010601")
dim(sdates) <- c(syear = 3)
source("/home/Earth/vagudets/oldhome/git/sunset/modules/Loading/R/get_forecast_times.R")
idxs <- get_forecast_times(sdates = sdates, ltmin = 1, ltmax = 2, time_freq = "daily_mean")
dim(idxs) <- c(syear = 3, time = 61)
## idxs is an array of values containing the dates for each time step
hcst <- Start(dat = hcst.path,
var = var,
var_dir = var_dir,
syear = sdates,
time = idxs,
time_across = "syear",
var_dir_depends = 'var',
latitude = values(list(0, 10)),
latitude_reorder = Sort(),
longitude = values(list(0, 10)),
synonims = list(latitude = c('lat', 'latitude'),
longitude = c('lon', 'longitude'),
ensemble = c('member', 'ensemble', 'lev')),
ensemble = 'all',
metadata_dims = 'var',
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = 'syear'),
split_multiselected_dims = TRUE,
merge_across_dims = TRUE,
retrieve = TRUE)
Module and Package version
Tested on R/4.4.1 and R/4.1.2, startR-2.5.0