Newer
Older
#if (identical(Sys.getenv("NOT_CRAN"), "")) Sys.setenv(NOT_CRAN='true')
context("Start() lat Reorder test")
#1 selector type 1-values(list) 2-values(vector) 3-indices 4-'all' 5-mix
#2 selector range 1-[10, 20] 2-[20, 10] 3-[-10, -20] 4-[-20, -10]
#3 resolution 1-1 2-<1 3->1
#4 returns_var 1-NULL 2-'dat'
#5 lat_reorder/Sort() 1-No 2-Yes,decreasing = F 3-Yes,decreasing = T
#6 lon_reorder/CircularSort() 1-No 2-Yes,(0, 360) 3-Yes,(-180, 180)
#7 transform 1-NO 2-YES
#8 transform_crop 1-T 2-F 3-region
##############################################
path_exp <- '/esarchive/exp/ecmwf/system5_m1/daily_mean/$var$_f6h/$var$_$sdate$.nc'
## Origin longitude in file: [0:360]
##############################################
test_that("1-1-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10.25761, 19.81264),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
35
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
# lon
expect_equal(
range((attr(res, 'Variables')$dat1$longitude)),
c(40, 45),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$longitude)[1] < (attr(res, 'Variables')$dat1$longitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$longitude),
19
)
expect_equal(
class(attr(res, 'Variables')$dat1$longitude),
'array'
)
})
##############################################
test_that("1-2-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 20
lats.max <- 10
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10.25761, 19.81264),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
35
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("1-3-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- -10
lats.max <- -20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(-19.81264, -10.25761),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
35
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("1-4-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- -20
lats.max <- -10
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(-19.81264, -10.25761),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
35
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("2-1-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(c(lats.min:lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(9.976578, 20.093670),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
# lon
expect_equal(
range((attr(res, 'Variables')$dat1$longitude)),
c(40, 45),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$longitude)[1] < (attr(res, 'Variables')$dat1$longitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$longitude),
19
)
expect_equal(
class(attr(res, 'Variables')$dat1$longitude),
'array'
)
})
##############################################
test_that("2-2-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 20
lats.max <- 10
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(c(lats.min:lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(9.976578, 20.093670),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("2-3-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- -10
lats.max <- -20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(c(lats.min:lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(-20.093670, -9.976578),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("2-4-2-2-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- -20
lats.max <- -10
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(c(lats.min:lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(-20.093670, -9.976578),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("1-1-2-3-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = NULL,
longitude = NULL,
time = NULL),
retrieve = F)
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# lat
expect_equal(
range((attr(res, 'Variables')$common$latitude)),
c(10.25761, 19.81264),
tolerance = 0.0001
)
expect_equal(
attr(res, 'Variables')$dat1$latitude,
NULL
)
expect_equal(
(attr(res, 'Variables')$common$latitude)[1] < (attr(res, 'Variables')$common$latitude)[2],
TRUE
)
expect_equal(
class(attr(res, 'Variables')$common$latitude),
'array'
)
})
##############################################
test_that("2-1-2-3-1-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(c(lats.min:lats.max)),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = NULL,
longitude = NULL,
time = NULL),
retrieve = F)
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# lat
expect_equal(
range((attr(res, 'Variables')$common$latitude)),
c(9.976578, 20.093670),
tolerance = 0.0001
)
expect_equal(
attr(res, 'Variables')$dat1$latitude,
NULL
)
expect_equal(
(attr(res, 'Variables')$common$latitude)[1] < (attr(res, 'Variables')$common$latitude)[2],
TRUE
)
expect_equal(
class(attr(res, 'Variables')$common$latitude),
'array'
)
})
##############################################
##############################################
test_that("1-1-2-2-2-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
latitude_reorder = Sort(),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10.25761, 19.81264),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
35
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
# lon
expect_equal(
range((attr(res, 'Variables')$dat1$longitude)),
c(40, 45),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$longitude)[1] < (attr(res, 'Variables')$dat1$longitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$longitude),
19
)
expect_equal(
class(attr(res, 'Variables')$dat1$longitude),
'array'
)
})
##############################################
test_that("1-2-2-2-2-1-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 20
lats.max <- 10
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
latitude_reorder = Sort(),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10.25761, 19.81264),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
35
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("1-1-2-2-2-3-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
latitude_reorder = Sort(decreasing = T),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10.25761, 19.81264),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
35
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("2-1-2-2-2-3-1-x", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(c(lats.min:lats.max)),
latitude_reorder = Sort(decreasing = T),
longitude = values(list(lons.min, lons.max)),
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(9.976578, 20.093670),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
#1 selector type 1-values(list) 2-values(vector) 3-indices 4-'all' 5-mix
#2 selector range 1-[10, 20] 2-[20, 10] 3-[-10, -20] 4-[-20, -10]
#3 resolution 1-1 2-<1 3->1
#4 returns_var 1-NULL 2-'dat'
#5 lat_reorder/Sort() 1-No 2-Yes,decreasing = F 3-Yes,decreasing = T
#6 lon_reorder/CircularSort() 1-No 2-Yes,(0, 360) 3-Yes,(-180, 180)
#7 transform 1-NO 2-YES
#8 transform_crop 1-T 2-F 3-region
##############################################
test_that("1-1-2-2-1-1-2-3", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
longitude = values(list(lons.min, lons.max)),
transform = CDORemapper,
transform_params = list(grid ='r360x181',
method = 'con',
crop = c(lons.min,lons.max,
lats.min,lats.max)),
transform_vars = c('longitude', 'latitude'),
transform_extra_cells = 2,
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10, 20),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
TRUE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("1-1-2-2-3-1-2-3", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
latitude_reorder = Sort(decreasing = T),
longitude = values(list(lons.min, lons.max)),
transform = CDORemapper,
transform_params = list(grid ='r360x181',
method = 'con',
crop = c(lons.min,lons.max,
lats.min,lats.max)),
transform_vars = c('longitude', 'latitude'),
transform_extra_cells = 2,
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10, 20),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("1-1-2-2-3-2-2-3", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
latitude_reorder = Sort(decreasing = T),
longitude = values(list(lons.min, lons.max)),
longitude_reorder = CircularSort(0, 360),
transform = CDORemapper,
transform_params = list(grid ='r360x181',
method = 'con',
crop = c(lons.min,lons.max,
lats.min,lats.max)),
transform_vars = c('longitude', 'latitude'),
transform_extra_cells = 2,
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10, 20),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
test_that("1-1-2-2-3-1-2-1", {
lons.min <- 40
lons.max <- 45
lats.min <- 10
lats.max <- 20
res <- Start(dat = list(list(path=path_exp)),
var = 'psl',
member = 'all',
sdate = '19821201',
time = indices(3:4),
latitude = values(list(lats.min, lats.max)),
latitude_reorder = Sort(decreasing = T),
longitude = values(list(lons.min, lons.max)),
transform = CDORemapper,
transform_params = list(grid ='r360x181',
method = 'con',
crop = T),
transform_vars = c('longitude', 'latitude'),
transform_extra_cells = 2,
synonims = list(latitude=c('lat','latitude'),
longitude=c('lon','longitude'),
member=c('ensemble','realization')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = NULL),
retrieve = F)
# lat
expect_equal(
range((attr(res, 'Variables')$dat1$latitude)),
c(10, 20),
tolerance = 0.0001
)
expect_equal(
(attr(res, 'Variables')$dat1$latitude)[1] < (attr(res, 'Variables')$dat1$latitude)[2],
FALSE
)
expect_equal(
length(attr(res, 'Variables')$dat1$latitude),
11
)
expect_equal(
class(attr(res, 'Variables')$dat1$latitude),
'array'
)
})
##############################################
#test_that("1-3. Selector type: indices(list)", {
#
#})
##############################################
#test_that("1-4. Selector type: indices(vector)", {
#
#})
##############################################
test_that("4-x-2-12-123-2-1-x", {
# 1-1. no Sort(), NULL
## lat should be descending
exp1_1 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc',
var = 'tas',
sdate = '20000101',
ensemble = indices(1),
time = indices(1),
latitude = 'all',
# latitude_reorder = Sort(),
longitude = 'all',
longitude_reorder = CircularSort(0, 360),
synonims = list(latitude = c('latitude', 'lat'),
longitude = c('longitude', 'lon')),
return_vars = list(latitude = NULL,
longitude = NULL,
time = 'sdate'),
retrieve = T)
# 1-2. Sort(), NULL
## lat should be ascending
exp1_2 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc',
var = 'tas',
sdate = '20000101',
ensemble = indices(1),
time = indices(1),
latitude = 'all',
latitude_reorder = Sort(),
longitude = 'all',
longitude_reorder = CircularSort(0, 360),
synonims = list(latitude = c('latitude', 'lat'),
longitude = c('longitude', 'lon')),
return_vars = list(latitude = NULL,
longitude = NULL,
time = 'sdate'),
retrieve = T)
# 1-3. Sort(drcreasing = T), NULL
## lat should be descending
exp1_3 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc',
var = 'tas',
sdate = '20000101',
ensemble = indices(1),
time = indices(1),
latitude = 'all',
latitude_reorder = Sort(decreasing = T),
longitude = 'all',
longitude_reorder = CircularSort(0, 360),
synonims = list(latitude = c('latitude', 'lat'),
longitude = c('longitude', 'lon')),
return_vars = list(latitude = NULL,
longitude = NULL,
time = 'sdate'),
retrieve = T)
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
expect_equal(
drop(exp1_1)[1:5, 2],
c(250.8470, 251.0054, 251.1874, 251.3769, 251.5602),
tolerance = 0.0001
)
expect_equal(
as.vector(drop(exp1_1)),
as.vector(drop(exp1_2)[640:1, ])
)
expect_equal(
as.vector(drop(exp1_1)),
as.vector(drop(exp1_3))
)
expect_equal(
as.vector(attr(exp1_1, 'Variables')$common$latitude)[1:5],
c(89.78488, 89.50620, 89.22588, 88.94519, 88.66436),
tolerance = 0.0001
)
expect_equal(
as.vector(attr(exp1_2, 'Variables')$common$latitude)[1:5],
c(-89.78488, -89.50620, -89.22588, -88.94519, -88.66436),
tolerance = 0.0001
)
expect_equal(
as.vector(attr(exp1_1, 'Variables')$common$latitude),
as.vector(attr(exp1_3, 'Variables')$common$latitude)
)
# 2-1. no Sort(), 'dat'
## lat should be descending
exp2_1 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc',
var = 'tas',
sdate = '20000101',
ensemble = indices(1),
time = indices(1),
latitude = 'all',
# latitude_reorder = Sort(),
longitude = 'all',
longitude_reorder = CircularSort(0, 360),
synonims = list(latitude = c('latitude', 'lat'),
longitude = c('longitude', 'lon')),
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = 'sdate'),
retrieve = T)
# 2-2. Sort(), 'dat'
## lat should be ascending
exp2_2 <- Start(dat = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc',
var = 'tas',
sdate = '20000101',
ensemble = indices(1),
time = indices(1),
latitude = 'all',
latitude_reorder = Sort(),
longitude = 'all',