Time information does not match the pre-defined date in Start()
Hi @aho
Since PA is adjusting the one-month lag for the timestamp in 'exp', for now, I have to manually create the required 'dates' for loading 'obs'. However, the 'time' info in the output is different from what I defined in Start(). Please see the codes below.
rm(list = ls())
library(startR)
library(s2dv)
library(ClimProjDiags)
library(multiApply)
path.output <- '/esarchive/scratch/cchou/FOCUS/teleconnection/output/'
path.obs <- '/esarchive/recon/ecmwf/era5/monthly_mean/$var$_f1h-r1440x721cds/$var$_$date$.nc'
var <- 'tos'
y1 <- 1981
y2 <- 2016
months <- 12:1
seasons <- c('DJF', 'NDJ', 'OND', 'SON', 'ASO', 'JAS',
'JJA', 'MJJ', 'AMJ', 'MAM', 'FMA', 'JFM')
indices <- c('NINO34', 'ALT3')
# Domains: NINO34, ALT3
lons.min <- c(360 - 170, 360 - 20)
lons.max <- c(360 - 120, 360)
lats.min <- c(-5, -3)
lats.max <- c(5, 3)
index <- 1
season = 3
ini_month <- sprintf("%02d", months[season])
dates.obs <- c(paste0(y1:y2, ini_month, '01'),
paste0(y1:y2, months[season] + 1, '01'),
paste0(y1:y2, months[season] + 2, '01'))
time.obs <- as.POSIXct(dates.obs, "%Y%m%d",
origin = paste0(y1,'-', ini_month), tz = 'UTC')
dim(time.obs) <- c(sdate = 36, time = 3)
# Load observation
obs <- Start(data = path.obs,
var = var,
date = unique(format(time.obs, '%Y%m')),
time = values(time.obs),
latitude = values(list(lats.min[index], lats.max[index])),
latitude_reorder = Sort(decreasing = TRUE),
longitude = values(list(lons.min[index], lons.max[index])),
time_across = 'date',
merge_across_dims = TRUE,
split_multiselected_dims = TRUE,
synonims = list(longitude = c('lon', 'longitude'),
latitude = c('lat', 'latitude')),
return_vars = list(longitude = NULL,
latitude = NULL,
time = 'date'),
retrieve = TRUE)
dates.obs <- attr(obs, 'Variables')$common$time
print(dates.obs)
Below is the 'time' information retrieved from the output. It only reaches 95 instead of 108.
[1] "1981-10-15 23:30:00 UTC" "1982-10-15 23:30:00 UTC"
[3] "1983-10-15 23:30:00 UTC" "1984-10-15 23:30:00 UTC"
[5] "1985-10-15 23:30:00 UTC" "1986-10-15 23:30:00 UTC"
...
[35] "2015-10-16 11:30:00 UTC" "2016-10-16 11:30:00 UTC"
[37] "1981-11-14 23:30:00 UTC" "1982-11-14 23:30:00 UTC"
...
[93] "2001-12-15 23:30:00 UTC" "2002-12-15 23:30:00 UTC"
[95] "2003-12-15 23:30:00 UTC"
However, time.obs
is what I defined in Start().
time.obs
[1] "1981-10-01 UTC" "1982-10-01 UTC" "1983-10-01 UTC" "1984-10-01 UTC"
[5] "1985-10-01 UTC" "1986-10-01 UTC" "1987-10-01 UTC" "1988-10-01 UTC"
...
[101] "2009-12-01 UTC" "2010-12-01 UTC" "2011-12-01 UTC" "2012-12-01 UTC"
[105] "2013-12-01 UTC" "2014-12-01 UTC" "2015-12-01 UTC" "2016-12-01 UTC"
The 'obs' data is repeating from the 96th value onwards too.
> obs[1,1,,,1,1]
[,1] [,2] [,3]
[1,] 301.8575 302.1779 301.7946
[2,] 302.6451 302.5957 301.7097
[3,] 301.6828 300.7412 300.6221
[4,] 301.4021 301.3306 300.9329
[5,] 302.0560 301.7993 301.3563
[6,] 302.9557 302.4423 301.9689
[7,] 303.0097 302.8050 302.3060
[8,] 300.0628 299.5734 300.4324
[9,] 301.8491 301.5519 301.9346
[10,] 302.6399 302.6531 302.5040
[11,] 303.0879 302.8238 302.1629
[12,] 302.2448 302.2204 302.2518
[13,] 302.4399 302.3959 301.7002
[14,] 302.9105 302.8586 302.3719
[15,] 301.2810 301.0879 300.9928
[16,] 301.8930 301.9221 301.6937
[17,] 302.2904 302.1191 301.3397
[18,] 301.4516 300.5764 299.8687
[19,] 301.3591 300.4803 299.9823
[20,] 301.3993 301.7407 300.9630
[21,] 302.1356 302.2521 301.8363
[22,] 303.1734 302.7776 302.2701
[23,] 302.4825 302.0382 302.2408
[24,] 303.1264 302.8351 302.8351 <- From here (96th), the values are the same as the left column
[25,] 302.0797 301.8065 301.8065
[26,] 303.3176 303.3181 303.3181
[27,] 301.3405 301.1152 301.1152
[28,] 301.7699 301.5423 301.5423
[29,] 303.0560 303.1032 303.1032
[30,] 300.6769 300.6130 300.6130
[31,] 301.7847 301.7355 301.7355
[32,] 302.4726 302.3659 302.3659
[33,] 301.9391 301.9062 301.9062
[34,] 302.7091 302.6886 302.6886
[35,] 302.4247 302.9544 302.9544
[36,] 302.0981 301.4453 301.4453
Could you please take a look either I defined the time.obs
in the wrong way?
Thank you so much.
Best, Chung