From a2f96efda73e5e7156d79238b984110c25d908f6 Mon Sep 17 00:00:00 2001 From: Victoria Agudetse Roures Date: Tue, 3 Oct 2023 12:00:32 +0200 Subject: [PATCH 1/2] Add TODO --- modules/Saving/R/get_dir.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/Saving/R/get_dir.R b/modules/Saving/R/get_dir.R index 915c3f11..a2cbc79f 100644 --- a/modules/Saving/R/get_dir.R +++ b/modules/Saving/R/get_dir.R @@ -37,7 +37,7 @@ get_dir <- function(recipe, variable, agg = "global") { fcst.sdate <- paste0("hcst-", recipe$Analysis$Time$sdate) } } - + ## TODO: Remove calibration method from output directory? calib.method <- tolower(recipe$Analysis$Workflow$Calibration$method) store.freq <- recipe$Analysis$Variables$freq ## TODO: Change "_country" @@ -52,7 +52,6 @@ get_dir <- function(recipe, variable, agg = "global") { "-", store.freq, "/", variable, "/", fcst.sdate, "/")}) } - ## TODO: Dir creation? return(dir) } -- GitLab From fe3b2f93af808ee2d6c17b26bec7f5d1fc8f2b9f Mon Sep 17 00:00:00 2001 From: Victoria Agudetse Roures Date: Tue, 3 Oct 2023 12:00:50 +0200 Subject: [PATCH 2/2] Add saving to Downscaling unit test --- tests/recipes/recipe-seasonal_downscaling.yml | 2 +- tests/testthat/test-seasonal_downscaling.R | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/recipes/recipe-seasonal_downscaling.yml b/tests/recipes/recipe-seasonal_downscaling.yml index 1a2a3110..41df9e82 100644 --- a/tests/recipes/recipe-seasonal_downscaling.yml +++ b/tests/recipes/recipe-seasonal_downscaling.yml @@ -44,7 +44,7 @@ Analysis: log_reg_method: nanalogs: 3 target_grid: /esarchive/recon/ecmwf/era5/daily_mean/tas_f1h/tas_199301.nc - save: 'none' + save: 'all' Output_format: S2S4E Run: Loglevel: INFO diff --git a/tests/testthat/test-seasonal_downscaling.R b/tests/testthat/test-seasonal_downscaling.R index 0353a04e..fde0756d 100644 --- a/tests/testthat/test-seasonal_downscaling.R +++ b/tests/testthat/test-seasonal_downscaling.R @@ -4,7 +4,7 @@ context("Seasonal daily data") source("modules/Loading/Loading.R") source("modules/Skill/Skill.R") source("modules/Downscaling/Downscaling.R") - +source("modules/Saving/Saving.R") recipe_file <- "tests/recipes/recipe-seasonal_downscaling.yml" recipe <- prepare_outputs(recipe_file, disable_checks = F) @@ -192,4 +192,17 @@ FALSE }) +test_that("4. Check saved data", { + +outputs <- paste0(recipe$Run$output_dir, "/outputs/Downscaling/") +expect_equal( +all(basename(list.files(outputs, recursive = T)) %in% +c("tas_19931201.nc", "tas_19941201.nc", "tas_19951201.nc", + "tas_19961201.nc", "tas-obs_19931201.nc", "tas-obs_19941201.nc", + "tas-obs_19951201.nc", "tas-obs_19961201.nc")), +TRUE +) + +}) + unlink(recipe$Run$output_dir, recursive = TRUE) -- GitLab