diff --git a/inst/doc/usecase/ex1_13_implicit_dependency.R b/inst/doc/usecase/ex1_13_implicit_dependency.R index 8f60413d504cd92d5e9114a3c863972863dcd237..85f99377855d98f1b4a19805052daa44f428eebc 100644 --- a/inst/doc/usecase/ex1_13_implicit_dependency.R +++ b/inst/doc/usecase/ex1_13_implicit_dependency.R @@ -1,6 +1,7 @@ # Author: An-Chi Ho # Date: 13th July 2021 # Implement case 3: 6th April 2022 +# Update case 1: 10th April 2025 #--------------------------------------------------------------------- # This script shows how to use a value array as the inner dimension selector to express @@ -19,14 +20,15 @@ library(startR) library(lubridate) +library(multiApply) # Case 1: 'time' depends on 'sdate' -repos <- '/esarchive/exp/ecmwf/system4_m1/daily_mean/$var$_f24h/$var$_$sdate$.nc' +repos <- '/esarchive/exp/ecmwf/system51c3s/daily_mean/$var$_f6h/$var$_$sdate$.nc' -sdates <- ymd("20010501") + rep(years(0:2), each = 1) -times <- array(ymd("20010501") + days(0:30) + rep(years(0:2), each = 31), - dim = c(time = 31, sdate = 3)) +sdates <- ymd("20010501") + years(0:2) +times <- sapply(sdates, FUN = function(x) {x %m+% days(0:30)}) times <- as.POSIXct(times * 86400, tz = 'UTC', origin = '1970-01-01') +dim(times) <- c(times = 31, sdate = 3) exp <- Start(dat = repos, var = 'tos', @@ -41,16 +43,16 @@ exp <- Start(dat = repos, retrieve = T) dim(exp) -# dat var sdate time ensemble lat lon -# 1 1 3 31 5 256 512 +# dat var sdate time ensemble lat lon +# 1 1 3 31 5 180 360 exp[1, 1, 2, 1:10, 1, 100, 100] -# [1] 302.1276 302.1346 302.2003 302.2121 302.2552 302.3312 302.3184 302.3507 -# [9] 302.3665 302.3865 +# [1] 302.0500 302.0074 302.0092 302.0135 302.0504 302.1292 302.0751 302.2324 +# [9] 302.0811 302.0998 summary(exp) -# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's -# 271 274 287 287 299 305 19757385 +# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's +# 271 274 288 287 299 307 10210935 #============================================================================= diff --git a/inst/doc/usecase/ex2_6_ext_param_func.R b/inst/doc/usecase/ex2_6_ext_param_func.R index 760e30d2c1e8422d560c9ff6d10da5206138bf71..713d9bbfdb2a2df27ef120a1a0551a14c695bf53 100644 --- a/inst/doc/usecase/ex2_6_ext_param_func.R +++ b/inst/doc/usecase/ex2_6_ext_param_func.R @@ -8,8 +8,10 @@ firsty <- "1981" lasty <- "1987" months <- 10:12 - firstd <- paste0(firsty,"1001") - sdates <- ymd(firstd) + months(0:2) + rep(years(0:(1987-1981)), each = 3) + firstd <- paste0(firsty, "1001") + sdates <- ymd(firstd) + years(0:(1987-1981)) + sdates <- as.Date(sapply(sdates, FUN = function(x) {x %m+% months(0:2)}), + origin = "1970-01-01") #=================== # Get daily winds