diff --git a/R/Load.R b/R/Load.R index cded9565fe77ae89528bd4c701d171982647c795..6b136ec90e904d15c6da40ba3d6f5b1074932ae2 100644 --- a/R/Load.R +++ b/R/Load.R @@ -1553,7 +1553,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, # the current date. if (is.null(exp) || dims == 0) { if (is.null(leadtimemax)) { - diff <- Sys.time() - as.POSIXct(sdates[1], format = '%Y%m%d') + diff <- Sys.time() - as.POSIXct(sdates[1], format = '%Y%m%d', tz = "UTC") if (diff > 0) { .warning("Loading observations only and no 'leadtimemax' specified. Data will be loaded from each starting date to current time.") if (storefreq == 'monthly') { @@ -1709,7 +1709,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, } day <- as.integer(day) startdate <- as.POSIXct(paste(substr(sdate, 1, 4), '-', - substr(sdate, 5, 6), '-', day, ' 12:00:00', sep = '')) + + substr(sdate, 5, 6), '-', day, ' 12:00:00', sep = ''), tz = "UTC") + (leadtimemin - 1) * 86400 year <- as.integer(substr(startdate, 1, 4)) month <- as.integer(substr(startdate, 6, 7)) @@ -2226,9 +2226,11 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, function(x) { do.call(c, lapply((0:(number_ftime - 1)) * sampleperiod, function(y) { - addTime(as.POSIXct(x, format = "%Y%m%d"), store_period, y + leadtimemin - 1) + addTime(as.POSIXct(x, format = "%Y%m%d", tz = "UTC"), store_period, y + leadtimemin - 1) })) })) + attr(dates[["start"]], "tzone") <- "UTC" + # end is similar to start, but contains the end dates of each forecast # time step dates[["end"]] <- do.call(c, lapply(dates[["start"]], @@ -2238,6 +2240,7 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, addTime(y, store_period) })) })) + attr(dates[["end"]], "tzone") <- "UTC" tags_to_find <- c('START_DATE', 'MEMBER_NUMBER', 'YEAR', 'MONTH', 'DAY') position_of_tags <- na.omit(match(tags_to_find, names(replace_values))) @@ -2249,14 +2252,19 @@ Load <- function(var, exp = NULL, obs = NULL, sdates, nmember = NULL, models <- list() for (jmod in 1:length(exp)) { member_names <- paste0("Member_", 1:nmember[jmod]) - models[[exp[[jmod]][["name"]]]] <- list( - InitializationDates = lapply(member_names, + + InitializationDates <- do.call(c, lapply(member_names, function(x) { do.call(c, lapply(sdates, function(y) { - as.POSIXct(y, format = "%Y%m%d") + as.POSIXct(y, format = "%Y%m%d", tz = "UTC") })) - }), + })) + attr(InitializationDates, "tzone") <- "UTC" + + models[[exp[[jmod]][["name"]]]] <- list( + InitializationDates = InitializationDates, Members = member_names) + names(models[[exp[[jmod]][["name"]]]]$InitializationDates) <- member_names attr(models[[exp[[jmod]][["name"]]]], 'dataset') <- exp[[jmod]][["name"]] attr(models[[exp[[jmod]][["name"]]]], 'source') <- {