diff --git a/R/Load.R b/R/Load.R index cca99bf3612242029f43ebeb9f54bf3bed45db58..47da2b32138902c1ba6ffadb6d8a35df9386b4b5 100644 --- a/R/Load.R +++ b/R/Load.R @@ -395,6 +395,10 @@ #' If not specified and the selected output type is 'lon', 'lat' or 'lonlat', #' this parameter takes as default value the grid of the first experimental #' dataset, which is read automatically from the source files.\cr +#' Note that the auto-detected grid type is not guarenteed to be correct, and +#' it won't be correct if the netCDF file doesn't contain global domain. +#' Please check the warning carefully to ensure the detected grid type is +#' expected, or assign this parameter even regridding is not needed. #' The grid must be supported by 'cdo' tools. Now only supported: rNXxNY #' or tTRgrid.\cr #' Both rNXxNY and tRESgrid yield rectangular regular grids. rNXxNY yields diff --git a/R/Utils.R b/R/Utils.R index cb6eb345739b7ad328b4ca17498d153335863848..adcded6fd3a8f40d549983d408df910d32723d21 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -291,6 +291,10 @@ } else { grid_name <- paste0('t', .nlat2t(grid_lats), 'grid') } + if (is.null(work_piece[['grid']])) { + .warning(paste0("Detect the grid type to be '", grid_name, "'. ", + "If it is not expected, assign parameter 'grid' to avoid wrong result.")) + } } # If a common grid is requested, we will also calculate its size which we will use # later on. diff --git a/man/Load.Rd b/man/Load.Rd index 10c03f94af836a709e9af17cfc409354681d6ee9..f91c315ca645c6c2af2aca2d3dd99242835909aa 100644 --- a/man/Load.Rd +++ b/man/Load.Rd @@ -273,6 +273,10 @@ interpolating to the specified grid.\cr If not specified and the selected output type is 'lon', 'lat' or 'lonlat', this parameter takes as default value the grid of the first experimental dataset, which is read automatically from the source files.\cr +Note that the auto-detected grid type is not guarenteed to be correct, and +it won't be correct if the netCDF file doesn't contain global domain. +Please check the warning carefully to ensure the detected grid type is +expected, or assign this parameter even regridding is not needed. The grid must be supported by 'cdo' tools. Now only supported: rNXxNY or tTRgrid.\cr Both rNXxNY and tRESgrid yield rectangular regular grids. rNXxNY yields diff --git a/tests/testthat/test-Load.R b/tests/testthat/test-Load.R index c87beac0094c897e0daaf2f78805911adf9d7515..5e2e72392d7f03d8cb3c769f939cb6b535d8a909 100644 --- a/tests/testthat/test-Load.R +++ b/tests/testthat/test-Load.R @@ -176,5 +176,45 @@ c(rep(NA, 4), 101250, rep(NA, 5), 100940, NA), tolerance = 0.0001 ) +}) + +test_that("1-4.", { + +exp <- list(list( + name = "system5_m1", + path = file.path("/esarchive/exp/ecmwf/system5_m1/monthly_mean/$VAR_NAME$_f6h/$VAR_NAME$_$START_DATE$.nc") + )) + +suppressWarnings( +res <- Load( + var = "tas", + exp = exp, + obs = NULL, + sdates = c('19930201'), + output = "lonlat", + leadtimemin = 1, + leadtimemax = 1, + nmember = 2, + latmin = -90, #10, + latmax = 90, #12, + lonmin = 0, + lonmax = 359.9, + grid = 'r1296x640', #'t426grid', + dimnames = list(lon='longitude', lat='latitude', member='ensemble'), + nprocs = 1) +) +expect_equal( +dim(res$mod), +c(dataset = 1, member = 2, sdate = 1, ftime = 1, lat = 640, lon = 1296) +) +expect_equal( +as.vector(res$mod[1, 1, 1, 1, 100, 1:4]), +c(277.38, 277.38, 277.37, 277.37), +tolerance = 0.0001 +) +expect_equal( +any(is.na(res$mod)), +FALSE +) })