Skip to content

Error when return_vars is not used

A bug found in startR_2.2.0-1 when return_vars is not used.

ecmwf_path <- paste0('/esarchive/exp/ecmwf/s2s-monthly_ensforhc/',
                     'weekly_mean/$var$_f24h/$sdate$/$var$_$syear$.nc')
sdates.seq <- c("20160104", "20160107")

exp <- Start(dat = ecmwf_path, 
              var = 'tas',
              sdate = sdates.seq,
              syear = 'all',   
              time = 'all',
              ensemble = indices(1),
              latitude = indices(1),
              longitude = indices(1),
              syear_depends = 'sdate',
              return_vars = list(latitude = NULL,
                                 longitude = NULL,
                                 time = c('sdate', 'syear')), 
              retrieve = FALSE)

dates <- attr(exp, 'Variables')$common$time   
file_date <- sapply(dates, format, '%Y%m%d')
dim(file_date) <- dim(dates)

obs_path <- paste0("/esarchive/recon/ecmwf/era5/weekly_mean/",
                   "$var$_f1h-240x121/$var$_$file_date$.nc")

obs <- Start(dat = obs_path,
             var = 'tas',
             file_date = file_date,  
             latitude = indices(1),
             longitude = indices(1),
             split_multiselected_dims = TRUE,
 #            return_vars = list(time = 'file_date'),
             retrieve = FALSE)

If return_vars is not used, this error returns:

Error in which(unlist(lapply(picked_common_vars, tmp_fun, names(all_split_dims)))) : argument to 'which' is not logical

In startR_2.2.0, it works well.

FYI @nperez