Standarize coordinates in s2dv_cube
Now, for different cases there are different coordinates classes:
- If coordinates are indices they never have dimensions
- Using as.s2dv_cube from Start, only spatial and time coordinates have dimensions:
repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc"
repos2 <- "/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc"
data3 <- Start(dat = list(list(name = 'system4_m1', path = repos2),
list(name = 'system5_m1', path = repos)),
var = c('tas', 'sfcWind'),
sdate = '20170101',
ensemble = indices(1),
time = indices(1:3),
lat = indices(1:4),
lon = indices(1:4),
synonims = list(lat = c('lat', 'latitude'),
lon = c('lon', 'longitude')),
return_vars = list(time = 'sdate',
longitude = 'dat',
latitude = 'dat'),
metadata_dims = c('dat', 'var'),
retrieve = T
)
exp_start <- as.s2dv_cube(data3)
exp_start$dims
# dat var sdate ensemble time lat lon
# 2 2 1 1 3 4 4
> dim(exp_start$coords$var)
NULL
> dim(exp_start$coords$dat)
NULL
> dim(exp_start$coords$ensemble)
NULL
> dim(exp_start$coords$sdate)
NULL
> dim(exp_start$coords$lat)
lat
4
> dim(exp_start$coords$time)
sdate time
1 3
- Using as.s2dv_cube from Load only spatial coordinates have dimensions:
> dim(lonlat_prec$coords$dataset)
NULL
> dim(lonlat_prec$coords$member)
NULL
> dim(lonlat_prec$coords$sdate)
NULL
> dim(lonlat_prec$coords$ftime)
NULL
> dim(lonlat_prec$coords$lat)
[1] 4
> dim(lonlat_prec$coords$lon)
[1] 4
To standarize the coordinates classes in s2dv_cube
we can do:
- All coordinates to be 1D arrays
- Allow indices coordinates to be vectors and other coordinates to be 1D arrays
- Allow some coordinates (indices, dataset, var) to be vectors; and spatial and time dimensions to be 1D arrays
Also, this development could be also done in CSTooos::s2dv_cube function and CSTools::CST_InsertDim.
What do you prefer?