Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
context("Start() metadata_dims check")
test_that("1. One data set", {
repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc"
data <- Start(dat = list(list(name = 'system5_m1', path = repos)),
var = 'tas',
sdate = '20170101',
ensemble = indices(1),
time = indices(1),
lat = indices(1:10),
lon = indices(1:10),
synonims = list(lat = c('lat', 'latitude'),
lon = c('lon', 'longitude')),
return_vars = list(time = 'sdate',
longitude = 'dat',
latitude = 'dat'),
metadata_dims = 'dat', # it can be omitted since it is automatically specified as 'dat'
retrieve = T
)
expect_equal(
length(attr(data, 'Variables')),
2
)
expect_equal(
names(attr(data, 'Variables')),
c("common", "system5_m1")
)
expect_equal(
names(attr(data, 'Variables')$common),
c('time', 'tas')
)
expect_equal(
names(attr(data, 'Variables')$system5_m1),
c("longitude", "latitude")
)
expect_equal(
length(attr(data, 'Variables')$common$tas),
12
)
}
test_that("2. Two data sets", {
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"
data <- Start(dat = list(list(name = 'system4_m1', path = repos2),
list(name = 'system5_m1', path = repos)),
var = 'tas',
sdate = '20170101',
ensemble = indices(1),
time = indices(1),
lat = indices(1:10),
lon = indices(1:10),
synonims = list(lat = c('lat', 'latitude'),
lon = c('lon', 'longitude')),
return_vars = list(time = 'sdate',
longitude = 'dat',
latitude = 'dat'),
metadata_dims = 'dat', # it can be omitted since it is automatically specified as 'dat'
retrieve = T
)
expect_equal(
length(attr(data, 'Variables')),
3
)
expect_equal(
names(attr(data, 'Variables')),
c("common", "system4_m1", "system5_m1")
)
expect_equal(
names(attr(data, 'Variables')$common),
'time'
)
expect_equal(
names(attr(data, 'Variables')$system4_m1),
c("longitude", "latitude", "tas")
)
expect_equal(
names(attr(data, 'Variables')$system5_m1),
c("longitude", "latitude", "tas")
)
expect_equal(
length(attr(data, 'Variables')$system5_m1$tas),
12
)
expect_equal(
length(attr(data, 'Variables')$system4_m1$tas),
11
)
}
test_that("3. Specify metadata_dims with another file dimension", {
}