Region selection returns uncompleted output
This issue deeps on an initial problem detected by @vtorralba.
First, I considered system5c3s dataset, for which a region subseting is requested. I got different output dimensions depending on the parameters used in Start():
Case | Requested trans | Type | Applied trans | system5 lon dim | glosea5 lon dim | system4 lon dim |
---|---|---|---|---|---|---|
1 | yes | file | yes | 131 | (trans) 131 | (trans) 131 |
2 | yes | r360x180 | yes | 131 | (no trans) 45 | (trans) 131 |
3 | yes | r360x181 | no | 46 | (trans) 131 | (trans) 131 |
4 | no | any | no | 46 | (no trans) 45 | (no trans)136 |
Table description:
- Transform using the same file Using CDORemapper to using as a target file the same dataset in 'grid' parameter. In fact, regrid is not necessary as the original and the target grids are the same but we obtain the desired output
- Transform using a grid different than the original one Using CDORemapper 'r360x180' grid. It is not the desired grid.
- Transform using the original grid: Using CDORemappe with 'r360x181'. It is the desired grid but this step seems unnecessary (at least that you load multiple datasets).
- No transformation applied.
Given these tests, I think that the difference in the longitude dimension is due to not applying transformation, probably when selector_checker
selects the requested values.
I have tested three different datasets. system5c3s and glosea5_system13c3s shows the same problems, and deeper test are require for system5_m1.
path_list <- list(list(name = 'system5c3s',
path = '/esarchive/exp/ecmwf/system5c3s/monthly_mean/$var$_f6h/$var$_$sdate$.nc'))
path_list <- list(list(name = 'glosea5c3s',
path= '/esarchive/exp/ukmo/glosea5_system13-c3s/monthly_mean/$var$_f24h/$var$_$sdate$.nc'))
path_list <- list(list(name = 'system5_m1',
path = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc'))
Here the code:
library(startR)
lats.min <- 27
lats.max <- 81
lons.min <- -85
lons.max <- 45
sdates_exp <- '19931101'
data_transfile <- Start(dat = path_list,
var = 'psl',
member = indices(1),
sdate = sdates_exp,
time = indices(1),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
latitude_reorder = Sort(),
transform = CDORemapper,
transform_params = list(grid ='/esarchive/exp/ecmwf/system5c3s/daily_mean/psl_f6h/psl_19991101.nc',
# transform_params = list(grid ='/esarchive/exp/ukmo/glosea5_system13-c3s/monthly_mean/$var$_f24h/psl_19991101.nc',
# transform_params = list(grid = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/psl_19991101.nc',
method = 'bilinear',
crop = c(lons.min,lons.max,lats.min,lats.max)),
transform_vars = c('latitude', 'longitude'),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
transform_extra_cells = 2,
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = FALSE)
attributes(data_transfile)$Dim
data_transres180 <- Start(dat = path_list,
var = 'psl',
member = indices(1),
sdate = sdates_exp,
time = indices(1),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
latitude_reorder = Sort(),
transform = CDORemapper,
transform_params = list(grid ='r360x180',
method = 'bilinear',
crop = c(lons.min,lons.max,lats.min,lats.max)),
transform_vars = c('latitude', 'longitude'),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
transform_extra_cells = 2,
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = FALSE)
attributes(data_transres180)$Dim
data_transres181 <- Start(dat = path_list,
var = 'psl',
member = indices(1),
sdate = sdates_exp,
time = indices(1),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
latitude_reorder = Sort(),
transform = CDORemapper,
transform_params = list(grid ='r360x181',
method = 'bilinear',
crop = c(lons.min,lons.max,lats.min,lats.max)),
transform_vars = c('latitude', 'longitude'),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
transform_extra_cells = 2,
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = FALSE)
attributes(data_transres181)$Dim
data_notrans <- Start(dat = path_list,
var = 'psl',
member = indices(1),
sdate = sdates_exp,
time = indices(1),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
latitude_reorder = Sort(),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = FALSE)
attributes(data_notrans)$Dim
Compare:
attributes(data_transfile)$Dim
attributes(data_transres180)$Dim
attributes(data_transres181)$Dim
attributes(data_notrans)$Dim