Commit 4b2d76a0 authored by nperez's avatar nperez
Browse files

Fix to new startR version and manually create obs file_date

parent 06406453
Pipeline #7126 failed with stage
in 53 minutes and 53 seconds
inst/doc/figures/subseasonal_5.png

492 KB | W: | H:

inst/doc/figures/subseasonal_5.png

449 KB | W: | H:

inst/doc/figures/subseasonal_5.png
inst/doc/figures/subseasonal_5.png
inst/doc/figures/subseasonal_5.png
inst/doc/figures/subseasonal_5.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -62,22 +62,36 @@ The time attributes returned by Start() are then used to define the correspondin
```r
# Corresponding ERA5
dates <- attr(exp, 'Variables')$common$time #20*4*103=8240 middle day of weekly averages
file_date <- sapply(dates, format, '%Y%m%d')
dim(file_date) <- c(length(sdates.seq), 20, 4)
names(dim(file_date)) <- c('sdate', 'syear', 'time')
## Generate the syears from the sdates.seq
syears <- t(sapply(sdates.seq, function(x) {
year <- as.numeric(substr(x, 1, 4))
syears <- paste0((year-20):(year-1), substr(x, 5, 8))
}))
names(dim(syears)) <- c('sdate', 'syear')
## Generate the times from the syears
Sys.setenv(TZ='UTC') # this helps to get UTC times
times <- lapply(syears, function(x) {
x <- as.Date(x, format = "%Y%m%d", tz = "UTC")
x <- seq(x, x + 25, by = 'week')
format(x, "%Y%m%d")
})
times <- Reduce(c, times)
dim(times) <- c(time = 4, sdate = 103, syear = 20)
times <- s2dv::Reorder(times, c(2,3,1))
obs_path <- paste0("/esarchive/recon/ecmwf/era5/weekly_mean/",
"$var$_f1h-240x121/$var$_$file_date$.nc")
obs <- Start(dat = obs_path,
var = 'tas',
file_date = file_date, # sdate syear time
# 103 20 4
file_date = times,
latitude = indices(1:121),
longitude = indices(1:240),
split_multiselected_dims = TRUE,
return_vars = list(latitude = NULL,
longitude = NULL,
time = 'file_date'),
retrieve = FALSE)
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment