Improve checking for wrong returned value of 2nd dataset when lat/lon selector is values and return_vars is not specified
When two datasets are retrieved in one Start call and lat/lon selector is values(), the 2nd dataset has wrong values if return_vars = list(lat = NULL, lon = NULL)
(no matter transform is used or not). With the correct assignment, return_vars = list(lat = 'dat', lon = 'dat')
, the values are correct. But it is dangerous to return something wrong without warnings and error messages. Should find a way to prevent users' mistake.
library(startR)
sdates <- '2000'
## Paths
# HadGEM3 (initialised in November)
path_hadgem3 <- paste0('/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/',
'MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Amon/$var$/gr/v20200316/',
'$var$_*_s$sdate$_r1i1p1f2_gr_$fyear$.nc')
#NorCPM1 (initialised in October)
path_norcpm1 <- paste0('/esarchive/exp/CMIP6/dcppA-hindcast/norcpm1/cmip6-dcppA-hindcast_i1p1/DCPP/',
'NCC/NorCPM1/dcppA-hindcast/r1i1p1f1/Amon/$var$/gn/v20200320/',
'$var$_Amon_NorCPM1_dcppA-hindcast_s$sdate$-r1i1p1f1_gn_$fyear$.nc')
data <- Start(dat = list(list(name = 'hadgem3', path = path_hadgem3),
list(name = 'norcpm1', path = path_norcpm1)),
var = 'tas',
sdate = sdates,
fyear = indices(1), ## there is one file per sdate
fyear_depends = 'sdate',
time = as.POSIXct('2000-11-16', tz = 'UTC'),
lat = values(list(50, 60)),
lon = values(list(50, 60)),
synonims = list(lon = c('lon', 'longitude'), lat = c('lat', 'latitude')),
transform = CDORemapper,
transform_params = list(grid = 'r180x90',
method = 'conservative',
crop = c(50, 60, 50, 60)),
transform_vars = c('lat', 'lon'),
return_vars = list(lat = 'dat', lon = 'dat', # Wrong returned values if NULL
time = 'dat'),
retrieve = TRUE)