diff --git a/R/Start.R b/R/Start.R index 6aeafc59fd09faa33806041ac6130b61a0d826f0..689374a89c1c351eb99410691583ff5fbf10c552 100644 --- a/R/Start.R +++ b/R/Start.R @@ -857,6 +857,10 @@ Start <- function(..., # dim = indices/selectors, if (!is.logical(merge_across_dims)) { stop("Parameter 'merge_across_dims' must be TRUE or FALSE.") } + if (merge_across_dims & is.null(inner_dims_across_files)) { + merge_across_dims <- FALSE + .warning("Parameter 'merge_across_dims' is changed to FALSE because there is no *_across argument.") + } # Check merge_across_dims_narm if (!is.logical(merge_across_dims_narm)) { diff --git a/inst/doc/usecase.md b/inst/doc/usecase.md index cd42b6b5d3ffd5450436055523646d593f32662e..b1cca75252a077f7895b4e4da0cab111f147bd99 100644 --- a/inst/doc/usecase.md +++ b/inst/doc/usecase.md @@ -55,6 +55,12 @@ You can find more explanation in FAQ [How-to-20](inst/doc/faq.md#20-use-metadata This script shows how to load and plot data in rotated coordinates using **Monarch-dust** simulations. + 13. [Use value array as selector to express dependency](inst/doc/usecase/ex1_13_implicit_dependency.R) + This script shows how to use a value array as the inner dimension selector to express +dependency on a file dimension. By this means, we do not need to specify the *_across +parameter and Start() can recognize this dependecy relationship. + + 2. **Execute computation (use `Compute()`)** 1. [Function working on time dimension](inst/doc/usecase/ex2_1_timedim.R) 2. [Function using attributes of the data](inst/doc/usecase/ex2_2_attr.R) diff --git a/inst/doc/usecase/ex1_13_implicit_dependency.R b/inst/doc/usecase/ex1_13_implicit_dependency.R new file mode 100644 index 0000000000000000000000000000000000000000..8d8f337308d06cca6c212e183ae31707bf96b948 --- /dev/null +++ b/inst/doc/usecase/ex1_13_implicit_dependency.R @@ -0,0 +1,88 @@ +# Author: An-Chi Ho +# Date: 13rd July 2021 +#--------------------------------------------------------------------- +# This script shows how to use a value array as the inner dimension selector to express +# dependency on a file dimension. By this means, we don't need to specify the *_across +# parameter and Start() can recognize this dependecy relationship. +# In the first case, 'time' is dependent on 'sdate'. We create the actual time values +# for each sdate beforehand. The time array is two-dimensional with the names 'time' +# and 'sdate'. +# In the second case, 'region' is dependent on 'sdate'. The two files have different +# index for Nino3. sdate 1993 has 'Nino3' at index 9 while sdate 2013 has 'Nino3' at +# index 11. Create a value array for region selector so Start() can look for 'Nino3' in +# each file. +#--------------------------------------------------------------------- + +library(startR) +library(lubridate) + +# Case 1: 'time' depends on 'sdate' +repos <- '/esarchive/exp/ecmwf/system4_m1/daily_mean/$var$_f24h/$var$_$sdate$.nc' + +sdates <- ymd("20010501") + rep(years(0:2), each = 1) +times <- array(ymd("20010501") + days(0:30) + rep(years(0:2), each = 31), + dim = c(time = 31, sdate = 3)) +times <- as.POSIXct(times * 86400, tz = 'UTC', origin = '1970-01-01') + +exp <- Start(dat = repos, + var = 'tos', + sdate = format(sdates, "%Y%m%d"), + time = times, #dim: [time = 31, sdate = 3]. time is corresponding to each sdate + ensemble = indices(1:5), + lat = 'all', + lon = 'all', + synonims = list(lat = c('lat', 'latitude'), + lon = c('lon', 'longitude')), + return_vars = list(lon = NULL, lat = NULL, time = 'sdate'), + retrieve = T) + +dim(exp) +# dat var sdate time ensemble lat lon +# 1 1 3 31 5 256 512 + +exp[1, 1, 2, 1:10, 1, 100, 100] +# [1] 302.1276 302.1346 302.2003 302.2121 302.2552 302.3312 302.3184 302.3507 +# [9] 302.3665 302.3865 + +summary(exp) +# Min. 1st Qu. Median Mean 3rd Qu. Max. NA's +# 271 274 287 287 299 305 19757385 + +#============================================================================= + +# Case 2: 'region' depends on 'sdate' +path <- paste0('/esarchive/exp/ecearth/a35b/diags/DCPP/EC-Earth-Consortium/', + 'EC-Earth3-HR/dcppA-hindcast/r1i1p1f1/Omon/$var$_mixed/gn/v20201107/', + '$var$_Omon_EC-Earth3-HR_dcppA-hindcast_s$sdate$-r1i1p1f1_gn_$chunk$.nc') + +region <- array('Nino3', dim = c(sdate = 2, region = 1)) + +data <- Start(dat = path, + var = 'tosmean', + sdate = c('1993', '2013'), + chunk = indices(1:2), + chunk_depends = 'sdate', + region = region, + time = 'all', + time_across = 'chunk', + merge_across_dims = TRUE, + return_vars = list(time = c('sdate', 'chunk'), + region = 'sdate'), + retrieve = T) + +dim(data) +# dat var sdate region time +# 1 1 2 1 2 + +data[1, 1, , 1, ] +# [,1] [,2] +#[1,] 24.98788 24.46488 # --> region index 9 in original file +#[2,] 24.47482 24.75953 # --> region index 11 in orginal file + + + + + + + + diff --git a/inst/doc/usecase/ex2_8_calibration.R b/inst/doc/usecase/ex2_8_calibration.R index d02afc1d63452bf2aa04105c38dc0c19c147fa4a..23ab3b01d89d0f7f8e651bbc753e4e1056af4a19 100644 --- a/inst/doc/usecase/ex2_8_calibration.R +++ b/inst/doc/usecase/ex2_8_calibration.R @@ -16,6 +16,8 @@ exp <- Start(dat = '/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f6h/$var$ latitude = values(list(lats.min, lats.max)), latitude_reorder = Sort(), longitude = values(list(lons.min, lons.max)), + synonims = list(latitude = c('lat', 'latitude'), + longitude = c('lon', 'longitude')), return_vars = list(latitude = 'dat', longitude = 'dat', time = c('sdate')), @@ -28,31 +30,30 @@ obs <- Start(dat = '/esarchive/recon/ecmwf/erainterim/monthly_mean/$var$_f6h/$va latitude = values(list(lats.min, lats.max)), latitude_reorder = Sort(), longitude = values(list(lons.min, lons.max)), + synonims = list(latitude = c('lat', 'latitude'), + longitude = c('lon', 'longitude')), return_vars = list(latitude = 'dat', longitude = 'dat', time = c('sdate')), - split_multiselected_dims = TRUE, - merge_across_dims = TRUE, retrieve = FALSE) # Define of the workflow # Function wrap_cal <- function(obs, exp) { - obs <- s2dverification::InsertDim(obs, 1, 1) - names(dim(obs))<- c('member', 'sdate') - exp <- t(exp) - names(dim(exp))<- c('member', 'sdate') + obs <- s2dv::InsertDim(obs, 1, 1, name = 'ensemble') #calibrated <- CSTools:::.cal(obs = obs, var_exp = exp) # CSTools version 1.0.1 or earlier calibrated <- CSTools:::.cal(exp = exp, obs = obs, cal.method = "mse_min", eval.method = "leave-one-out", - multi.model = FALSE) + multi.model = FALSE, + na.fill = TRUE, na.rm = TRUE, + apply_to = 'sign', alpha = 0.1) return(calibrated) } step <- Step(wrap_cal, - target_dims = list(obs = c('sdate'), exp = c('sdate', 'ensemble')), + target_dims = list(obs = c('sdate'), exp = c('ensemble', 'sdate')), output_dims = c('ensemble', 'sdate')) # workflow of operations @@ -92,10 +93,10 @@ res_nord3 <- Compute(wf, ecflow_suite_dir = "/esarchive/scratch/nperez/ecflow") # your path! # Results - dim(res$output1) +dim(res$output1) # ensemble sdate dat var time latitude longitude # 15 11 1 1 1 14 15 - summary(res$output1) +summary(res$output1) # Min. 1st Qu. Median Mean 3rd Qu. Max. -# 292.7 300.6 301.1 301.1 301.6 306.8 +# 293.1 300.6 301.1 301.1 301.6 306.8 diff --git a/tests/testthat/test-AddStep-DimNames.R b/tests/testthat/test-AddStep-DimNames.R index 5577ff5dd68e4e6b78f3e4af0431eaf0ece0a7ed..46042f173cc1f3dbe5bb9d66f1d64a8afe515b53 100644 --- a/tests/testthat/test-AddStep-DimNames.R +++ b/tests/testthat/test-AddStep-DimNames.R @@ -2,7 +2,8 @@ context("Error with bad dimensions tests.") test_that("Single File - Local execution", { -skip_on_cran() +skip_on_cran() +suppressWarnings( data <- Start(dataset = '/esarchive/recon/jma/jra55/monthly_mean/$var$_f6h/$var$_$sdate$$month$.nc', var = 'tas', sdate = '2000', @@ -15,6 +16,7 @@ skip_on_cran() lon = c('lon','longitude')), return_vars = list(lat = 'dataset', lon = 'dataset'), num_procs = 1, retrieve = FALSE) +) fun <- function(x) { return(x) diff --git a/tests/testthat/test-Compute-CDORemap.R b/tests/testthat/test-Compute-CDORemap.R index 67f2a1005654ab7c0592cd88d6d808bf484a4ff5..991e7e1e12d308fb75be27863a4b274ce6c7ba40 100644 --- a/tests/testthat/test-Compute-CDORemap.R +++ b/tests/testthat/test-Compute-CDORemap.R @@ -3,6 +3,8 @@ context("Compute use CDORemap") test_that("ex2_3", { repos <- '/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc' + +suppressWarnings( data <- Start(dat = repos, var = 'tas', sdate = c('20170101'), @@ -12,7 +14,7 @@ test_that("ex2_3", { longitude = 'all', return_vars = list(latitude = 'dat', longitude = 'dat', time = 'sdate'), retrieve = FALSE) - +) fun <- function(x) { lons_data <- as.vector(attr(x, 'Variables')$dat1$longitude) @@ -28,9 +30,11 @@ test_that("ex2_3", { use_attributes = list(data = "Variables")) wf3 <- AddStep(list(data = data), step3) +suppressWarnings( res3 <- Compute(workflow = wf3, chunks = list(ensemble = 1)) - + ) + expect_equal( attr(data, 'Dimensions'), c(dat = 1, var = 1, sdate = 1, ensemble = 1, time = 1, latitude = 640, longitude = 1296) diff --git a/tests/testthat/test-Compute-NumChunks.R b/tests/testthat/test-Compute-NumChunks.R index 319a18b65c6f8afda3c124e2908a98d413d2384b..507f981f8e0721d955536fb4a8e84b7caf2a16f2 100644 --- a/tests/testthat/test-Compute-NumChunks.R +++ b/tests/testthat/test-Compute-NumChunks.R @@ -3,6 +3,8 @@ context("Number of chunks tests.") test_that("Single File - Local execution", { skip_on_cran() + +suppressWarnings( data <- Start(dataset = '/esarchive/recon/jma/jra55/monthly_mean/$var$_f6h/$var$_$sdate$$month$.nc', var = 'tas', sdate = '2000', @@ -16,6 +18,7 @@ data <- Start(dataset = '/esarchive/recon/jma/jra55/monthly_mean/$var$_f6h/$var$ return_vars = list(lat = 'dataset', lon = 'dataset'), num_procs = 1, retrieve = FALSE) +) fun <- function(x) { return(x) @@ -24,18 +27,26 @@ step <- Step(fun = fun, target_dims = c('month'), output_dims = c('month')) -wf = AddStep(inputs = data, +wf <- AddStep(inputs = data, step_fun = step) -expect_equal(Compute(workflow = wf, - chunks = list(lat = 2, lon = 2), - threads_load = 1, - threads_compute = 2), +suppressWarnings( +res1 <- Compute(workflow = wf, + chunks = list(lat = 2, lon = 2), + threads_load = 1, + threads_compute = 2) +) +suppressWarnings( +res2 <- Compute(workflow = wf, + chunks = list(lat = 3, lon = 3), + threads_load = 1, + threads_compute = 2) +) - Compute(workflow = wf, - chunks = list(lat = 3, lon = 3), - threads_load = 1, - threads_compute = 2), - check.attributes = FALSE) +expect_equal( +res1, +res2, +check.attributes = FALSE +) }) diff --git a/tests/testthat/test-Compute-extra_params.R b/tests/testthat/test-Compute-extra_params.R index 9dae43c1be0614e09b112ea9896b49773b59c453..9b42e43c126fe53e0f3f015c9247a724ba1a02d8 100644 --- a/tests/testthat/test-Compute-extra_params.R +++ b/tests/testthat/test-Compute-extra_params.R @@ -11,6 +11,7 @@ test_that("ex2_6", { #=================== # Get daily winds #=================== +suppressWarnings( wind <- Start(dataset = dataset, var = "sfcWind", sdate = sdates, @@ -21,6 +22,7 @@ test_that("ex2_6", { retrieve = FALSE, synonims = list(longitude = c('lon', 'longitude'), latitude = c('lat', 'latitude'))) +) # Synthetic MJO for 'season = OND': set.seed(1) @@ -78,9 +80,11 @@ test_that("ex2_6", { target_dims = list(field = c('dataset', 'var', 'sdate', 'time')), output_dims = list(strat = c('phase'), t_test = c('phase'))) workflow <- AddStep(wind, step, MJO = MJO, season = "OND", lag = "0", amp = 0) - + +suppressWarnings( res <- Compute(workflow$strat, chunks = list(latitude = 2)) +) expect_equal( attr(wind, 'Dimensions'), diff --git a/tests/testthat/test-Compute-inconsistent_target_dim.R b/tests/testthat/test-Compute-inconsistent_target_dim.R index 241ab6e70404ca670238398b9fd28bf05eb3b119..fa4992afe565d5e28b501c8b2e3e488bce886261 100644 --- a/tests/testthat/test-Compute-inconsistent_target_dim.R +++ b/tests/testthat/test-Compute-inconsistent_target_dim.R @@ -4,6 +4,7 @@ context("Compute()/ByChunks(): dimension consistence check") # only margin dimensions need to be identical. Target dimensions can have # different lengths. +test_that("ex2_11", { path.exp <- '/esarchive/exp/ecmwf/system5c3s/monthly_mean/$var$_f6h/$var$_$sdate$.nc' path.obs <- '/esarchive/recon/ecmwf/era5/monthly_mean/$var$_f1h-r1440x721cds/$var$_$date$.nc' @@ -109,9 +110,10 @@ workflow <- AddStep(list(exp = exp, obs = obs), step, lons_exp = lons_exp, lats_exp = lats_exp, lons_obs = lons_obs, lats_obs = lats_obs) +suppressWarnings( res <- Compute(workflow$ind_exp, chunks = list(var = 1)) - +) expect_equal( attr(exp, 'Dimensions'), @@ -136,3 +138,4 @@ mean(res$ind_obs)*10^15, tolerance = 0.00001 ) +}) diff --git a/tests/testthat/test-Compute-timedim.R b/tests/testthat/test-Compute-timedim.R index 4c17806c6adacbffef08020d5de243e311f9021d..80d96ff0bf2ade58ae1b30c9f2cadd1c6e6e8e36 100644 --- a/tests/testthat/test-Compute-timedim.R +++ b/tests/testthat/test-Compute-timedim.R @@ -27,9 +27,11 @@ suppressWarnings( wf1 <- AddStep(data, step1) +suppressWarnings( res1 <- Compute(wf1, chunks = list(ensemble = 2)) - +) + expect_equal( attr(data, 'Dimensions'), c(dat = 1, var = 1, sdate = 2, ensemble = 2, time = 7, latitude = 10, longitude = 15) diff --git a/tests/testthat/test-Compute-two_data.R b/tests/testthat/test-Compute-two_data.R index e55a1538141711197c27f3b35ff1538deb1d0d93..9cb7145dc05c5c41b7935342c5b84a5d88147391 100644 --- a/tests/testthat/test-Compute-two_data.R +++ b/tests/testthat/test-Compute-two_data.R @@ -7,6 +7,7 @@ test_that("ex2_7", { '$var$_f6h/$var$_$sdate$.nc') sdates <- sapply(2013:2014, function(x) paste0(x, sprintf('%02d', 1:12), '01')) +suppressWarnings( exp <- Start(dat = repos, var = 'tas', sdate = sdates, @@ -19,12 +20,12 @@ test_that("ex2_7", { synonims = list(longitude = c('lon', 'longitude'), latitude = c('lat', 'latitude')), retrieve = F) - +) # obs data repos_obs <- paste0('/esarchive/recon/ecmwf/erainterim/monthly_mean/', '$var$_f6h/$var$_$sdate$.nc') sdates_obs <- (sapply(2012:2013, function(x) paste0(x, sprintf('%02d', 1:12)))) - +suppressWarnings( obs <- Start(dat = repos_obs, var = 'tas', sdate = sdates_obs, @@ -36,7 +37,7 @@ test_that("ex2_7", { synonims = list(longitude = c('lon', 'longitude'), latitude = c('lat', 'latitude')), retrieve = F) - +) func <- function(x, y) { crps <- mean(SpecsVerification::EnsCrps(x, y, R.new = Inf)) @@ -48,8 +49,10 @@ test_that("ex2_7", { # Compute() on fatnodes +suppressWarnings( res <- Compute(wf, chunks = list(latitude = 2)) +) expect_equal( attr(exp, 'Dimensions'), diff --git a/tests/testthat/test-Start-DCPP-across-depends.R b/tests/testthat/test-Start-DCPP-across-depends.R index f5a5dc6f7ee8dbbc535dabf813825b3cbada3747..452a2306f7415d936719f03041c43bcb89769d2a 100644 --- a/tests/testthat/test-Start-DCPP-across-depends.R +++ b/tests/testthat/test-Start-DCPP-across-depends.R @@ -4,6 +4,7 @@ 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') +suppressWarnings( dat <- Start(dat = path, var = 'tos', sdate = sdates, @@ -16,25 +17,30 @@ test_that("Chunks of DCPP files- Local execution", { merge_across_dims = TRUE, retrieve = TRUE, return_vars = list(time = 'sdate')) +) # [sdate = 2, chunk = 3] +suppressWarnings( 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,,], dat_2018_chunk3[1,1,,,]) # [sdate = 1, chunk = 2] +suppressWarnings( 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] +suppressWarnings( 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,,,]) diff --git a/tests/testthat/test-Start-calendar.R b/tests/testthat/test-Start-calendar.R index 328aa0e1fe611e4f98b39c161b7d4fff4516265b..8ac0760502fe1924b109f00d14616145606bf2b0 100644 --- a/tests/testthat/test-Start-calendar.R +++ b/tests/testthat/test-Start-calendar.R @@ -50,6 +50,7 @@ expect_equal( test_that("2. 365_day, daily, unit = 'days since 1984-01-01'", { path_bcc_csm2 <- '/esarchive/exp/CMIP6/dcppA-hindcast/bcc-csm2-mr/cmip6-dcppA-hindcast_i1p1/DCPP/BCC/BCC-CSM2-MR/dcppA-hindcast/r1i1p1f1/day/$var$/gn/v20200408/$var$_day_BCC-CSM2-MR_dcppA-hindcast_s$sdate$-r1i1p1f1_gn_19800101-19891231.nc' +suppressWarnings( data <- Start(dat = path_bcc_csm2, var = 'tasmax', sdate = '1980', @@ -58,6 +59,7 @@ path_bcc_csm2 <- '/esarchive/exp/CMIP6/dcppA-hindcast/bcc-csm2-mr/cmip6-dcppA-hi lon = indices(1), return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'), retrieve = FALSE) +) expect_equal( dim(attr(data, 'Variables')$common$time), @@ -87,6 +89,7 @@ test_that("3. standard, daily, unit = 'days since 1850-1-1 00:00:00'", { sdate <- '2000' fyear_mpi_esm <- paste0(sdate, '1101-', as.numeric(sdate) + 10, '1231') +suppressWarnings( data <- Start(dat = path_mpi_esm, var = var, sdate = sdate, @@ -97,6 +100,7 @@ test_that("3. standard, daily, unit = 'days since 1850-1-1 00:00:00'", { lon = indices(1), return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'), retrieve = FALSE) +) expect_equal( dim(attr(data, 'Variables')$common$time), @@ -123,6 +127,7 @@ test_that("4. standard, monthly, unit = 'days since 1850-1-1 00:00:00'", { sdate <- '2000' fyear_mpi_esm <- paste0(sdate, '1101-', as.numeric(sdate) + 10, '1231') +suppressWarnings( data <- Start(dat = path_mpi_esm, var = 'tasmax', sdate = '2000', @@ -131,6 +136,7 @@ test_that("4. standard, monthly, unit = 'days since 1850-1-1 00:00:00'", { lon = indices(1), return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'), retrieve = FALSE) +) expect_equal( dim(attr(data, 'Variables')$common$time), @@ -153,6 +159,8 @@ test_that("5. proleptic_gregorian, 6hrly, unit = 'hours since 2000-11-01 00:00:0 date <- paste0('1994-05-', sprintf('%02d', 1:31), ' 00:00:00') date <- as.POSIXct(date, tz = 'UTC') # attr(date, 'tzone') <- 'UTC' + +suppressWarnings( data <- Start(dat = repos_obs, var = 'tas', time = date, @@ -162,6 +170,7 @@ test_that("5. proleptic_gregorian, 6hrly, unit = 'hours since 2000-11-01 00:00:0 longitude = NULL, time = NULL), retrieve = TRUE) +) expect_equal( as.vector(attr(data, 'Variables')$common$time[1:31]), @@ -182,6 +191,7 @@ expect_equal( test_that("6. standard, monthly, unit = 'months since 1870-01-16 12:00:00'", { repos_obs <- '/esarchive/obs/ukmo/hadisst_v1.1/monthly_mean/$var$/$var$_$date$.nc' +suppressWarnings( obs <- Start(dat = repos_obs, var = 'tos', date = '200505', #dates_file, @@ -199,6 +209,7 @@ test_that("6. standard, monthly, unit = 'months since 1870-01-16 12:00:00'", { lon = 'dat', time = 'date'), retrieve = FALSE) +) expect_equal( attr(obs, 'Variables')$common$time[1, 1], @@ -210,6 +221,7 @@ expect_equal( test_that("7. proleptic_gregorian, monthly, unit = 'days since 1850-1-1 00:00:00'", { repos <- '/esarchive/exp/mpi-esm-lr/cmip5-historical_i0p1/monthly_mean/$var$/$var$_$sdate$.nc' +suppressWarnings( data <- Start(dat = repos, var = 'tas', sdate = '20000101', @@ -218,7 +230,7 @@ test_that("7. proleptic_gregorian, monthly, unit = 'days since 1850-1-1 00:00:00 latitude = indices(1:4), longitude = indices(1:3), return_vars = list(time = NULL)) - +) time <- c(as.POSIXct('2000-01-16 12:00:00', tz = 'UTC'), as.POSIXct('2000-02-15 12:00:00', tz = 'UTC'), as.POSIXct('2000-03-16 12:00:00', tz = 'UTC')) @@ -241,14 +253,15 @@ test_that("7. proleptic_gregorian, monthly, unit = 'days since 1850-1-1 00:00:00 test_that("8. gregorian, 3hrly, unit = 'days since 1850-1-1'", { repos <- '/esarchive/exp/CMIP5/historical/ecearth/cmip5-historical_i0p1/$var$_3hr_EC-EARTH_historical_r6i1p1_$period$.nc' - data <- Start(dat = repos, + suppressWarnings( + data <- Start(dat = repos, var = 'vas', period = '200501010300-200601010000', time = indices(1:3), lat = indices(1:4), lon = indices(1:3), return_vars = list(time = NULL)) - +) time <- c(as.POSIXct('2005-01-01 03:00:00', tz = 'UTC'), as.POSIXct('2005-01-01 06:00:00', tz = 'UTC'), as.POSIXct('2005-01-01 09:00:00', tz = 'UTC')) diff --git a/tests/testthat/test-Start-first_file_missing.R b/tests/testthat/test-Start-first_file_missing.R index 25f4d0241cea4b25d642db5863f79fd8df08e0f6..392841aa0a44121807d74d27df6456615f252f97 100644 --- a/tests/testthat/test-Start-first_file_missing.R +++ b/tests/testthat/test-Start-first_file_missing.R @@ -16,6 +16,7 @@ sdates5 <- c("20130611", "20130612") #both exist test_that("1. first file missing, no assign parameter 'metadata_dims'", { +suppressWarnings( data <- Start(dat = file, var = var, file_date = sdates4, @@ -32,6 +33,7 @@ data <- Start(dat = file, time = 'file_date'), #metadata_dims = c('file_date'), retrieve = T) +) expect_equal( dim(data), @@ -54,7 +56,7 @@ data <- Start(dat = file, }) test_that("2. Use parameter 'metadata_dims'", { - +suppressWarnings( data <- Start(dat = file, var = var, file_date = sdates4, @@ -71,6 +73,7 @@ data <- Start(dat = file, time = 'file_date'), metadata_dims = c('file_date'), retrieve = T) +) expect_equal( dim(data), @@ -92,7 +95,7 @@ data <- Start(dat = file, }) test_that("3. Use parameter 'metadata_dims', all common attributes, 1st file missing", { - +suppressWarnings( data <- Start(dat = file, var = var, file_date = sdates4, @@ -109,7 +112,7 @@ data <- Start(dat = file, time = 'file_date'), metadata_dims = c('file_date'), retrieve = T) - +) expect_equal( names(attr(data, 'Variables')$common), c('latitude', 'longitude', 'time', NA, 'tas') @@ -122,7 +125,7 @@ data <- Start(dat = file, }) test_that("4. Use parameter 'metadata_dims', all common attributes, 2nd file missing", { - +suppressWarnings( data <- Start(dat = file, var = var, file_date = sdates3, @@ -139,7 +142,7 @@ data <- Start(dat = file, time = 'file_date'), metadata_dims = c('file_date'), retrieve = T) - +) expect_equal( names(attr(data, 'Variables')$common), c('latitude', 'longitude', 'time', 'tas', NA) @@ -152,7 +155,7 @@ data <- Start(dat = file, }) test_that("5. Use parameter 'metadata_dims', all common attributes, no file missing", { - +suppressWarnings( data <- Start(dat = file, var = var, file_date = sdates5, @@ -169,7 +172,7 @@ data <- Start(dat = file, time = 'file_date'), metadata_dims = c('file_date'), retrieve = T) - +) expect_equal( names(attr(data, 'Variables')$common), c('latitude', 'longitude', 'time', 'tas', 'tas') diff --git a/tests/testthat/test-Start-global-lon-across_meridian.R b/tests/testthat/test-Start-global-lon-across_meridian.R index 16507033c30bb95c0009b92b99794dcb6adbad91..0c01db52a3ab3e02ce6b6643fc880109a63371f2 100644 --- a/tests/testthat/test-Start-global-lon-across_meridian.R +++ b/tests/testthat/test-Start-global-lon-across_meridian.R @@ -12,6 +12,7 @@ skip_on_cran() lat.min <- -90 lat.max <- 90 +suppressWarnings( data <- Start(dat = repos, var = var, sdate = c('20170101'), @@ -26,7 +27,8 @@ skip_on_cran() latitude = 'dat'), retrieve = FALSE ) - +) +suppressWarnings( data2 <- Start(dat = repos, var = var, sdate = c('20170101'), @@ -41,6 +43,7 @@ skip_on_cran() latitude = 'dat'), retrieve = FALSE ) +) expect_equal( attr(data, 'Dimensions'), diff --git a/tests/testthat/test-Start-selector_with_dim.R b/tests/testthat/test-Start-implicit_dependency_by_selector.R similarity index 59% rename from tests/testthat/test-Start-selector_with_dim.R rename to tests/testthat/test-Start-implicit_dependency_by_selector.R index 47762d3f19eafb6b35a70af54bf0723bf53f101f..bcc5ac111f252f7cdf93e6f757414360f54f8624 100644 --- a/tests/testthat/test-Start-selector_with_dim.R +++ b/tests/testthat/test-Start-implicit_dependency_by_selector.R @@ -1,8 +1,12 @@ +# Similar as usecase ex1_13. +# Use a value array as the inner dimension selector to express dependency on a +# file dimension. By this means, we don't need to specify the *_across parameter +# and Start() can recognize this dependecy relationship. #--------------------------------------------------- # If assign a selector with an array that has file dim as dimension, Start() read # the values depending on the the file dim. #--------------------------------------------------- -context("Start() implicit inner dimension") +context("Start() implicit dependency by selector dimension") test_that("1. region with different index between files", { @@ -14,6 +18,7 @@ path <- paste0('/esarchive/exp/ecearth/a35b/diags/DCPP/EC-Earth-Consortium/', # two sdates have different index for Nino3. region <- array('Nino3', dim = c(sdate = 2, region = 1)) +suppressWarnings( data <- Start(dat = path, var = 'tosmean', sdate = c('1993', '2013'), @@ -26,7 +31,8 @@ data <- Start(dat = path, return_vars = list(time = c('sdate', 'chunk'), region = 'sdate'), retrieve = T) - +) +suppressWarnings( data1 <- Start(dat = path, var = 'tosmean', sdate = c('1993'), @@ -39,7 +45,8 @@ data1 <- Start(dat = path, return_vars = list(time = c('sdate', 'chunk'), region = NULL), retrieve = T) - +) +suppressWarnings( data2 <- Start(dat = path, var = 'tosmean', sdate = c('2013'), @@ -52,6 +59,7 @@ data2 <- Start(dat = path, return_vars = list(time = c('sdate', 'chunk'), region = NULL), retrieve = T) +) expect_equal( dim(data), @@ -67,4 +75,47 @@ data2[1, 1, 1, 1, ] ) +}) + +test_that("2. time depends on sdate", { + +library(lubridate) + +repos <- '/esarchive/exp/ecmwf/system4_m1/daily_mean/$var$_f24h/$var$_$sdate$.nc' + +sdates <- ymd("20010501") + rep(years(0:2), each = 1) +times <- array(ymd("20010501") + days(0:30) + rep(years(0:2), each = 31), + dim = c(time = 31, sdate = 3)) +times <- as.POSIXct(times * 86400, tz = 'UTC', origin = '1970-01-01') + +suppressWarnings( +exp <- Start(dat = repos, + var = 'tos', + sdate = format(sdates, "%Y%m%d"), + time = times, #dim: [time = 31, sdate = 3]. time is corresponding to each sdate + ensemble = indices(1:2), + lat = indices(1:3), + lon = indices(1:6), + synonims = list(lat = c('lat', 'latitude'), + lon = c('lon', 'longitude')), + return_vars = list(lon = NULL, lat = NULL, time = 'sdate'), + retrieve = T) +) + +expect_equal( +dim(exp), +c(dat = 1, var = 1, sdate = 3, time = 31, ensemble = 2, lat = 3, lon = 6) +) +expect_equal( +mean(exp, na.rm = T), +271.4913, +tolerance = 0.0001 +) +expect_equal( +exp[1, 1, 3, 28:30, 1, 3, 2], +c(272.4185, 272.6533, 272.6494), +tolerance = 0.0001 +) + + }) diff --git a/tests/testthat/test-Start-largest_dims_length.R b/tests/testthat/test-Start-largest_dims_length.R index fe0899e8d19d46ff5372f2d1ee2796f15974b27f..59b73e89c4a8987d99524d4714e139e98f31cbfc 100644 --- a/tests/testthat/test-Start-largest_dims_length.R +++ b/tests/testthat/test-Start-largest_dims_length.R @@ -12,6 +12,7 @@ repos <- list(list(name = 'system5c3s', path = "/esarchive/exp/cmcc/system3_m1-c3s/monthly_mean/g500_f12h/$var$_$sdate$.nc")) # largest_dims_length = FALSE +suppressWarnings( dat1 <- Start(dataset = repos, var = "g500", sdate = c("19931101","20200901"), @@ -28,7 +29,7 @@ dat1 <- Start(dataset = repos, latitude = 'dataset', longitude = 'dataset'), retrieve = T) - +) expect_equal( dim(dat1), c(dataset = 2, var = 1, sdate = 2, time = 6, ensemble = 40, latitude = 3, longitude = 2) @@ -47,6 +48,7 @@ dat1 <- Start(dataset = repos, ) # largest_dims_length = TRUE +suppressWarnings( dat2 <- Start(dataset = repos, var = "g500", sdate = c("19931101","20200901"), @@ -63,7 +65,7 @@ dat2 <- Start(dataset = repos, latitude = 'dataset', longitude = 'dataset'), retrieve = T) - +) expect_equal( dim(dat2), c(dataset = 2, var = 1, sdate = 2, time = 6, ensemble = 51, latitude = 3, longitude = 2) @@ -82,6 +84,7 @@ dat2 <- Start(dataset = repos, ) # largest_dims_length = c(ensemble = 51) +suppressWarnings( dat3 <- Start(dataset = repos, var = "g500", sdate = c("19931101","20200901"), @@ -98,7 +101,7 @@ dat3 <- Start(dataset = repos, latitude = 'dataset', longitude = 'dataset'), retrieve = T) - +) expect_equal( dim(dat3), c(dataset = 2, var = 1, sdate = 2, time = 6, ensemble = 51, latitude = 3, longitude = 2) diff --git a/tests/testthat/test-Start-line_order-consistency.R b/tests/testthat/test-Start-line_order-consistency.R index 74ffae2ad7cb4abd91710d9e6be0a8b69bc97fa9..dab029082413e211754beeada9b868f90658152e 100644 --- a/tests/testthat/test-Start-line_order-consistency.R +++ b/tests/testthat/test-Start-line_order-consistency.R @@ -13,6 +13,7 @@ context("Start() line order consistency check") test_that("1. lon and lat order", { skip_on_cran() +suppressWarnings( dat1 <- Start(dat = obs.path, var = variable, file_date = dates_file, @@ -31,7 +32,8 @@ skip_on_cran() longitude = 'dat', time = 'file_date'), retrieve = T) - +) +suppressWarnings( dat2 <- Start(dat = obs.path, var = variable, file_date = dates_file, @@ -50,7 +52,7 @@ skip_on_cran() longitude = 'dat', time = 'file_date'), retrieve = T) - +) expect_equal( length(attr(dat1, 'Variables')$dat1$latitude), length(attr(dat2, 'Variables')$dat1$latitude) @@ -64,7 +66,7 @@ skip_on_cran() test_that("2. dim length check: with/out reorder", { skip_on_cran() - +suppressWarnings( dat1 <- Start(dat = obs.path, var = variable, file_date = dates_file, @@ -83,7 +85,8 @@ skip_on_cran() longitude = 'dat', time = 'file_date'), retrieve = T) - +) +suppressWarnings( dat2 <- Start(dat = obs.path, var = variable, file_date = dates_file, @@ -104,7 +107,8 @@ skip_on_cran() longitude = 'dat', time = 'file_date'), retrieve = T) - +) +suppressWarnings( dat3 <- Start(dat = obs.path, var = variable, file_date = dates_file, @@ -124,7 +128,7 @@ skip_on_cran() longitude = 'dat', time = 'file_date'), retrieve = T) - +) expect_equal( length(attr(dat1, 'Variables')$dat1$latitude), length(attr(dat2, 'Variables')$dat1$latitude) diff --git a/tests/testthat/test-Start-metadata_dims.R b/tests/testthat/test-Start-metadata_dims.R index b446d1c29692b405aa3f71fe5a0ff9a6d1fcfdd3..b514df6be41647626f15108c1db801b00beb10e7 100644 --- a/tests/testthat/test-Start-metadata_dims.R +++ b/tests/testthat/test-Start-metadata_dims.R @@ -2,6 +2,7 @@ context("Start() metadata_dims check") test_that("1. One data set, one var", { repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" +suppressWarnings( data <- Start(dat = list(list(name = 'system5_m1', path = repos)), var = 'tas', sdate = '20170101', @@ -17,7 +18,7 @@ test_that("1. One data set, one var", { metadata_dims = 'dat', # it can be omitted since it is automatically specified as 'dat' retrieve = T ) - +) expect_equal( length(attr(data, 'Variables')), 2 @@ -45,7 +46,7 @@ test_that("1. One data set, one var", { test_that("2. Two data sets, one var", { repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" repos2 <- "/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" - +suppressWarnings( data <- Start(dat = list(list(name = 'system4_m1', path = repos2), list(name = 'system5_m1', path = repos)), var = 'tas', @@ -62,7 +63,7 @@ test_that("2. Two data sets, one var", { metadata_dims = 'dat', # it can be omitted since it is automatically specified as 'dat' retrieve = T ) - +) expect_equal( length(attr(data, 'Variables')), 3 @@ -100,7 +101,7 @@ test_that("3. One data set, two vars", { '$var$_Amon_EC-Earth3_historical_r24i1p1f1_gr_185001-185012.nc') var <- c('tas', 'clt') sdate <- '20170101' - +suppressWarnings( data <- Start(dat = repos, var = var, time = indices(1), @@ -112,7 +113,7 @@ test_that("3. One data set, two vars", { lon = c('lon', 'longitude')), retrieve = TRUE ) - +) expect_equal( length(attr(data, 'Variables')), 2 @@ -143,7 +144,7 @@ test_that("3. One data set, two vars", { test_that("4. Two data sets, two vars", { repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" repos2 <- "/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" - +suppressWarnings( data <- Start(dat = list(list(name = 'system4_m1', path = repos2), list(name = 'system5_m1', path = repos)), var = c('tas', 'sfcWind'), @@ -160,7 +161,7 @@ test_that("4. Two data sets, two vars", { metadata_dims = 'dat', retrieve = T ) - +) expect_equal( length(attr(data, 'Variables')), 3 @@ -190,7 +191,7 @@ test_that("4. Two data sets, two vars", { 11 ) - +suppressWarnings( data <- Start(dat = list(list(name = 'system4_m1', path = repos2), list(name = 'system5_m1', path = repos)), var = c('tas', 'sfcWind'), @@ -207,6 +208,8 @@ test_that("4. Two data sets, two vars", { metadata_dims = c('dat', 'var'), retrieve = T ) +) + expect_equal( length(attr(data, 'Variables')), 3 @@ -249,7 +252,7 @@ test_that("4. Two data sets, two vars", { test_that("5. Specify metadata_dims with another file dimension", { repos <- "/esarchive/exp/ecmwf/system5_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" repos2 <- "/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f6h/$var$_$sdate$.nc" - +suppressWarnings( data <- Start(dat = list(list(name = 'system4_m1', path = repos2), list(name = 'system5_m1', path = repos)), var = c('tas', 'sfcWind'), @@ -266,6 +269,8 @@ test_that("5. Specify metadata_dims with another file dimension", { metadata_dims = 'sdate', retrieve = T ) +) + expect_equal( length(attr(data, 'Variables')), 3 @@ -296,7 +301,7 @@ test_that("5. Specify metadata_dims with another file dimension", { test_that("6. One data set, two vars from one file", { mask_path <- '/esarchive/autosubmit/con_files/mask.regions.Ec3.0_O1L46.nc' - +suppressWarnings( data <- Start(repos = mask_path, var = c('nav_lon', 'nav_lat'), t = 'first', @@ -306,7 +311,7 @@ data <- Start(repos = mask_path, return_vars = list(var_names = NULL), var_var = 'var_names', retrieve = T) - +) expect_equal( length(attr(data, 'Variables')), 2 @@ -335,7 +340,8 @@ test_that("7. Two data sets, while one is missing", { # incorrect path. Therefore repos2 doesn't have any valid files repos2 <- "/esarchive/exp/ecmwf/system4_m1/monthly_mean/$var$_f2h/$var$_$sdate$.nc" # correct one is _f6h var <- 'tas' - data <- Start(dat = list(list(name = 'system4_m1', path = repos2), +suppressWarnings( + data <- Start(dat = list(list(name = 'system4_m1', path = repos2), list(name = 'system5_m1', path = repos)), var = var, sdate = '20170101', @@ -351,7 +357,7 @@ test_that("7. Two data sets, while one is missing", { metadata_dims = 'dat', # it can be omitted since it is automatically specified as 'dat' retrieve = T ) - +) expect_equal( length(data[is.na(data)]), 829440 @@ -387,7 +393,7 @@ path_list <- list( 'cmip6-dcppA-hindcast_i1p1/DCPP/MOHC/HadGEM3-GC31-MM/', 'dcppA-hindcast/$member$/day/$var$/gn/v20200101/', '$var$_day_HadGEM3-GC31-MM_dcppA-hindcast_s$sdate$-$member$_gn_$chunk$.nc'))) - +suppressWarnings( data <- Start(dataset = path_list, var = 'tasmin', member = list(c('r1i1p1f1', 'r2i1p1f2')), @@ -403,7 +409,7 @@ data <- Start(dataset = path_list, lat_reorder = Sort(), num_procs = 1, retrieve = T) - +) expect_equal( length(data[is.na(data)]), 5500 diff --git a/tests/testthat/test-Start-multiple-sdates.R b/tests/testthat/test-Start-multiple-sdates.R index 832205ae2e8bfd9e8abc4ef776f840b0564dda05..89c8ed89e0803931084a14c36d977226ae1472fd 100644 --- a/tests/testthat/test-Start-multiple-sdates.R +++ b/tests/testthat/test-Start-multiple-sdates.R @@ -17,23 +17,25 @@ sdates.seq <- c("20161222","20161229","20170105","20170112") test_that("1. ", { skip_on_cran() -hcst<-Start(dat = ecmwf_path_hc, - var = var_name, - sdate = sdates.seq, - syear = 'all', - time = 'all', - latitude = indices(1), - longitude = indices(1), - ensemble = 'all', - syear_depends = 'sdate', - return_vars = list(latitude = 'dat', +suppressWarnings( +hcst <- Start(dat = ecmwf_path_hc, + var = var_name, + sdate = sdates.seq, + syear = 'all', + time = 'all', + latitude = indices(1), + longitude = indices(1), + ensemble = 'all', + syear_depends = 'sdate', + return_vars = list(latitude = 'dat', longitude = 'dat', time = c('sdate','syear') ), - retrieve = F) + retrieve = F) +) dates <- attr(hcst, 'Variables')$common$time file_date <- unique(sapply(dates, format, '%Y%m')) - +suppressWarnings( obs <- Start(dat = obs_path, var = var100_name, latitude = indices(1), @@ -51,7 +53,7 @@ obs <- Start(dat = obs_path, longitude = 'dat',# time = c('file_date')), retrieve = T) - +) expect_equal( dim(obs), c(dat = 1, var = 1, latitude = 1, longitude = 1, sdate = 4, syear = 20, time = 47) @@ -89,7 +91,8 @@ obs <- Start(dat = obs_path, test_that("2. change the file_date order", { skip_on_cran() - hcst<-Start(dat = ecmwf_path_hc, +suppressWarnings( +hcst <- Start(dat = ecmwf_path_hc, var = var_name, sdate = sdates.seq, syear = indices(1:20), @@ -103,10 +106,12 @@ skip_on_cran() time = c('sdate','syear') ), retrieve = F) +) + dates <- attr(hcst, 'Variables')$common$time file_date <- sort(unique(sapply(dates, format, '%Y%m'))) - +suppressWarnings( obs <- Start(dat = obs_path, var = var100_name, latitude = indices(1), @@ -124,6 +129,7 @@ obs <- Start(dat = obs_path, longitude = 'dat',# time = c('file_date')), retrieve = T) +) expect_equal( dim(obs), diff --git a/tests/testthat/test-Start-path_glob_permissive.R b/tests/testthat/test-Start-path_glob_permissive.R index 2809d73585a4364fc06db41afb76a802e05a4244..f298bd440d9bfe091c896640ed316cfaefecec05 100644 --- a/tests/testthat/test-Start-path_glob_permissive.R +++ b/tests/testthat/test-Start-path_glob_permissive.R @@ -8,7 +8,7 @@ years <- paste0(c(1960:1961), '01-', c(1960:1961), '12') repos <- paste0('/esarchive/exp/ecearth/$expid$/diags/CMIP/EC-Earth-Consortium/', 'EC-Earth3/historical/*/Omon/$var$/gn/v*/', '$var$_Omon_EC-Earth3_historical_*_gn_$year$.nc') - +suppressWarnings( data <- Start(dat = repos, var = 'tosmean', expid = c('a1st', 'a1sx'), @@ -18,7 +18,7 @@ data <- Start(dat = repos, path_glob_permissive = 6, #TRUE, return_vars = list(time = NULL, region = NULL), retrieve = T) - +) expect_equal( dim(data), @@ -48,7 +48,7 @@ data <- Start(dat = repos, repos <- paste0('/esarchive/exp/ecearth/$expid$/diags/CMIP/EC-Earth-Consortium/', 'EC-Earth3/historical/$member$/Omon/$var$/gn/v*/', '$var$_Omon_EC-Earth3_historical_*_gn_$year$.nc') - +suppressWarnings( data <- Start(dat = repos, var = 'tosmean', expid = c('a1st', 'a1sx'), @@ -60,7 +60,7 @@ data <- Start(dat = repos, path_glob_permissive = 2, #TRUE, return_vars = list(time = NULL, region = NULL), retrieve = T) - +) expect_equal( dim(data), @@ -99,7 +99,7 @@ test_that("2. tag at the end", { sdates.seq.thu <- format(seq(as.Date(paste(2020, 06, 11, sep = '-')), as.Date(paste(2020, 09, 17, sep = '-')), by = 'weeks'), format='%Y%m%d') path <- "/esarchive/oper/S2S4E-data/weekly_statistics/S2S/$var$/$sdate$/$var$_$sdate$_*.nc" - +suppressWarnings( exp <- Start(dat = path, var = "tas", sdate = sdates.seq.thu, @@ -109,7 +109,7 @@ exp <- Start(dat = path, longitude = indices(1:2), path_glob_permissive = 1, retrieve = F) - +) asd <- as.list(attr(exp, 'ExpectedFiles')) qwe <- sapply(sapply(asd, strsplit, '/'), '[[', 9) files <- paste0('tas_', sdates.seq.thu, '_', 24:38, '.nc') @@ -117,6 +117,7 @@ exp <- Start(dat = path, qwe, files ) +suppressWarnings( exp <- Start(dat = path, var = "tas", sdate = sdates.seq.thu, @@ -126,7 +127,7 @@ exp <- Start(dat = path, longitude = indices(1:2), path_glob_permissive = FALSE, retrieve = F) - +) asd <- as.list(attr(exp, 'ExpectedFiles')) qwe <- sapply(sapply(asd, strsplit, '/'), '[[', 9) files <- paste0('tas_', sdates.seq.thu, '_', 24, '.nc') diff --git a/tests/testthat/test-Start-reorder-lat.R b/tests/testthat/test-Start-reorder-lat.R index 9c2729a930041831e13c707f75dfe41d5bea77da..262cf374e8815dcb04334f3da17568e6ca9e46a4 100644 --- a/tests/testthat/test-Start-reorder-lat.R +++ b/tests/testthat/test-Start-reorder-lat.R @@ -23,7 +23,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -38,7 +38,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -86,7 +86,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 20 lats.max <- 10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -101,7 +101,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -130,7 +130,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -10 lats.max <- -20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -145,7 +145,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -172,7 +172,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -20 lats.max <- -10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -187,7 +187,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -215,7 +215,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -230,7 +230,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -278,7 +278,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 20 lats.max <- 10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -293,7 +293,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -320,7 +320,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -10 lats.max <- -20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -335,6 +335,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -361,7 +362,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -20 lats.max <- -10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -376,6 +377,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -402,7 +404,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -417,6 +419,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = NULL, time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$common$latitude)), @@ -444,7 +447,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -459,6 +462,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = NULL, time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$common$latitude)), @@ -486,7 +490,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -502,6 +506,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -548,7 +553,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 20 lats.max <- 10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -564,6 +569,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -590,7 +596,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -606,6 +612,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -632,7 +639,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -648,6 +655,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -687,7 +695,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -709,6 +717,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -736,7 +745,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -759,6 +768,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -785,7 +795,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -809,6 +819,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -835,7 +846,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -857,6 +868,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), diff --git a/tests/testthat/test-Start-reorder-latCoarse.R b/tests/testthat/test-Start-reorder-latCoarse.R index 4229b06a09944b87d06fcf2060360fefd39ecf1c..b9d923cc3e4ba5cfd36c5342c7f30d38aeedf07f 100644 --- a/tests/testthat/test-Start-reorder-latCoarse.R +++ b/tests/testthat/test-Start-reorder-latCoarse.R @@ -25,7 +25,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path = path_exp)), var = 'psl', member = 'all', @@ -40,7 +40,7 @@ res <- Start(dat = list(list(path = path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -88,7 +88,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 20 lats.max <- 10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -103,7 +103,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -132,7 +132,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -10 lats.max <- -20 - +suppressWarnings( res <- Start(dat = list(list(path = path_exp)), var = 'psl', member = 'all', @@ -147,7 +147,7 @@ res <- Start(dat = list(list(path = path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -174,7 +174,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -20 lats.max <- -10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -189,7 +189,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -218,6 +218,7 @@ lons.max <- 45 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -232,7 +233,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -280,7 +281,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 20 lats.max <- 10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -295,7 +296,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -322,7 +323,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -10 lats.max <- -20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -337,6 +338,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -363,7 +365,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- -20 lats.max <- -10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -378,6 +380,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -405,6 +408,7 @@ lons.max <- 45 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -419,6 +423,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = NULL, time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$common$latitude)), @@ -446,7 +451,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -461,6 +466,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = NULL, time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$common$latitude)), @@ -488,7 +494,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -504,6 +510,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -550,7 +557,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 20 lats.max <- 10 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -566,6 +573,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -592,7 +600,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -608,6 +616,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -634,7 +643,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -650,6 +659,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -689,7 +699,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -711,6 +721,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -738,7 +749,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -761,6 +772,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -787,7 +799,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -811,6 +823,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), @@ -837,7 +850,7 @@ lons.min <- 40 lons.max <- 45 lats.min <- 10 lats.max <- 20 - +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -859,6 +872,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) # lat expect_equal( range((attr(res, 'Variables')$dat1$latitude)), diff --git a/tests/testthat/test-Start-reorder-lon_-180to180.R b/tests/testthat/test-Start-reorder-lon-180to180.R similarity index 98% rename from tests/testthat/test-Start-reorder-lon_-180to180.R rename to tests/testthat/test-Start-reorder-lon-180to180.R index bdfc1da5343c95597e6ef76224d7ae781c0744be..f3c2a3cbc98fe73fb068d820fd09855993a7599d 100644 --- a/tests/testthat/test-Start-reorder-lon_-180to180.R +++ b/tests/testthat/test-Start-reorder-lon-180to180.R @@ -25,6 +25,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -37,7 +38,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lon expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -65,6 +66,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -77,6 +79,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10.12500, 19.96875), @@ -95,6 +98,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -107,7 +111,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-19.96875, -10.12500), @@ -126,6 +130,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -138,7 +143,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-19.96875, -10.12500), @@ -157,6 +162,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -169,6 +175,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-9.84375,9.84375), @@ -188,6 +195,7 @@ lons.min <- 10 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -200,6 +208,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c( -9.84375, 9.84375), @@ -218,6 +227,7 @@ lons.min <- 170 lons.max <- 190 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -230,6 +240,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(170.1562, 180), @@ -249,6 +260,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -263,6 +275,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10.12500, 19.96875), @@ -288,6 +301,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -302,6 +316,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10.12500, 19.96875), @@ -323,6 +338,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -337,6 +353,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), 1244 @@ -358,6 +375,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -372,6 +390,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), 1244 @@ -394,6 +413,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -408,6 +428,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), 1244 @@ -430,6 +451,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -444,6 +466,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), 1244 @@ -461,6 +484,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -475,6 +499,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(340.0312, 349.8750), @@ -492,6 +517,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -506,6 +532,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-19.96875, -10.12500), @@ -523,6 +550,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -537,6 +565,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359.7188), @@ -564,6 +593,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -578,6 +608,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-9.84375, 9.84375), @@ -595,6 +626,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -609,6 +641,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(20.2500, 349.8750), @@ -631,6 +664,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -645,6 +679,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179.7188), @@ -671,6 +706,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -685,6 +721,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330.1875, 349.8750), @@ -703,6 +740,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -717,6 +755,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-29.8125, -10.1250), @@ -740,6 +779,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -754,6 +794,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), 71, @@ -772,6 +813,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -786,6 +828,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), 71, diff --git a/tests/testthat/test-Start-reorder-lon-transform_-180to180.R b/tests/testthat/test-Start-reorder-lon-transform_-180to180.R index efbe178401b929b11df534a8dcf16f2da6b72cbb..218a8a12375b78f26aad16c1b07526bf4ab644f7 100644 --- a/tests/testthat/test-Start-reorder-lon-transform_-180to180.R +++ b/tests/testthat/test-Start-reorder-lon-transform_-180to180.R @@ -24,6 +24,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -41,6 +42,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -67,6 +69,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -84,6 +87,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -106,6 +110,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -123,6 +128,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), @@ -145,6 +151,7 @@ lons.min <- 10 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -162,6 +169,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), @@ -183,6 +191,7 @@ lons.min <- 170 lons.max <- 190 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -200,6 +209,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(170, 180), @@ -223,6 +233,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -244,6 +255,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -270,6 +282,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -291,7 +304,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -318,6 +331,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -339,7 +353,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -366,6 +380,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -387,6 +402,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(340, 350), @@ -408,6 +424,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -429,7 +446,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -456,6 +473,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -477,7 +495,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(20, 350), @@ -499,6 +517,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -520,6 +539,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -541,6 +561,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -562,6 +583,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -591,6 +613,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -612,6 +635,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -637,6 +661,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -658,6 +683,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -684,6 +710,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -705,6 +732,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -731,6 +759,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -752,6 +781,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-20, -10), @@ -774,6 +804,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -795,6 +826,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), @@ -816,6 +848,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -837,6 +870,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -863,6 +897,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -884,6 +919,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-30, -10), @@ -905,6 +941,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, sdate = sdate, @@ -926,6 +963,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), diff --git a/tests/testthat/test-Start-reorder-lon-transform_0to360.R b/tests/testthat/test-Start-reorder-lon-transform_0to360.R index 0a973bcfcd04eaad0e634fda06dff7da9ed57f10..0887615d5319fcf2c26fc23ea4efb376368913ad 100644 --- a/tests/testthat/test-Start-reorder-lon-transform_0to360.R +++ b/tests/testthat/test-Start-reorder-lon-transform_0to360.R @@ -24,6 +24,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -43,6 +44,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -69,6 +71,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -88,6 +91,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -109,6 +113,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -128,6 +133,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -150,6 +156,7 @@ lons.min <- 10 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -169,6 +176,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -190,6 +198,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -209,6 +218,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -230,6 +240,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -249,6 +260,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(350, 359), @@ -272,6 +284,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -295,7 +308,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -321,6 +334,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -344,7 +358,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -371,6 +385,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -394,7 +409,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -421,6 +436,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -444,6 +460,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(340, 350), @@ -465,6 +482,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -488,7 +506,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -515,6 +533,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -538,7 +557,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(20, 350), @@ -560,6 +579,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -583,6 +603,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -604,6 +625,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -627,7 +649,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -656,6 +678,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -679,6 +702,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -704,6 +728,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -727,6 +752,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -753,6 +779,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -776,6 +803,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -802,6 +830,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -825,6 +854,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-20, -10), @@ -847,6 +877,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -870,6 +901,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), @@ -891,6 +923,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -914,6 +947,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -940,6 +974,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -963,6 +998,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-30, -10), @@ -984,6 +1020,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -1007,6 +1044,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), diff --git a/tests/testthat/test-Start-reorder-lon-transform_0to360Coarse.R b/tests/testthat/test-Start-reorder-lon-transform_0to360Coarse.R index 01b5d68919b98c0d7f9886064e7680d18c459dd9..6d45a67fec078bcf4b15a7bcff86e19d24a11641 100644 --- a/tests/testthat/test-Start-reorder-lon-transform_0to360Coarse.R +++ b/tests/testthat/test-Start-reorder-lon-transform_0to360Coarse.R @@ -28,6 +28,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -47,6 +48,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -73,6 +75,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -92,6 +95,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -113,6 +117,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -132,6 +137,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -154,6 +160,7 @@ lons.min <- 10 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -173,6 +180,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -194,6 +202,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -213,6 +222,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -234,6 +244,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -253,6 +264,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(350, 359), @@ -276,6 +288,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -299,6 +312,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -325,6 +339,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -348,7 +363,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -375,6 +390,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -398,7 +414,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -425,6 +441,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -448,6 +465,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(340, 350), @@ -469,6 +487,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -492,6 +511,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -519,6 +539,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -542,6 +563,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -564,6 +586,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -587,6 +610,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -608,6 +632,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -631,7 +656,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 359), @@ -660,6 +685,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -683,6 +709,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -708,6 +735,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -731,6 +759,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -757,6 +786,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -780,6 +810,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -806,6 +837,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -829,6 +861,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-20, -10), @@ -851,6 +884,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -874,6 +908,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), @@ -895,6 +930,7 @@ lons.min <- 20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -918,6 +954,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-180, 179), @@ -944,6 +981,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -967,6 +1005,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-30, -10), @@ -988,6 +1027,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = variable, member = indices(1), @@ -1011,6 +1051,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-10, 10), diff --git a/tests/testthat/test-Start-reorder-lon_0to360.R b/tests/testthat/test-Start-reorder-lon0to360.R similarity index 98% rename from tests/testthat/test-Start-reorder-lon_0to360.R rename to tests/testthat/test-Start-reorder-lon0to360.R index 5faf713a849260765a1cc52adb14bd13b967eddc..20066d405230e9c5f8492b4c64b4e1d48c4d5f57 100644 --- a/tests/testthat/test-Start-reorder-lon_0to360.R +++ b/tests/testthat/test-Start-reorder-lon0to360.R @@ -23,6 +23,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -37,7 +38,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lon expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -65,6 +66,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -79,6 +81,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -96,6 +99,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -110,6 +114,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -129,6 +134,7 @@ lons.min <- 10 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -143,6 +149,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -161,6 +168,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -175,6 +183,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -192,6 +201,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -206,6 +216,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(350, 359.7222222), @@ -225,6 +236,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -241,6 +253,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -266,6 +279,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -282,6 +296,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -303,6 +318,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -319,6 +335,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(1261) @@ -340,6 +357,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -356,6 +374,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(1261) @@ -378,6 +397,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -394,6 +414,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(1261) @@ -416,6 +437,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -432,6 +454,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(1261) @@ -449,6 +472,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -465,6 +489,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(340, 350), @@ -482,6 +507,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -498,6 +524,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-20, -10), @@ -516,6 +543,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -532,6 +560,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -545,6 +574,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -561,6 +591,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-30, -10), @@ -579,6 +610,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -595,6 +627,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(73), @@ -613,6 +646,8 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 + +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -629,6 +664,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(73), diff --git a/tests/testthat/test-Start-reorder-lon0to360Coarse.R b/tests/testthat/test-Start-reorder-lon0to360Coarse.R index cb7649a82b11e0fa797bb002e2a47f94526ee44e..bb2153e90705d10def4c3327ce0d17b807cae8e6 100644 --- a/tests/testthat/test-Start-reorder-lon0to360Coarse.R +++ b/tests/testthat/test-Start-reorder-lon0to360Coarse.R @@ -23,6 +23,8 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 + +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -37,7 +39,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) - +) # lon expect_equal( range((attr(res, 'Variables')$dat1$longitude)), @@ -65,6 +67,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -79,6 +82,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -96,6 +100,7 @@ lons.min <- -10 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -110,6 +115,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -129,6 +135,7 @@ lons.min <- 10 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -143,6 +150,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(0, 10), @@ -161,6 +169,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -175,6 +184,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -192,6 +202,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -206,6 +217,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(350, 358.75), @@ -225,6 +237,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -241,6 +254,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -266,6 +280,7 @@ lons.min <- 10 lons.max <- 20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -282,6 +297,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(10, 20), @@ -303,6 +319,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -319,6 +336,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(281) @@ -340,6 +358,7 @@ lons.min <- 20 lons.max <- 10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -356,6 +375,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(281) @@ -378,6 +398,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -394,6 +415,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(281) @@ -416,6 +438,7 @@ lons.min <- -10 lons.max <- -20 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -432,6 +455,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(281) @@ -449,6 +473,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -465,6 +490,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(340, 350), @@ -482,6 +508,7 @@ lons.min <- -20 lons.max <- -10 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -498,6 +525,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-20, -10), @@ -516,6 +544,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -532,6 +561,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(330, 350), @@ -545,6 +575,7 @@ lons.min <- 330 lons.max <- 350 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -561,6 +592,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( range((attr(res, 'Variables')$dat1$longitude)), c(-30, -10), @@ -579,6 +611,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -595,6 +628,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(17), @@ -613,6 +647,7 @@ lons.min <- 350 lons.max <- 370 lats.min <- 10 lats.max <- 20 +suppressWarnings( res <- Start(dat = list(list(path=path_exp)), var = 'psl', member = 'all', @@ -629,6 +664,7 @@ res <- Start(dat = list(list(path=path_exp)), longitude = 'dat', time = NULL), retrieve = F) +) expect_equal( length((attr(res, 'Variables')$dat1$longitude)), c(17), diff --git a/tests/testthat/test-Start-reorder-metadata.R b/tests/testthat/test-Start-reorder-metadata.R index b522a36d9ae24371ced0c7aa57812929c95b6eab..4b6f909176214091a55866245e44e59009ae480c 100644 --- a/tests/testthat/test-Start-reorder-metadata.R +++ b/tests/testthat/test-Start-reorder-metadata.R @@ -11,6 +11,7 @@ lats.min <- 10 lats.max <- 20 # return_vars is NULL +suppressWarnings( res_null <- Start(dat = list(list(path = path_exp)), var = 'tas', sdate = '199212', @@ -25,7 +26,7 @@ res_null <- Start(dat = list(list(path = path_exp)), longitude = NULL, time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_null, 'Variables')$common$longitude)), 2 @@ -73,6 +74,7 @@ res_null <- Start(dat = list(list(path = path_exp)), ) # return_vars is dat +suppressWarnings( res_dat <- Start(dat = list(list(path = path_exp)), var = 'tas', sdate = '199212', @@ -87,7 +89,7 @@ res_dat <- Start(dat = list(list(path = path_exp)), longitude = 'dat', time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_dat, 'Variables')$dat1$longitude)), 2 @@ -146,6 +148,7 @@ lats.min <- 10 lats.max <- 20 # return_vars is NULL +suppressWarnings( res_null <- Start(dat = list(list(path = path_exp)), var = 'psl', member = 'all', @@ -162,7 +165,7 @@ res_null <- Start(dat = list(list(path = path_exp)), longitude = NULL, time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_null, 'Variables')$common$longitude)), 2 @@ -210,6 +213,7 @@ res_null <- Start(dat = list(list(path = path_exp)), ) # return_vars is 'dat' +suppressWarnings( res_dat <- Start(dat = list(list(path = path_exp)), var = 'psl', member = 'all', @@ -226,7 +230,7 @@ res_dat <- Start(dat = list(list(path = path_exp)), longitude = 'dat', time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_dat, 'Variables')$dat1$longitude)), 2 diff --git a/tests/testthat/test-Start-reorder-retrieve.R b/tests/testthat/test-Start-reorder-retrieve.R index cb6cfc6929ff778623d7285a40843a1c0979ba41..09928fd3c3d9a077ac5e7c96a1ab95cc9a1330ba 100644 --- a/tests/testthat/test-Start-reorder-retrieve.R +++ b/tests/testthat/test-Start-reorder-retrieve.R @@ -14,7 +14,7 @@ lons.max <- 2 lats.min <- 10 lats.max <- 12 - +suppressWarnings( res <- Start(dat = path_exp, var = 'psl', member = indices(1), @@ -30,8 +30,8 @@ res <- Start(dat = path_exp, longitude = 'dat', time = NULL), retrieve = T) - - +) +suppressWarnings( res1 <- Start(dat = path_exp, var = 'psl', member = indices(1), @@ -48,8 +48,8 @@ res1 <- Start(dat = path_exp, longitude = 'dat', time = NULL), retrieve = T) - - +) +suppressWarnings( res2 <- Start(dat = path_exp, var = 'psl', member = indices(1), @@ -66,7 +66,7 @@ res2 <- Start(dat = path_exp, longitude = 'dat', time = NULL), retrieve = T) - +) expect_equal( res1[1,1,1,1,1,1:7,], res[1,1,1,1,1,7:1,] @@ -96,7 +96,7 @@ lons.max <- 2 lats.min <- 10 lats.max <- 12 - +suppressWarnings( res <- Start(dat = path_exp, var = variable, sdate = '199212', @@ -110,7 +110,8 @@ res <- Start(dat = path_exp, longitude = 'dat', time = NULL), retrieve = T) - +) +suppressWarnings( res1 <- Start(dat = path_exp, var = variable, sdate = '199212', @@ -125,8 +126,8 @@ res1 <- Start(dat = path_exp, longitude = 'dat', time = NULL), retrieve = T) - - +) +suppressWarnings( res2 <- Start(dat = path_exp, var = variable, sdate = '199212', @@ -141,7 +142,7 @@ res2 <- Start(dat = path_exp, longitude = 'dat', time = NULL), retrieve = T) - +) expect_equal( res1[1,1,1,1,1:7,], res[1,1,1,1,7:1,] diff --git a/tests/testthat/test-Start-reshape.R b/tests/testthat/test-Start-reshape.R index 793a3b3cbcf0a28a07314af001d866812fc3ee19..3d576d806115cf4ce0caec983b475f45ad0a37be 100644 --- a/tests/testthat/test-Start-reshape.R +++ b/tests/testthat/test-Start-reshape.R @@ -53,6 +53,7 @@ sorted_dates <- sort(unique(format(dates, '%Y%m'))) unsorted_dates <- unique(format(dates, '%Y%m')) # unsorted dates +suppressWarnings( obs1 <- Start(dat = path_obs, var = var, date = unsorted_dates, @@ -69,8 +70,9 @@ obs1 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) - +) # sorted_dates +suppressWarnings( obs2 <- Start(dat = path_obs, var = var, date = sorted_dates, @@ -87,7 +89,7 @@ obs2 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) - +) expect_equal( dim(obs1), c(dat = 1, var = 1, sdate = 3, time = 90, lat = 1, lon = 1) @@ -117,7 +119,7 @@ as.vector(easy_array[, 3]) test_that("2. split + merge", { - +suppressWarnings( exp <- Start(dat = path_exp, var = var, sdate = sdate, @@ -131,13 +133,14 @@ exp <- Start(dat = path_exp, lat = NULL, time = 'sdate'), retrieve = FALSE) - +) dates <- attr(exp, 'Variables')$common$time sorted_dates <- sort(unique(format(dates, '%Y%m'))) unsorted_dates <- unique(format(dates, '%Y%m')) # unsorted dates +suppressWarnings( obs1 <- Start(dat = path_obs, var = var, date = unsorted_dates, @@ -154,8 +157,9 @@ obs1 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) - +) # sorted_dates +suppressWarnings( obs2 <- Start(dat = path_obs, var = var, date = sorted_dates, @@ -172,7 +176,7 @@ obs2 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) - +) expect_equal( dim(obs1), c(dat = 1, var = 1, sdate = 3, time = 62, lat = 1, lon = 1) @@ -241,7 +245,7 @@ test_that("4. merge + narm", { # (1) Notice that the NAs at the tail of 199402 won't be removed because Start() # considers all the files have the same length, i.e., 31. # The NAs in 199402 are regarded as part of the original file. - +suppressWarnings( obs3 <- Start(dat = path_obs, var = var, date = c('199312', '199401', '199402'), @@ -258,7 +262,7 @@ obs3 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) - +) expect_equal( dim(obs3), c(dat = 1, var = 1, time = 93, lat = 1, lon = 1) @@ -273,6 +277,7 @@ c(as.vector(easy_array[, 1]), NA, NA, NA) # time = indices(93). # The first 14 time steps of 199312 will be removed but the NAs at the tail # of 199402 will be preserved. +suppressWarnings( obs4 <- Start(dat = path_obs, var = var, date = c('199312', '199401', '199402'), @@ -289,7 +294,7 @@ obs4 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) - +) expect_equal( dim(obs4), c(dat = 1, var = 1, time = 79, lat = 1, lon = 1) @@ -300,6 +305,7 @@ c(as.vector(easy_array[15:90, 1]), NA, NA, NA) ) # (3) If time is values(), 199402 is considered time = 28, so NAs will be removed. +suppressWarnings( obs5 <- Start(dat = path_obs, var = var, date = c('199312', '199401', '199402'), @@ -316,6 +322,7 @@ obs5 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) +) expect_equal( dim(obs5), c(dat = 1, var = 1, time = 90, lat = 1, lon = 1) @@ -333,6 +340,7 @@ date_array <- c('199312', '199401', '199412', '199501') dim(date_array) <- c(month = 2, year = 2) # split file dim +suppressWarnings( obs1 <- Start(dat = path_obs, var = var, date = date_array, # [month = 2, year = 2] @@ -349,7 +357,7 @@ obs1 <- Start(dat = path_obs, lat = NULL), # time = 'date'), retrieve = TRUE) - +) expect_equal( dim(obs1), c(dat = 1, var = 1, month = 2, year = 2, time = 31, lat = 1, lon = 1) @@ -374,6 +382,7 @@ as.vector(easy_array[32:62, 2]) # split inner time ## time is indices time_array <- array(1:62, dim = c(day = 31, month = 2)) +suppressWarnings( exp1 <- Start(dat = path_exp, var = var, sdate = sdate[1], @@ -388,7 +397,7 @@ exp1 <- Start(dat = path_exp, lat = NULL, time = 'sdate'), retrieve = TRUE) - +) # easyNCDF easy_sdate_exp <- '19931201' easy_file_exp <- NcOpen(paste0('/esarchive/exp/ecmwf/system5c3s/daily_mean/tas_f6h/tas_', @@ -410,6 +419,7 @@ as.vector(easy_exp) ## time is values time_array <- dates[1, 1:62] dim(time_array) <- c(day = 31, month = 2) +suppressWarnings( exp2 <- Start(dat = path_exp, var = var, sdate = sdate[1], @@ -424,6 +434,7 @@ exp2 <- Start(dat = path_exp, lat = NULL), # time = 'sdate'), retrieve = TRUE) +) expect_equal( dim(exp2), c(dat = 1, var = 1, sdate = 1, day = 31, month = 2, ensemble = 1, lat = 1, lon = 1) @@ -437,7 +448,7 @@ as.vector(exp2) }) test_that("6. repetitive values", { - +suppressWarnings( exp <- Start(dat = path_exp, var = var, sdate = c('19931101', '19931201'), @@ -452,6 +463,7 @@ exp <- Start(dat = path_exp, lat = NULL, time = 'sdate'), retrieve = F) +) dates <- attr(exp, 'Variables')$common$time # sorted and unsorted are the same here @@ -459,6 +471,7 @@ sorted_dates <- sort(unique(format(dates, '%Y%m'))) #unsorted_dates <- unique(format(dates, '%Y%m')) # sorted_dates +suppressWarnings( obs2 <- Start(dat = path_obs, var = var, date = sorted_dates, @@ -475,7 +488,7 @@ obs2 <- Start(dat = path_obs, lat = NULL, time = 'date'), retrieve = TRUE) - +) # easyNCDF easy_file_199311 <- NcOpen(paste0('/esarchive/recon/ecmwf/era5/daily_mean/tas_f1h-r360x181/tas_', '199311', '.nc')) diff --git a/tests/testthat/test-Start-transform-lon-across_meridian.R b/tests/testthat/test-Start-transform-lon-across_meridian.R index 9ac0b8de89bb130a6a316e17ea27f2e4e37e3e03..caa2b75e3bae6b8769e23b27013c4b3a2fec872c 100644 --- a/tests/testthat/test-Start-transform-lon-across_meridian.R +++ b/tests/testthat/test-Start-transform-lon-across_meridian.R @@ -12,6 +12,7 @@ skip_on_cran() lat.min <- -10 #-90 lat.max <- 20 #90 +suppressWarnings( data_across <- Start(dat = repos, var = var, sdate = c('20170101'), @@ -33,7 +34,8 @@ skip_on_cran() longitude = 'dat', latitude = 'dat'), retrieve = T) - +) +suppressWarnings( data_no_across <- Start(dat = repos, var = var, sdate = c('20170101'), @@ -56,7 +58,7 @@ skip_on_cran() longitude = 'dat', latitude = 'dat'), retrieve = T) - +) expect_equal( as.vector(attr(data_across, 'Variables')$dat1$longitude), diff --git a/tests/testthat/test-Start-transform-metadata.R b/tests/testthat/test-Start-transform-metadata.R index f19a02a587a6859989be15eb3b97dd5c46d66952..ede3c959c22c258b384dc7789ab68fb299d7040c 100644 --- a/tests/testthat/test-Start-transform-metadata.R +++ b/tests/testthat/test-Start-transform-metadata.R @@ -11,6 +11,7 @@ lats.min <- 10 lats.max <- 20 # return_vars is NULL +suppressWarnings( res_null <- Start(dat = list(list(path = path_exp)), var = 'tas', sdate = '199212', @@ -32,7 +33,7 @@ res_null <- Start(dat = list(list(path = path_exp)), longitude = NULL, time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_null, 'Variables')$common$latitude)), 1 @@ -72,6 +73,7 @@ res_null <- Start(dat = list(list(path = path_exp)), ) # return_vars is dat +suppressWarnings( res_dat <- Start(dat = list(list(path = path_exp)), var = 'tas', sdate = '199212', @@ -93,7 +95,7 @@ res_dat <- Start(dat = list(list(path = path_exp)), longitude = 'dat', time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_dat, 'Variables')$dat1$latitude)), 1 @@ -144,6 +146,7 @@ lats.min <- 10 lats.max <- 20 # return_vars is NULL +suppressWarnings( res_null <- Start(dat = list(list(path = path_exp)), var = 'psl', member = 'all', @@ -167,7 +170,7 @@ res_null <- Start(dat = list(list(path = path_exp)), longitude = NULL, time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_null, 'Variables')$common$latitude)), 1 @@ -207,6 +210,7 @@ res_null <- Start(dat = list(list(path = path_exp)), ) # return_vars is 'dat' +suppressWarnings( res_dat <- Start(dat = list(list(path = path_exp)), var = 'psl', member = 'all', @@ -230,7 +234,7 @@ res_dat <- Start(dat = list(list(path = path_exp)), longitude = 'dat', time = 'sdate'), retrieve = F) - +) expect_equal( length(attributes(attr(res_dat, 'Variables')$dat1$latitude)), 1