diff --git a/tools/divide_recipe.R b/tools/divide_recipe.R index 0097efa9dcad7cb3cceb3f7bc57520f625acc5b6..57841526ec27ec621d0a6a2b3a47b7c1ba5b3f8e 100644 --- a/tools/divide_recipe.R +++ b/tools/divide_recipe.R @@ -180,20 +180,22 @@ divide_recipe <- function(recipe) { # Remove extra NA days if sdate is not a leap year: days <- days[!is.na(days)] day_of_the_week_ini <- days[days$wday == sdate_weekday] + } else if (nchar(recipe$Analysis$Time$sdate[sdate]) == 8) { - day_of_the_week_ini <- as.POSIXct(as.character(recipe$Analysis$Time$sdate[sdate]), + day_of_the_week_ini <- as.POSIXct(as.character(recipe$Analysis$Time$sdate), format = "%Y%m%d", origin = '1970-01-01', tz = 'UTC') } else { - stop("what other cases can exist in subaseasonal?") + stop("what other cases can exist in subseasonal?") } } + fcst_years <- format(day_of_the_week_ini, "%Y") for (sdate in 1:length(day_of_the_week_ini)) { for (reci in 1:length(all_recipes)) { all_recipes[[reci]]$Analysis$Time <- list(sdate = format(day_of_the_week_ini[sdate], "%Y%m%d"), - fcst_year = recipe$Analysis$Time$fcst_year, + fcst_year = fcst_years[sdate], hcst_start = recipe$Analysis$Time$hcst_start, hcst_end = recipe$Analysis$Time$hcst_end, ftime_min = recipe$Analysis$Time$ftime_min,