From c42f99edb4f12ab812720cd9d8635f69e70542e1 Mon Sep 17 00:00:00 2001 From: vagudets Date: Tue, 23 Sep 2025 11:20:57 +0200 Subject: [PATCH 1/2] Fix subseasonal startdate recipe splitting when giving individual dates --- tools/divide_recipe.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/divide_recipe.R b/tools/divide_recipe.R index 0097efa9..f68dbcd5 100644 --- a/tools/divide_recipe.R +++ b/tools/divide_recipe.R @@ -181,12 +181,12 @@ divide_recipe <- function(recipe) { 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?") } } for (sdate in 1:length(day_of_the_week_ini)) { -- GitLab From 604426c958d44d45457f3e94096545a7618ec3fd Mon Sep 17 00:00:00 2001 From: vagudets Date: Tue, 23 Sep 2025 11:47:03 +0200 Subject: [PATCH 2/2] Parse correct fcst_year when splitting subseasonal recipes --- tools/divide_recipe.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/divide_recipe.R b/tools/divide_recipe.R index f68dbcd5..57841526 100644 --- a/tools/divide_recipe.R +++ b/tools/divide_recipe.R @@ -180,6 +180,7 @@ 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), format = "%Y%m%d", @@ -189,11 +190,12 @@ divide_recipe <- function(recipe) { 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, -- GitLab