diff --git a/DESCRIPTION b/DESCRIPTION index f481e5fe157174a910ad804c4f8716058b3660dc..92c364760912d07dcf1b02840596b1c7984a8e1b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Title: Assessing Skill of Climate Forecasts on Seasonal-to-Decadal Timescales Version: 3.1.0 Authors@R: c( - person("Núria", "Pérez-Zanón", , "nuria.perez@bsc.es", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8568-3071")), + person("Nuria", "Perez-Zanon", , "nuria.perez@bsc.es", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8568-3071")), person("Louis-Philippe", "Caron", , "louis-philippe.caron@bsc.es", role = "aut", comment = c(ORCID = "0000-0001-5221-0147")), person("Carmen", "Alvarez-Castro", , "carmen.alvarez-castro@cmcc.it", role = "aut"), person("Jost", "von Hardenberg", , email = c("j.vonhardenberg@isac.cnr.it", "jost.hardenberg@polito.it"), role = "aut", comment = c(ORCID = "0000-0002-5312-8070")), @@ -71,6 +71,7 @@ Suggests: zeallot, testthat, knitr, + markdown, rmarkdown VignetteBuilder: knitr License: Apache License 2.0 diff --git a/R/CST_EnsClustering.R b/R/CST_EnsClustering.R index 53bf013a6bd999dd5b5273838182f15eb5d8767a..93a34d9ffa9f9caf05b8cd5b693b7be4b52220f4 100644 --- a/R/CST_EnsClustering.R +++ b/R/CST_EnsClustering.R @@ -73,22 +73,23 @@ #' \code{$lon} (selected longitudes of output fields), #' \code{$lat} (selected longitudes of output fields). #' @examples +#'\donttest{ #' exp <- lonlat_data$exp #' # Example 1: Cluster on all start dates, members and models #' res <- CST_EnsClustering(exp, numclus = 3, #' cluster_dim = c("member", "dataset", "sdate")) #' iclus = res$cluster[2, 1, 3] -#'\donttest{ +#' #' print(paste("Cluster of 2. member, 1. dataset, 3. sdate:", iclus)) #' print(paste("Frequency (numerosity) of cluster (", iclus, ") :", res$freq[iclus])) #' library(s2dverification) #' PlotEquiMap(res$repr_field[iclus, , ], exp$lon, exp$lat, #' filled.continents = FALSE, #' toptitle = paste("Representative field of cluster", iclus)) -#'} +#' #' # Example 2: Cluster on members retaining 4 EOFs during #' # preliminary dimensional reduction -#'\donttest{ +#' #' res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") #' # Example 3: Cluster on members, retain 80% of variance during #' # preliminary dimensional reduction @@ -161,9 +162,11 @@ CST_EnsClustering <- function(exp, time_moment = "mean", numclus = NULL, #' \code{$lat} (selected longitudes of output fields). #' #' @examples +#'\donttest{ #' exp <- lonlat_data$exp #' res <- EnsClustering(exp$data, exp$lat, exp$lon, numclus = 3, #' cluster_dim = c("member", "dataset", "sdate")) +#'} #'@export EnsClustering <- function(data, lat, lon, time_moment = "mean", numclus = NULL, diff --git a/R/CST_RegimesAssign.R b/R/CST_RegimesAssign.R index b0817a71e46a10051eba46eaa53bd5e9fbe78650..580cf1e5096ab718344e791c1b6bffbfdb157498 100644 --- a/R/CST_RegimesAssign.R +++ b/R/CST_RegimesAssign.R @@ -31,9 +31,11 @@ #'@import multiApply #'@importFrom ClimProjDiags Subset #'@examples +#'\dontrun{ #'regimes <- CST_WeatherRegimes(data = lonlat_data$obs, EOFs = FALSE, ncenters = 4) #'res1 <- CST_RegimesAssign(data = lonlat_data$exp, ref_maps = regimes, composite = FALSE) #'res2 <- CST_RegimesAssign(data = lonlat_data$exp, ref_maps = regimes, composite = TRUE) +#'} #'@export #' @@ -105,10 +107,12 @@ CST_RegimesAssign <- function(data, ref_maps, #'@import multiApply #'@importFrom ClimProjDiags Subset #'@examples +#'\dontrun{ #'regimes <- WeatherRegime(data = lonlat_data$obs$data, lat = lonlat_data$obs$lat, #' EOFs = FALSE, ncenters = 4)$composite #'res1 <- RegimesAssign(data = lonlat_data$exp$data, ref_maps = drop(regimes), #' lat = lonlat_data$exp$lat, composite = FALSE) +#'} #'@export RegimesAssign <- function(data, ref_maps, lat, method = "distance", composite = FALSE, diff --git a/R/CST_WeatherRegimes.R b/R/CST_WeatherRegimes.R index f4495a29303e2768818ed6c2752a38b162a8d385..72ab3987e38e2ab4b7f45bcc2b10016f3eecbb92 100644 --- a/R/CST_WeatherRegimes.R +++ b/R/CST_WeatherRegimes.R @@ -37,8 +37,10 @@ #'@import s2dverification #'@import multiApply #'@examples +#'\dontrun{ #'res1 <- CST_WeatherRegimes(data = lonlat_data$obs, EOFs = FALSE, ncenters = 4) #'res2 <- CST_WeatherRegimes(data = lonlat_data$obs, EOFs = TRUE, ncenters = 3) +#'} #'@export #' CST_WeatherRegimes <- function(data, ncenters = NULL, @@ -110,8 +112,10 @@ CST_WeatherRegimes <- function(data, ncenters = NULL, #'@import s2dverification #'@import multiApply #'@examples +#'\dontrun{ #'res <- WeatherRegime(data = lonlat_data$obs$data, lat = lonlat_data$obs$lat, #' EOFs = FALSE, ncenters = 4) +#'} #'@export WeatherRegime <- function(data, ncenters = NULL, diff --git a/man/CST_EnsClustering.Rd b/man/CST_EnsClustering.Rd index 6ee79b7c0cd023afc07926077f99b444206d3645..a7ca4a9c2d86dd839e6f4316ac0082b274f1c6fa 100644 --- a/man/CST_EnsClustering.Rd +++ b/man/CST_EnsClustering.Rd @@ -99,22 +99,23 @@ the maximum distance between a member in a cluster and the cluster centroid deviation for each cluster (i.e. how much the cluster is compact). } \examples{ +\donttest{ exp <- lonlat_data$exp # Example 1: Cluster on all start dates, members and models res <- CST_EnsClustering(exp, numclus = 3, cluster_dim = c("member", "dataset", "sdate")) iclus = res$cluster[2, 1, 3] -\donttest{ + print(paste("Cluster of 2. member, 1. dataset, 3. sdate:", iclus)) print(paste("Frequency (numerosity) of cluster (", iclus, ") :", res$freq[iclus])) library(s2dverification) PlotEquiMap(res$repr_field[iclus, , ], exp$lon, exp$lat, filled.continents = FALSE, toptitle = paste("Representative field of cluster", iclus)) -} + # Example 2: Cluster on members retaining 4 EOFs during # preliminary dimensional reduction -\donttest{ + res <- CST_EnsClustering(exp, numclus = 3, numpcs = 4, cluster_dim = "member") # Example 3: Cluster on members, retain 80\% of variance during # preliminary dimensional reduction diff --git a/man/CST_RegimesAssign.Rd b/man/CST_RegimesAssign.Rd index 22b762b209b7471bf4a7fc652ac79f863bf42deb..43df97c45b387185eb00ecb937fcbc18eab46694 100644 --- a/man/CST_RegimesAssign.Rd +++ b/man/CST_RegimesAssign.Rd @@ -43,10 +43,12 @@ for which the minimum Eucledian distance (method=’distance’) or highest spat (method=‘ACC’) is obtained. } \examples{ +\dontrun{ regimes <- CST_WeatherRegimes(data = lonlat_data$obs, EOFs = FALSE, ncenters = 4) res1 <- CST_RegimesAssign(data = lonlat_data$exp, ref_maps = regimes, composite = FALSE) res2 <- CST_RegimesAssign(data = lonlat_data$exp, ref_maps = regimes, composite = TRUE) } +} \references{ Torralba, V. (2019) Seasonal climate prediction for the wind energy sector: methods and tools for the development of a climate service. Thesis. Available online: \url{https://eprints.ucm.es/56841/} diff --git a/man/CST_WeatherRegimes.Rd b/man/CST_WeatherRegimes.Rd index a840c59535b0721e296b17134aac588101400ee8..a243a76ae2f0484babf3f67075467ed54fa7991a 100644 --- a/man/CST_WeatherRegimes.Rd +++ b/man/CST_WeatherRegimes.Rd @@ -54,9 +54,11 @@ The cluster analysis can be performed with the traditional k-means or those meth included in the hclust (stats package). } \examples{ +\dontrun{ res1 <- CST_WeatherRegimes(data = lonlat_data$obs, EOFs = FALSE, ncenters = 4) res2 <- CST_WeatherRegimes(data = lonlat_data$obs, EOFs = TRUE, ncenters = 3) } +} \references{ Cortesi, N., V., Torralba, N., González-Reviriego, A., Soret, and F.J., Doblas-Reyes (2019). Characterization of European wind speed variability using weather regimes. Climate Dynamics,53, diff --git a/man/EnsClustering.Rd b/man/EnsClustering.Rd index 30d81f87f44bdffe3f935b39bedddb15a85d19de..510fc1686d6e62a618052db96aa2fe2985ef3bd4 100644 --- a/man/EnsClustering.Rd +++ b/man/EnsClustering.Rd @@ -67,10 +67,12 @@ and returns a number of scenarios, with representative members for each of them. The clustering is performed in a reduced EOF space. } \examples{ +\donttest{ exp <- lonlat_data$exp res <- EnsClustering(exp$data, exp$lat, exp$lon, numclus = 3, cluster_dim = c("member", "dataset", "sdate")) } +} \author{ Federico Fabiano - ISAC-CNR, \email{f.fabiano@isac.cnr.it} diff --git a/man/RegimesAssign.Rd b/man/RegimesAssign.Rd index d578e5b24863216db69830f36374714fa590ff33..c145e8ef6ad5b84478ecdcdbbedc95e47d9c5067 100644 --- a/man/RegimesAssign.Rd +++ b/man/RegimesAssign.Rd @@ -46,10 +46,12 @@ for which the minimum Eucledian distance (method=’distance’) or highest spat (method=‘ACC’) is obtained. } \examples{ +\dontrun{ regimes <- WeatherRegime(data = lonlat_data$obs$data, lat = lonlat_data$obs$lat, EOFs = FALSE, ncenters = 4)$composite res1 <- RegimesAssign(data = lonlat_data$exp$data, ref_maps = drop(regimes), lat = lonlat_data$exp$lat, composite = FALSE) +} } \references{ Torralba, V. (2019) Seasonal climate prediction for the wind energy sector: methods and tools for the development of a climate service. Thesis. Available online: \url{https://eprints.ucm.es/56841/} diff --git a/man/WeatherRegimes.Rd b/man/WeatherRegimes.Rd index 812585ce17ff7fac6becb833c29c69bd0bf5883a..3f77841e89095623fb0e8d5b50624e12d28aae97 100644 --- a/man/WeatherRegimes.Rd +++ b/man/WeatherRegimes.Rd @@ -61,9 +61,11 @@ The cluster analysis can be performed with the traditional k-means or those meth included in the hclust (stats package). } \examples{ +\dontrun{ res <- WeatherRegime(data = lonlat_data$obs$data, lat = lonlat_data$obs$lat, EOFs = FALSE, ncenters = 4) } +} \references{ Cortesi, N., V., Torralba, N., González-Reviriego, A., Soret, and F.J., Doblas-Reyes (2019). Characterization of European wind speed variability using weather regimes. Climate Dynamics,53, diff --git a/vignettes/WeatherRegimes_vignette.Rmd b/vignettes/WeatherRegimes_vignette.Rmd index 47d78aee2c7055098c7fe530cfe103684f46cb13..62e4883db6b55406f5100f7d6cb4e9187859f3d2 100644 --- a/vignettes/WeatherRegimes_vignette.Rmd +++ b/vignettes/WeatherRegimes_vignette.Rmd @@ -45,10 +45,12 @@ c(exp, obs) %<-% CST_Load(var = 'psl', exp = 'system4_m1', lonmin = 274.5, lonmax = 45, output = 'lonlat') ``` + Notice that you need the files to be stored locally in your computer or server with correct configuration file. If you are interested into run this vignette, contact nuria.perez at bsc.es to get a data sample. The objects returned by `CST_Load()` are s2v_cube class. They contains among others, the array with the requested data. + ```r > dim(exp$data) dataset member sdate ftime lat lon @@ -58,7 +60,8 @@ dataset member sdate ftime lat lon 1 1 20 31 77 186 ``` -## #3- Daily anomalies based on a smoothed climatology) + +### 3- Daily anomalies based on a smoothed climatology) The weather regimes classification is based on daily anomalies, which have been computed by following these steps: @@ -77,7 +80,7 @@ from the stats R package. In this example we have made different assumptions: fo ```r -WR_obs <- CST_WeatherRegimes(data = ano_obs, EOFS = FALSE, ncenters = 4) +WR_obs <- CST_WeatherRegimes(data = ano_obs, EOFs = FALSE, ncenters = 4) ``` @@ -121,8 +124,7 @@ PlotTriangles4Categories(freq_obs, toptitle = 'Persistence', ``` - - + ### 7- Weather regimes in the predictions