Start(): return_vars of latitude and longitude is wrong when transformation
The problem happens when transformation is applied and return_vars = list(longitude = NULL, latitude = NULL)
. The following two scripts return the same values of the variable, but the longitude attributes are different. The first script is correct.
Correct. longitude attribute follows 'longitude_reorder', [-180, 180].
repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc"
var <- 'tas'
sdate <- c('20170101')
lon.min <- 0
lon.max <- 359.9
lat.min <- -90
lat.max <- 90
data2 <- Start(dat = repos,
var = var,
sdate = sdate,
ensemble = indices(1),
time = indices(1),
latitude = values(list(lat.min, lat.max)),
latitude_reorder = Sort(),
longitude = values(list(lon.min, lon.max)),
longitude_reorder = CircularSort(-180, 180),
transform = CDORemapper,
transform_extra_cells = 2,
transform_params = list(grid = 'r360x181',
method = 'conservative',
crop = c(lon.min, lon.max,
lat.min, lat.max)),
transform_vars = c('latitude', 'longitude'),
synonims = list(latitude = c('lat', 'latitude'),
longitude = c('lon', 'longitude')),
return_vars = list(time = 'sdate',
longitude = 'dat',
latitude = 'dat'),
retrieve = T)
asd <- ClimProjDiags::Subset(data2, c(1,2,3,4,5), list(1,1,1,1,1), drop = 'selected')
lat <- attr(asd, 'Variable')$dat1$latitude
lon <- attr(asd, 'Variable')$dat1$longitude
s2dverification::PlotEquiMap(asd, lon, lat)
Wrong. Longitude attribute should be [-180, 180], not [0, 360]
data <- Start(dat = repos,
var = var,
sdate = sdate,
ensemble = indices(1),
time = indices(1),
latitude = values(list(lat.min, lat.max)),
latitude_reorder = Sort(),
longitude = values(list(lon.min, lon.max)),
longitude_reorder = CircularSort(-180, 180),
transform = CDORemapper,
transform_extra_cells = 2,
transform_params = list(grid = 'r360x181',
method = 'conservative',
crop = c(lon.min, lon.max,
lat.min, lat.max)),
transform_vars = c('latitude', 'longitude'),
synonims = list(latitude = c('lat', 'latitude'),
longitude = c('lon', 'longitude')),
return_vars = list(time = 'sdate',
longitude = NULL,
latitude = NULL),
retrieve = T
)
qwe <- ClimProjDiags::Subset(data, c(1,2,3,4,5), list(1,1,1,1,1), drop = 'selected')
lat2 <- attr(qwe, 'Variable')$common$latitude
lon2 <- attr(qwe, 'Variable')$common$longitude
s2dverification::PlotEquiMap(qwe, lon2, lat2)