From edfaeadb7d35670192fb2961f2c294cab2944338 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Thu, 4 Sep 2025 17:21:21 +0200 Subject: [PATCH 01/26] Update NEWS.md for release v2.2.0 --- NEWS.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NEWS.md b/NEWS.md index 75e33f9e..f34fcd0b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,17 @@ +# s2dv 2.2.0 (Release date: 2024-09-26) + +**Bugfixes** +- RandomWalkTest(): Fix error when 'A_better' or 'B_better' is NA +- test-Load(): Remove deleted experiment +- RandomWalkTest(): Relax dimensions check to accept dimensions in different order + +**Development** +- RMSSS(): calculate the climatological forecast from the average of 'obs' if 'ref' is NULL +- Accept probabilities as inputs for Fair RPS() and Fair RPSS() + +**Other** +- Add CONTRIBUTING.md + # s2dv 2.1.0 (Release date: 2024-09-26) **Bugfixes** -- GitLab From aec5d4775845aac66c76f0f17a0e4885482523fe Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Fri, 5 Sep 2025 10:27:47 +0200 Subject: [PATCH 02/26] Update man/RPSS.Rd NEWS.md DESCRIPTION for release --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- man/RPSS.Rd | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index aa79da2d..fd4d800d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: s2dv Title: A Set of Common Tools for Seasonal to Decadal Verification -Version: 2.1.0 +Version: 2.2.0 Authors@R: c( person("BSC-CNS", role = c("aut", "cph")), person("An-Chi", "Ho", , "an.ho@bsc.es", role = c("aut")), @@ -53,5 +53,5 @@ BugReports: https://earth.bsc.es/gitlab/es/s2dv/-/issues LazyData: true SystemRequirements: cdo Encoding: UTF-8 -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md index f34fcd0b..e1f9753d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# s2dv 2.2.0 (Release date: 2024-09-26) +# s2dv 2.2.0 (Release date: 2025-09-05) **Bugfixes** - RandomWalkTest(): Fix error when 'A_better' or 'B_better' is NA diff --git a/man/RPSS.Rd b/man/RPSS.Rd index f6c80460..14cf158a 100644 --- a/man/RPSS.Rd +++ b/man/RPSS.Rd @@ -65,7 +65,12 @@ The default value is NULL.} \item{prob_thresholds}{A numeric vector of the relative thresholds (from 0 to 1) between the categories. The default value is c(1/3, 2/3), which -corresponds to tercile equiprobable categories.} +corresponds to tercile equiprobable categories. When the inputs are +ensemble members ('cat_dim' is NULL), these thresholds are used to compute +category probabilities. If 'ref' is NULL, the thresholds are also used to +compute the reference forecast ('clim_probs'), even when 'exp' and 'obs' are +already given as probabilities. If 'ref' is provided and the inputs are +probabilities, 'prob_thresholds' is ignored.} \item{indices_for_clim}{A vector of the indices to be taken along 'time_dim' for computing the thresholds between the probabilistic categories. If NULL, -- GitLab From e2257277c6e0b0c8baba13f86d7b57501286c76a Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Mon, 8 Sep 2025 13:30:28 +0200 Subject: [PATCH 03/26] Update .Rbuildignore for release v2.2.0 --- .Rbuildignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index e817c8bf..ec01f1d7 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -17,3 +17,6 @@ vignettes # but test-CDORemap.R and test-Load.R needs to be hidden #tests/testthat/test-CDORemap.R #tests/testthat/test-Load.R +^.*\.Rproj$ # Automatically added by RStudio +^\.Rproj\.user$ # Used for temporary files +^CONTRIBUTING\.md$ \ No newline at end of file -- GitLab From 0224e644d4932ef6581562ec20a118351d9153f1 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Mon, 8 Sep 2025 17:17:29 +0200 Subject: [PATCH 04/26] Update .Rbuildignore --- .Rbuildignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index ec01f1d7..c823928b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -17,6 +17,6 @@ vignettes # but test-CDORemap.R and test-Load.R needs to be hidden #tests/testthat/test-CDORemap.R #tests/testthat/test-Load.R -^.*\.Rproj$ # Automatically added by RStudio -^\.Rproj\.user$ # Used for temporary files +^.*\.Rproj$ +^\.Rproj\.user$ ^CONTRIBUTING\.md$ \ No newline at end of file -- GitLab From 04ad64a1afa36695cb6f4aca5b872bbeec91a68b Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Mon, 15 Sep 2025 18:18:38 +0200 Subject: [PATCH 05/26] Update title, quotes, acronyms, references and @return upon CRAN request --- DESCRIPTION | 26 +++++++++++++++----------- R/AnimateMap.R | 2 ++ R/Plot2VarsVsLTime.R | 3 +++ R/PlotACC.R | 3 +++ R/PlotAno.R | 3 +++ R/PlotClim.R | 3 +++ R/PlotSection.R | 3 +++ R/PlotVsLTime.R | 3 +++ R/clim.palette.R | 5 +++++ man/AnimateMap.Rd | 3 +++ man/Plot2VarsVsLTime.Rd | 3 +++ man/PlotACC.Rd | 3 +++ man/PlotAno.Rd | 3 +++ man/PlotClim.Rd | 3 +++ man/PlotSection.Rd | 3 +++ man/PlotVsLTime.Rd | 3 +++ man/clim.palette.Rd | 5 +++++ man/s2dv-package.Rd | 4 ++-- 18 files changed, 68 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fd4d800d..1271a5b4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: s2dv -Title: A Set of Common Tools for Seasonal to Decadal Verification +Title: Seasonal to Decadal Verification Version: 2.2.0 Authors@R: c( person("BSC-CNS", role = c("aut", "cph")), @@ -15,16 +15,20 @@ Authors@R: c( person("Victòria", "Agudetse", , "victoria.agudetse@bsc.es", role = "ctb"), person("Nadia", "Milders", , "nadia.milders@bsc.es", role = "ctb"), person("Ariadna", "Batalla", , "ariadna.batalla@bsc.es", role = c("ctb", "cre"))) -Description: The advanced version of package 's2dverification'. It is - intended for 'seasonal to decadal' (s2d) climate forecast verification, but - it can also be used in other kinds of forecasts or general climate analysis. - This package is specially designed for the comparison between the experimental - and observational datasets. The functionality of the included functions covers - from data retrieval, data post-processing, skill scores against observation, - to visualization. Compared to 's2dverification', 's2dv' is more compatible - with the package 'startR', able to use multiple cores for computation and - handle multi-dimensional arrays with a higher flexibility. The CDO version used - in development is 1.9.8. +Description: An advanced version of package 's2dverification'. Intended for + seasonal to decadal (s2d) climate forecast verification, but also applicable + to other types of forecasts or general climate analysis. This package is + specifically designed for comparing experimental and observational datasets. + It provides functionality for data retrieval, post-processing, skill score + computation against observations, and visualization. Compared to + 's2dverification', 's2dv' is more compatible with the package 'startR', able + to use multiple cores for computation and handle multi-dimensional arrays + with a higher flexibility. The Climate Data Operators (CDO) version used in + development is 1.9.8. Implements methods described in Wilks (2011) + , DelSole and Tippett + (2016) , Kharin et al. (2012) + , Doblas-Reyes et al. (2003) + . Depends: R (>= 3.6.0) Imports: diff --git a/R/AnimateMap.R b/R/AnimateMap.R index 1cd1ffe0..87f937aa 100644 --- a/R/AnimateMap.R +++ b/R/AnimateMap.R @@ -89,6 +89,8 @@ #' } #'} #' +#'@return No return value, called for side effects. +#' #'@examples #'# See ?Load for explanations on the first part of this example #' \dontrun{ diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index 12e04ae2..5430e366 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -49,6 +49,9 @@ #'------------------\cr\cr #'RMSE error for a number of experiments and along lead-time: (nexp, nltime) #' +#'@return +#'No return value, called for side effects. +#' #'@examples #'# Load sample data as in Load() example: #'example(Load) diff --git a/R/PlotACC.R b/R/PlotACC.R index 6ea51820..b03cf6d2 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -47,6 +47,9 @@ #' lend lheight ljoin lmitre mar mex mfcol mfrow mfg mkh oma omd omi page #' plt smo srt tck tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog\cr #' For more information about the parameters see `par`. +#' +#'@return +#'No return value, called for side effects. #' #'@examples #' \dontshow{ diff --git a/R/PlotAno.R b/R/PlotAno.R index 9a4a9714..596180f9 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -51,6 +51,9 @@ #' srt tck tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog \cr #' For more information about the parameters see `par`. #' +#'@return +#'No return value, called for side effects. +#' #'@examples #'# Load sample data as in Load() example: #'example(Load) diff --git a/R/PlotClim.R b/R/PlotClim.R index aff96e40..507cd16c 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -40,6 +40,9 @@ #' lheight ljoin lmitre mar mex mfcol mfrow mfg mkh oma omd omi page pch plt #' smo srt tck usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog \cr #' For more information about the parameters see `par`. +#' +#'@return +#'No return value, called for side effects. #' #'@examples #'# Load sample data as in Load() example: diff --git a/R/PlotSection.R b/R/PlotSection.R index 29bdd492..16fb9e68 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -36,6 +36,9 @@ #' yaxt ylbias ylog \cr #' For more information about the parameters see `par`. #' +#'@return +#'No return value, called for side effects. +#' #'@examples #'sampleData <- s2dv::sampleDepthData #'PlotSection(sampleData$mod[1, 1, 1, 1, , ], sampleData$lat, sampleData$depth, diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index c51e31b3..52479f6f 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -65,6 +65,9 @@ #'would plot the correlations or RMS between each exp & each obs as a function #'of the forecast time. #' +#'@return +#'No return value, called for side effects. +#' #'@examples #'# Load sample data as in Load() example: #'example(Load) diff --git a/R/clim.palette.R b/R/clim.palette.R index b23ff842..7d1cb10f 100644 --- a/R/clim.palette.R +++ b/R/clim.palette.R @@ -10,6 +10,11 @@ #' and from orange through white to purple ('orangepurple'). #'@param n Number of colors to generate. #' +#'@return +#'A function that generates a vector of \code{n} color hex codes when +#'called. The returned function has an optional attribute \code{"na_color"} +#'specifying the color used for missing values. +#' #'@examples #'lims <- seq(-1, 1, length.out = 21) #' diff --git a/man/AnimateMap.Rd b/man/AnimateMap.Rd index 2ec930d5..90dd6177 100644 --- a/man/AnimateMap.Rd +++ b/man/AnimateMap.Rd @@ -106,6 +106,9 @@ lwd mai mar mex mfcol mfrow mfg mgp mkh oma omd omi page pch plt pty smo srt tck tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog. \cr For more information about the parameters see `par`.} } +\value{ +No return value, called for side effects. +} \description{ Create animations of maps in an equi-rectangular or stereographic projection, showing the anomalies, the climatologies, the mean InterQuartile diff --git a/man/Plot2VarsVsLTime.Rd b/man/Plot2VarsVsLTime.Rd index 9eeb9282..0de4774d 100644 --- a/man/Plot2VarsVsLTime.Rd +++ b/man/Plot2VarsVsLTime.Rd @@ -91,6 +91,9 @@ lheight ljoin lmitre mar mex mfcol mfrow mfg mkh oma omd omi page pch plt smo srt tck tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog \cr For more information about the parameters see `par`.} } +\value{ +No return value, called for side effects. +} \description{ Plot two input variables that have the same dimensions in a common plot. One plot for all experiments. diff --git a/man/PlotACC.Rd b/man/PlotACC.Rd index 9a32f8b8..dc2bfb17 100644 --- a/man/PlotACC.Rd +++ b/man/PlotACC.Rd @@ -85,6 +85,9 @@ lend lheight ljoin lmitre mar mex mfcol mfrow mfg mkh oma omd omi page plt smo srt tck tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog\cr For more information about the parameters see `par`.} } +\value{ +No return value, called for side effects. +} \description{ Plots plumes/timeseries of ACC from an array with dimensions (output from \code{ACC()}): \cr diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 6591ef19..84a9a069 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -98,6 +98,9 @@ lheight ljoin lmitre mar mex mfcol mfrow mfg mkh oma omd omi page plt smo srt tck tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog \cr For more information about the parameters see `par`.} } +\value{ +No return value, called for side effects. +} \description{ Plots time series of raw or smoothed anomalies of any variable output from \code{Load()} or \code{Ano()} or or \code{Ano_CrossValid()} or diff --git a/man/PlotClim.Rd b/man/PlotClim.Rd index 9b3381ed..529d8683 100644 --- a/man/PlotClim.Rd +++ b/man/PlotClim.Rd @@ -78,6 +78,9 @@ lheight ljoin lmitre mar mex mfcol mfrow mfg mkh oma omd omi page pch plt smo srt tck usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog \cr For more information about the parameters see `par`.} } +\value{ +No return value, called for side effects. +} \description{ Plots climatologies as a function of the forecast time for any index output from \code{Clim()} and organized in matrix with dimensions:\cr diff --git a/man/PlotSection.Rd b/man/PlotSection.Rd index 16273398..ee693e78 100644 --- a/man/PlotSection.Rd +++ b/man/PlotSection.Rd @@ -77,6 +77,9 @@ omi page pch pin plt pty smo srt tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog \cr For more information about the parameters see `par`.} } +\value{ +No return value, called for side effects. +} \description{ Plot a (longitude,depth) or (latitude,depth) section. } diff --git a/man/PlotVsLTime.Rd b/man/PlotVsLTime.Rd index 21cfe530..5cd5413a 100644 --- a/man/PlotVsLTime.Rd +++ b/man/PlotVsLTime.Rd @@ -90,6 +90,9 @@ lheight ljoin lmitre mar mex mfcol mfrow mfg mkh oma omd omi page pch plt smo srt tck tcl usr xaxp xaxs xaxt xlog xpd yaxp yaxs yaxt ylbias ylog \cr For more information about the parameters see `par`.} } +\value{ +No return value, called for side effects. +} \description{ Plot the correlation (\code{Corr()}), the root mean square error (\code{RMS()}) between the forecast values and their observational diff --git a/man/clim.palette.Rd b/man/clim.palette.Rd index 94c90553..f97a3b26 100644 --- a/man/clim.palette.Rd +++ b/man/clim.palette.Rd @@ -18,6 +18,11 @@ and from orange through white to purple ('orangepurple').} \item{n}{Number of colors to generate.} } +\value{ +A function that generates a vector of \code{n} color hex codes when +called. The returned function has an optional attribute \code{"na_color"} +specifying the color used for missing values. +} \description{ Generates a colorblind friendly color palette with color ranges useful in climate temperature variable plotting. diff --git a/man/s2dv-package.Rd b/man/s2dv-package.Rd index 24ed0bf8..612611b3 100644 --- a/man/s2dv-package.Rd +++ b/man/s2dv-package.Rd @@ -4,9 +4,9 @@ \name{s2dv-package} \alias{s2dv} \alias{s2dv-package} -\title{s2dv: A Set of Common Tools for Seasonal to Decadal Verification} +\title{s2dv: Seasonal to Decadal Verification} \description{ -The advanced version of package 's2dverification'. It is intended for 'seasonal to decadal' (s2d) climate forecast verification, but it can also be used in other kinds of forecasts or general climate analysis. This package is specially designed for the comparison between the experimental and observational datasets. The functionality of the included functions covers from data retrieval, data post-processing, skill scores against observation, to visualization. Compared to 's2dverification', 's2dv' is more compatible with the package 'startR', able to use multiple cores for computation and handle multi-dimensional arrays with a higher flexibility. The CDO version used in development is 1.9.8. +An advanced version of package 's2dverification'. Intended for seasonal to decadal (s2d) climate forecast verification, but also applicable to other types of forecasts or general climate analysis. This package is specifically designed for comparing experimental and observational datasets. It provides functionality for data retrieval, post-processing, skill score computation against observations, and visualization. Compared to 's2dverification', 's2dv' is more compatible with the package 'startR', able to use multiple cores for computation and handle multi-dimensional arrays with a higher flexibility. The Climate Data Operators (CDO) version used in development is 1.9.8. Implements methods described in Wilks (2011) \url{https://doi.org/10.1016/B978-0-12-385022-5.00008-7}, DelSole and Tippett (2016) \url{https://doi.org/10.1175/MWR-D-15-0218.1}, Kharin et al. (2012) \url{https://doi.org/10.1029/2012GL052647}, Doblas-Reyes et al. (2003) \doi{10.1007/s00382-003-0350-4}. } \references{ \url{https://earth.bsc.es/gitlab/es/s2dv/} -- GitLab From e66589799aac68fe0e2273199fef4c61170bc124 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 16 Sep 2025 12:47:04 +0200 Subject: [PATCH 06/26] Remove one colon from 'foo:::f' in s2dv examples upon CRAN request --- R/ACC.R | 2 +- R/AnimateMap.R | 2 +- R/EOF.R | 2 +- R/Histo2Hindcast.R | 2 +- R/Load.R | 2 +- man/ACC.Rd | 2 +- man/AnimateMap.Rd | 2 +- man/EOF.Rd | 2 +- man/Histo2Hindcast.Rd | 2 +- man/Load.Rd | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/ACC.R b/R/ACC.R index ee9d3812..7b6b8454 100644 --- a/R/ACC.R +++ b/R/ACC.R @@ -102,7 +102,7 @@ #'@examples #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, #' leadtimemin = 1, #' leadtimemax = 4, diff --git a/R/AnimateMap.R b/R/AnimateMap.R index 87f937aa..a4524ce2 100644 --- a/R/AnimateMap.R +++ b/R/AnimateMap.R @@ -110,7 +110,7 @@ #' } #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, #' output = 'lonlat', #' latmin = 27, latmax = 48, diff --git a/R/EOF.R b/R/EOF.R index 38c3fae0..ed6ad575 100644 --- a/R/EOF.R +++ b/R/EOF.R @@ -69,7 +69,7 @@ #'# use this function. #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, #' leadtimemin = 1, #' leadtimemax = 4, diff --git a/R/Histo2Hindcast.R b/R/Histo2Hindcast.R index 649b75bb..f65ec0cd 100644 --- a/R/Histo2Hindcast.R +++ b/R/Histo2Hindcast.R @@ -25,7 +25,7 @@ #'@examples #' \dontshow{ #'startDates <- c('19901101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, #' leadtimemin = 1, #' leadtimemax = 60, diff --git a/R/Load.R b/R/Load.R index 47da2b32..95993513 100644 --- a/R/Load.R +++ b/R/Load.R @@ -829,7 +829,7 @@ #' } #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, #' output = 'areave', #' latmin = 27, latmax = 48, diff --git a/man/ACC.Rd b/man/ACC.Rd index f733f741..15f85ffa 100644 --- a/man/ACC.Rd +++ b/man/ACC.Rd @@ -142,7 +142,7 @@ Wilks (2011; section 7.6.4; https://doi.org/10.1016/B978-0-12-385022-5.00008-7). \examples{ \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, leadtimemin = 1, leadtimemax = 4, diff --git a/man/AnimateMap.Rd b/man/AnimateMap.Rd index 90dd6177..8b48a5a8 100644 --- a/man/AnimateMap.Rd +++ b/man/AnimateMap.Rd @@ -168,7 +168,7 @@ sampleData <- Load('tos', list(expA), list(obsX), startDates, } \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, output = 'lonlat', latmin = 27, latmax = 48, diff --git a/man/EOF.Rd b/man/EOF.Rd index 3d673089..d9e0a742 100644 --- a/man/EOF.Rd +++ b/man/EOF.Rd @@ -92,7 +92,7 @@ set to TRUE. # use this function. \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, leadtimemin = 1, leadtimemax = 4, diff --git a/man/Histo2Hindcast.Rd b/man/Histo2Hindcast.Rd index a2bc5cac..421343ed 100644 --- a/man/Histo2Hindcast.Rd +++ b/man/Histo2Hindcast.Rd @@ -48,7 +48,7 @@ should be monthly. \examples{ \dontshow{ startDates <- c('19901101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, leadtimemin = 1, leadtimemax = 60, diff --git a/man/Load.Rd b/man/Load.Rd index f91c315c..3e771021 100644 --- a/man/Load.Rd +++ b/man/Load.Rd @@ -892,7 +892,7 @@ sampleData <- Load('tos', c('experiment'), c('observation'), startDates, } \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), +sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, output = 'areave', latmin = 27, latmax = 48, -- GitLab From 27660b3827b69f35a07d54b7754ab392ff56a8bf Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 16 Sep 2025 17:55:15 +0200 Subject: [PATCH 07/26] Replace dontrun{} with donttest{} in doc examples --- R/AnimateMap.R | 4 ++-- R/CDORemap.R | 4 ++-- R/EOF.R | 2 +- R/Histo2Hindcast.R | 2 +- R/Load.R | 4 ++-- R/NAO.R | 2 +- man/AnimateMap.Rd | 4 ++-- man/CDORemap.Rd | 4 ++-- man/EOF.Rd | 2 +- man/Histo2Hindcast.Rd | 2 +- man/Load.Rd | 4 ++-- man/NAO.Rd | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/R/AnimateMap.R b/R/AnimateMap.R index a4524ce2..4560486a 100644 --- a/R/AnimateMap.R +++ b/R/AnimateMap.R @@ -93,7 +93,7 @@ #' #'@examples #'# See ?Load for explanations on the first part of this example -#' \dontrun{ +#' \donttest{ #'data_path <- system.file('sample_data', package = 's2dv') #'expA <- list(name = 'experiment', path = file.path(data_path, #' 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', @@ -117,7 +117,7 @@ #' lonmin = -12, lonmax = 40) #' } #'clim <- Clim(sampleData$mod, sampleData$obs, memb = FALSE) -#' \dontrun{ +#' \donttest{ #'AnimateMap(clim$clim_exp, sampleData$lon, sampleData$lat, #' toptitle = "climatology of decadal prediction", sizetit = 1, #' units = "degree", brks = seq(270, 300, 3), monini = 11, freq = 12, diff --git a/R/CDORemap.R b/R/CDORemap.R index 0933d113..d789e4d1 100644 --- a/R/CDORemap.R +++ b/R/CDORemap.R @@ -88,7 +88,7 @@ #' \item{'lons'}{The longitudes of the data on the destination grid.} #' \item{'lats'}{The latitudes of the data on the destination grid.} #'@examples -#' \dontrun{ +#' \donttest{ #'# Interpolating only vectors of longitudes and latitudes #'lon <- seq(0, 360 - 360/50, length.out = 50) #'lat <- seq(-90, 90, length.out = 25) @@ -219,7 +219,7 @@ #'names(dim(lat)) <- c('i', 'j') #'tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil') #'tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil', FALSE) -#'# It is ossible to specify an external NetCDF file as target grid reference +#'# It is possible to specify an external NetCDF file as target grid reference #'tas2 <- CDORemap(tas, lon, lat, 'external_file.nc', 'bil') #'} #'@import ncdf4 diff --git a/R/EOF.R b/R/EOF.R index ed6ad575..d8015758 100644 --- a/R/EOF.R +++ b/R/EOF.R @@ -82,7 +82,7 @@ #'ano <- tmp[1, , ,] #'names(dim(ano)) <- names(dim(tmp))[-2] #'eof <- EOF(ano, sampleData$lat, sampleData$lon) -#'\dontrun{ +#'\donttest{ #'PlotEquiMap(eof$EOFs[1, , ], sampleData$lon, sampleData$lat) #'} #' diff --git a/R/Histo2Hindcast.R b/R/Histo2Hindcast.R index f65ec0cd..0d3f5c22 100644 --- a/R/Histo2Hindcast.R +++ b/R/Histo2Hindcast.R @@ -40,7 +40,7 @@ #' sdates_out, leadtimes_per_startdate) #'obs_data <- Histo2Hindcast(sampleData$obs, startDates, #' sdates_out, leadtimes_per_startdate) -#' \dontrun{ +#' \donttest{ #'exp_data <- Reorder(exp_data, c(3, 4, 1, 2)) #'obs_data <- Reorder(obs_data, c(3, 4, 1, 2)) #'PlotAno(exp_data, obs_data, sdates_out, diff --git a/R/Load.R b/R/Load.R index 95993513..bc05647c 100644 --- a/R/Load.R +++ b/R/Load.R @@ -758,7 +758,7 @@ #'# #'# Example 1: Providing lists of lists to 'exp' and 'obs': #'# -#' \dontrun{ +#' \donttest{ #'data_path <- system.file('sample_data', package = 's2dv') #'exp <- list( #' name = 'experiment', @@ -784,7 +784,7 @@ #'# has the proper entries to load these (see ?LoadConfigFile for details on #'# writing a configuration file). #'# -#' \dontrun{ +#' \donttest{ #'data_path <- system.file('sample_data', package = 's2dv') #'expA <- list(name = 'experiment', path = file.path(data_path, #' 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', diff --git a/R/NAO.R b/R/NAO.R index 2f562d3d..8934ce77 100644 --- a/R/NAO.R +++ b/R/NAO.R @@ -90,7 +90,7 @@ #'exp_cor <- array(rnorm(540), dim = c(member = 2, sdate = 1, ftime = 5, lat = 6, lon = 9)) #'nao <- NAO(exp = exp, obs = obs, exp_cor = exp_cor, lat = lat, lon = lon, obsproj = TRUE) #'# plot the NAO index -#' \dontrun{ +#' \donttest{ #'nao$exp <- Reorder(nao$exp, c(2, 1)) #'nao$obs <- Reorder(nao$obs, c(2, 1)) #'PlotBoxWhisker(nao$exp, nao$obs, "NAO index, DJF", "NAO index (PC1) TOS", diff --git a/man/AnimateMap.Rd b/man/AnimateMap.Rd index 8b48a5a8..4309bf98 100644 --- a/man/AnimateMap.Rd +++ b/man/AnimateMap.Rd @@ -151,7 +151,7 @@ Examples of input: } \examples{ # See ?Load for explanations on the first part of this example - \dontrun{ + \donttest{ data_path <- system.file('sample_data', package = 's2dv') expA <- list(name = 'experiment', path = file.path(data_path, 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', @@ -175,7 +175,7 @@ sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), lonmin = -12, lonmax = 40) } clim <- Clim(sampleData$mod, sampleData$obs, memb = FALSE) - \dontrun{ + \donttest{ AnimateMap(clim$clim_exp, sampleData$lon, sampleData$lat, toptitle = "climatology of decadal prediction", sizetit = 1, units = "degree", brks = seq(270, 300, 3), monini = 11, freq = 12, diff --git a/man/CDORemap.Rd b/man/CDORemap.Rd index 9bfeaa55..1a221e70 100644 --- a/man/CDORemap.Rd +++ b/man/CDORemap.Rd @@ -120,7 +120,7 @@ Any metadata attached to the input data array, longitudes or latitudes will be preserved or accordingly modified. } \examples{ - \dontrun{ + \donttest{ # Interpolating only vectors of longitudes and latitudes lon <- seq(0, 360 - 360/50, length.out = 50) lat <- seq(-90, 90, length.out = 25) @@ -251,7 +251,7 @@ lat <- t(array(seq(-90, 90, length.out = num_lats), names(dim(lat)) <- c('i', 'j') tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil') tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil', FALSE) -# It is ossible to specify an external NetCDF file as target grid reference +# It is possible to specify an external NetCDF file as target grid reference tas2 <- CDORemap(tas, lon, lat, 'external_file.nc', 'bil') } } diff --git a/man/EOF.Rd b/man/EOF.Rd index d9e0a742..d4523a93 100644 --- a/man/EOF.Rd +++ b/man/EOF.Rd @@ -105,7 +105,7 @@ tmp <- MeanDims(ano$exp, c('dataset', 'member')) ano <- tmp[1, , ,] names(dim(ano)) <- names(dim(tmp))[-2] eof <- EOF(ano, sampleData$lat, sampleData$lon) -\dontrun{ +\donttest{ PlotEquiMap(eof$EOFs[1, , ], sampleData$lon, sampleData$lat) } diff --git a/man/Histo2Hindcast.Rd b/man/Histo2Hindcast.Rd index 421343ed..4a6a387f 100644 --- a/man/Histo2Hindcast.Rd +++ b/man/Histo2Hindcast.Rd @@ -63,7 +63,7 @@ exp_data <- Histo2Hindcast(sampleData$mod, startDates, sdates_out, leadtimes_per_startdate) obs_data <- Histo2Hindcast(sampleData$obs, startDates, sdates_out, leadtimes_per_startdate) - \dontrun{ + \donttest{ exp_data <- Reorder(exp_data, c(3, 4, 1, 2)) obs_data <- Reorder(obs_data, c(3, 4, 1, 2)) PlotAno(exp_data, obs_data, sdates_out, diff --git a/man/Load.Rd b/man/Load.Rd index 3e771021..124ed853 100644 --- a/man/Load.Rd +++ b/man/Load.Rd @@ -821,7 +821,7 @@ to the package or check the comments in the code. # # Example 1: Providing lists of lists to 'exp' and 'obs': # - \dontrun{ + \donttest{ data_path <- system.file('sample_data', package = 's2dv') exp <- list( name = 'experiment', @@ -847,7 +847,7 @@ sampleData <- Load('tos', list(exp), list(obs), startDates, # has the proper entries to load these (see ?LoadConfigFile for details on # writing a configuration file). # - \dontrun{ + \donttest{ data_path <- system.file('sample_data', package = 's2dv') expA <- list(name = 'experiment', path = file.path(data_path, 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', diff --git a/man/NAO.Rd b/man/NAO.Rd index 8115fa22..3788bc68 100644 --- a/man/NAO.Rd +++ b/man/NAO.Rd @@ -116,7 +116,7 @@ nao <- NAO(exp = exp, obs = obs, lat = lat, lon = lon) exp_cor <- array(rnorm(540), dim = c(member = 2, sdate = 1, ftime = 5, lat = 6, lon = 9)) nao <- NAO(exp = exp, obs = obs, exp_cor = exp_cor, lat = lat, lon = lon, obsproj = TRUE) # plot the NAO index - \dontrun{ + \donttest{ nao$exp <- Reorder(nao$exp, c(2, 1)) nao$obs <- Reorder(nao$obs, c(2, 1)) PlotBoxWhisker(nao$exp, nao$obs, "NAO index, DJF", "NAO index (PC1) TOS", -- GitLab From af22e96bb1c705a91458d2a8f19c9fe34dc282d2 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Wed, 17 Sep 2025 16:32:43 +0200 Subject: [PATCH 08/26] Replace 'dontrun' with 'donttest' and modify examples in R/ToyModel.R R/Spread.R R/Smoothing.R and R/REOF.R to address errors --- R/PlotBoxWhisker.R | 2 +- R/PlotStereoMap.R | 2 +- R/ProjectField.R | 2 +- R/REOF.R | 7 +++++-- R/Smoothing.R | 13 ++++++++++--- R/Spread.R | 16 ++++++++++------ R/ToyModel.R | 31 ++++++++----------------------- man/PlotBoxWhisker.Rd | 2 +- man/PlotStereoMap.Rd | 2 +- man/ProjectField.Rd | 2 +- man/REOF.Rd | 7 +++++-- man/Smoothing.Rd | 13 ++++++++++--- man/Spread.Rd | 16 ++++++++++------ man/ToyModel.Rd | 31 ++++++++----------------------- 14 files changed, 72 insertions(+), 74 deletions(-) diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index 9b4c88e0..f84d8284 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -92,7 +92,7 @@ #'ano_obs <- array(ano$obs, dim = dim(ano$obs)[-2]) #'nao <- NAO(exp = ano_exp, obs = ano_obs, lat = sampleData$lat, lon = sampleData$lon) #'# Finally plot the nao index -#' \dontrun{ +#' \donttest{ #'nao$exp <- Reorder(nao$exp, c(2, 1)) #'nao$obs <- Reorder(nao$obs, c(2, 1)) #'PlotBoxWhisker(nao$exp, nao$obs, "NAO index, DJF", "NAO index (PC1) TOS", diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index a2fdb85d..4b97cdc9 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -170,7 +170,7 @@ #'data <- matrix(rnorm(100 * 50), 100, 50) #'x <- seq(from = 0, to = 360, length.out = 100) #'y <- seq(from = -90, to = 90, length.out = 50) -#' \dontrun{ +#' \donttest{ #'PlotStereoMap(data, x, y, latlims = c(60, 90), brks = 50, #' toptitle = "This is the title") #' } diff --git a/R/ProjectField.R b/R/ProjectField.R index 70c8552c..961c117b 100644 --- a/R/ProjectField.R +++ b/R/ProjectField.R @@ -45,7 +45,7 @@ #'mode1_exp <- ProjectField(ano$exp, eof_exp, mode = 1) #'mode1_obs <- ProjectField(ano$obs, eof_obs, mode = 1) #' -#'\dontrun{ +#'\donttest{ #' # Plot the forecast and the observation of the first mode for the last year #' # of forecast #' sdate_dim_length <- dim(mode1_obs)['sdate'] diff --git a/R/REOF.R b/R/REOF.R index 11353329..5f06e611 100644 --- a/R/REOF.R +++ b/R/REOF.R @@ -67,8 +67,11 @@ #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) #'ano <- MeanDims(ano$exp, c('dataset', 'member')) #'res <- REOF(ano, lat = sampleData$lat, lon = sampleData$lon, ntrunc = 5) -#'\dontrun{ -#'PlotEquiMap(eof$EOFs[1, , , 1], sampleData$lat, sampleData$lon) +#'eof_to_plot <- array(res$REOFs[1, , , 1], +#' dim = c(length(sampleData$lat), length(sampleData$lon)), +#' dimnames = list(lat = sampleData$lat, lon = sampleData$lon)) +#'\donttest{ +#'PlotEquiMap(eof_to_plot, sampleData$lat, sampleData$lon) #'} #' #'@import multiApply diff --git a/R/Smoothing.R b/R/Smoothing.R index f1efa449..1dc5bb18 100644 --- a/R/Smoothing.R +++ b/R/Smoothing.R @@ -21,11 +21,18 @@ #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) -#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) -#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) +#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 3) +#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 3) +#'# Collapse lat and lon dimensions +#'smooth_ano_exp <- Apply(list(smooth_ano_exp), +#' target_dims = list(c("lat", "lon")), +#' fun = mean, na.rm = TRUE)$output1 +#'smooth_ano_obs <- Apply(list(smooth_ano_obs), +#' target_dims = list(c("lat", "lon")), +#' fun = mean, na.rm = TRUE)$output1 #'smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) #'smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) -#' \dontrun{ +#' \donttest{ #'PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, #' toptitle = "Smoothed Mediterranean mean SST", ytitle = "K") #' } diff --git a/R/Spread.R b/R/Spread.R index 88ead15b..67bf3e18 100644 --- a/R/Spread.R +++ b/R/Spread.R @@ -45,7 +45,7 @@ #'example(Load) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) -#'runmean_months <- 12 +#'runmean_months <- 3 #'smooth_ano_exp <- Smoothing(ano_exp, runmeanlen = runmean_months) #'smooth_ano_exp_m_sub <- smooth_ano_exp - InsertDim(MeanDims(smooth_ano_exp, 'member', #' na.rm = TRUE), @@ -55,24 +55,28 @@ #'suppressWarnings({ #'spread <- Spread(smooth_ano_exp_m_sub, compute_dim = c('member', 'sdate')) #'}) +#'iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) ### +#'maxmin_avg <- MeanDims(spread$maxmin, dims = c("lat", "lon"), na.rm = TRUE) +#'sd_avg <- MeanDims(spread$sd, dims = c("lat", "lon"), na.rm = TRUE) +#'mad_avg <- MeanDims(spread$mad, dims = c("lat", "lon"), na.rm = TRUE) #' -#'\dontrun{ -#'PlotVsLTime(Reorder(spread$iqr, c('dataset', 'stats', 'ftime')), +#'\donttest{ +#'PlotVsLTime(Reorder(iqr_avg, c('dataset', 'stats', 'ftime')), #' toptitle = "Inter-Quartile Range between ensemble members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, #' hlines = c(0)) -#'PlotVsLTime(Reorder(spread$maxmin, c('dataset', 'stats', 'ftime')), +#'PlotVsLTime(Reorder(maxmin_avg, c('dataset', 'stats', 'ftime')), #' toptitle = "Maximum minus minimum of the members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, #' hlines = c(0)) -#'PlotVsLTime(Reorder(spread$sd, c('dataset', 'stats', 'ftime')), +#'PlotVsLTime(Reorder(sd_avg, c('dataset', 'stats', 'ftime')), #' toptitle = "Standard deviation of the members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, #' hlines = c(0)) -#'PlotVsLTime(Reorder(spread$mad, c('dataset', 'stats', 'ftime')), +#'PlotVsLTime(Reorder(mad_avg, c('dataset', 'stats', 'ftime')), #' toptitle = "Median Absolute Deviation of the members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, diff --git a/R/ToyModel.R b/R/ToyModel.R index 2a0a47f5..3c6cbe6e 100644 --- a/R/ToyModel.R +++ b/R/ToyModel.R @@ -62,29 +62,14 @@ #' #'# Example 2: Generate forecast from loaded observations #'# Decadal prediction example -#' \dontrun{ -#'data_path <- system.file('sample_data', package = 's2dv') -#'expA <- list(name = 'experiment', path = file.path(data_path, -#' 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', -#' '$VAR_NAME$_$START_DATE$.nc')) -#'obsX <- list(name = 'observation', path = file.path(data_path, -#' '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', -#' '$VAR_NAME$_$YEAR$$MONTH$.nc')) -#' -#'# Now we are ready to use Load(). -#'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- Load('tos', list(expA), list(obsX), startDates, -#' output = 'areave', latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } -#' \dontshow{ +#'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') #'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, #' output = 'areave', #' latmin = 27, latmax = 48, #' lonmin = -12, lonmax = 40) -#' } +#'} #' #'a <- 0.1 #'b <- 0.3 @@ -93,12 +78,12 @@ #' #'toyforecast <- ToyModel(alpha = a, beta = b, gamma = g, nmemb = nm, #' obsini = sampleData$obs, nstartd = 5, nleadt = 60) -#'## Add PlotAno() back when this function is included!! -#'# \donttest{ -#'#PlotAno(toyforecast$mod, toyforecast$obs, startDates, -#'# toptitle = c("Synthetic decadal temperature prediction"), -#'# fileout = "ex_toymodel.eps") -#'# } +#' +#'\donttest{ +#'PlotAno(toyforecast$mod, toyforecast$obs, startDates, +#' toptitle = c("Synthetic decadal temperature prediction"), +#' fileout = "ex_toymodel.eps") +#'} #' #'@importFrom stats rnorm #'@export diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index e8681607..69e33c3a 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -125,7 +125,7 @@ ano_exp <- array(ano$exp, dim = dim(ano$exp)[-2]) ano_obs <- array(ano$obs, dim = dim(ano$obs)[-2]) nao <- NAO(exp = ano_exp, obs = ano_obs, lat = sampleData$lat, lon = sampleData$lon) # Finally plot the nao index - \dontrun{ + \donttest{ nao$exp <- Reorder(nao$exp, c(2, 1)) nao$obs <- Reorder(nao$obs, c(2, 1)) PlotBoxWhisker(nao$exp, nao$obs, "NAO index, DJF", "NAO index (PC1) TOS", diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index 10e7503e..0f2b7fa5 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -283,7 +283,7 @@ compatible with figure layouts if colour bar is disabled. data <- matrix(rnorm(100 * 50), 100, 50) x <- seq(from = 0, to = 360, length.out = 100) y <- seq(from = -90, to = 90, length.out = 50) - \dontrun{ + \donttest{ PlotStereoMap(data, x, y, latlims = c(60, 90), brks = 50, toptitle = "This is the title") } diff --git a/man/ProjectField.Rd b/man/ProjectField.Rd index 358f4ee8..284c180b 100644 --- a/man/ProjectField.Rd +++ b/man/ProjectField.Rd @@ -65,7 +65,7 @@ eof_obs <- EOF(ano$obs, sampleData$lat, sampleData$lon) mode1_exp <- ProjectField(ano$exp, eof_exp, mode = 1) mode1_obs <- ProjectField(ano$obs, eof_obs, mode = 1) -\dontrun{ +\donttest{ # Plot the forecast and the observation of the first mode for the last year # of forecast sdate_dim_length <- dim(mode1_obs)['sdate'] diff --git a/man/REOF.Rd b/man/REOF.Rd index a5d416c2..07dc8f81 100644 --- a/man/REOF.Rd +++ b/man/REOF.Rd @@ -90,8 +90,11 @@ sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) ano <- MeanDims(ano$exp, c('dataset', 'member')) res <- REOF(ano, lat = sampleData$lat, lon = sampleData$lon, ntrunc = 5) -\dontrun{ -PlotEquiMap(eof$EOFs[1, , , 1], sampleData$lat, sampleData$lon) +eof_to_plot <- array(res$REOFs[1, , , 1], + dim = c(length(sampleData$lat), length(sampleData$lon)), + dimnames = list(lat = sampleData$lat, lon = sampleData$lon)) +\donttest{ +PlotEquiMap(eof_to_plot, sampleData$lat, sampleData$lon) } } diff --git a/man/Smoothing.Rd b/man/Smoothing.Rd index 5769aa2b..218b2b97 100644 --- a/man/Smoothing.Rd +++ b/man/Smoothing.Rd @@ -33,11 +33,18 @@ example(Load) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) -smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) -smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) +smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 3) +smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 3) +# Collapse lat and lon dimensions +smooth_ano_exp <- Apply(list(smooth_ano_exp), + target_dims = list(c("lat", "lon")), + fun = mean, na.rm = TRUE)$output1 +smooth_ano_obs <- Apply(list(smooth_ano_obs), + target_dims = list(c("lat", "lon")), + fun = mean, na.rm = TRUE)$output1 smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) - \dontrun{ + \donttest{ PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, toptitle = "Smoothed Mediterranean mean SST", ytitle = "K") } diff --git a/man/Spread.Rd b/man/Spread.Rd index d3f93bbb..c1ded469 100644 --- a/man/Spread.Rd +++ b/man/Spread.Rd @@ -65,7 +65,7 @@ data can be the output of \code{Load()}, \code{Ano()}, or example(Load) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) -runmean_months <- 12 +runmean_months <- 3 smooth_ano_exp <- Smoothing(ano_exp, runmeanlen = runmean_months) smooth_ano_exp_m_sub <- smooth_ano_exp - InsertDim(MeanDims(smooth_ano_exp, 'member', na.rm = TRUE), @@ -75,24 +75,28 @@ smooth_ano_exp_m_sub <- smooth_ano_exp - InsertDim(MeanDims(smooth_ano_exp, 'mem suppressWarnings({ spread <- Spread(smooth_ano_exp_m_sub, compute_dim = c('member', 'sdate')) }) +iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) ### +maxmin_avg <- MeanDims(spread$maxmin, dims = c("lat", "lon"), na.rm = TRUE) +sd_avg <- MeanDims(spread$sd, dims = c("lat", "lon"), na.rm = TRUE) +mad_avg <- MeanDims(spread$mad, dims = c("lat", "lon"), na.rm = TRUE) -\dontrun{ -PlotVsLTime(Reorder(spread$iqr, c('dataset', 'stats', 'ftime')), +\donttest{ +PlotVsLTime(Reorder(iqr_avg, c('dataset', 'stats', 'ftime')), toptitle = "Inter-Quartile Range between ensemble members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, hlines = c(0)) -PlotVsLTime(Reorder(spread$maxmin, c('dataset', 'stats', 'ftime')), +PlotVsLTime(Reorder(maxmin_avg, c('dataset', 'stats', 'ftime')), toptitle = "Maximum minus minimum of the members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, hlines = c(0)) -PlotVsLTime(Reorder(spread$sd, c('dataset', 'stats', 'ftime')), +PlotVsLTime(Reorder(sd_avg, c('dataset', 'stats', 'ftime')), toptitle = "Standard deviation of the members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, hlines = c(0)) -PlotVsLTime(Reorder(spread$mad, c('dataset', 'stats', 'ftime')), +PlotVsLTime(Reorder(mad_avg, c('dataset', 'stats', 'ftime')), toptitle = "Median Absolute Deviation of the members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, diff --git a/man/ToyModel.Rd b/man/ToyModel.Rd index ee7a98e9..407d3110 100644 --- a/man/ToyModel.Rd +++ b/man/ToyModel.Rd @@ -91,29 +91,14 @@ toyforecast <- ToyModel(alpha = a, beta = b, gamma = g, sig = sig, trend = t, # Example 2: Generate forecast from loaded observations # Decadal prediction example - \dontrun{ -data_path <- system.file('sample_data', package = 's2dv') -expA <- list(name = 'experiment', path = file.path(data_path, - 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', - '$VAR_NAME$_$START_DATE$.nc')) -obsX <- list(name = 'observation', path = file.path(data_path, - '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', - '$VAR_NAME$_$YEAR$$MONTH$.nc')) - -# Now we are ready to use Load(). -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- Load('tos', list(expA), list(obsX), startDates, - output = 'areave', latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } - \dontshow{ +\dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, output = 'areave', latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) - } +} a <- 0.1 b <- 0.3 @@ -122,11 +107,11 @@ nm <- 10 toyforecast <- ToyModel(alpha = a, beta = b, gamma = g, nmemb = nm, obsini = sampleData$obs, nstartd = 5, nleadt = 60) -## Add PlotAno() back when this function is included!! -# \donttest{ -#PlotAno(toyforecast$mod, toyforecast$obs, startDates, -# toptitle = c("Synthetic decadal temperature prediction"), -# fileout = "ex_toymodel.eps") -# } + +\donttest{ +PlotAno(toyforecast$mod, toyforecast$obs, startDates, + toptitle = c("Synthetic decadal temperature prediction"), + fileout = "ex_toymodel.eps") +} } -- GitLab From a439783dc4018e96a4a2fb3c1b10c863fc67b5ae Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Wed, 17 Sep 2025 16:47:08 +0200 Subject: [PATCH 09/26] Replace 'print()' for 'message()' so messages can be more easily suppressed --- R/Plot2VarsVsLTime.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index 5430e366..2a04d3c8 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -113,11 +113,11 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, nvars <- 2 if (length(dim(var1)) != length(dim(var2))) { - print("the two input variables should have the same dimensions") + message("the two input variables should have the same dimensions") stop() } if (length(dim(var1)) >= 4) { - print("dimensions of input variables should be 3") + message("dimensions of input variables should be 3") stop() } nleadtime <- dim(var1)[3] -- GitLab From d3882355a903853742b0aa04e973e327e2cfeb2f Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Fri, 19 Sep 2025 10:53:54 +0200 Subject: [PATCH 10/26] Bugfix documentation examples and use 'donttrest' instead of 'dontrun' --- R/Ano.R | 4 +++- R/Ano_CrossValid.R | 8 ++++++-- R/CDORemap.R | 4 +++- R/Clim.R | 8 +++++--- R/Load.R | 37 +++++-------------------------------- R/PlotBoxWhisker.R | 24 ++++-------------------- R/PlotEquiMap.R | 19 +------------------ R/PlotLayout.R | 18 ------------------ R/RatioSDRMS.R | 8 +++++--- R/Smoothing.R | 10 +++------- R/Spread.R | 2 +- man/Ano.Rd | 4 +++- man/Ano_CrossValid.Rd | 8 ++++++-- man/CDORemap.Rd | 4 +++- man/Clim.Rd | 8 +++++--- man/Load.Rd | 37 +++++-------------------------------- man/PlotBoxWhisker.Rd | 21 +-------------------- man/PlotEquiMap.Rd | 19 +------------------ man/PlotLayout.Rd | 18 ------------------ man/RatioSDRMS.Rd | 8 +++++--- man/Smoothing.Rd | 10 +++------- man/Spread.Rd | 2 +- 22 files changed, 69 insertions(+), 212 deletions(-) diff --git a/R/Ano.R b/R/Ano.R index ccb41e0a..e32c8619 100644 --- a/R/Ano.R +++ b/R/Ano.R @@ -21,7 +21,9 @@ #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) -#'\dontrun{ +#'ano_exp <- MeanDims(ano_exp, dims = c("lat", "lon"), na.rm = TRUE) +#'ano_obs <- MeanDims(ano_obs, dims = c("lat", "lon"), na.rm = TRUE) +#'\donttest{ #'PlotAno(ano_exp, ano_obs, startDates, #' toptitle = 'Anomaly', ytitle = c('K', 'K', 'K'), #' legends = 'ERSST', biglab = FALSE) diff --git a/R/Ano_CrossValid.R b/R/Ano_CrossValid.R index e083fc90..497800cd 100644 --- a/R/Ano_CrossValid.R +++ b/R/Ano_CrossValid.R @@ -45,8 +45,12 @@ #'# Load sample data as in Load() example: #'example(Load) #'anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) -#'\dontrun{ -#'PlotAno(anomalies$exp, anomalies$obs, startDates, +#'ano_exp <- MeanDims(anomalies$exp, dims = c("lat", "lon"), na.rm = TRUE) +#'ano_obs <- MeanDims(anomalies$obs, dims = c("lat", "lon"), na.rm = TRUE) +#'ano_exp <- Reorder(ano_exp, c(2, 3, 4, 1)) +#'ano_obs <- Reorder(ano_obs, c(2, 3, 4, 1)) +#'\donttest{ +#'PlotAno(ano_exp, ano_obs, startDates, #' toptitle = paste('anomalies'), ytitle = c('K', 'K', 'K'), #' legends = 'ERSST', biglab = FALSE) #'} diff --git a/R/CDORemap.R b/R/CDORemap.R index d789e4d1..a1f572b5 100644 --- a/R/CDORemap.R +++ b/R/CDORemap.R @@ -219,9 +219,11 @@ #'names(dim(lat)) <- c('i', 'j') #'tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil') #'tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil', FALSE) +#' } +#' \dontrun{ #'# It is possible to specify an external NetCDF file as target grid reference #'tas2 <- CDORemap(tas, lon, lat, 'external_file.nc', 'bil') -#'} +#' } #'@import ncdf4 #'@importFrom easyNCDF ArrayToNc #'@importFrom stats lm predict setNames diff --git a/R/Clim.R b/R/Clim.R index d3dde13d..4801fc47 100644 --- a/R/Clim.R +++ b/R/Clim.R @@ -63,9 +63,11 @@ #'# Load sample data as in Load() example: #'example(Load) #'clim <- Clim(sampleData$mod, sampleData$obs) -#'clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) -#'\dontrun{ -#'PlotClim(clim$clim_exp, clim$clim_obs, +#'# clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) +#'clim_exp <- MeanDims(clim$clim_exp, c("lat", "lon"), na.rm = TRUE) +#'clim_obs <- MeanDims(clim$clim_obs, c("lat", "lon"), na.rm = TRUE) +#'\donttest{ +#'PlotClim(clim_exp, clim_obs, #' toptitle = paste('sea surface temperature climatologies'), #' ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), #' listobs = c('ERSST'), biglab = FALSE) diff --git a/R/Load.R b/R/Load.R index bc05647c..fecc4640 100644 --- a/R/Load.R +++ b/R/Load.R @@ -756,28 +756,7 @@ #'# Instead, the code in 'dontshow' is run, which loads the equivalent #'# already processed data in R. #'# -#'# Example 1: Providing lists of lists to 'exp' and 'obs': -#'# -#' \donttest{ -#'data_path <- system.file('sample_data', package = 's2dv') -#'exp <- list( -#' name = 'experiment', -#' path = file.path(data_path, 'model/$EXP_NAME$/monthly_mean', -#' '$VAR_NAME$_3hourly/$VAR_NAME$_$START_DATES$.nc') -#' ) -#'obs <- list( -#' name = 'observation', -#' path = file.path(data_path, 'observation/$OBS_NAME$/monthly_mean', -#' '$VAR_NAME$/$VAR_NAME$_$YEAR$$MONTH$.nc') -#' ) -#'# Now we are ready to use Load(). -#'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- Load('tos', list(exp), list(obs), startDates, -#' output = 'areave', latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } -#'# -#'# Example 2: Providing vectors of character strings to 'exp' and 'obs' +#'# Example 1: Providing vectors of character strings to 'exp' and 'obs' #'# and using a configuration file. #'# #'# The configuration file 'sample.conf' that we will create in the example @@ -799,8 +778,9 @@ #' output = 'areave', latmin = 27, latmax = 48, #' lonmin = -12, lonmax = 40) #'# -#'# Example 3: providing character strings in 'exp' and 'obs', and providing -#'# a configuration file. +#'# Example 2: providing character strings in 'exp' and 'obs', and providing +#'# a configuration file. +#'# #'# The configuration file 'sample.conf' that we will create in the example #'# has the proper entries to load these (see ?LoadConfigFile for details on #'# writing a configuration file). @@ -827,14 +807,7 @@ #' output = 'areave', latmin = 27, latmax = 48, #' lonmin = -12, lonmax = 40, configfile = configfile) #' } -#' \dontshow{ -#'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'areave', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } +#' #'@import parallel bigmemory methods #'@importFrom stats ts window na.omit #'@importFrom abind abind diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index f84d8284..06cd7d32 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -53,24 +53,8 @@ #'0.2 - 2015-03 (L. Batte, \email{lauriane.batte@@ic3.cat}) - Removed all\cr #' normalization for sake of clarity. #'1.0 - 2016-03 (N. Manubens, \email{nicolau.manubens@@bsc.es}) - Formatting to R CRAN -#'@examples -#'# See examples on Load() to understand the first lines in this example -#' \dontrun{ -#'data_path <- system.file('sample_data', package = 's2dverification') -#'expA <- list(name = 'experiment', path = file.path(data_path, -#' 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', -#' '$VAR_NAME$_$START_DATE$.nc')) -#'obsX <- list(name = 'observation', path = file.path(data_path, -#' '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', -#' '$VAR_NAME$_$YEAR$$MONTH$.nc')) #' -#'# Now we are ready to use Load(). -#'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- Load('tos', list(expA), list(obsX), startDates, -#' leadtimemin = 1, leadtimemax = 4, output = 'lonlat', -#' latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) -#' } -#' \dontshow{ +#'@examples #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') #'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, @@ -84,7 +68,7 @@ #'# NAO region directly. #'sampleData$lon[] <- c(40, 280, 340) #'sampleData$lat[] <- c(20, 80) -#' } +#' #'# Now ready to compute the EOFs and project on, for example, the first #'# variability mode. #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) @@ -92,12 +76,10 @@ #'ano_obs <- array(ano$obs, dim = dim(ano$obs)[-2]) #'nao <- NAO(exp = ano_exp, obs = ano_obs, lat = sampleData$lat, lon = sampleData$lon) #'# Finally plot the nao index -#' \donttest{ #'nao$exp <- Reorder(nao$exp, c(2, 1)) #'nao$obs <- Reorder(nao$obs, c(2, 1)) #'PlotBoxWhisker(nao$exp, nao$obs, "NAO index, DJF", "NAO index (PC1) TOS", #' monini = 12, yearini = 1985, freq = 1, "Exp. A", "Obs. X") -#' } #' #'@importFrom grDevices dev.cur dev.new dev.off #'@importFrom stats cor @@ -203,6 +185,8 @@ PlotBoxWhisker <- function(exp, obs, toptitle = '', ytitle = '', monini = 1, } # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) ## Observed time series. diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index a2a7e3d4..e18c02ad 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -225,23 +225,6 @@ #'} #' #'@examples -#'# See examples on Load() to understand the first lines in this example -#' \dontrun{ -#'data_path <- system.file('sample_data', package = 's2dv') -#'expA <- list(name = 'experiment', path = file.path(data_path, -#' 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', -#' '$VAR_NAME$_$START_DATE$.nc')) -#'obsX <- list(name = 'observation', path = file.path(data_path, -#' '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', -#' '$VAR_NAME$_$YEAR$$MONTH$.nc')) -#' -#'# Now we are ready to use Load(). -#'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- Load('tos', list(expA), list(obsX), startDates, -#' leadtimemin = 1, leadtimemax = 4, output = 'lonlat', -#' latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) -#' } -#' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') #'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, @@ -250,10 +233,10 @@ #' output = 'lonlat', #' latmin = 27, latmax = 48, #' lonmin = -12, lonmax = 40) -#' } #'PlotEquiMap(sampleData$mod[1, 1, 1, 1, , ], sampleData$lon, sampleData$lat, #' toptitle = 'Predicted sea surface temperature for Nov 1960 from 1st Nov', #' title_scale = 0.5) +#' #'@import graphics maps #'@importFrom grDevices dev.cur dev.new dev.off gray #'@importFrom stats cor diff --git a/R/PlotLayout.R b/R/PlotLayout.R index c77b25a4..29441ef6 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -179,23 +179,6 @@ #'} #' #'@examples -#'# See examples on Load() to understand the first lines in this example -#' \dontrun{ -#'data_path <- system.file('sample_data', package = 's2dv') -#'expA <- list(name = 'experiment', path = file.path(data_path, -#' 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', -#' '$VAR_NAME$_$START_DATE$.nc')) -#'obsX <- list(name = 'observation', path = file.path(data_path, -#' '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', -#' '$VAR_NAME$_$YEAR$$MONTH$.nc')) -#' -#'# Now we are ready to use Load(). -#'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- Load('tos', list(expA), list(obsX), startDates, -#' leadtimemin = 1, leadtimemax = 4, output = 'lonlat', -#' latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) -#' } -#' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') #'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), #' c('observation'), startDates, @@ -204,7 +187,6 @@ #' output = 'lonlat', #' latmin = 27, latmax = 48, #' lonmin = -12, lonmax = 40) -#' } #'PlotLayout(PlotEquiMap, c('lat', 'lon'), sampleData$mod[1, , 1, 1, , ], #' sampleData$lon, sampleData$lat, #' toptitle = 'Predicted tos for Nov 1960 from 1st Nov', diff --git a/R/RatioSDRMS.R b/R/RatioSDRMS.R index f7e848f3..abed5acf 100644 --- a/R/RatioSDRMS.R +++ b/R/RatioSDRMS.R @@ -38,11 +38,13 @@ #'# Load sample data as in Load() example: #'example(Load) #'rsdrms <- RatioSDRMS(sampleData$mod, sampleData$obs, dat_dim = 'dataset') +#'rsdrms_ratio <- MeanDims(rsdrms$ratio, dims = c("lat", "lon"), na.rm = TRUE) +#'rsdrms_pval <- MeanDims(rsdrms$p.val, dims = c("lat", "lon"), na.rm = TRUE) #'# Reorder the data in order to plot it with PlotVsLTime #'rsdrms_plot <- array(dim = c(dim(rsdrms$ratio)[1:2], 4, dim(rsdrms$ratio)[3])) -#'rsdrms_plot[, , 2, ] <- rsdrms$ratio -#'rsdrms_plot[, , 4, ] <- rsdrms$p.val -#'\dontrun{ +#'rsdrms_plot[, , 2, ] <- rsdrms_ratio +#'rsdrms_plot[, , 4, ] <- rsdrms_pval +#'\donttest{ #'PlotVsLTime(rsdrms_plot, toptitle = "Ratio ensemble spread / RMSE", ytitle = "", #' monini = 11, limits = c(-1, 1.3), listexp = c('CMIP5 IC3'), #' listobs = c('ERSST'), biglab = FALSE, siglev = TRUE) diff --git a/R/Smoothing.R b/R/Smoothing.R index 1dc5bb18..bc162a3e 100644 --- a/R/Smoothing.R +++ b/R/Smoothing.R @@ -23,13 +23,9 @@ #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) #'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 3) #'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 3) -#'# Collapse lat and lon dimensions -#'smooth_ano_exp <- Apply(list(smooth_ano_exp), -#' target_dims = list(c("lat", "lon")), -#' fun = mean, na.rm = TRUE)$output1 -#'smooth_ano_obs <- Apply(list(smooth_ano_obs), -#' target_dims = list(c("lat", "lon")), -#' fun = mean, na.rm = TRUE)$output1 +#'# Calculate spatial average +#'smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) +#'smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) #'smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) #'smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) #' \donttest{ diff --git a/R/Spread.R b/R/Spread.R index 67bf3e18..706eb00d 100644 --- a/R/Spread.R +++ b/R/Spread.R @@ -55,7 +55,7 @@ #'suppressWarnings({ #'spread <- Spread(smooth_ano_exp_m_sub, compute_dim = c('member', 'sdate')) #'}) -#'iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) ### +#'iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) #'maxmin_avg <- MeanDims(spread$maxmin, dims = c("lat", "lon"), na.rm = TRUE) #'sd_avg <- MeanDims(spread$sd, dims = c("lat", "lon"), na.rm = TRUE) #'mad_avg <- MeanDims(spread$mad, dims = c("lat", "lon"), na.rm = TRUE) diff --git a/man/Ano.Rd b/man/Ano.Rd index e30467e0..331bdcbf 100644 --- a/man/Ano.Rd +++ b/man/Ano.Rd @@ -32,7 +32,9 @@ example(Load) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) -\dontrun{ +ano_exp <- MeanDims(ano_exp, dims = c("lat", "lon"), na.rm = TRUE) +ano_obs <- MeanDims(ano_obs, dims = c("lat", "lon"), na.rm = TRUE) +\donttest{ PlotAno(ano_exp, ano_obs, startDates, toptitle = 'Anomaly', ytitle = c('K', 'K', 'K'), legends = 'ERSST', biglab = FALSE) diff --git a/man/Ano_CrossValid.Rd b/man/Ano_CrossValid.Rd index 2a827131..8fa6cc10 100644 --- a/man/Ano_CrossValid.Rd +++ b/man/Ano_CrossValid.Rd @@ -67,8 +67,12 @@ the 'exp' and 'obs' are excluded when computing the climatologies. # Load sample data as in Load() example: example(Load) anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) -\dontrun{ -PlotAno(anomalies$exp, anomalies$obs, startDates, +ano_exp <- MeanDims(anomalies$exp, dims = c("lat", "lon"), na.rm = TRUE) +ano_obs <- MeanDims(anomalies$obs, dims = c("lat", "lon"), na.rm = TRUE) +ano_exp <- Reorder(ano_exp, c(2, 3, 4, 1)) +ano_obs <- Reorder(ano_obs, c(2, 3, 4, 1)) +\donttest{ +PlotAno(ano_exp, ano_obs, startDates, toptitle = paste('anomalies'), ytitle = c('K', 'K', 'K'), legends = 'ERSST', biglab = FALSE) } diff --git a/man/CDORemap.Rd b/man/CDORemap.Rd index 1a221e70..a211ce61 100644 --- a/man/CDORemap.Rd +++ b/man/CDORemap.Rd @@ -251,7 +251,9 @@ lat <- t(array(seq(-90, 90, length.out = num_lats), names(dim(lat)) <- c('i', 'j') tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil') tas2 <- CDORemap(tas, lon, lat, 't17grid', 'bil', FALSE) + } + \dontrun{ # It is possible to specify an external NetCDF file as target grid reference tas2 <- CDORemap(tas, lon, lat, 'external_file.nc', 'bil') -} + } } diff --git a/man/Clim.Rd b/man/Clim.Rd index c3bd96fa..cacb4978 100644 --- a/man/Clim.Rd +++ b/man/Clim.Rd @@ -91,9 +91,11 @@ per-pair correction beforehand. # Load sample data as in Load() example: example(Load) clim <- Clim(sampleData$mod, sampleData$obs) -clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) -\dontrun{ -PlotClim(clim$clim_exp, clim$clim_obs, +# clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) +clim_exp <- MeanDims(clim$clim_exp, c("lat", "lon"), na.rm = TRUE) +clim_obs <- MeanDims(clim$clim_obs, c("lat", "lon"), na.rm = TRUE) +\donttest{ +PlotClim(clim_exp, clim_obs, toptitle = paste('sea surface temperature climatologies'), ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE) diff --git a/man/Load.Rd b/man/Load.Rd index 124ed853..7b2b0393 100644 --- a/man/Load.Rd +++ b/man/Load.Rd @@ -819,28 +819,7 @@ to the package or check the comments in the code. # Instead, the code in 'dontshow' is run, which loads the equivalent # already processed data in R. # -# Example 1: Providing lists of lists to 'exp' and 'obs': -# - \donttest{ -data_path <- system.file('sample_data', package = 's2dv') -exp <- list( - name = 'experiment', - path = file.path(data_path, 'model/$EXP_NAME$/monthly_mean', - '$VAR_NAME$_3hourly/$VAR_NAME$_$START_DATES$.nc') - ) -obs <- list( - name = 'observation', - path = file.path(data_path, 'observation/$OBS_NAME$/monthly_mean', - '$VAR_NAME$/$VAR_NAME$_$YEAR$$MONTH$.nc') - ) -# Now we are ready to use Load(). -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- Load('tos', list(exp), list(obs), startDates, - output = 'areave', latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } -# -# Example 2: Providing vectors of character strings to 'exp' and 'obs' +# Example 1: Providing vectors of character strings to 'exp' and 'obs' # and using a configuration file. # # The configuration file 'sample.conf' that we will create in the example @@ -862,8 +841,9 @@ sampleData <- Load('tos', list(expA), list(obsX), startDates, output = 'areave', latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) # -# Example 3: providing character strings in 'exp' and 'obs', and providing -# a configuration file. +# Example 2: providing character strings in 'exp' and 'obs', and providing +# a configuration file. +# # The configuration file 'sample.conf' that we will create in the example # has the proper entries to load these (see ?LoadConfigFile for details on # writing a configuration file). @@ -890,12 +870,5 @@ sampleData <- Load('tos', c('experiment'), c('observation'), startDates, output = 'areave', latmin = 27, latmax = 48, lonmin = -12, lonmax = 40, configfile = configfile) } - \dontshow{ -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'areave', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } + } diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index 69e33c3a..b0b41668 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -87,23 +87,6 @@ forecast and observational data is calculated and displayed. Only works for n-monthly to n-yearly time series. } \examples{ -# See examples on Load() to understand the first lines in this example - \dontrun{ -data_path <- system.file('sample_data', package = 's2dverification') -expA <- list(name = 'experiment', path = file.path(data_path, - 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', - '$VAR_NAME$_$START_DATE$.nc')) -obsX <- list(name = 'observation', path = file.path(data_path, - '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', - '$VAR_NAME$_$YEAR$$MONTH$.nc')) - -# Now we are ready to use Load(). -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- Load('tos', list(expA), list(obsX), startDates, - leadtimemin = 1, leadtimemax = 4, output = 'lonlat', - latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) - } - \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, @@ -117,7 +100,7 @@ sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), # NAO region directly. sampleData$lon[] <- c(40, 280, 340) sampleData$lat[] <- c(20, 80) - } + # Now ready to compute the EOFs and project on, for example, the first # variability mode. ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) @@ -125,12 +108,10 @@ ano_exp <- array(ano$exp, dim = dim(ano$exp)[-2]) ano_obs <- array(ano$obs, dim = dim(ano$obs)[-2]) nao <- NAO(exp = ano_exp, obs = ano_obs, lat = sampleData$lat, lon = sampleData$lon) # Finally plot the nao index - \donttest{ nao$exp <- Reorder(nao$exp, c(2, 1)) nao$obs <- Reorder(nao$obs, c(2, 1)) PlotBoxWhisker(nao$exp, nao$obs, "NAO index, DJF", "NAO index (PC1) TOS", monini = 12, yearini = 1985, freq = 1, "Exp. A", "Obs. X") - } } \seealso{ diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index 5d3739a0..aee9d181 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -376,23 +376,6 @@ include continents, oceans, and lakes. This plot function is compatible with figure layouts if colour bar is disabled. } \examples{ -# See examples on Load() to understand the first lines in this example - \dontrun{ -data_path <- system.file('sample_data', package = 's2dv') -expA <- list(name = 'experiment', path = file.path(data_path, - 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', - '$VAR_NAME$_$START_DATE$.nc')) -obsX <- list(name = 'observation', path = file.path(data_path, - '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', - '$VAR_NAME$_$YEAR$$MONTH$.nc')) - -# Now we are ready to use Load(). -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- Load('tos', list(expA), list(obsX), startDates, - leadtimemin = 1, leadtimemax = 4, output = 'lonlat', - latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) - } - \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, @@ -401,8 +384,8 @@ sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), output = 'lonlat', latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) - } PlotEquiMap(sampleData$mod[1, 1, 1, 1, , ], sampleData$lon, sampleData$lat, toptitle = 'Predicted sea surface temperature for Nov 1960 from 1st Nov', title_scale = 0.5) + } diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index 2a053ad0..62c39c1b 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -265,23 +265,6 @@ This function pops up a blank new device and fills it in, so it cannot be nested in complex layouts. } \examples{ -# See examples on Load() to understand the first lines in this example - \dontrun{ -data_path <- system.file('sample_data', package = 's2dv') -expA <- list(name = 'experiment', path = file.path(data_path, - 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', - '$VAR_NAME$_$START_DATE$.nc')) -obsX <- list(name = 'observation', path = file.path(data_path, - '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', - '$VAR_NAME$_$YEAR$$MONTH$.nc')) - -# Now we are ready to use Load(). -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- Load('tos', list(expA), list(obsX), startDates, - leadtimemin = 1, leadtimemax = 4, output = 'lonlat', - latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) - } - \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), c('observation'), startDates, @@ -290,7 +273,6 @@ sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), output = 'lonlat', latmin = 27, latmax = 48, lonmin = -12, lonmax = 40) - } PlotLayout(PlotEquiMap, c('lat', 'lon'), sampleData$mod[1, , 1, 1, , ], sampleData$lon, sampleData$lat, toptitle = 'Predicted tos for Nov 1960 from 1st Nov', diff --git a/man/RatioSDRMS.Rd b/man/RatioSDRMS.Rd index 07afc461..e01492a2 100644 --- a/man/RatioSDRMS.Rd +++ b/man/RatioSDRMS.Rd @@ -61,11 +61,13 @@ Fisher's test. # Load sample data as in Load() example: example(Load) rsdrms <- RatioSDRMS(sampleData$mod, sampleData$obs, dat_dim = 'dataset') +rsdrms_ratio <- MeanDims(rsdrms$ratio, dims = c("lat", "lon"), na.rm = TRUE) +rsdrms_pval <- MeanDims(rsdrms$p.val, dims = c("lat", "lon"), na.rm = TRUE) # Reorder the data in order to plot it with PlotVsLTime rsdrms_plot <- array(dim = c(dim(rsdrms$ratio)[1:2], 4, dim(rsdrms$ratio)[3])) -rsdrms_plot[, , 2, ] <- rsdrms$ratio -rsdrms_plot[, , 4, ] <- rsdrms$p.val -\dontrun{ +rsdrms_plot[, , 2, ] <- rsdrms_ratio +rsdrms_plot[, , 4, ] <- rsdrms_pval +\donttest{ PlotVsLTime(rsdrms_plot, toptitle = "Ratio ensemble spread / RMSE", ytitle = "", monini = 11, limits = c(-1, 1.3), listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, siglev = TRUE) diff --git a/man/Smoothing.Rd b/man/Smoothing.Rd index 218b2b97..3b67566a 100644 --- a/man/Smoothing.Rd +++ b/man/Smoothing.Rd @@ -35,13 +35,9 @@ ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 3) smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 3) -# Collapse lat and lon dimensions -smooth_ano_exp <- Apply(list(smooth_ano_exp), - target_dims = list(c("lat", "lon")), - fun = mean, na.rm = TRUE)$output1 -smooth_ano_obs <- Apply(list(smooth_ano_obs), - target_dims = list(c("lat", "lon")), - fun = mean, na.rm = TRUE)$output1 +# Calculate spatial average +smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) +smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) \donttest{ diff --git a/man/Spread.Rd b/man/Spread.Rd index c1ded469..99b5163c 100644 --- a/man/Spread.Rd +++ b/man/Spread.Rd @@ -75,7 +75,7 @@ smooth_ano_exp_m_sub <- smooth_ano_exp - InsertDim(MeanDims(smooth_ano_exp, 'mem suppressWarnings({ spread <- Spread(smooth_ano_exp_m_sub, compute_dim = c('member', 'sdate')) }) -iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) ### +iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) maxmin_avg <- MeanDims(spread$maxmin, dims = c("lat", "lon"), na.rm = TRUE) sd_avg <- MeanDims(spread$sd, dims = c("lat", "lon"), na.rm = TRUE) mad_avg <- MeanDims(spread$mad, dims = c("lat", "lon"), na.rm = TRUE) -- GitLab From 9a9a472a674e2e04362aa8d10b45b2433f393feb Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Fri, 19 Sep 2025 11:05:06 +0200 Subject: [PATCH 11/26] Export LoadSampleData.R --- R/LoadSampleData.R | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 R/LoadSampleData.R diff --git a/R/LoadSampleData.R b/R/LoadSampleData.R new file mode 100644 index 00000000..2a59a112 --- /dev/null +++ b/R/LoadSampleData.R @@ -0,0 +1,56 @@ +.LoadSampleData <- function(var, exp = NULL, obs = NULL, sdates, + nmember = NULL, nmemberobs = NULL, + nleadtime = NULL, leadtimemin = 1, + leadtimemax = NULL, storefreq = 'monthly', + sampleperiod = 1, lonmin = 0, lonmax = 360, + latmin = -90, latmax = 90, output = 'areave', + method = 'conservative', grid = NULL, + maskmod = vector("list", 15), + maskobs = vector("list", 15), + configfile = NULL, suffixexp = NULL, + suffixobs = NULL, varmin = NULL, varmax = NULL, + silent = FALSE, nprocs = NULL) { + ## This function loads and selects sample data stored in sampleMap and + ## sampleTimeSeries and is used in the examples instead of Load() so as + ## to avoid nco and cdo system calls and computation time in the stage + ## of running examples in the CHECK process on CRAN. + selected_start_dates <- match(sdates, c('19851101', '19901101', '19951101', + '20001101', '20051101')) + start_dates_position <- 3 + lead_times_position <- 4 + + if (output == 'lonlat') { + sampleData <- s2dv::sampleMap + if (is.null(leadtimemax)) { + leadtimemax <- dim(sampleData$mod)[lead_times_position] + } + selected_lead_times <- leadtimemin:leadtimemax + + dataOut <- sampleData + dataOut$mod <- sampleData$mod[, , selected_start_dates, selected_lead_times, , ] + dataOut$obs <- sampleData$obs[, , selected_start_dates, selected_lead_times, , ] + } else if (output == 'areave') { + sampleData <- s2dv::sampleTimeSeries + if (is.null(leadtimemax)) { + leadtimemax <- dim(sampleData$mod)[lead_times_position] + } + selected_lead_times <- leadtimemin:leadtimemax + + dataOut <- sampleData + dataOut$mod <- sampleData$mod[, , selected_start_dates, selected_lead_times] + dataOut$obs <- sampleData$obs[, , selected_start_dates, selected_lead_times] + } + + dims_out <- dim(sampleData$mod) + dims_out[start_dates_position] <- length(selected_start_dates) + dims_out[lead_times_position] <- length(selected_lead_times) + dim(dataOut$mod) <- dims_out + + dims_out <- dim(sampleData$obs) + dims_out[start_dates_position] <- length(selected_start_dates) + dims_out[lead_times_position] <- length(selected_lead_times) + dim(dataOut$obs) <- dims_out + + invisible(list(mod = dataOut$mod, obs = dataOut$obs, + lat = dataOut$lat, lon = dataOut$lon)) +} \ No newline at end of file -- GitLab From 43ca1e586d89e44efb7a587ea0aedf8273b6f65a Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Fri, 19 Sep 2025 16:25:39 +0200 Subject: [PATCH 12/26] Add documentation and remove unused parameters to R/LoadSampleData.R --- R/LoadSampleData.R | 61 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/R/LoadSampleData.R b/R/LoadSampleData.R index 2a59a112..ca6b0f58 100644 --- a/R/LoadSampleData.R +++ b/R/LoadSampleData.R @@ -1,19 +1,44 @@ -.LoadSampleData <- function(var, exp = NULL, obs = NULL, sdates, - nmember = NULL, nmemberobs = NULL, - nleadtime = NULL, leadtimemin = 1, - leadtimemax = NULL, storefreq = 'monthly', - sampleperiod = 1, lonmin = 0, lonmax = 360, - latmin = -90, latmax = 90, output = 'areave', - method = 'conservative', grid = NULL, - maskmod = vector("list", 15), - maskobs = vector("list", 15), - configfile = NULL, suffixexp = NULL, - suffixobs = NULL, varmin = NULL, varmax = NULL, - silent = FALSE, nprocs = NULL) { - ## This function loads and selects sample data stored in sampleMap and - ## sampleTimeSeries and is used in the examples instead of Load() so as - ## to avoid nco and cdo system calls and computation time in the stage - ## of running examples in the CHECK process on CRAN. +#' Load Sample Data for Package Examples +#' +#' Loads and subsets sample data stored in the internal datasets +#' \code{sampleMap} and \code{sampleTimeSeries}, included with the package. +#' Intended for use in documentation examples instead of \code{Load()}, in order +#' to avoid reliance on external system dependencies like 'nco' and 'cdo' and +#' to reduce computation time during CRAN checks. +#' +#' @param sdates Character vector of start dates to include (e.g., +#' \code{c("19851101", "19901101")}). Must match one or more of the available +#' dates in the internal sample datasets: "19851101", "19901101", "19951101", +#' "20001101" or "20051101". +#' @param leadtimemin Integer specifying the first lead time to include. Default +#' is 1. +#' @param leadtimemax Integer specifying the last lead time to include. If NULL, +#' the full lead time range is included. Default is NULL. +#' @param output Character string indicating the type of output: \code{"areave"} +#' for area-averaged time series data, or \code{"lonlat"} for gridded spatial +#' data. Default is \code{"areave"}. +#' +#' @return A named list with the following elements: +#' \item{mod}{Array of model data with the selected start dates and lead times.} +#' \item{obs}{Array of observational data with the selected start dates and lead +#' times.} +#' \item{lat}{Vector of latitudes.} +#' \item{lon}{Vector of longitudes.} +#' +#' @details +#' This function is designed for use in examples and tests within the +#' 's2dv' package. It provides quick access to precomputed datasets, helping to +#' avoid slow or system-dependent operations during automated checks. +#' +#' @examples +#' startDates <- c("19851101", "19901101", "19951101") +#' data <- LoadSampleData(sdates = startDates, output = "lonlat") +#' str(data$mod) +#' +#' @export +LoadSampleData <- function(sdates, leadtimemin = 1, leadtimemax = NULL, + output = 'areave') { + selected_start_dates <- match(sdates, c('19851101', '19901101', '19951101', '20001101', '20051101')) start_dates_position <- 3 @@ -51,6 +76,6 @@ dims_out[lead_times_position] <- length(selected_lead_times) dim(dataOut$obs) <- dims_out - invisible(list(mod = dataOut$mod, obs = dataOut$obs, - lat = dataOut$lat, lon = dataOut$lon)) + return(list(mod = dataOut$mod, obs = dataOut$obs, + lat = dataOut$lat, lon = dataOut$lon)) } \ No newline at end of file -- GitLab From 33617121a43fee7094f6ea1a9192d502c0b52bfc Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Fri, 19 Sep 2025 16:26:46 +0200 Subject: [PATCH 13/26] R/ACC.R --- R/AnimateMap.R | 12 +++++++----- R/ColorBar.R | 2 ++ R/EOF.R | 16 ++++++++-------- R/Histo2Hindcast.R | 16 ++++++++-------- R/Plot2VarsVsLTime.R | 2 ++ R/PlotACC.R | 18 ++++++++++-------- R/PlotAno.R | 4 +++- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/R/AnimateMap.R b/R/AnimateMap.R index 4560486a..d1565274 100644 --- a/R/AnimateMap.R +++ b/R/AnimateMap.R @@ -110,11 +110,11 @@ #' } #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #' } #'clim <- Clim(sampleData$mod, sampleData$obs, memb = FALSE) #' \donttest{ @@ -220,6 +220,8 @@ AnimateMap <- function(var, lon, lat, toptitle = rep("", 11), sizetit = 1, ".png", sep = ""), width = 550, height = 300, bg = "white") # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) for (jt in 1:nleadtime) { title <- paste(toptitle[(jexp - 1) * nobs + jobs], diff --git a/R/ColorBar.R b/R/ColorBar.R index b6da2bb3..1ad8cf5f 100644 --- a/R/ColorBar.R +++ b/R/ColorBar.R @@ -435,6 +435,8 @@ ColorBar <- function(brks = NULL, cols = NULL, vertical = TRUE, # ~~~~~~~~~~~~~~~~~~~ # if (plot) { + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) pars_to_save <- c('mar', 'cex', names(userArgs), 'mai', 'mgp', 'las', 'xpd') saved_pars <- par(pars_to_save) par(mar = c(0, 0, 0, 0), cex = 1) diff --git a/R/EOF.R b/R/EOF.R index d8015758..e908798b 100644 --- a/R/EOF.R +++ b/R/EOF.R @@ -69,14 +69,14 @@ #'# use this function. #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#'} +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) +#' #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) #'tmp <- MeanDims(ano$exp, c('dataset', 'member')) #'ano <- tmp[1, , ,] diff --git a/R/Histo2Hindcast.R b/R/Histo2Hindcast.R index 0d3f5c22..1d5fa365 100644 --- a/R/Histo2Hindcast.R +++ b/R/Histo2Hindcast.R @@ -25,14 +25,14 @@ #'@examples #' \dontshow{ #'startDates <- c('19901101') -#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 60, -#' output = 'areave', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 60, +#' output = 'areave', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) +#' #' #'sdates_out <- c('19901101', '19911101', '19921101', '19931101', '19941101') #'leadtimes_per_startdate <- 12 diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index 2a04d3c8..f15c2897 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -196,6 +196,8 @@ Plot2VarsVsLTime <- function(var1, var2, toptitle = '', ytitle = '', monini = 1, } # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) if (biglab) { diff --git a/R/PlotACC.R b/R/PlotACC.R index b03cf6d2..51d660ec 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -54,14 +54,14 @@ #'@examples #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) +#' #'sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) #'sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) #'clim <- Clim(sampleData$mod, sampleData$obs) @@ -145,6 +145,8 @@ PlotACC <- function(ACC, sdates, toptitle = "", sizetit = 1, ytitle = "", } # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) if (biglab) { diff --git a/R/PlotAno.R b/R/PlotAno.R index 596180f9..08fde426 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -108,7 +108,7 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, toptitle = rep('', 15), stop("4 dim needed : c(nexp/nobs, nmemb, nsdates, nltime)") } if (dim(obs_ano)[3] != nsdates | dim(obs_ano)[4] != nleadtime ) { - stop("obs and exp must have same number of sdates & ltimes") + stop("obs and exp must have the same number of sdates & ltimes") } } else { nobs <- 0 @@ -183,6 +183,8 @@ PlotAno <- function(exp_ano, obs_ano = NULL, sdates, toptitle = rep('', 15), # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) if (biglab) { -- GitLab From 4bbc413e5a45469801822c8b9e7623efc72bd82f Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Fri, 19 Sep 2025 16:30:32 +0200 Subject: [PATCH 14/26] Remove internal call to LoadSampleData.R and include 'on.exit()' to ensure user's par settings are not modified --- .Rbuildignore | 2 +- R/ACC.R | 14 +++++------ R/PlotBoxWhisker.R | 14 +++++------ R/PlotClim.R | 2 ++ R/PlotEquiMap.R | 16 ++++++------ R/PlotLayout.R | 16 ++++++------ R/PlotMatrix.R | 5 +++- R/PlotSection.R | 2 ++ R/PlotStereoMap.R | 2 ++ R/PlotVsLTime.R | 2 ++ R/ProbBins.R | 10 ++++---- R/ProjectField.R | 16 ++++++------ R/REOF.R | 14 +++++------ R/RatioRMS.R | 10 ++++---- R/ToyModel.R | 10 ++++---- R/UltimateBrier.R | 16 ++++++------ R/Utils.R | 57 ------------------------------------------- man/ACC.Rd | 14 +++++------ man/AnimateMap.Rd | 10 ++++---- man/EOF.Rd | 25 ------------------- man/Histo2Hindcast.Rd | 27 -------------------- man/PlotACC.Rd | 29 ---------------------- man/PlotBoxWhisker.Rd | 14 +++++------ man/PlotEquiMap.Rd | 14 +++++------ man/PlotLayout.Rd | 14 +++++------ man/ProbBins.Rd | 10 ++++---- man/ProjectField.Rd | 31 ----------------------- man/REOF.Rd | 14 +++++------ man/RatioRMS.Rd | 10 ++++---- man/ToyModel.Rd | 10 ++++---- man/UltimateBrier.Rd | 20 --------------- 31 files changed, 138 insertions(+), 312 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index c823928b..6221ce7f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,7 +12,7 @@ vignettes .gitlab-ci.yml .lintr # unit tests should be ignored when building the package for CRAN -^tests$ +###^tests$ # CDO is not in windbuilder, so we can test the unit tests by winbuilder # but test-CDORemap.R and test-Load.R needs to be hidden #tests/testthat/test-CDORemap.R diff --git a/R/ACC.R b/R/ACC.R index 7b6b8454..65a9cbba 100644 --- a/R/ACC.R +++ b/R/ACC.R @@ -102,13 +102,13 @@ #'@examples #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #' } #'sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) #'sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index 06cd7d32..34e26778 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -56,13 +56,13 @@ #' #'@examples #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 20, latmax = 80, -#' lonmin = -80, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 20, latmax = 80, +#' lonmin = -80, lonmax = 40) #'# No example data is available over NAO region, so in this example we will #'# tweak the available data. In a real use case, one can Load() the data over #'# NAO region directly. diff --git a/R/PlotClim.R b/R/PlotClim.R index 507cd16c..f9340995 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -154,6 +154,8 @@ PlotClim <- function(exp_clim, obs_clim = NULL, toptitle = '', ytitle = '', } # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) if (biglab) { diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index e18c02ad..017bd014 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -226,13 +226,13 @@ #' #'@examples #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #'PlotEquiMap(sampleData$mod[1, 1, 1, 1, , ], sampleData$lon, sampleData$lat, #' toptitle = 'Predicted sea surface temperature for Nov 1960 from 1st Nov', #' title_scale = 0.5) @@ -1041,6 +1041,8 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, } plot.new() # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) par(mar = margins, cex.main = cex_title, cex.axis = cex_axes_labels, mgp = c(0, spaceticklab, 0), las = 0) diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 29441ef6..18afd64e 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -180,13 +180,13 @@ #' #'@examples #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #'PlotLayout(PlotEquiMap, c('lat', 'lon'), sampleData$mod[1, , 1, 1, , ], #' sampleData$lon, sampleData$lat, #' toptitle = 'Predicted tos for Nov 1960 from 1st Nov', @@ -499,6 +499,8 @@ PlotLayout <- function(fun, plot_dims, var, ..., special_args = NULL, vertical <- drawleg %in% c('E', 'W') # Open connection to graphical device + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) if (!is.null(fileout)) { saveToFile(fileout) } else if (names(dev.cur()) == 'null device') { diff --git a/R/PlotMatrix.R b/R/PlotMatrix.R index 269d059c..558661a2 100644 --- a/R/PlotMatrix.R +++ b/R/PlotMatrix.R @@ -120,7 +120,10 @@ PlotMatrix <- function(var, brks = NULL, cols = NULL, dev.new(units = size_units, res = res, width = 8 * figure.width, height = 5) } - + + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) + if (!is.null(fileout)) { # Draw empty plot: diff --git a/R/PlotSection.R b/R/PlotSection.R index 16fb9e68..d4e43e57 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -122,6 +122,8 @@ PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, } # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) xmargin <- 0.5 diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 4b97cdc9..9006d73d 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -603,6 +603,8 @@ PlotStereoMap <- function(var, lon, lat, varu = NULL, varv = NULL, latlims = c(6 layout(matrix(1:2, ncol = 2, nrow = 1), widths = c(8, 2)) } # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) par(mar = margins, las = 0) coast <- map("world", interior = FALSE, projection = "stereographic", diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index 52479f6f..4c11ac67 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -200,6 +200,8 @@ PlotVsLTime <- function(var, toptitle = '', ytitle = '', monini = 1, freq = 12, } # Load the user parameters + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(userArgs) if (biglab) { diff --git a/R/ProbBins.R b/R/ProbBins.R index adc88909..1c0d3b65 100644 --- a/R/ProbBins.R +++ b/R/ProbBins.R @@ -42,11 +42,11 @@ #'@examples #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #'} #'clim <- Clim(sampleMap$mod, sampleMap$obs) #'ano_exp <- Ano(sampleMap$mod, clim$clim_exp) diff --git a/R/ProjectField.R b/R/ProjectField.R index 961c117b..e0e650d7 100644 --- a/R/ProjectField.R +++ b/R/ProjectField.R @@ -31,14 +31,14 @@ #'@examples #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#'} +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) +#' #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) #'eof_exp <- EOF(ano$exp, sampleData$lat, sampleData$lon) #'eof_obs <- EOF(ano$obs, sampleData$lat, sampleData$lon) diff --git a/R/REOF.R b/R/REOF.R index 5f06e611..79b48465 100644 --- a/R/REOF.R +++ b/R/REOF.R @@ -56,13 +56,13 @@ #'# use this function. #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #'} #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) #'ano <- MeanDims(ano$exp, c('dataset', 'member')) diff --git a/R/RatioRMS.R b/R/RatioRMS.R index d09fc0fb..433beaaf 100644 --- a/R/RatioRMS.R +++ b/R/RatioRMS.R @@ -33,11 +33,11 @@ #'@examples #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #'} #'# Compute DJF seasonal means and anomalies. #'initial_month <- 11 diff --git a/R/ToyModel.R b/R/ToyModel.R index 3c6cbe6e..10527a06 100644 --- a/R/ToyModel.R +++ b/R/ToyModel.R @@ -64,11 +64,11 @@ #'# Decadal prediction example #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'areave', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' output = 'areave', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) #'} #' #'a <- 0.1 diff --git a/R/UltimateBrier.R b/R/UltimateBrier.R index 79b98645..b46baf47 100644 --- a/R/UltimateBrier.R +++ b/R/UltimateBrier.R @@ -68,14 +68,14 @@ #'@examples #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' leadtimemin = 1, -#' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } +#'sampleData <- LoadSampleData('tos', c('experiment'), +#' c('observation'), startDates, +#' leadtimemin = 1, +#' leadtimemax = 4, +#' output = 'lonlat', +#' latmin = 27, latmax = 48, +#' lonmin = -12, lonmax = 40) +#' #'sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) #'sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) #'clim <- Clim(sampleData$mod, sampleData$obs) diff --git a/R/Utils.R b/R/Utils.R index c6e233c0..67d73eb2 100644 --- a/R/Utils.R +++ b/R/Utils.R @@ -997,63 +997,6 @@ } } -.LoadSampleData <- function(var, exp = NULL, obs = NULL, sdates, - nmember = NULL, nmemberobs = NULL, - nleadtime = NULL, leadtimemin = 1, - leadtimemax = NULL, storefreq = 'monthly', - sampleperiod = 1, lonmin = 0, lonmax = 360, - latmin = -90, latmax = 90, output = 'areave', - method = 'conservative', grid = NULL, - maskmod = vector("list", 15), - maskobs = vector("list", 15), - configfile = NULL, suffixexp = NULL, - suffixobs = NULL, varmin = NULL, varmax = NULL, - silent = FALSE, nprocs = NULL) { - ## This function loads and selects sample data stored in sampleMap and - ## sampleTimeSeries and is used in the examples instead of Load() so as - ## to avoid nco and cdo system calls and computation time in the stage - ## of running examples in the CHECK process on CRAN. - selected_start_dates <- match(sdates, c('19851101', '19901101', '19951101', - '20001101', '20051101')) - start_dates_position <- 3 - lead_times_position <- 4 - - if (output == 'lonlat') { - sampleData <- s2dv::sampleMap - if (is.null(leadtimemax)) { - leadtimemax <- dim(sampleData$mod)[lead_times_position] - } - selected_lead_times <- leadtimemin:leadtimemax - - dataOut <- sampleData - dataOut$mod <- sampleData$mod[, , selected_start_dates, selected_lead_times, , ] - dataOut$obs <- sampleData$obs[, , selected_start_dates, selected_lead_times, , ] - } else if (output == 'areave') { - sampleData <- s2dv::sampleTimeSeries - if (is.null(leadtimemax)) { - leadtimemax <- dim(sampleData$mod)[lead_times_position] - } - selected_lead_times <- leadtimemin:leadtimemax - - dataOut <- sampleData - dataOut$mod <- sampleData$mod[, , selected_start_dates, selected_lead_times] - dataOut$obs <- sampleData$obs[, , selected_start_dates, selected_lead_times] - } - - dims_out <- dim(sampleData$mod) - dims_out[start_dates_position] <- length(selected_start_dates) - dims_out[lead_times_position] <- length(selected_lead_times) - dim(dataOut$mod) <- dims_out - - dims_out <- dim(sampleData$obs) - dims_out[start_dates_position] <- length(selected_start_dates) - dims_out[lead_times_position] <- length(selected_lead_times) - dim(dataOut$obs) <- dims_out - - invisible(list(mod = dataOut$mod, obs = dataOut$obs, - lat = dataOut$lat, lon = dataOut$lon)) -} - .ConfigGetDatasetInfo <- function(matching_entries, table_name) { # This function obtains the information of a dataset and variable pair, # applying all the entries that match in the configuration file. diff --git a/man/ACC.Rd b/man/ACC.Rd index 15f85ffa..77733f82 100644 --- a/man/ACC.Rd +++ b/man/ACC.Rd @@ -142,13 +142,13 @@ Wilks (2011; section 7.6.4; https://doi.org/10.1016/B978-0-12-385022-5.00008-7). \examples{ \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) } sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) diff --git a/man/AnimateMap.Rd b/man/AnimateMap.Rd index 4309bf98..ed006dfa 100644 --- a/man/AnimateMap.Rd +++ b/man/AnimateMap.Rd @@ -168,11 +168,11 @@ sampleData <- Load('tos', list(expA), list(obsX), startDates, } \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + output = 'lonlat', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) } clim <- Clim(sampleData$mod, sampleData$obs, memb = FALSE) \donttest{ diff --git a/man/EOF.Rd b/man/EOF.Rd index d4523a93..6eee5996 100644 --- a/man/EOF.Rd +++ b/man/EOF.Rd @@ -84,31 +84,6 @@ A list containing: Perform an area-weighted EOF analysis using single value decomposition (SVD) based on a covariance matrix or a correlation matrix if parameter 'corr' is set to TRUE. -} -\examples{ -# This example computes the EOFs along forecast horizons and plots the one -# that explains the greatest amount of variability. The example data has low -# resolution so the result may not be explanatory, but it displays how to -# use this function. -\dontshow{ -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) -} -ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) -tmp <- MeanDims(ano$exp, c('dataset', 'member')) -ano <- tmp[1, , ,] -names(dim(ano)) <- names(dim(tmp))[-2] -eof <- EOF(ano, sampleData$lat, sampleData$lon) -\donttest{ -PlotEquiMap(eof$EOFs[1, , ], sampleData$lon, sampleData$lat) -} - } \seealso{ ProjectField, NAO, PlotBoxWhisker diff --git a/man/Histo2Hindcast.Rd b/man/Histo2Hindcast.Rd index 4a6a387f..eddc2f3f 100644 --- a/man/Histo2Hindcast.Rd +++ b/man/Histo2Hindcast.Rd @@ -45,30 +45,3 @@ Reorganize a long run (historical typically) with only one start date into chunks corresponding to a set of start dates. The time frequency of the data should be monthly. } -\examples{ - \dontshow{ -startDates <- c('19901101') -sampleData <- s2dv::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 60, - output = 'areave', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } - -sdates_out <- c('19901101', '19911101', '19921101', '19931101', '19941101') -leadtimes_per_startdate <- 12 -exp_data <- Histo2Hindcast(sampleData$mod, startDates, - sdates_out, leadtimes_per_startdate) -obs_data <- Histo2Hindcast(sampleData$obs, startDates, - sdates_out, leadtimes_per_startdate) - \donttest{ -exp_data <- Reorder(exp_data, c(3, 4, 1, 2)) -obs_data <- Reorder(obs_data, c(3, 4, 1, 2)) -PlotAno(exp_data, obs_data, sdates_out, - toptitle = paste('Anomalies reorganized into shorter chunks'), - ytitle = 'K', fileout = NULL) - } - -} diff --git a/man/PlotACC.Rd b/man/PlotACC.Rd index dc2bfb17..111757be 100644 --- a/man/PlotACC.Rd +++ b/man/PlotACC.Rd @@ -97,32 +97,3 @@ the 95\% confidence interval, the ACC, the upper limit of the 95\% confidence interval and the 95\% significance level given by a one-sided T-test. } -\examples{ - \dontshow{ -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } -sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) -sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) -clim <- Clim(sampleData$mod, sampleData$obs) -ano_exp <- Ano(sampleData$mod, clim$clim_exp) -ano_obs <- Ano(sampleData$obs, clim$clim_obs) -acc <- ACC(ano_exp, ano_obs, lat = sampleData$lat, dat_dim = 'dataset') -acc_bootstrap <- ACC(ano_exp, ano_obs, lat = sampleData$lat, conftype = 'bootstrap', - dat_dim = 'dataset') -# Combine acc results for PlotACC -res <- array(c(acc$conf.lower, acc$acc, acc$conf.upper, acc$p.val), - dim = c(dim(acc$acc), 4)) -res_bootstrap <- array(c(acc$acc_conf.lower, acc$acc, acc$acc_conf.upper, acc$p.val), - dim = c(dim(acc$acc), 4)) - \donttest{ -PlotACC(res, startDates) -PlotACC(res_bootstrap, startDates) - } -} diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index b0b41668..ae6e14e4 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -88,13 +88,13 @@ n-monthly to n-yearly time series. } \examples{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 20, latmax = 80, - lonmin = -80, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat', + latmin = 20, latmax = 80, + lonmin = -80, lonmax = 40) # No example data is available over NAO region, so in this example we will # tweak the available data. In a real use case, one can Load() the data over # NAO region directly. diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index aee9d181..19ac3860 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -377,13 +377,13 @@ figure layouts if colour bar is disabled. } \examples{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) PlotEquiMap(sampleData$mod[1, 1, 1, 1, , ], sampleData$lon, sampleData$lat, toptitle = 'Predicted sea surface temperature for Nov 1960 from 1st Nov', title_scale = 0.5) diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index 62c39c1b..7db35703 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -266,13 +266,13 @@ nested in complex layouts. } \examples{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) PlotLayout(PlotEquiMap, c('lat', 'lon'), sampleData$mod[1, , 1, 1, , ], sampleData$lon, sampleData$lat, toptitle = 'Predicted tos for Nov 1960 from 1st Nov', diff --git a/man/ProbBins.Rd b/man/ProbBins.Rd index cfd7affe..7249db09 100644 --- a/man/ProbBins.Rd +++ b/man/ProbBins.Rd @@ -67,11 +67,11 @@ probabilistic bins are being computed (see 'compPeriod'). \examples{ \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + output = 'lonlat', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) } clim <- Clim(sampleMap$mod, sampleMap$obs) ano_exp <- Ano(sampleMap$mod, clim$clim_exp) diff --git a/man/ProjectField.Rd b/man/ProjectField.Rd index 284c180b..60183557 100644 --- a/man/ProjectField.Rd +++ b/man/ProjectField.Rd @@ -47,37 +47,6 @@ the EOF mode selected. It returns principal components (PCs) by area-weighted projection onto EOF pattern (from \code{EOF()}) or REOF pattern (from \code{REOF()} or \code{EuroAtlanticTC()}). The calculation removes NA and returns NA if the whole spatial pattern is NA. -} -\examples{ -\dontshow{ -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) -} -ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) -eof_exp <- EOF(ano$exp, sampleData$lat, sampleData$lon) -eof_obs <- EOF(ano$obs, sampleData$lat, sampleData$lon) -mode1_exp <- ProjectField(ano$exp, eof_exp, mode = 1) -mode1_obs <- ProjectField(ano$obs, eof_obs, mode = 1) - -\donttest{ - # Plot the forecast and the observation of the first mode for the last year - # of forecast - sdate_dim_length <- dim(mode1_obs)['sdate'] - plot(mode1_obs[sdate_dim_length, 1, 1, ], type = "l", ylim = c(-1, 1), - lwd = 2) - for (i in 1:dim(mode1_exp)['member']) { - par(new = TRUE) - plot(mode1_exp[sdate_dim_length, 1, i, ], type = "l", col = rainbow(10)[i], - ylim = c(-15000, 15000)) - } -} - } \seealso{ EOF, NAO, PlotBoxWhisker diff --git a/man/REOF.Rd b/man/REOF.Rd index 07dc8f81..8e2e679c 100644 --- a/man/REOF.Rd +++ b/man/REOF.Rd @@ -79,13 +79,13 @@ internally. # use this function. \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) } ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) ano <- MeanDims(ano$exp, c('dataset', 'member')) diff --git a/man/RatioRMS.Rd b/man/RatioRMS.Rd index 4e834ad3..3e8e94e1 100644 --- a/man/RatioRMS.Rd +++ b/man/RatioRMS.Rd @@ -47,11 +47,11 @@ two-sided Fischer test. \examples{ \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + output = 'lonlat', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) } # Compute DJF seasonal means and anomalies. initial_month <- 11 diff --git a/man/ToyModel.Rd b/man/ToyModel.Rd index 407d3110..e288e2e8 100644 --- a/man/ToyModel.Rd +++ b/man/ToyModel.Rd @@ -93,11 +93,11 @@ toyforecast <- ToyModel(alpha = a, beta = b, gamma = g, sig = sig, trend = t, # Decadal prediction example \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'areave', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('tos', c('experiment'), + c('observation'), startDates, + output = 'areave', + latmin = 27, latmax = 48, + lonmin = -12, lonmax = 40) } a <- 0.1 diff --git a/man/UltimateBrier.Rd b/man/UltimateBrier.Rd index a20412e3..e1353913 100644 --- a/man/UltimateBrier.Rd +++ b/man/UltimateBrier.Rd @@ -93,23 +93,3 @@ Interface to compute probabilistic scores (Brier Score, Brier Skill Score) from the forecast and observational data anomalies. It provides six types to choose. } -\examples{ - \dontshow{ -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - leadtimemin = 1, - leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } -sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) -sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) -clim <- Clim(sampleData$mod, sampleData$obs) -exp <- Ano(sampleData$mod, clim$clim_exp) -obs <- Ano(sampleData$obs, clim$clim_obs) -bs <- UltimateBrier(exp, obs, dat_dim = 'dataset') -bss <- UltimateBrier(exp, obs, type = 'BSS', dat_dim = 'dataset') - -} -- GitLab From 394e940cc4f52a090e69e7b721c0984266905109 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Mon, 22 Sep 2025 17:16:49 +0200 Subject: [PATCH 15/26] Remove unused parameters in calls to LoadSampleData, unify format and export LoadSampleData in NAMESPACE --- .gitignore | 1 + NAMESPACE | 1 + R/ACC.R | 7 ++----- R/AnimateMap.R | 24 +----------------------- R/CDORemap.R | 1 + R/Clim.R | 1 + R/ColorBar.R | 1 + R/ConfigApplyMatchingEntries.R | 3 +++ R/ConfigEditDefinition.R | 2 ++ R/ConfigEditEntry.R | 2 ++ R/ConfigFileOpen.R | 2 ++ R/ConfigShowSimilarEntries.R | 2 ++ R/EOF.R | 12 +++++------- R/EuroAtlanticTC.R | 1 + R/Histo2Hindcast.R | 9 ++------- R/LoadSampleData.R | 2 +- R/MeanDims.R | 1 + R/PlotACC.R | 9 +++------ R/PlotAno.R | 6 ++++-- R/PlotBoxWhisker.R | 7 ++----- R/PlotEquiMap.R | 7 ++----- R/PlotLayout.R | 7 ++----- R/PlotMatrix.R | 1 + R/PlotSection.R | 1 + R/PlotStereoMap.R | 3 +-- R/ProbBins.R | 8 +------- R/ProjectField.R | 14 +++++--------- R/REOF.R | 1 + R/RatioRMS.R | 9 ++------- R/Reorder.R | 1 + R/Season.R | 1 + R/Smoothing.R | 1 + R/UltimateBrier.R | 9 +++------ 33 files changed, 60 insertions(+), 97 deletions(-) diff --git a/.gitignore b/.gitignore index 26a2200c..985765ba 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ README.Rmd *.ps Rplots.pdf .nfs* +.Rproj.user diff --git a/NAMESPACE b/NAMESPACE index 587aec21..a94059fc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -41,6 +41,7 @@ export(Histo2Hindcast) export(InsertDim) export(LeapYear) export(Load) +export(LoadSampleData) export(MSE) export(MSSS) export(MeanDims) diff --git a/R/ACC.R b/R/ACC.R index 65a9cbba..8d6cb862 100644 --- a/R/ACC.R +++ b/R/ACC.R @@ -102,13 +102,10 @@ #'@examples #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#' output = 'lonlat') #' } #'sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) #'sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) diff --git a/R/AnimateMap.R b/R/AnimateMap.R index d1565274..917b9b5e 100644 --- a/R/AnimateMap.R +++ b/R/AnimateMap.R @@ -92,30 +92,8 @@ #'@return No return value, called for side effects. #' #'@examples -#'# See ?Load for explanations on the first part of this example -#' \donttest{ -#'data_path <- system.file('sample_data', package = 's2dv') -#'expA <- list(name = 'experiment', path = file.path(data_path, -#' 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', -#' '$VAR_NAME$_$START_DATE$.nc')) -#'obsX <- list(name = 'observation', path = file.path(data_path, -#' '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', -#' '$VAR_NAME$_$YEAR$$MONTH$.nc')) -#' -#'# Now we are ready to use Load(). #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- Load('tos', list(expA), list(obsX), startDates, -#' output = 'lonlat', latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } -#' \dontshow{ -#'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' } +#'sampleData <- LoadSampleData(startDates, output = 'lonlat') #'clim <- Clim(sampleData$mod, sampleData$obs, memb = FALSE) #' \donttest{ #'AnimateMap(clim$clim_exp, sampleData$lon, sampleData$lat, diff --git a/R/CDORemap.R b/R/CDORemap.R index a1f572b5..acda5d95 100644 --- a/R/CDORemap.R +++ b/R/CDORemap.R @@ -87,6 +87,7 @@ #' is provided at all, NULL otherwise).} #' \item{'lons'}{The longitudes of the data on the destination grid.} #' \item{'lats'}{The latitudes of the data on the destination grid.} +#' #'@examples #' \donttest{ #'# Interpolating only vectors of longitudes and latitudes diff --git a/R/Clim.R b/R/Clim.R index 4801fc47..75369090 100644 --- a/R/Clim.R +++ b/R/Clim.R @@ -72,6 +72,7 @@ #' ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), #' listobs = c('ERSST'), biglab = FALSE) #'} +#' #'@importFrom abind adrop #'@importFrom ClimProjDiags Subset #'@import multiApply diff --git a/R/ColorBar.R b/R/ColorBar.R index 1ad8cf5f..fd71df21 100644 --- a/R/ColorBar.R +++ b/R/ColorBar.R @@ -139,6 +139,7 @@ #' "white", "yellow", "orange", "red", "saddlebrown") #'lims <- seq(-1, 1, 0.2) #'ColorBar(lims, cols) +#' #'@importFrom grDevices col2rgb rgb #'@export ColorBar <- function(brks = NULL, cols = NULL, vertical = TRUE, diff --git a/R/ConfigApplyMatchingEntries.R b/R/ConfigApplyMatchingEntries.R index 21a304bb..7cec76c5 100644 --- a/R/ConfigApplyMatchingEntries.R +++ b/R/ConfigApplyMatchingEntries.R @@ -25,9 +25,11 @@ #' #'@return A list with the information resulting of applying the matching #' entries is returned. +#' #'@seealso ConfigApplyMatchingEntries, ConfigEditDefinition, #' ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, #' ConfigShowTable +#' #'@examples #'# Create an empty configuration file #'config_file <- paste0(tempdir(), "/example.conf") @@ -49,6 +51,7 @@ #'# result #'match_info <- ConfigApplyMatchingEntries(configuration, 'tas', #' exp = c('ExampleExperiment2'), show_result = TRUE) +#' #'@export ConfigApplyMatchingEntries <- function(configuration, var, exp = NULL, obs = NULL, show_entries = FALSE, show_result = TRUE) { ## Function to tell if a regexpr() match is a complete match to a specified name diff --git a/R/ConfigEditDefinition.R b/R/ConfigEditDefinition.R index e0cf1a0d..001e01c0 100644 --- a/R/ConfigEditDefinition.R +++ b/R/ConfigEditDefinition.R @@ -13,9 +13,11 @@ #' variable is being modified. Takes by default TRUE. #' #'@return A modified configuration object is returned. +#' #'@seealso [ConfigApplyMatchingEntries()], [ConfigEditDefinition()], #' [ConfigEditEntry()], [ConfigFileOpen()], [ConfigShowSimilarEntries()], #' [ConfigShowTable()]. +#' #'@examples #'# Create an empty configuration file #'config_file <- paste0(tempdir(), "/example.conf") diff --git a/R/ConfigEditEntry.R b/R/ConfigEditEntry.R index d625c1a6..e6c1482d 100644 --- a/R/ConfigEditEntry.R +++ b/R/ConfigEditEntry.R @@ -44,6 +44,7 @@ #' #'@seealso ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, #' ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable +#' #'@examples #'# Create an empty configuration file #'config_file <- paste0(tempdir(), "/example.conf") @@ -73,6 +74,7 @@ #'ConfigShowTable(configuration, "experiments") #'# Save the configuration #'ConfigFileSave(configuration, config_file, confirm = FALSE) +#' #'@rdname ConfigEditEntry #'@export ConfigEditEntry <- function(configuration, dataset_type, position, dataset_name = NULL, var_name = NULL, main_path = NULL, file_path = NULL, nc_var_name = NULL, suffix = NULL, varmin = NULL, varmax = NULL) { diff --git a/R/ConfigFileOpen.R b/R/ConfigFileOpen.R index 7d1fd96e..43a12aa1 100644 --- a/R/ConfigFileOpen.R +++ b/R/ConfigFileOpen.R @@ -145,9 +145,11 @@ #' #'@seealso ConfigApplyMatchingEntries, ConfigEditDefinition, #' ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable +#' #'@references #'[1] \url{https://stat.ethz.ch/R-manual/R-devel/library/base/html/regex.html}\cr #'[2] \url{https://tldp.org/LDP/abs/html/globbingref.html} +#' #'@examples #'# Create an empty configuration file #'config_file <- paste0(tempdir(), "/example.conf") diff --git a/R/ConfigShowSimilarEntries.R b/R/ConfigShowSimilarEntries.R index ccad3f32..06066ec3 100644 --- a/R/ConfigShowSimilarEntries.R +++ b/R/ConfigShowSimilarEntries.R @@ -30,9 +30,11 @@ #' #'@seealso ConfigApplyMatchingEntries, ConfigEditDefinition, #' ConfigEditEntry, ConfigFileOpen, ConfigShowSimilarEntries, ConfigShowTable +#' #'@references #'[1] Simon White, string seamness: #' \url{http://www.catalysoft.com/articles/StrikeAMatch.html} +#' #'@examples #'# Create an empty configuration file #'config_file <- paste0(tempdir(), "/example.conf") diff --git a/R/EOF.R b/R/EOF.R index e908798b..5ab55269 100644 --- a/R/EOF.R +++ b/R/EOF.R @@ -62,26 +62,24 @@ #'} #' #'@seealso ProjectField, NAO, PlotBoxWhisker +#' #'@examples #'# This example computes the EOFs along forecast horizons and plots the one #'# that explains the greatest amount of variability. The example data has low #'# resolution so the result may not be explanatory, but it displays how to #'# use this function. -#'\dontshow{ +#' #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#' output = 'lonlat') #' #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) #'tmp <- MeanDims(ano$exp, c('dataset', 'member')) #'ano <- tmp[1, , ,] #'names(dim(ano)) <- names(dim(tmp))[-2] -#'eof <- EOF(ano, sampleData$lat, sampleData$lon) +#'eof <- EOF(ano, sampleData$lat, sampleData$lon, neofs = 4) #'\donttest{ #'PlotEquiMap(eof$EOFs[1, , ], sampleData$lon, sampleData$lat) #'} diff --git a/R/EuroAtlanticTC.R b/R/EuroAtlanticTC.R index a18e6fbc..b38fcbd0 100644 --- a/R/EuroAtlanticTC.R +++ b/R/EuroAtlanticTC.R @@ -51,6 +51,7 @@ #' by the square root of cosine of 'lat' and used to compute the fraction of #' variance explained by each REOFs. #'} +#' #'@examples #'# Use synthetic data #'set.seed(1) diff --git a/R/Histo2Hindcast.R b/R/Histo2Hindcast.R index 1d5fa365..d3de1ac2 100644 --- a/R/Histo2Hindcast.R +++ b/R/Histo2Hindcast.R @@ -23,16 +23,11 @@ #' of sdate_dim is 'sdatesout' and the length of ftime_dim is nleadtimesout. #' #'@examples -#' \dontshow{ #'startDates <- c('19901101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 60, -#' output = 'areave', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' +#' output = 'areave') #' #'sdates_out <- c('19901101', '19911101', '19921101', '19931101', '19941101') #'leadtimes_per_startdate <- 12 diff --git a/R/LoadSampleData.R b/R/LoadSampleData.R index ca6b0f58..91e7aa37 100644 --- a/R/LoadSampleData.R +++ b/R/LoadSampleData.R @@ -78,4 +78,4 @@ LoadSampleData <- function(sdates, leadtimemin = 1, leadtimemax = NULL, return(list(mod = dataOut$mod, obs = dataOut$obs, lat = dataOut$lat, lon = dataOut$lon)) -} \ No newline at end of file +} diff --git a/R/MeanDims.R b/R/MeanDims.R index 45fd6f6c..eb65d477 100644 --- a/R/MeanDims.R +++ b/R/MeanDims.R @@ -21,6 +21,7 @@ #'dim(ens_mean) #'ens_time_mean <- MeanDims(a, c(2, 3), drop = FALSE) #'dim(ens_time_mean) +#' #'@import multiApply #'@export MeanDims <- function(data, dims, na.rm = FALSE, drop = TRUE) { diff --git a/R/PlotACC.R b/R/PlotACC.R index 51d660ec..48f6a1f6 100644 --- a/R/PlotACC.R +++ b/R/PlotACC.R @@ -52,15 +52,11 @@ #'No return value, called for side effects. #' #'@examples -#' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#' output = 'lonlat') #' #'sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) #'sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) @@ -80,6 +76,7 @@ #'PlotACC(res, startDates) #'PlotACC(res_bootstrap, startDates) #' } +#' #'@importFrom grDevices dev.cur dev.new dev.off #'@importFrom stats ts #'@export diff --git a/R/PlotAno.R b/R/PlotAno.R index 08fde426..6204d297 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -60,8 +60,10 @@ #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) -#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) -#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) +#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 1) +#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 1) +#'smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) +#'smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) #'smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) #'smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) #'PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, diff --git a/R/PlotBoxWhisker.R b/R/PlotBoxWhisker.R index 34e26778..81bcea84 100644 --- a/R/PlotBoxWhisker.R +++ b/R/PlotBoxWhisker.R @@ -56,13 +56,10 @@ #' #'@examples #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 20, latmax = 80, -#' lonmin = -80, lonmax = 40) +#' output = 'lonlat') #'# No example data is available over NAO region, so in this example we will #'# tweak the available data. In a real use case, one can Load() the data over #'# NAO region directly. diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index 017bd014..825883c8 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -226,13 +226,10 @@ #' #'@examples #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#' output = 'lonlat') #'PlotEquiMap(sampleData$mod[1, 1, 1, 1, , ], sampleData$lon, sampleData$lat, #' toptitle = 'Predicted sea surface temperature for Nov 1960 from 1st Nov', #' title_scale = 0.5) diff --git a/R/PlotLayout.R b/R/PlotLayout.R index 18afd64e..b515e5fc 100644 --- a/R/PlotLayout.R +++ b/R/PlotLayout.R @@ -180,13 +180,10 @@ #' #'@examples #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#' output = 'lonlat') #'PlotLayout(PlotEquiMap, c('lat', 'lon'), sampleData$mod[1, , 1, 1, , ], #' sampleData$lon, sampleData$lat, #' toptitle = 'Predicted tos for Nov 1960 from 1st Nov', diff --git a/R/PlotMatrix.R b/R/PlotMatrix.R index 558661a2..5f01049c 100644 --- a/R/PlotMatrix.R +++ b/R/PlotMatrix.R @@ -58,6 +58,7 @@ #' xtitle = "Forecast time (month)", ytitle = "Start date", #' xlabels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", #' "Aug", "Sep", "Oct", "Nov", "Dec")) +#' #'@importFrom grDevices dev.new dev.off dev.cur #'@export PlotMatrix <- function(var, brks = NULL, cols = NULL, diff --git a/R/PlotSection.R b/R/PlotSection.R index d4e43e57..d0cb060f 100644 --- a/R/PlotSection.R +++ b/R/PlotSection.R @@ -43,6 +43,7 @@ #'sampleData <- s2dv::sampleDepthData #'PlotSection(sampleData$mod[1, 1, 1, 1, , ], sampleData$lat, sampleData$depth, #' toptitle = 'temperature 1995-11 member 0') +#' #'@importFrom grDevices dev.cur dev.new dev.off rainbow #'@export PlotSection <- function(var, horiz, depth, toptitle = '', sizetit = 1, diff --git a/R/PlotStereoMap.R b/R/PlotStereoMap.R index 9006d73d..fb4e117b 100644 --- a/R/PlotStereoMap.R +++ b/R/PlotStereoMap.R @@ -170,10 +170,9 @@ #'data <- matrix(rnorm(100 * 50), 100, 50) #'x <- seq(from = 0, to = 360, length.out = 100) #'y <- seq(from = -90, to = 90, length.out = 50) -#' \donttest{ #'PlotStereoMap(data, x, y, latlims = c(60, 90), brks = 50, #' toptitle = "This is the title") -#' } +#' #'@import mapproj #'@importFrom grDevices dev.cur dev.new dev.off gray #'@importFrom stats median diff --git a/R/ProbBins.R b/R/ProbBins.R index 1c0d3b65..78c19379 100644 --- a/R/ProbBins.R +++ b/R/ProbBins.R @@ -40,14 +40,8 @@ #' grid point, time step, member and start date belongs to. #' #'@examples -#'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#'} +#'sampleData <- LoadSampleData(startDates, output = 'lonlat') #'clim <- Clim(sampleMap$mod, sampleMap$obs) #'ano_exp <- Ano(sampleMap$mod, clim$clim_exp) #'PB <- ProbBins(ano_exp, fcyr = 3, thr = c(1/3, 2/3), quantile = TRUE) diff --git a/R/ProjectField.R b/R/ProjectField.R index e0e650d7..9b4a3ed2 100644 --- a/R/ProjectField.R +++ b/R/ProjectField.R @@ -28,20 +28,16 @@ #' format. The dimensions are the same as 'ano' except 'space_dim'. #' #'@seealso EOF, NAO, PlotBoxWhisker +#' #'@examples -#'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' +#' output = 'lonlat') #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) -#'eof_exp <- EOF(ano$exp, sampleData$lat, sampleData$lon) -#'eof_obs <- EOF(ano$obs, sampleData$lat, sampleData$lon) +#'eof_exp <- EOF(ano$exp, sampleData$lat, sampleData$lon, neofs = 5) +#'eof_obs <- EOF(ano$obs, sampleData$lat, sampleData$lon, neofs = 5) #'mode1_exp <- ProjectField(ano$exp, eof_exp, mode = 1) #'mode1_obs <- ProjectField(ano$obs, eof_obs, mode = 1) #' diff --git a/R/REOF.R b/R/REOF.R index 79b48465..a20a59de 100644 --- a/R/REOF.R +++ b/R/REOF.R @@ -49,6 +49,7 @@ #'} #' #'@seealso EOF +#' #'@examples #'# This example computes the REOFs along forecast horizons and plots the one #'# that explains the greatest amount of variability. The example data has low diff --git a/R/RatioRMS.R b/R/RatioRMS.R index 433beaaf..17fbe381 100644 --- a/R/RatioRMS.R +++ b/R/RatioRMS.R @@ -31,14 +31,9 @@ #'} #' #'@examples -#'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#'} +#'sampleData <- LoadSampleData(startDates, output = 'lonlat') +#' #'# Compute DJF seasonal means and anomalies. #'initial_month <- 11 #'mean_start_month <- 12 diff --git a/R/Reorder.R b/R/Reorder.R index 2809a00e..30309d8b 100644 --- a/R/Reorder.R +++ b/R/Reorder.R @@ -24,6 +24,7 @@ #' # A character array #' dat3 <- array(paste0('a', 1:24), dim = c(b = 2, c = 3, d = 4)) #' dat3_reorder <- Reorder(dat3, c('d', 'c', 'b')) +#' #'@export Reorder <- function(data, order) { diff --git a/R/Season.R b/R/Season.R index 46dcc489..f9c1ec0d 100644 --- a/R/Season.R +++ b/R/Season.R @@ -36,6 +36,7 @@ #'dat2[na] <- NA #'res <- Season(data = dat2, monini = 3, moninf = 1, monsup = 2) #'res <- Season(data = dat2, monini = 3, moninf = 1, monsup = 2, na.rm = FALSE) +#' #'@import multiApply #'@export Season <- function(data, monini, moninf, monsup, time_dim = 'ftime', diff --git a/R/Smoothing.R b/R/Smoothing.R index bc162a3e..467e4503 100644 --- a/R/Smoothing.R +++ b/R/Smoothing.R @@ -32,6 +32,7 @@ #'PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, #' toptitle = "Smoothed Mediterranean mean SST", ytitle = "K") #' } +#' #'@import plyr multiApply #'@export Smoothing <- function(data, time_dim = 'ftime', runmeanlen = 12, ncores = NULL) { diff --git a/R/UltimateBrier.R b/R/UltimateBrier.R index b46baf47..f69a5ebd 100644 --- a/R/UltimateBrier.R +++ b/R/UltimateBrier.R @@ -68,14 +68,11 @@ #'@examples #' \dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#' +#' output = 'lonlat') +#' } #'sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) #'sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) #'clim <- Clim(sampleData$mod, sampleData$obs) -- GitLab From b53a7de19a294b958e7106c37b539a25587e990b Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Mon, 22 Sep 2025 17:21:47 +0200 Subject: [PATCH 16/26] add man/LoadSampleData.Rd and update other man files --- man/ACC.Rd | 7 ++--- man/AnimateMap.Rd | 24 +-------------- man/Clim.Rd | 1 + man/ColorBar.Rd | 1 + man/ConfigApplyMatchingEntries.Rd | 1 + man/ConfigEditEntry.Rd | 1 + man/EOF.Rd | 22 ++++++++++++++ man/Histo2Hindcast.Rd | 22 ++++++++++++++ man/LoadSampleData.Rd | 50 +++++++++++++++++++++++++++++++ man/MeanDims.Rd | 1 + man/PlotACC.Rd | 26 ++++++++++++++++ man/PlotAno.Rd | 6 ++-- man/PlotBoxWhisker.Rd | 7 ++--- man/PlotEquiMap.Rd | 7 ++--- man/PlotLayout.Rd | 7 ++--- man/PlotMatrix.Rd | 1 + man/PlotSection.Rd | 1 + man/PlotStereoMap.Rd | 3 +- man/ProbBins.Rd | 8 +---- man/ProjectField.Rd | 26 ++++++++++++++++ man/RatioRMS.Rd | 9 ++---- man/Reorder.Rd | 1 + man/Season.Rd | 1 + man/Smoothing.Rd | 1 + man/UltimateBrier.Rd | 17 +++++++++++ 25 files changed, 190 insertions(+), 61 deletions(-) create mode 100644 man/LoadSampleData.Rd diff --git a/man/ACC.Rd b/man/ACC.Rd index 77733f82..33d661e6 100644 --- a/man/ACC.Rd +++ b/man/ACC.Rd @@ -142,13 +142,10 @@ Wilks (2011; section 7.6.4; https://doi.org/10.1016/B978-0-12-385022-5.00008-7). \examples{ \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, +sampleData <- LoadSampleData(startDates, leadtimemin = 1, leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) + output = 'lonlat') } sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) diff --git a/man/AnimateMap.Rd b/man/AnimateMap.Rd index ed006dfa..009e1fe6 100644 --- a/man/AnimateMap.Rd +++ b/man/AnimateMap.Rd @@ -150,30 +150,8 @@ Examples of input: } } \examples{ -# See ?Load for explanations on the first part of this example - \donttest{ -data_path <- system.file('sample_data', package = 's2dv') -expA <- list(name = 'experiment', path = file.path(data_path, - 'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly', - '$VAR_NAME$_$START_DATE$.nc')) -obsX <- list(name = 'observation', path = file.path(data_path, - '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$', - '$VAR_NAME$_$YEAR$$MONTH$.nc')) - -# Now we are ready to use Load(). -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- Load('tos', list(expA), list(obsX), startDates, - output = 'lonlat', latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } - \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) - } +sampleData <- LoadSampleData(startDates, output = 'lonlat') clim <- Clim(sampleData$mod, sampleData$obs, memb = FALSE) \donttest{ AnimateMap(clim$clim_exp, sampleData$lon, sampleData$lat, diff --git a/man/Clim.Rd b/man/Clim.Rd index cacb4978..0932e7c9 100644 --- a/man/Clim.Rd +++ b/man/Clim.Rd @@ -100,4 +100,5 @@ PlotClim(clim_exp, clim_obs, ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE) } + } diff --git a/man/ColorBar.Rd b/man/ColorBar.Rd index 6d62f153..d661892f 100644 --- a/man/ColorBar.Rd +++ b/man/ColorBar.Rd @@ -191,4 +191,5 @@ cols <- c("dodgerblue4", "dodgerblue1", "forestgreen", "yellowgreen", "white", "white", "yellow", "orange", "red", "saddlebrown") lims <- seq(-1, 1, 0.2) ColorBar(lims, cols) + } diff --git a/man/ConfigApplyMatchingEntries.Rd b/man/ConfigApplyMatchingEntries.Rd index ee4cb5a4..694861f1 100644 --- a/man/ConfigApplyMatchingEntries.Rd +++ b/man/ConfigApplyMatchingEntries.Rd @@ -68,6 +68,7 @@ configuration <- ConfigEditEntry(configuration, "experiments", 1, # result match_info <- ConfigApplyMatchingEntries(configuration, 'tas', exp = c('ExampleExperiment2'), show_result = TRUE) + } \seealso{ ConfigApplyMatchingEntries, ConfigEditDefinition, diff --git a/man/ConfigEditEntry.Rd b/man/ConfigEditEntry.Rd index e597709d..204e5fb0 100644 --- a/man/ConfigEditEntry.Rd +++ b/man/ConfigEditEntry.Rd @@ -118,6 +118,7 @@ configuration <- ConfigRemoveEntry(configuration, "experiments", ConfigShowTable(configuration, "experiments") # Save the configuration ConfigFileSave(configuration, config_file, confirm = FALSE) + } \seealso{ ConfigApplyMatchingEntries, ConfigEditDefinition, ConfigEditEntry, diff --git a/man/EOF.Rd b/man/EOF.Rd index 6eee5996..ddd5d654 100644 --- a/man/EOF.Rd +++ b/man/EOF.Rd @@ -84,6 +84,28 @@ A list containing: Perform an area-weighted EOF analysis using single value decomposition (SVD) based on a covariance matrix or a correlation matrix if parameter 'corr' is set to TRUE. +} +\examples{ +# This example computes the EOFs along forecast horizons and plots the one +# that explains the greatest amount of variability. The example data has low +# resolution so the result may not be explanatory, but it displays how to +# use this function. + +startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') +sampleData <- LoadSampleData(startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat') + +ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) +tmp <- MeanDims(ano$exp, c('dataset', 'member')) +ano <- tmp[1, , ,] +names(dim(ano)) <- names(dim(tmp))[-2] +eof <- EOF(ano, sampleData$lat, sampleData$lon, neofs = 4) +\donttest{ +PlotEquiMap(eof$EOFs[1, , ], sampleData$lon, sampleData$lat) +} + } \seealso{ ProjectField, NAO, PlotBoxWhisker diff --git a/man/Histo2Hindcast.Rd b/man/Histo2Hindcast.Rd index eddc2f3f..e09f6a68 100644 --- a/man/Histo2Hindcast.Rd +++ b/man/Histo2Hindcast.Rd @@ -45,3 +45,25 @@ Reorganize a long run (historical typically) with only one start date into chunks corresponding to a set of start dates. The time frequency of the data should be monthly. } +\examples{ +startDates <- c('19901101') +sampleData <- LoadSampleData(startDates, + leadtimemin = 1, + leadtimemax = 60, + output = 'areave') + +sdates_out <- c('19901101', '19911101', '19921101', '19931101', '19941101') +leadtimes_per_startdate <- 12 +exp_data <- Histo2Hindcast(sampleData$mod, startDates, + sdates_out, leadtimes_per_startdate) +obs_data <- Histo2Hindcast(sampleData$obs, startDates, + sdates_out, leadtimes_per_startdate) + \donttest{ +exp_data <- Reorder(exp_data, c(3, 4, 1, 2)) +obs_data <- Reorder(obs_data, c(3, 4, 1, 2)) +PlotAno(exp_data, obs_data, sdates_out, + toptitle = paste('Anomalies reorganized into shorter chunks'), + ytitle = 'K', fileout = NULL) + } + +} diff --git a/man/LoadSampleData.Rd b/man/LoadSampleData.Rd new file mode 100644 index 00000000..de870bce --- /dev/null +++ b/man/LoadSampleData.Rd @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/LoadSampleData.R +\name{LoadSampleData} +\alias{LoadSampleData} +\title{Load Sample Data for Package Examples} +\usage{ +LoadSampleData(sdates, leadtimemin = 1, leadtimemax = NULL, output = "areave") +} +\arguments{ +\item{sdates}{Character vector of start dates to include (e.g., +\code{c("19851101", "19901101")}). Must match one or more of the available +dates in the internal sample datasets: "19851101", "19901101", "19951101", +"20001101" or "20051101".} + +\item{leadtimemin}{Integer specifying the first lead time to include. Default +is 1.} + +\item{leadtimemax}{Integer specifying the last lead time to include. If NULL, +the full lead time range is included. Default is NULL.} + +\item{output}{Character string indicating the type of output: \code{"areave"} +for area-averaged time series data, or \code{"lonlat"} for gridded spatial +data. Default is \code{"areave"}.} +} +\value{ +A named list with the following elements: +\item{mod}{Array of model data with the selected start dates and lead times.} +\item{obs}{Array of observational data with the selected start dates and lead + times.} +\item{lat}{Vector of latitudes.} +\item{lon}{Vector of longitudes.} +} +\description{ +Loads and subsets sample data stored in the internal datasets +\code{sampleMap} and \code{sampleTimeSeries}, included with the package. +Intended for use in documentation examples instead of \code{Load()}, in order +to avoid reliance on external system dependencies like 'nco' and 'cdo' and +to reduce computation time during CRAN checks. +} +\details{ +This function is designed for use in examples and tests within the +'s2dv' package. It provides quick access to precomputed datasets, helping to +avoid slow or system-dependent operations during automated checks. +} +\examples{ +startDates <- c("19851101", "19901101", "19951101") +data <- LoadSampleData(sdates = startDates, output = "lonlat") +str(data$mod) + +} diff --git a/man/MeanDims.Rd b/man/MeanDims.Rd index 94369da0..9234f916 100644 --- a/man/MeanDims.Rd +++ b/man/MeanDims.Rd @@ -34,4 +34,5 @@ ens_mean <- MeanDims(a, 'member') dim(ens_mean) ens_time_mean <- MeanDims(a, c(2, 3), drop = FALSE) dim(ens_time_mean) + } diff --git a/man/PlotACC.Rd b/man/PlotACC.Rd index 111757be..c0fbe8f1 100644 --- a/man/PlotACC.Rd +++ b/man/PlotACC.Rd @@ -97,3 +97,29 @@ the 95\% confidence interval, the ACC, the upper limit of the 95\% confidence interval and the 95\% significance level given by a one-sided T-test. } +\examples{ +startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') +sampleData <- LoadSampleData(startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat') + +sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) +sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) +clim <- Clim(sampleData$mod, sampleData$obs) +ano_exp <- Ano(sampleData$mod, clim$clim_exp) +ano_obs <- Ano(sampleData$obs, clim$clim_obs) +acc <- ACC(ano_exp, ano_obs, lat = sampleData$lat, dat_dim = 'dataset') +acc_bootstrap <- ACC(ano_exp, ano_obs, lat = sampleData$lat, conftype = 'bootstrap', + dat_dim = 'dataset') +# Combine acc results for PlotACC +res <- array(c(acc$conf.lower, acc$acc, acc$conf.upper, acc$p.val), + dim = c(dim(acc$acc), 4)) +res_bootstrap <- array(c(acc$acc_conf.lower, acc$acc, acc$acc_conf.upper, acc$p.val), + dim = c(dim(acc$acc), 4)) + \donttest{ +PlotACC(res, startDates) +PlotACC(res_bootstrap, startDates) + } + +} diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 84a9a069..6336f3d8 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -112,8 +112,10 @@ example(Load) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) -smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) -smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) +smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 1) +smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 1) +smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) +smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, diff --git a/man/PlotBoxWhisker.Rd b/man/PlotBoxWhisker.Rd index ae6e14e4..ab0b05bf 100644 --- a/man/PlotBoxWhisker.Rd +++ b/man/PlotBoxWhisker.Rd @@ -88,13 +88,10 @@ n-monthly to n-yearly time series. } \examples{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, +sampleData <- LoadSampleData(startDates, leadtimemin = 1, leadtimemax = 4, - output = 'lonlat', - latmin = 20, latmax = 80, - lonmin = -80, lonmax = 40) + output = 'lonlat') # No example data is available over NAO region, so in this example we will # tweak the available data. In a real use case, one can Load() the data over # NAO region directly. diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index 19ac3860..9714602e 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -377,13 +377,10 @@ figure layouts if colour bar is disabled. } \examples{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, +sampleData <- LoadSampleData(startDates, leadtimemin = 1, leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) + output = 'lonlat') PlotEquiMap(sampleData$mod[1, 1, 1, 1, , ], sampleData$lon, sampleData$lat, toptitle = 'Predicted sea surface temperature for Nov 1960 from 1st Nov', title_scale = 0.5) diff --git a/man/PlotLayout.Rd b/man/PlotLayout.Rd index 7db35703..a040c39f 100644 --- a/man/PlotLayout.Rd +++ b/man/PlotLayout.Rd @@ -266,13 +266,10 @@ nested in complex layouts. } \examples{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, +sampleData <- LoadSampleData(startDates, leadtimemin = 1, leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) + output = 'lonlat') PlotLayout(PlotEquiMap, c('lat', 'lon'), sampleData$mod[1, , 1, 1, , ], sampleData$lon, sampleData$lat, toptitle = 'Predicted tos for Nov 1960 from 1st Nov', diff --git a/man/PlotMatrix.Rd b/man/PlotMatrix.Rd index 5275df03..61623a0c 100644 --- a/man/PlotMatrix.Rd +++ b/man/PlotMatrix.Rd @@ -108,4 +108,5 @@ PlotMatrix(var = matrix(rnorm(n = 120, mean = 0.3), 10, 12), xtitle = "Forecast time (month)", ytitle = "Start date", xlabels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) + } diff --git a/man/PlotSection.Rd b/man/PlotSection.Rd index ee693e78..3bf154b9 100644 --- a/man/PlotSection.Rd +++ b/man/PlotSection.Rd @@ -87,4 +87,5 @@ Plot a (longitude,depth) or (latitude,depth) section. sampleData <- s2dv::sampleDepthData PlotSection(sampleData$mod[1, 1, 1, 1, , ], sampleData$lat, sampleData$depth, toptitle = 'temperature 1995-11 member 0') + } diff --git a/man/PlotStereoMap.Rd b/man/PlotStereoMap.Rd index 0f2b7fa5..957eab00 100644 --- a/man/PlotStereoMap.Rd +++ b/man/PlotStereoMap.Rd @@ -283,8 +283,7 @@ compatible with figure layouts if colour bar is disabled. data <- matrix(rnorm(100 * 50), 100, 50) x <- seq(from = 0, to = 360, length.out = 100) y <- seq(from = -90, to = 90, length.out = 50) - \donttest{ PlotStereoMap(data, x, y, latlims = c(60, 90), brks = 50, toptitle = "This is the title") -} + } diff --git a/man/ProbBins.Rd b/man/ProbBins.Rd index 7249db09..88e0851b 100644 --- a/man/ProbBins.Rd +++ b/man/ProbBins.Rd @@ -65,14 +65,8 @@ the selected forecast years ('fcyr') or the forecast year for which the probabilistic bins are being computed (see 'compPeriod'). } \examples{ -\dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) -} +sampleData <- LoadSampleData(startDates, output = 'lonlat') clim <- Clim(sampleMap$mod, sampleMap$obs) ano_exp <- Ano(sampleMap$mod, clim$clim_exp) PB <- ProbBins(ano_exp, fcyr = 3, thr = c(1/3, 2/3), quantile = TRUE) diff --git a/man/ProjectField.Rd b/man/ProjectField.Rd index 60183557..0901f353 100644 --- a/man/ProjectField.Rd +++ b/man/ProjectField.Rd @@ -47,6 +47,32 @@ the EOF mode selected. It returns principal components (PCs) by area-weighted projection onto EOF pattern (from \code{EOF()}) or REOF pattern (from \code{REOF()} or \code{EuroAtlanticTC()}). The calculation removes NA and returns NA if the whole spatial pattern is NA. +} +\examples{ +startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') +sampleData <- LoadSampleData(startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat') +ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) +eof_exp <- EOF(ano$exp, sampleData$lat, sampleData$lon, neofs = 5) +eof_obs <- EOF(ano$obs, sampleData$lat, sampleData$lon, neofs = 5) +mode1_exp <- ProjectField(ano$exp, eof_exp, mode = 1) +mode1_obs <- ProjectField(ano$obs, eof_obs, mode = 1) + +\donttest{ + # Plot the forecast and the observation of the first mode for the last year + # of forecast + sdate_dim_length <- dim(mode1_obs)['sdate'] + plot(mode1_obs[sdate_dim_length, 1, 1, ], type = "l", ylim = c(-1, 1), + lwd = 2) + for (i in 1:dim(mode1_exp)['member']) { + par(new = TRUE) + plot(mode1_exp[sdate_dim_length, 1, i, ], type = "l", col = rainbow(10)[i], + ylim = c(-15000, 15000)) + } +} + } \seealso{ EOF, NAO, PlotBoxWhisker diff --git a/man/RatioRMS.Rd b/man/RatioRMS.Rd index 3e8e94e1..6b541a32 100644 --- a/man/RatioRMS.Rd +++ b/man/RatioRMS.Rd @@ -45,14 +45,9 @@ that is, RMSE(ens, obs) / RMSE(ens.ref, obs). The p-value is provided by a two-sided Fischer test. } \examples{ -\dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) -} +sampleData <- LoadSampleData(startDates, output = 'lonlat') + # Compute DJF seasonal means and anomalies. initial_month <- 11 mean_start_month <- 12 diff --git a/man/Reorder.Rd b/man/Reorder.Rd index c4e4a231..4ce0aa32 100644 --- a/man/Reorder.Rd +++ b/man/Reorder.Rd @@ -34,4 +34,5 @@ by Load(). # A character array dat3 <- array(paste0('a', 1:24), dim = c(b = 2, c = 3, d = 4)) dat3_reorder <- Reorder(dat3, c('d', 'c', 'b')) + } diff --git a/man/Season.Rd b/man/Season.Rd index 60fbbbc6..aa9e65b8 100644 --- a/man/Season.Rd +++ b/man/Season.Rd @@ -61,4 +61,5 @@ na <- floor(runif(30, min = 1, max = 144 * 3)) dat2[na] <- NA res <- Season(data = dat2, monini = 3, moninf = 1, monsup = 2) res <- Season(data = dat2, monini = 3, moninf = 1, monsup = 2, na.rm = FALSE) + } diff --git a/man/Smoothing.Rd b/man/Smoothing.Rd index 3b67566a..023012ac 100644 --- a/man/Smoothing.Rd +++ b/man/Smoothing.Rd @@ -44,4 +44,5 @@ smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, toptitle = "Smoothed Mediterranean mean SST", ytitle = "K") } + } diff --git a/man/UltimateBrier.Rd b/man/UltimateBrier.Rd index e1353913..4744629a 100644 --- a/man/UltimateBrier.Rd +++ b/man/UltimateBrier.Rd @@ -93,3 +93,20 @@ Interface to compute probabilistic scores (Brier Score, Brier Skill Score) from the forecast and observational data anomalies. It provides six types to choose. } +\examples{ + \dontshow{ +startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') +sampleData <- LoadSampleData(startDates, + leadtimemin = 1, + leadtimemax = 4, + output = 'lonlat') + } +sampleData$mod <- Season(sampleData$mod, monini = 11, moninf = 12, monsup = 2) +sampleData$obs <- Season(sampleData$obs, monini = 11, moninf = 12, monsup = 2) +clim <- Clim(sampleData$mod, sampleData$obs) +exp <- Ano(sampleData$mod, clim$clim_exp) +obs <- Ano(sampleData$obs, clim$clim_obs) +bs <- UltimateBrier(exp, obs, dat_dim = 'dataset') +bss <- UltimateBrier(exp, obs, type = 'BSS', dat_dim = 'dataset') + +} -- GitLab From 6e365388dc650300536fd92228529f555322f7d6 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 10:46:50 +0200 Subject: [PATCH 17/26] Move example that defines 'sampleData' to LoadSampleData.R --- R/Ano.R | 2 +- R/Ano_CrossValid.R | 2 +- R/BrierScore.R | 2 +- R/Clim.R | 2 +- R/Consist_Trend.R | 2 +- R/Corr.R | 2 +- R/Filter.R | 2 +- R/LoadSampleData.R | 6 +++--- R/MSE.R | 2 +- R/MSSS.R | 2 +- R/Plot2VarsVsLTime.R | 2 +- R/PlotAno.R | 2 +- R/PlotClim.R | 2 +- R/PlotVsLTime.R | 2 +- R/RMS.R | 2 +- R/RMSSS.R | 2 +- R/RatioSDRMS.R | 2 +- R/Regression.R | 2 +- R/Smoothing.R | 2 +- R/Spectrum.R | 2 +- R/Spread.R | 2 +- R/Trend.R | 2 +- 22 files changed, 24 insertions(+), 24 deletions(-) diff --git a/R/Ano.R b/R/Ano.R index e32c8619..3a8926c9 100644 --- a/R/Ano.R +++ b/R/Ano.R @@ -17,7 +17,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/Ano_CrossValid.R b/R/Ano_CrossValid.R index 497800cd..ead2baa9 100644 --- a/R/Ano_CrossValid.R +++ b/R/Ano_CrossValid.R @@ -43,7 +43,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) #'ano_exp <- MeanDims(anomalies$exp, dims = c("lat", "lon"), na.rm = TRUE) #'ano_obs <- MeanDims(anomalies$obs, dims = c("lat", "lon"), na.rm = TRUE) diff --git a/R/BrierScore.R b/R/BrierScore.R index 82526c03..672e5477 100644 --- a/R/BrierScore.R +++ b/R/BrierScore.R @@ -79,7 +79,7 @@ #'x <- BrierScore(exp, obs) #' #'# Inputs are arrays -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/Clim.R b/R/Clim.R index 75369090..49991185 100644 --- a/R/Clim.R +++ b/R/Clim.R @@ -61,7 +61,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'# clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) #'clim_exp <- MeanDims(clim$clim_exp, c("lat", "lon"), na.rm = TRUE) diff --git a/R/Consist_Trend.R b/R/Consist_Trend.R index 8289168c..77d7ae36 100644 --- a/R/Consist_Trend.R +++ b/R/Consist_Trend.R @@ -52,7 +52,7 @@ #' #'@examples #'#'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/Corr.R b/R/Corr.R index 28d166ea..667c128e 100644 --- a/R/Corr.R +++ b/R/Corr.R @@ -77,7 +77,7 @@ #' #'@examples #'# Case 1: Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/Filter.R b/R/Filter.R index e7043e27..156e62fe 100644 --- a/R/Filter.R +++ b/R/Filter.R @@ -21,7 +21,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'ensmod <- MeanDims(sampleData$mod, 2) #'spectrum <- Spectrum(ensmod) #' diff --git a/R/LoadSampleData.R b/R/LoadSampleData.R index 91e7aa37..2d2bb7ed 100644 --- a/R/LoadSampleData.R +++ b/R/LoadSampleData.R @@ -31,9 +31,9 @@ #' avoid slow or system-dependent operations during automated checks. #' #' @examples -#' startDates <- c("19851101", "19901101", "19951101") -#' data <- LoadSampleData(sdates = startDates, output = "lonlat") -#' str(data$mod) +#' startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') +#' sampleData <- LoadSampleData(sdates = startDates, output = 'areave') +#' # str(sampleData$mod) #' #' @export LoadSampleData <- function(sdates, leadtimemin = 1, leadtimemax = NULL, diff --git a/R/MSE.R b/R/MSE.R index 5c502bae..2fa5bbe2 100644 --- a/R/MSE.R +++ b/R/MSE.R @@ -52,7 +52,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/MSSS.R b/R/MSSS.R index ca854f30..fe05cb2d 100644 --- a/R/MSSS.R +++ b/R/MSSS.R @@ -77,7 +77,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/Plot2VarsVsLTime.R b/R/Plot2VarsVsLTime.R index f15c2897..6343fcbf 100644 --- a/R/Plot2VarsVsLTime.R +++ b/R/Plot2VarsVsLTime.R @@ -54,7 +54,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/PlotAno.R b/R/PlotAno.R index 6204d297..ac5e8f7e 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -56,7 +56,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/PlotClim.R b/R/PlotClim.R index f9340995..6aa3b9eb 100644 --- a/R/PlotClim.R +++ b/R/PlotClim.R @@ -46,7 +46,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'PlotClim(clim$clim_exp, clim$clim_obs, toptitle = paste('climatologies'), #' ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), diff --git a/R/PlotVsLTime.R b/R/PlotVsLTime.R index 4c11ac67..434f5115 100644 --- a/R/PlotVsLTime.R +++ b/R/PlotVsLTime.R @@ -70,7 +70,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/RMS.R b/R/RMS.R index a08af127..a96fd233 100644 --- a/R/RMS.R +++ b/R/RMS.R @@ -53,7 +53,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/RMSSS.R b/R/RMSSS.R index 7bf97dd7..e8bdd531 100644 --- a/R/RMSSS.R +++ b/R/RMSSS.R @@ -77,7 +77,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/RatioSDRMS.R b/R/RatioSDRMS.R index abed5acf..e657acf9 100644 --- a/R/RatioSDRMS.R +++ b/R/RatioSDRMS.R @@ -36,7 +36,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'rsdrms <- RatioSDRMS(sampleData$mod, sampleData$obs, dat_dim = 'dataset') #'rsdrms_ratio <- MeanDims(rsdrms$ratio, dims = c("lat", "lon"), na.rm = TRUE) #'rsdrms_pval <- MeanDims(rsdrms$p.val, dims = c("lat", "lon"), na.rm = TRUE) diff --git a/R/Regression.R b/R/Regression.R index ef92fc4e..0001d578 100644 --- a/R/Regression.R +++ b/R/Regression.R @@ -74,7 +74,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'datay <- sampleData$mod[, 1, , ] #'names(dim(datay)) <- c('sdate', 'ftime') #'datax <- sampleData$obs[, 1, , ] diff --git a/R/Smoothing.R b/R/Smoothing.R index 467e4503..bc336bde 100644 --- a/R/Smoothing.R +++ b/R/Smoothing.R @@ -17,7 +17,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/R/Spectrum.R b/R/Spectrum.R index cbaf1359..0f73cf59 100644 --- a/R/Spectrum.R +++ b/R/Spectrum.R @@ -27,7 +27,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'ensmod <- MeanDims(sampleData$mod, 2) #'spectrum <- Spectrum(ensmod) #' diff --git a/R/Spread.R b/R/Spread.R index 706eb00d..bc7893c5 100644 --- a/R/Spread.R +++ b/R/Spread.R @@ -42,7 +42,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'runmean_months <- 3 diff --git a/R/Trend.R b/R/Trend.R index 883bcdf4..68287583 100644 --- a/R/Trend.R +++ b/R/Trend.R @@ -66,7 +66,7 @@ #' #'@examples #'# Load sample data as in Load() example: -#'example(Load) +#'example(LoadSampleData) #'months_between_startdates <- 60 #'trend <- Trend(sampleData$obs, polydeg = 2, interval = months_between_startdates) #' -- GitLab From 34c3fdfb3bd21e3c80a5decfbb6dd43811cc73ad Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 10:55:30 +0200 Subject: [PATCH 18/26] Update man files --- man/Ano.Rd | 2 +- man/Ano_CrossValid.Rd | 2 +- man/BrierScore.Rd | 2 +- man/Clim.Rd | 2 +- man/Consist_Trend.Rd | 2 +- man/Corr.Rd | 2 +- man/Filter.Rd | 2 +- man/LoadSampleData.Rd | 6 +++--- man/MSE.Rd | 2 +- man/MSSS.Rd | 2 +- man/Plot2VarsVsLTime.Rd | 2 +- man/PlotAno.Rd | 2 +- man/PlotClim.Rd | 2 +- man/PlotVsLTime.Rd | 2 +- man/RMS.Rd | 2 +- man/RMSSS.Rd | 2 +- man/RatioSDRMS.Rd | 2 +- man/Regression.Rd | 2 +- man/Smoothing.Rd | 2 +- man/Spectrum.Rd | 2 +- man/Spread.Rd | 2 +- man/Trend.Rd | 2 +- 22 files changed, 24 insertions(+), 24 deletions(-) diff --git a/man/Ano.Rd b/man/Ano.Rd index 331bdcbf..fdeaa1ea 100644 --- a/man/Ano.Rd +++ b/man/Ano.Rd @@ -28,7 +28,7 @@ climatology array. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/Ano_CrossValid.Rd b/man/Ano_CrossValid.Rd index 8fa6cc10..398194dd 100644 --- a/man/Ano_CrossValid.Rd +++ b/man/Ano_CrossValid.Rd @@ -65,7 +65,7 @@ the 'exp' and 'obs' are excluded when computing the climatologies. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) ano_exp <- MeanDims(anomalies$exp, dims = c("lat", "lon"), na.rm = TRUE) ano_obs <- MeanDims(anomalies$obs, dims = c("lat", "lon"), na.rm = TRUE) diff --git a/man/BrierScore.Rd b/man/BrierScore.Rd index 76fb27eb..41cf8d6c 100644 --- a/man/BrierScore.Rd +++ b/man/BrierScore.Rd @@ -94,7 +94,7 @@ obs <- round(exp) x <- BrierScore(exp, obs) # Inputs are arrays -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/Clim.Rd b/man/Clim.Rd index 0932e7c9..8400bc67 100644 --- a/man/Clim.Rd +++ b/man/Clim.Rd @@ -89,7 +89,7 @@ per-pair correction beforehand. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) # clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) clim_exp <- MeanDims(clim$clim_exp, c("lat", "lon"), na.rm = TRUE) diff --git a/man/Consist_Trend.Rd b/man/Consist_Trend.Rd index 2ac7d426..92b6299a 100644 --- a/man/Consist_Trend.Rd +++ b/man/Consist_Trend.Rd @@ -72,7 +72,7 @@ member dimension, ensemble mean needs to be computed beforehand. } \examples{ #'# Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/Corr.Rd b/man/Corr.Rd index 38d5c646..99779c7e 100644 --- a/man/Corr.Rd +++ b/man/Corr.Rd @@ -113,7 +113,7 @@ compute the correlation. } \examples{ # Case 1: Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/Filter.Rd b/man/Filter.Rd index f98fe0ac..f7dc4fde 100644 --- a/man/Filter.Rd +++ b/man/Filter.Rd @@ -33,7 +33,7 @@ the specified frequency and phase. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) ensmod <- MeanDims(sampleData$mod, 2) spectrum <- Spectrum(ensmod) diff --git a/man/LoadSampleData.Rd b/man/LoadSampleData.Rd index de870bce..bf5907ef 100644 --- a/man/LoadSampleData.Rd +++ b/man/LoadSampleData.Rd @@ -43,8 +43,8 @@ This function is designed for use in examples and tests within the avoid slow or system-dependent operations during automated checks. } \examples{ -startDates <- c("19851101", "19901101", "19951101") -data <- LoadSampleData(sdates = startDates, output = "lonlat") -str(data$mod) +startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') +sampleData <- LoadSampleData(sdates = startDates, output = 'areave') +# str(sampleData$mod) } diff --git a/man/MSE.Rd b/man/MSE.Rd index ded3c248..6d6b21ce 100644 --- a/man/MSE.Rd +++ b/man/MSE.Rd @@ -80,7 +80,7 @@ The confidence interval is computed by the chi2 distribution.\cr } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/MSSS.Rd b/man/MSSS.Rd index c3c5662e..cdf97922 100644 --- a/man/MSSS.Rd +++ b/man/MSSS.Rd @@ -111,7 +111,7 @@ Fisher test or Random Walk test.\cr } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/Plot2VarsVsLTime.Rd b/man/Plot2VarsVsLTime.Rd index 0de4774d..a73c3272 100644 --- a/man/Plot2VarsVsLTime.Rd +++ b/man/Plot2VarsVsLTime.Rd @@ -106,7 +106,7 @@ RMSE error for a number of experiments and along lead-time: (nexp, nltime) } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 6336f3d8..93905590 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -108,7 +108,7 @@ Plots time series of raw or smoothed anomalies of any variable output from } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/PlotClim.Rd b/man/PlotClim.Rd index 529d8683..5294d921 100644 --- a/man/PlotClim.Rd +++ b/man/PlotClim.Rd @@ -90,7 +90,7 @@ c(nobs, nmemb, nltime) or c(nobs, nltime) for the observational data } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) PlotClim(clim$clim_exp, clim$clim_obs, toptitle = paste('climatologies'), ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), diff --git a/man/PlotVsLTime.Rd b/man/PlotVsLTime.Rd index 5cd5413a..0f05caf2 100644 --- a/man/PlotVsLTime.Rd +++ b/man/PlotVsLTime.Rd @@ -120,7 +120,7 @@ of the forecast time. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/RMS.Rd b/man/RMS.Rd index 57473544..1a974c6b 100644 --- a/man/RMS.Rd +++ b/man/RMS.Rd @@ -81,7 +81,7 @@ The confidence interval is computed by the chi2 distribution.\cr } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/RMSSS.Rd b/man/RMSSS.Rd index 706788c1..d7722f07 100644 --- a/man/RMSSS.Rd +++ b/man/RMSSS.Rd @@ -111,7 +111,7 @@ Fisher test or Random Walk test.\cr } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/RatioSDRMS.Rd b/man/RatioSDRMS.Rd index e01492a2..24558d31 100644 --- a/man/RatioSDRMS.Rd +++ b/man/RatioSDRMS.Rd @@ -59,7 +59,7 @@ Fisher's test. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) rsdrms <- RatioSDRMS(sampleData$mod, sampleData$obs, dat_dim = 'dataset') rsdrms_ratio <- MeanDims(rsdrms$ratio, dims = c("lat", "lon"), na.rm = TRUE) rsdrms_pval <- MeanDims(rsdrms$p.val, dims = c("lat", "lon"), na.rm = TRUE) diff --git a/man/Regression.Rd b/man/Regression.Rd index 9ac0c946..fdae1f9e 100644 --- a/man/Regression.Rd +++ b/man/Regression.Rd @@ -100,7 +100,7 @@ on the student-T distribution. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) datay <- sampleData$mod[, 1, , ] names(dim(datay)) <- c('sdate', 'ftime') datax <- sampleData$obs[, 1, , ] diff --git a/man/Smoothing.Rd b/man/Smoothing.Rd index 023012ac..2f2f9ffa 100644 --- a/man/Smoothing.Rd +++ b/man/Smoothing.Rd @@ -29,7 +29,7 @@ Smooth an array of any number of dimensions along one dimension. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) diff --git a/man/Spectrum.Rd b/man/Spectrum.Rd index 18671e5c..caf2979c 100644 --- a/man/Spectrum.Rd +++ b/man/Spectrum.Rd @@ -39,7 +39,7 @@ and the confidence interval is estimated by the Monte-Carlo method. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) ensmod <- MeanDims(sampleData$mod, 2) spectrum <- Spectrum(ensmod) diff --git a/man/Spread.Rd b/man/Spread.Rd index 99b5163c..211dcea4 100644 --- a/man/Spread.Rd +++ b/man/Spread.Rd @@ -62,7 +62,7 @@ data can be the output of \code{Load()}, \code{Ano()}, or } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) runmean_months <- 3 diff --git a/man/Trend.Rd b/man/Trend.Rd index 01247487..450ec3c9 100644 --- a/man/Trend.Rd +++ b/man/Trend.Rd @@ -92,7 +92,7 @@ is calculated by ANOVA. } \examples{ # Load sample data as in Load() example: -example(Load) +example(LoadSampleData) months_between_startdates <- 60 trend <- Trend(sampleData$obs, polydeg = 2, interval = months_between_startdates) -- GitLab From dbfeaa0e3226178a345f339adef412e152d4685c Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 10:57:22 +0200 Subject: [PATCH 19/26] Double quotes instead of single in LoadSampleData.R example --- R/LoadSampleData.R | 4 ++-- man/LoadSampleData.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/LoadSampleData.R b/R/LoadSampleData.R index 2d2bb7ed..0f2aa5bd 100644 --- a/R/LoadSampleData.R +++ b/R/LoadSampleData.R @@ -31,8 +31,8 @@ #' avoid slow or system-dependent operations during automated checks. #' #' @examples -#' startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#' sampleData <- LoadSampleData(sdates = startDates, output = 'areave') +#' startDates <- c("19851101", "19901101", "19951101", "20001101", "20051101") +#' sampleData <- LoadSampleData(sdates = startDates, output = "areave") #' # str(sampleData$mod) #' #' @export diff --git a/man/LoadSampleData.Rd b/man/LoadSampleData.Rd index bf5907ef..3debf6ec 100644 --- a/man/LoadSampleData.Rd +++ b/man/LoadSampleData.Rd @@ -43,8 +43,8 @@ This function is designed for use in examples and tests within the avoid slow or system-dependent operations during automated checks. } \examples{ -startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData(sdates = startDates, output = 'areave') +startDates <- c("19851101", "19901101", "19951101", "20001101", "20051101") +sampleData <- LoadSampleData(sdates = startDates, output = "areave") # str(sampleData$mod) } -- GitLab From 7d0c0205cd287892e1f34b043a17aab65cf1234d Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 12:04:29 +0200 Subject: [PATCH 20/26] Align R/Ano.R and R/Ano_CrossValid.R with sampleData in LoadSampleData.R (had previously modified them assuming a sampleData object different from the one returned by Load.R, now returned by LoadSampleData.R) --- R/Ano.R | 2 -- R/Ano_CrossValid.R | 6 ++---- R/LoadSampleData.R | 1 - man/Ano.Rd | 2 -- man/Ano_CrossValid.Rd | 6 ++---- man/LoadSampleData.Rd | 1 - 6 files changed, 4 insertions(+), 14 deletions(-) diff --git a/R/Ano.R b/R/Ano.R index 3a8926c9..bb7c45b4 100644 --- a/R/Ano.R +++ b/R/Ano.R @@ -21,8 +21,6 @@ #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) -#'ano_exp <- MeanDims(ano_exp, dims = c("lat", "lon"), na.rm = TRUE) -#'ano_obs <- MeanDims(ano_obs, dims = c("lat", "lon"), na.rm = TRUE) #'\donttest{ #'PlotAno(ano_exp, ano_obs, startDates, #' toptitle = 'Anomaly', ytitle = c('K', 'K', 'K'), diff --git a/R/Ano_CrossValid.R b/R/Ano_CrossValid.R index ead2baa9..62824823 100644 --- a/R/Ano_CrossValid.R +++ b/R/Ano_CrossValid.R @@ -45,10 +45,8 @@ #'# Load sample data as in Load() example: #'example(LoadSampleData) #'anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) -#'ano_exp <- MeanDims(anomalies$exp, dims = c("lat", "lon"), na.rm = TRUE) -#'ano_obs <- MeanDims(anomalies$obs, dims = c("lat", "lon"), na.rm = TRUE) -#'ano_exp <- Reorder(ano_exp, c(2, 3, 4, 1)) -#'ano_obs <- Reorder(ano_obs, c(2, 3, 4, 1)) +#'ano_exp <- Reorder(ano_exp, c(2, 3, 1, 4)) +#'ano_obs <- Reorder(ano_obs, c(2, 3, 1, 4)) #'\donttest{ #'PlotAno(ano_exp, ano_obs, startDates, #' toptitle = paste('anomalies'), ytitle = c('K', 'K', 'K'), diff --git a/R/LoadSampleData.R b/R/LoadSampleData.R index 0f2aa5bd..475de178 100644 --- a/R/LoadSampleData.R +++ b/R/LoadSampleData.R @@ -33,7 +33,6 @@ #' @examples #' startDates <- c("19851101", "19901101", "19951101", "20001101", "20051101") #' sampleData <- LoadSampleData(sdates = startDates, output = "areave") -#' # str(sampleData$mod) #' #' @export LoadSampleData <- function(sdates, leadtimemin = 1, leadtimemax = NULL, diff --git a/man/Ano.Rd b/man/Ano.Rd index fdeaa1ea..2bacf588 100644 --- a/man/Ano.Rd +++ b/man/Ano.Rd @@ -32,8 +32,6 @@ example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) -ano_exp <- MeanDims(ano_exp, dims = c("lat", "lon"), na.rm = TRUE) -ano_obs <- MeanDims(ano_obs, dims = c("lat", "lon"), na.rm = TRUE) \donttest{ PlotAno(ano_exp, ano_obs, startDates, toptitle = 'Anomaly', ytitle = c('K', 'K', 'K'), diff --git a/man/Ano_CrossValid.Rd b/man/Ano_CrossValid.Rd index 398194dd..6b8b7aeb 100644 --- a/man/Ano_CrossValid.Rd +++ b/man/Ano_CrossValid.Rd @@ -67,10 +67,8 @@ the 'exp' and 'obs' are excluded when computing the climatologies. # Load sample data as in Load() example: example(LoadSampleData) anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) -ano_exp <- MeanDims(anomalies$exp, dims = c("lat", "lon"), na.rm = TRUE) -ano_obs <- MeanDims(anomalies$obs, dims = c("lat", "lon"), na.rm = TRUE) -ano_exp <- Reorder(ano_exp, c(2, 3, 4, 1)) -ano_obs <- Reorder(ano_obs, c(2, 3, 4, 1)) +ano_exp <- Reorder(ano_exp, c(2, 3, 1, 4)) +ano_obs <- Reorder(ano_obs, c(2, 3, 1, 4)) \donttest{ PlotAno(ano_exp, ano_obs, startDates, toptitle = paste('anomalies'), ytitle = c('K', 'K', 'K'), diff --git a/man/LoadSampleData.Rd b/man/LoadSampleData.Rd index 3debf6ec..b1e1a7fe 100644 --- a/man/LoadSampleData.Rd +++ b/man/LoadSampleData.Rd @@ -45,6 +45,5 @@ avoid slow or system-dependent operations during automated checks. \examples{ startDates <- c("19851101", "19901101", "19951101", "20001101", "20051101") sampleData <- LoadSampleData(sdates = startDates, output = "areave") -# str(sampleData$mod) } -- GitLab From 9886fc08d855903417f6fbea7beb9b469433e101 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 13:34:59 +0200 Subject: [PATCH 21/26] Revert spatial agregation of examples --- R/Clim.R | 6 ++---- R/Consist_Trend.R | 2 +- R/PlotAno.R | 6 ++---- R/RatioSDRMS.R | 8 +++----- R/Smoothing.R | 7 ++----- R/Spread.R | 18 +++++++----------- man/Clim.Rd | 6 ++---- man/Consist_Trend.Rd | 2 +- man/PlotAno.Rd | 6 ++---- man/RatioSDRMS.Rd | 8 +++----- man/Smoothing.Rd | 7 ++----- man/Spread.Rd | 18 +++++++----------- 12 files changed, 34 insertions(+), 60 deletions(-) diff --git a/R/Clim.R b/R/Clim.R index 49991185..b56f2bcf 100644 --- a/R/Clim.R +++ b/R/Clim.R @@ -63,11 +63,9 @@ #'# Load sample data as in Load() example: #'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) -#'# clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) -#'clim_exp <- MeanDims(clim$clim_exp, c("lat", "lon"), na.rm = TRUE) -#'clim_obs <- MeanDims(clim$clim_obs, c("lat", "lon"), na.rm = TRUE) +#'clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) #'\donttest{ -#'PlotClim(clim_exp, clim_obs, +#'PlotClim(clim$clim_exp, clim$clim_obs, #' toptitle = paste('sea surface temperature climatologies'), #' ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), #' listobs = c('ERSST'), biglab = FALSE) diff --git a/R/Consist_Trend.R b/R/Consist_Trend.R index 77d7ae36..fb161fd2 100644 --- a/R/Consist_Trend.R +++ b/R/Consist_Trend.R @@ -51,7 +51,7 @@ #'} #' #'@examples -#'#'# Load sample data as in Load() example: +#'# Load sample data as in Load() example: #'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) diff --git a/R/PlotAno.R b/R/PlotAno.R index ac5e8f7e..042069fa 100644 --- a/R/PlotAno.R +++ b/R/PlotAno.R @@ -60,10 +60,8 @@ #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) -#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 1) -#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 1) -#'smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) -#'smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) +#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) +#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) #'smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) #'smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) #'PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, diff --git a/R/RatioSDRMS.R b/R/RatioSDRMS.R index e657acf9..6aa886d6 100644 --- a/R/RatioSDRMS.R +++ b/R/RatioSDRMS.R @@ -38,13 +38,11 @@ #'# Load sample data as in Load() example: #'example(LoadSampleData) #'rsdrms <- RatioSDRMS(sampleData$mod, sampleData$obs, dat_dim = 'dataset') -#'rsdrms_ratio <- MeanDims(rsdrms$ratio, dims = c("lat", "lon"), na.rm = TRUE) -#'rsdrms_pval <- MeanDims(rsdrms$p.val, dims = c("lat", "lon"), na.rm = TRUE) #'# Reorder the data in order to plot it with PlotVsLTime #'rsdrms_plot <- array(dim = c(dim(rsdrms$ratio)[1:2], 4, dim(rsdrms$ratio)[3])) -#'rsdrms_plot[, , 2, ] <- rsdrms_ratio -#'rsdrms_plot[, , 4, ] <- rsdrms_pval -#'\donttest{ +#'rsdrms_plot[, , 2, ] <- rsdrms$ratio +#'rsdrms_plot[, , 4, ] <- rsdrms$p.val +#'\dontrun{ #'PlotVsLTime(rsdrms_plot, toptitle = "Ratio ensemble spread / RMSE", ytitle = "", #' monini = 11, limits = c(-1, 1.3), listexp = c('CMIP5 IC3'), #' listobs = c('ERSST'), biglab = FALSE, siglev = TRUE) diff --git a/R/Smoothing.R b/R/Smoothing.R index bc336bde..f320dd88 100644 --- a/R/Smoothing.R +++ b/R/Smoothing.R @@ -21,11 +21,8 @@ #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) #'ano_obs <- Ano(sampleData$obs, clim$clim_obs) -#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 3) -#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 3) -#'# Calculate spatial average -#'smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) -#'smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) +#'smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) +#'smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) #'smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) #'smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) #' \donttest{ diff --git a/R/Spread.R b/R/Spread.R index bc7893c5..ad141c50 100644 --- a/R/Spread.R +++ b/R/Spread.R @@ -45,7 +45,7 @@ #'example(LoadSampleData) #'clim <- Clim(sampleData$mod, sampleData$obs) #'ano_exp <- Ano(sampleData$mod, clim$clim_exp) -#'runmean_months <- 3 +#'runmean_months <- 12 #'smooth_ano_exp <- Smoothing(ano_exp, runmeanlen = runmean_months) #'smooth_ano_exp_m_sub <- smooth_ano_exp - InsertDim(MeanDims(smooth_ano_exp, 'member', #' na.rm = TRUE), @@ -55,33 +55,29 @@ #'suppressWarnings({ #'spread <- Spread(smooth_ano_exp_m_sub, compute_dim = c('member', 'sdate')) #'}) -#'iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) -#'maxmin_avg <- MeanDims(spread$maxmin, dims = c("lat", "lon"), na.rm = TRUE) -#'sd_avg <- MeanDims(spread$sd, dims = c("lat", "lon"), na.rm = TRUE) -#'mad_avg <- MeanDims(spread$mad, dims = c("lat", "lon"), na.rm = TRUE) #' -#'\donttest{ -#'PlotVsLTime(Reorder(iqr_avg, c('dataset', 'stats', 'ftime')), +#' \donttest{ +#'PlotVsLTime(Reorder(spread$iqr, c('dataset', 'stats', 'ftime')), #' toptitle = "Inter-Quartile Range between ensemble members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, #' hlines = c(0)) -#'PlotVsLTime(Reorder(maxmin_avg, c('dataset', 'stats', 'ftime')), +#'PlotVsLTime(Reorder(spread$maxmin, c('dataset', 'stats', 'ftime')), #' toptitle = "Maximum minus minimum of the members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, #' hlines = c(0)) -#'PlotVsLTime(Reorder(sd_avg, c('dataset', 'stats', 'ftime')), +#'PlotVsLTime(Reorder(spread$sd, c('dataset', 'stats', 'ftime')), #' toptitle = "Standard deviation of the members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, #' hlines = c(0)) -#'PlotVsLTime(Reorder(mad_avg, c('dataset', 'stats', 'ftime')), +#'PlotVsLTime(Reorder(spread$mad, c('dataset', 'stats', 'ftime')), #' toptitle = "Median Absolute Deviation of the members", #' ytitle = "K", monini = 11, limits = NULL, #' listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, #' hlines = c(0)) -#'} +#' } #' #'@import multiApply #'@importFrom stats IQR sd mad runif quantile diff --git a/man/Clim.Rd b/man/Clim.Rd index 8400bc67..4ee2a9fb 100644 --- a/man/Clim.Rd +++ b/man/Clim.Rd @@ -91,11 +91,9 @@ per-pair correction beforehand. # Load sample data as in Load() example: example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) -# clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) -clim_exp <- MeanDims(clim$clim_exp, c("lat", "lon"), na.rm = TRUE) -clim_obs <- MeanDims(clim$clim_obs, c("lat", "lon"), na.rm = TRUE) +clim2 <- Clim(sampleData$mod, sampleData$obs, method = 'kharin', memb = FALSE) \donttest{ -PlotClim(clim_exp, clim_obs, +PlotClim(clim$clim_exp, clim$clim_obs, toptitle = paste('sea surface temperature climatologies'), ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE) diff --git a/man/Consist_Trend.Rd b/man/Consist_Trend.Rd index 92b6299a..0463370e 100644 --- a/man/Consist_Trend.Rd +++ b/man/Consist_Trend.Rd @@ -71,7 +71,7 @@ The function doesn't do the ensemble mean, so if the input data have the member dimension, ensemble mean needs to be computed beforehand. } \examples{ -#'# Load sample data as in Load() example: +# Load sample data as in Load() example: example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) diff --git a/man/PlotAno.Rd b/man/PlotAno.Rd index 93905590..48a473f5 100644 --- a/man/PlotAno.Rd +++ b/man/PlotAno.Rd @@ -112,10 +112,8 @@ example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) -smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 1) -smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 1) -smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) -smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) +smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) +smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) PlotAno(smooth_ano_exp, smooth_ano_obs, startDates, diff --git a/man/RatioSDRMS.Rd b/man/RatioSDRMS.Rd index 24558d31..ae85feb0 100644 --- a/man/RatioSDRMS.Rd +++ b/man/RatioSDRMS.Rd @@ -61,13 +61,11 @@ Fisher's test. # Load sample data as in Load() example: example(LoadSampleData) rsdrms <- RatioSDRMS(sampleData$mod, sampleData$obs, dat_dim = 'dataset') -rsdrms_ratio <- MeanDims(rsdrms$ratio, dims = c("lat", "lon"), na.rm = TRUE) -rsdrms_pval <- MeanDims(rsdrms$p.val, dims = c("lat", "lon"), na.rm = TRUE) # Reorder the data in order to plot it with PlotVsLTime rsdrms_plot <- array(dim = c(dim(rsdrms$ratio)[1:2], 4, dim(rsdrms$ratio)[3])) -rsdrms_plot[, , 2, ] <- rsdrms_ratio -rsdrms_plot[, , 4, ] <- rsdrms_pval -\donttest{ +rsdrms_plot[, , 2, ] <- rsdrms$ratio +rsdrms_plot[, , 4, ] <- rsdrms$p.val +\dontrun{ PlotVsLTime(rsdrms_plot, toptitle = "Ratio ensemble spread / RMSE", ytitle = "", monini = 11, limits = c(-1, 1.3), listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, siglev = TRUE) diff --git a/man/Smoothing.Rd b/man/Smoothing.Rd index 2f2f9ffa..3fc48c26 100644 --- a/man/Smoothing.Rd +++ b/man/Smoothing.Rd @@ -33,11 +33,8 @@ example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) ano_obs <- Ano(sampleData$obs, clim$clim_obs) -smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 3) -smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 3) -# Calculate spatial average -smooth_ano_exp <- MeanDims(smooth_ano_exp, c("lat", "lon"), na.rm = TRUE) -smooth_ano_obs <- MeanDims(smooth_ano_obs, c("lat", "lon"), na.rm = TRUE) +smooth_ano_exp <- Smoothing(ano_exp, time_dim = 'ftime', runmeanlen = 12) +smooth_ano_obs <- Smoothing(ano_obs, time_dim = 'ftime', runmeanlen = 12) smooth_ano_exp <- Reorder(smooth_ano_exp, c(2, 3, 4, 1)) smooth_ano_obs <- Reorder(smooth_ano_obs, c(2, 3, 4, 1)) \donttest{ diff --git a/man/Spread.Rd b/man/Spread.Rd index 211dcea4..1569230f 100644 --- a/man/Spread.Rd +++ b/man/Spread.Rd @@ -65,7 +65,7 @@ data can be the output of \code{Load()}, \code{Ano()}, or example(LoadSampleData) clim <- Clim(sampleData$mod, sampleData$obs) ano_exp <- Ano(sampleData$mod, clim$clim_exp) -runmean_months <- 3 +runmean_months <- 12 smooth_ano_exp <- Smoothing(ano_exp, runmeanlen = runmean_months) smooth_ano_exp_m_sub <- smooth_ano_exp - InsertDim(MeanDims(smooth_ano_exp, 'member', na.rm = TRUE), @@ -75,32 +75,28 @@ smooth_ano_exp_m_sub <- smooth_ano_exp - InsertDim(MeanDims(smooth_ano_exp, 'mem suppressWarnings({ spread <- Spread(smooth_ano_exp_m_sub, compute_dim = c('member', 'sdate')) }) -iqr_avg <- MeanDims(spread$iqr, dims = c("lat", "lon"), na.rm = TRUE) -maxmin_avg <- MeanDims(spread$maxmin, dims = c("lat", "lon"), na.rm = TRUE) -sd_avg <- MeanDims(spread$sd, dims = c("lat", "lon"), na.rm = TRUE) -mad_avg <- MeanDims(spread$mad, dims = c("lat", "lon"), na.rm = TRUE) -\donttest{ -PlotVsLTime(Reorder(iqr_avg, c('dataset', 'stats', 'ftime')), + \dontrun{ +PlotVsLTime(Reorder(spread$iqr, c('dataset', 'stats', 'ftime')), toptitle = "Inter-Quartile Range between ensemble members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, hlines = c(0)) -PlotVsLTime(Reorder(maxmin_avg, c('dataset', 'stats', 'ftime')), +PlotVsLTime(Reorder(spread$maxmin, c('dataset', 'stats', 'ftime')), toptitle = "Maximum minus minimum of the members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, hlines = c(0)) -PlotVsLTime(Reorder(sd_avg, c('dataset', 'stats', 'ftime')), +PlotVsLTime(Reorder(spread$sd, c('dataset', 'stats', 'ftime')), toptitle = "Standard deviation of the members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, hlines = c(0)) -PlotVsLTime(Reorder(mad_avg, c('dataset', 'stats', 'ftime')), +PlotVsLTime(Reorder(spread$mad, c('dataset', 'stats', 'ftime')), toptitle = "Median Absolute Deviation of the members", ytitle = "K", monini = 11, limits = NULL, listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, hlines = c(0)) -} + } } -- GitLab From 111cd172df4470f5b74c46e39833a7da55cb0efe Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 15:02:10 +0200 Subject: [PATCH 22/26] Bigfix Ano_CrossValid.R (open issue on order of dimensions or a better error message for PlotAno.R?) --- R/Ano_CrossValid.R | 4 ++-- man/Ano_CrossValid.Rd | 4 ++-- man/Spread.Rd | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/Ano_CrossValid.R b/R/Ano_CrossValid.R index 62824823..772e438e 100644 --- a/R/Ano_CrossValid.R +++ b/R/Ano_CrossValid.R @@ -45,8 +45,8 @@ #'# Load sample data as in Load() example: #'example(LoadSampleData) #'anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) -#'ano_exp <- Reorder(ano_exp, c(2, 3, 1, 4)) -#'ano_obs <- Reorder(ano_obs, c(2, 3, 1, 4)) +#'ano_exp <- Reorder(anomalies$exp, c(2, 3, 1, 4)) +#'ano_obs <- Reorder(anomalies$obs, c(2, 3, 1, 4)) #'\donttest{ #'PlotAno(ano_exp, ano_obs, startDates, #' toptitle = paste('anomalies'), ytitle = c('K', 'K', 'K'), diff --git a/man/Ano_CrossValid.Rd b/man/Ano_CrossValid.Rd index 6b8b7aeb..532cdee4 100644 --- a/man/Ano_CrossValid.Rd +++ b/man/Ano_CrossValid.Rd @@ -67,8 +67,8 @@ the 'exp' and 'obs' are excluded when computing the climatologies. # Load sample data as in Load() example: example(LoadSampleData) anomalies <- Ano_CrossValid(sampleData$mod, sampleData$obs) -ano_exp <- Reorder(ano_exp, c(2, 3, 1, 4)) -ano_obs <- Reorder(ano_obs, c(2, 3, 1, 4)) +ano_exp <- Reorder(anomalies$exp, c(2, 3, 1, 4)) +ano_obs <- Reorder(anomalies$obs, c(2, 3, 1, 4)) \donttest{ PlotAno(ano_exp, ano_obs, startDates, toptitle = paste('anomalies'), ytitle = c('K', 'K', 'K'), diff --git a/man/Spread.Rd b/man/Spread.Rd index 1569230f..27af61eb 100644 --- a/man/Spread.Rd +++ b/man/Spread.Rd @@ -76,7 +76,7 @@ suppressWarnings({ spread <- Spread(smooth_ano_exp_m_sub, compute_dim = c('member', 'sdate')) }) - \dontrun{ + \donttest{ PlotVsLTime(Reorder(spread$iqr, c('dataset', 'stats', 'ftime')), toptitle = "Inter-Quartile Range between ensemble members", ytitle = "K", monini = 11, limits = NULL, -- GitLab From fe1645e3f556e6a66563269a247a3dc76a06ea05 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 15:47:40 +0200 Subject: [PATCH 23/26] Bugfix call to LoadSampleData and update README.md example --- R/REOF.R | 7 ++----- R/ToyModel.R | 8 +------- README.md | 8 +++----- man/REOF.Rd | 7 ++----- man/ToyModel.Rd | 8 +------- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/R/REOF.R b/R/REOF.R index a20a59de..27fcfdc9 100644 --- a/R/REOF.R +++ b/R/REOF.R @@ -57,13 +57,10 @@ #'# use this function. #'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, +#'sampleData <- LoadSampleData(sdates = startDates, #' leadtimemin = 1, #' leadtimemax = 4, -#' output = 'lonlat', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) +#' output = 'lonlat') #'} #'ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) #'ano <- MeanDims(ano$exp, c('dataset', 'member')) diff --git a/R/ToyModel.R b/R/ToyModel.R index 10527a06..fc7c67f7 100644 --- a/R/ToyModel.R +++ b/R/ToyModel.R @@ -62,14 +62,8 @@ #' #'# Example 2: Generate forecast from loaded observations #'# Decadal prediction example -#'\dontshow{ #'startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -#'sampleData <- LoadSampleData('tos', c('experiment'), -#' c('observation'), startDates, -#' output = 'areave', -#' latmin = 27, latmax = 48, -#' lonmin = -12, lonmax = 40) -#'} +#'sampleData <- LoadSampleData(startDates, output = 'areave') #' #'a <- 0.1 #'b <- 0.3 diff --git a/README.md b/README.md index baba3c39..87dfa8ae 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,9 @@ data input of the functions should have names for all the dimensions. It should not be a problem since the data retrieved by s2dv::Load or startR::Start have named dimension inherently. Take the sample data in s2dv as an example: ```r -sampleData <- s2dv:::.LoadSampleData('tos', c('experiment'), c('observation'), - '19901101', leadtimemin = 1, leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) +sampleData <- LoadSampleData('19901101', leadtimemin = 1, leadtimemax = 4, + output = 'lonlat') + # It returns an object 'sampleData' dim(sampleData$mod) dataset member sdate ftime lat lon diff --git a/man/REOF.Rd b/man/REOF.Rd index 8e2e679c..ff85572d 100644 --- a/man/REOF.Rd +++ b/man/REOF.Rd @@ -79,13 +79,10 @@ internally. # use this function. \dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, +sampleData <- LoadSampleData(sdates = startDates, leadtimemin = 1, leadtimemax = 4, - output = 'lonlat', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) + output = 'lonlat') } ano <- Ano_CrossValid(sampleData$mod, sampleData$obs) ano <- MeanDims(ano$exp, c('dataset', 'member')) diff --git a/man/ToyModel.Rd b/man/ToyModel.Rd index e288e2e8..d7ce1164 100644 --- a/man/ToyModel.Rd +++ b/man/ToyModel.Rd @@ -91,14 +91,8 @@ toyforecast <- ToyModel(alpha = a, beta = b, gamma = g, sig = sig, trend = t, # Example 2: Generate forecast from loaded observations # Decadal prediction example -\dontshow{ startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101') -sampleData <- LoadSampleData('tos', c('experiment'), - c('observation'), startDates, - output = 'areave', - latmin = 27, latmax = 48, - lonmin = -12, lonmax = 40) -} +sampleData <- LoadSampleData(startDates, output = 'areave') a <- 0.1 b <- 0.3 -- GitLab From 898f5117cde7224b39bb6a0b1e3caf389a851093 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 15:54:47 +0200 Subject: [PATCH 24/26] Change 'dontrun' to 'donttest' in R/RatioSDRMS.R --- R/RatioSDRMS.R | 4 ++-- man/RatioSDRMS.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/RatioSDRMS.R b/R/RatioSDRMS.R index 6aa886d6..159d8298 100644 --- a/R/RatioSDRMS.R +++ b/R/RatioSDRMS.R @@ -42,11 +42,11 @@ #'rsdrms_plot <- array(dim = c(dim(rsdrms$ratio)[1:2], 4, dim(rsdrms$ratio)[3])) #'rsdrms_plot[, , 2, ] <- rsdrms$ratio #'rsdrms_plot[, , 4, ] <- rsdrms$p.val -#'\dontrun{ +#' \donttest{ #'PlotVsLTime(rsdrms_plot, toptitle = "Ratio ensemble spread / RMSE", ytitle = "", #' monini = 11, limits = c(-1, 1.3), listexp = c('CMIP5 IC3'), #' listobs = c('ERSST'), biglab = FALSE, siglev = TRUE) -#'} +#' } #' #'@import multiApply #'@export diff --git a/man/RatioSDRMS.Rd b/man/RatioSDRMS.Rd index ae85feb0..caac0806 100644 --- a/man/RatioSDRMS.Rd +++ b/man/RatioSDRMS.Rd @@ -65,7 +65,7 @@ rsdrms <- RatioSDRMS(sampleData$mod, sampleData$obs, dat_dim = 'dataset') rsdrms_plot <- array(dim = c(dim(rsdrms$ratio)[1:2], 4, dim(rsdrms$ratio)[3])) rsdrms_plot[, , 2, ] <- rsdrms$ratio rsdrms_plot[, , 4, ] <- rsdrms$p.val -\dontrun{ + \donttest{ PlotVsLTime(rsdrms_plot, toptitle = "Ratio ensemble spread / RMSE", ytitle = "", monini = 11, limits = c(-1, 1.3), listexp = c('CMIP5 IC3'), listobs = c('ERSST'), biglab = FALSE, siglev = TRUE) -- GitLab From 437baa4be0f9ab4e4b46d562260f0b844bc974b5 Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 16:27:50 +0200 Subject: [PATCH 25/26] Uncomment 'tests' in .Rbuildignore --- .Rbuildignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.Rbuildignore b/.Rbuildignore index 6221ce7f..c823928b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,7 +12,7 @@ vignettes .gitlab-ci.yml .lintr # unit tests should be ignored when building the package for CRAN -###^tests$ +^tests$ # CDO is not in windbuilder, so we can test the unit tests by winbuilder # but test-CDORemap.R and test-Load.R needs to be hidden #tests/testthat/test-CDORemap.R -- GitLab From 701da3df527459962ffda0b070934a98089fea6e Mon Sep 17 00:00:00 2001 From: ARIADNA BATALLA FERRES Date: Tue, 23 Sep 2025 17:19:21 +0200 Subject: [PATCH 26/26] Change format of doi references in DESCRIPTION --- DESCRIPTION | 6 +++--- man/s2dv-package.Rd | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1271a5b4..6e031594 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,9 +25,9 @@ Description: An advanced version of package 's2dverification'. Intended for to use multiple cores for computation and handle multi-dimensional arrays with a higher flexibility. The Climate Data Operators (CDO) version used in development is 1.9.8. Implements methods described in Wilks (2011) - , DelSole and Tippett - (2016) , Kharin et al. (2012) - , Doblas-Reyes et al. (2003) + , DelSole and Tippett + (2016) , Kharin et al. (2012) + , Doblas-Reyes et al. (2003) . Depends: R (>= 3.6.0) diff --git a/man/s2dv-package.Rd b/man/s2dv-package.Rd index 612611b3..095b9a3a 100644 --- a/man/s2dv-package.Rd +++ b/man/s2dv-package.Rd @@ -6,7 +6,7 @@ \alias{s2dv-package} \title{s2dv: Seasonal to Decadal Verification} \description{ -An advanced version of package 's2dverification'. Intended for seasonal to decadal (s2d) climate forecast verification, but also applicable to other types of forecasts or general climate analysis. This package is specifically designed for comparing experimental and observational datasets. It provides functionality for data retrieval, post-processing, skill score computation against observations, and visualization. Compared to 's2dverification', 's2dv' is more compatible with the package 'startR', able to use multiple cores for computation and handle multi-dimensional arrays with a higher flexibility. The Climate Data Operators (CDO) version used in development is 1.9.8. Implements methods described in Wilks (2011) \url{https://doi.org/10.1016/B978-0-12-385022-5.00008-7}, DelSole and Tippett (2016) \url{https://doi.org/10.1175/MWR-D-15-0218.1}, Kharin et al. (2012) \url{https://doi.org/10.1029/2012GL052647}, Doblas-Reyes et al. (2003) \doi{10.1007/s00382-003-0350-4}. +An advanced version of package 's2dverification'. Intended for seasonal to decadal (s2d) climate forecast verification, but also applicable to other types of forecasts or general climate analysis. This package is specifically designed for comparing experimental and observational datasets. It provides functionality for data retrieval, post-processing, skill score computation against observations, and visualization. Compared to 's2dverification', 's2dv' is more compatible with the package 'startR', able to use multiple cores for computation and handle multi-dimensional arrays with a higher flexibility. The Climate Data Operators (CDO) version used in development is 1.9.8. Implements methods described in Wilks (2011) \doi{10.1016/B978-0-12-385022-5.00008-7}, DelSole and Tippett (2016) \doi{10.1175/MWR-D-15-0218.1}, Kharin et al. (2012) \doi{10.1029/2012GL052647}, Doblas-Reyes et al. (2003) \doi{10.1007/s00382-003-0350-4}. } \references{ \url{https://earth.bsc.es/gitlab/es/s2dv/} -- GitLab