ex1_4_variable_nmember.R 2.13 KB
Newer Older
nperez's avatar
nperez committed
# This code shows that the number of members could depend on the start date
# and the order of start dates requested
# See FAQ 10 [The members depends on the start date](/inst/doc/faq.md)

library(startR)

path_list <- list(list(name = 'system5',   
    path = '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc'))
sdates_exp <- c('19991101', '19990901')
data_Nov_Sep <- Start(dat = path_list,
                      var = 'psl',
                      member = 'all',
                      sdate = sdates_exp,
                      time = indices(1),
                      latitude = values(list(0, 20)),
                      latitude_reorder=Sort(),
nperez's avatar
nperez committed
                      longitude = values(list(0, 5)),
                      synonims = list(latitude = c('lat', 'latitude'),
                                      longitude = c('lon', 'longitude'),
                                      member = c('ensemble', 'realization')),
                      retrieve = TRUE)
# 51 members 
dim(data_Nov_Sep)
#      dat       var    member     sdate      time  latitude longitude 
#        1         1        51         2         1        71        19 
nperez's avatar
nperez committed
apply(data_Nov_Sep, 4, function(x){sum(is.na(x))})
# 26 missing values for the second start date

sdates_exp <- c('19990901', '19991101')
data_Sep_Nov <- Start(dat = path_list,
                      var = 'psl',
                      member = 'all',
                      sdate = sdates_exp,
                      time = indices(1),
                      latitude = values(list(0, 20)),
                      latitude_reorder=Sort(),
nperez's avatar
nperez committed
                      longitude = values(list(0, 5)),
                      synonims = list(latitude = c('lat', 'latitude'),
                                      longitude = c('lon', 'longitude'),
                                       member = c('ensemble', 'realization')),
                      retrieve = TRUE)

# 25 members available
dim(data_Sep_Nov)
#      dat       var    member     sdate      time  latitude longitude 
#        1         1        25         2         1        71        19 
nperez's avatar
nperez committed

# Any missing value:
apply(data_Sep_Nov, 4, function(x){sum(is.na(x))})