Start: return_vars returns repetitive metadata
When lat/lon selectors are assigned by values() + parameter 'synonims' is used + 'return_vars' list name is the synonmin + 'return_vars' value is not 'dat', the returned metadata is repetitive. Take the code below as an example. 'return_vars' has 'latitude' and 'longitude' as the list names instead of 'lat' and 'lon'. The value is NULL rather than 'dat'. The returned metadata includes 'lon' and 'lat' as well as 'longitude' and 'latitude'.
Need to test if 'time' has the same situation, and if the situation only happens when the metadata is common (i.e., under $common rather than $dat1).
The bug exists in startR_v1.0.3, too.
library(startR)
repos_obs <- '/esarchive/obs/ukmo/hadisst_v1.1/monthly_mean/$var$/$var$_$date$.nc'
obs <- Start(dat = repos_obs,
var = 'tos',
date = '200505',
time = 'all',
lat = values(list(-10, 10)), # if use indices(), no bug
lat_reorder = Sort(),
lon = values(list(10, 20)),
lon_reorder = CircularSort(0, 360),
time_across = 'date',
#combine time and file_date dims
merge_across_dims = TRUE,
#exclude the additional NAs generated by merge_across_dims
merge_across_dims_narm = TRUE,
synonims = list(lat = c('lat', 'latitude'),
lon = c('lon', 'longitude')),
return_vars = list(latitude = NULL, # the name should be lat
longitude = NULL,
time = 'date'),
retrieve = TRUE)
names(attr(obs, 'Variables')$common)
[1] "latitude" "longitude" "time" "lat" "lon" "tos"
@nperez I tag you to keep you in the loop.