From ddfa2387a8222ade842dd33e0b8e6bb2f60bcad0 Mon Sep 17 00:00:00 2001 From: nperez Date: Thu, 13 May 2021 19:41:41 +0200 Subject: [PATCH 1/2] Test for DCPP HadGem3 --- .../testthat/test-Start-DCPP-across-depends.R | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/testthat/test-Start-DCPP-across-depends.R diff --git a/tests/testthat/test-Start-DCPP-across-depends.R b/tests/testthat/test-Start-DCPP-across-depends.R new file mode 100644 index 0000000..40f4268 --- /dev/null +++ b/tests/testthat/test-Start-DCPP-across-depends.R @@ -0,0 +1,26 @@ +context("DCPP successfull retrieved for depends and across parameters.") +test_that("Chunks of DCPP files- Local execution", { + + path <- '/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Omon/tos/gn/v20200417/$var$_Omon_HadGEM3-GC31-MM_dcppA-hindcast_s$sdate$-r1i1p1f2_gn_$chunk$.nc' + + sdates <- c('2017', '2018') + dat <- Start(dat = path, + var = 'tos', + sdate = sdates, + chunk = indices(3:5), + chunk_depends = 'sdate', + time = 'all', + i = indices(1:10), + j = indices(1:10), + time_across = 'chunk', + merge_across_dims = TRUE, + retrieve = TRUE, + return_vars = list(time = 'sdate')) + + one <- Start(dat = '/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Omon/tos/gn/v20200417/$var$_Omon_HadGEM3-GC31-MM_dcppA-hindcast_s2018-r1i1p1f2_gn_202201-202212.nc', + var = 'tos', time = 'all', i = indices(1:10), j = indices(1:10), + retrieve = TRUE) + + expect_equal(dat[1,1,2,25:36,,], one[1,1,,,]) +}) + -- GitLab From a12220c8deb6431dc2380612b2ec4538e3828eaf Mon Sep 17 00:00:00 2001 From: aho Date: Fri, 14 May 2021 12:30:19 +0200 Subject: [PATCH 2/2] Add two more tests for middle points. --- .../testthat/test-Start-DCPP-across-depends.R | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-Start-DCPP-across-depends.R b/tests/testthat/test-Start-DCPP-across-depends.R index 40f4268..f5a5dc6 100644 --- a/tests/testthat/test-Start-DCPP-across-depends.R +++ b/tests/testthat/test-Start-DCPP-across-depends.R @@ -17,10 +17,26 @@ test_that("Chunks of DCPP files- Local execution", { retrieve = TRUE, return_vars = list(time = 'sdate')) - one <- Start(dat = '/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Omon/tos/gn/v20200417/$var$_Omon_HadGEM3-GC31-MM_dcppA-hindcast_s2018-r1i1p1f2_gn_202201-202212.nc', +# [sdate = 2, chunk = 3] +dat_2018_chunk3 <- Start(dat = '/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Omon/tos/gn/v20200417/$var$_Omon_HadGEM3-GC31-MM_dcppA-hindcast_s2018-r1i1p1f2_gn_202201-202212.nc', var = 'tos', time = 'all', i = indices(1:10), j = indices(1:10), retrieve = TRUE) - expect_equal(dat[1,1,2,25:36,,], one[1,1,,,]) +expect_equal(dat[1,1,2,25:36,,], dat_2018_chunk3[1,1,,,]) + +# [sdate = 1, chunk = 2] +dat_2017_chunk2 <- Start(dat = '/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Omon/tos/gn/v20200417/$var$_Omon_HadGEM3-GC31-MM_dcppA-hindcast_s2017-r1i1p1f2_gn_202001-202012.nc', + var = 'tos', time = 'all', i = indices(1:10), j = indices(1:10), + retrieve = TRUE) + +expect_equal(dat[1,1,1,13:24,,], dat_2017_chunk2[1,1,,,]) + +# [sdate = 2, chunk = 1] +dat_2018_chunk1 <- Start(dat = '/esarchive/exp/CMIP6/dcppA-hindcast/hadgem3-gc31-mm/cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/dcppA-hindcast/r1i1p1f2/Omon/tos/gn/v20200417/$var$_Omon_HadGEM3-GC31-MM_dcppA-hindcast_s2018-r1i1p1f2_gn_202001-202012.nc', + var = 'tos', time = 'all', i = indices(1:10), j = indices(1:10), + retrieve = TRUE) + +expect_equal(dat[1,1,2,1:12,,], dat_2018_chunk1[1,1,,,]) + }) -- GitLab