data_path <- system.file('extdata', package = 'startR')
path_obs <- file.path(data_path, 'obs/monthly_mean/$var$/$var$_$sdate$.nc')
sdates <- c('200011', '200012')
data <- Start(dat = list(list(path = path_obs)),
var = 'tos',
sdate = sdates,
time = 'all',
latitude = 'all',
longitude = 'all',
return_vars = list(latitude = 'dat',
longitude = 'dat',
time = 'sdate'),
retrieve = FALSE)
fun <- function(x) {
lat = attributes(x)$Variables$dat1$latitude
weight = sqrt(cos(lat * pi / 180))
corrected = Apply(list(x), target_dims = "latitude",
fun = function(x) {x * weight})
}
step <- Step(fun = fun,
target_dims = 'latitude',
output_dims = 'latitude',
use_libraries = c('multiApply'),
use_attributes = list(data = "Variables"))
wf <- AddStep(data, step)
if (FALSE) {
res <- Compute(wf, chunks = list(longitude = 2, sdate = 2),
threads_load = 1,
threads_compute = 4,
cluster = list(queue_host = 'nord3',
queue_type = 'lsf',
temp_dir = '/on_hpc/tmp_dir/',
cores_per_job = 2,
job_wallclock = '05:00',
max_jobs = 4,
extra_queue_params = list('#BSUB -q bsc_es'),
bidirectional = FALSE,
polling_period = 10
),
ecflow_suite_dir = '/on_local_machine/username/ecflow_dir/',
wait = FALSE)
saveRDS(res, file = 'test_collect.Rds')
collect_info <- readRDS('test_collect.Rds')
result <- Collect(collect_info, wait = TRUE)
}
Run the code above in your browser using DataLab