From 2b2600d119102ff1b36a666334c7942a497df474 Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Mon, 12 Sep 2022 12:32:05 +0200 Subject: [PATCH 1/3] Correct vignette error of Ano_Exp var --- vignettes/MostLikelyTercile_vignette.Rmd | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/vignettes/MostLikelyTercile_vignette.Rmd b/vignettes/MostLikelyTercile_vignette.Rmd index 6a5ce547..86e711e5 100644 --- a/vignettes/MostLikelyTercile_vignette.Rmd +++ b/vignettes/MostLikelyTercile_vignette.Rmd @@ -126,8 +126,8 @@ The seasonal mean of both forecasts and observations are computed by averaging o ```r -ano_exp$data <- MeanDims(Ano_Exp$data, 'ftime') -ano_obs$data <- MeanDims(Ano_Obs$data, 'ftime') +Ano_Exp$data <- MeanDims(Ano_Exp$data, 'ftime') +Ano_Obs$data <- MeanDims(Ano_Obs$data, 'ftime') ``` @@ -135,7 +135,7 @@ Finally, the probabilities of each tercile are computed by evaluating which terc ```r -PB <- ProbBins(ano_exp$data, fcyr = numyears, thr = c(1/3, 2/3), quantile = TRUE, +PB <- ProbBins(Ano_Exp$data, fcyr = numyears, thr = c(1/3, 2/3), quantile = TRUE, posdates = 3, posdim = 2, compPeriod = "Without fcyr") prob_map <- MeanDims(PB, c('sdate', 'member', 'dataset')) ``` @@ -149,7 +149,7 @@ We then plot the most likely quantile using the **CSTools** function `PlotMostLi ``` PlotMostLikelyQuantileMap(probs = prob_map, lon = Lon, lat = Lat, - coast_width=1.5, legend_scale = 0.8, + coast_width = 1.5, legend_scale = 0.8, toptitle = paste0('Most likely tercile - ', clim_var, ' - ECMWF System5 - JJA 2020')) ``` @@ -190,10 +190,8 @@ From the RPSS, we create a mask: regions with RPSS <= 0 will be masked. ```r -mask_rpss <- RPSS[[1]] -mask_rpss[RPSS[[1]] <= 0] <- 1 -mask_rpss[is.na(RPSS[[1]])] <- 1 -mask_rpss[RPSS[[1]] > 0] <- 0 +mask_rpss <- lapply(RPSS[[1]], function(x) ifelse(x <= 0 | is.na(x), 1, x)) +mask_rpss <- lapply(mask_rpss, function(x) ifelse(x > 0 & x < 1, 0, x)) ``` Finally, we plot the latest forecast, as in the previous step, but add the mask we just created. @@ -201,7 +199,7 @@ Finally, we plot the latest forecast, as in the previous step, but add the mask ```r PlotMostLikelyQuantileMap(probs = prob_map, lon = Lon, lat = Lat, coast_width = 1.5, - legend_scale = 0.8, mask = t(mask_rpss), + legend_scale = 0.8, mask = mask_rpss[[1]][,,1], toptitle = paste('Most likely tercile -', clim_var, '- ECMWF System5 - JJA 2020')) ``` -- GitLab From f6967e73094a1904f87e520eb1bdf7a607a7f58e Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Mon, 12 Sep 2022 13:26:36 +0200 Subject: [PATCH 2/3] Increase plot size to avoid legend error --- vignettes/MostLikelyTercile_vignette.Rmd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vignettes/MostLikelyTercile_vignette.Rmd b/vignettes/MostLikelyTercile_vignette.Rmd index 86e711e5..8e1972b7 100644 --- a/vignettes/MostLikelyTercile_vignette.Rmd +++ b/vignettes/MostLikelyTercile_vignette.Rmd @@ -149,9 +149,10 @@ We then plot the most likely quantile using the **CSTools** function `PlotMostLi ``` PlotMostLikelyQuantileMap(probs = prob_map, lon = Lon, lat = Lat, - coast_width = 1.5, legend_scale = 0.8, + coast_width = 1.5, legend_scale = 0.5, toptitle = paste0('Most likely tercile - ', clim_var, - ' - ECMWF System5 - JJA 2020')) + ' - ECMWF System5 - JJA 2020'), + width = 10, height = 8) ``` ![](./Figures/MostLikelyTercile_fig1.png) @@ -199,9 +200,10 @@ Finally, we plot the latest forecast, as in the previous step, but add the mask ```r PlotMostLikelyQuantileMap(probs = prob_map, lon = Lon, lat = Lat, coast_width = 1.5, - legend_scale = 0.8, mask = mask_rpss[[1]][,,1], + legend_scale = 0.5, mask = mask_rpss[[1]][,,1], toptitle = paste('Most likely tercile -', clim_var, - '- ECMWF System5 - JJA 2020')) + '- ECMWF System5 - JJA 2020'), + width = 10, height = 8) ``` ![](./Figures/MostLikelyTercile_fig3.png) -- GitLab From 166ef6bf2408a9b3909dfd3ac689147c4ee6e84c Mon Sep 17 00:00:00 2001 From: Eva Rifa Date: Tue, 13 Sep 2022 11:55:52 +0200 Subject: [PATCH 3/3] Update deprecated function and improve code --- vignettes/MostLikelyTercile_vignette.Rmd | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vignettes/MostLikelyTercile_vignette.Rmd b/vignettes/MostLikelyTercile_vignette.Rmd index 8e1972b7..a5d46a81 100644 --- a/vignettes/MostLikelyTercile_vignette.Rmd +++ b/vignettes/MostLikelyTercile_vignette.Rmd @@ -24,10 +24,9 @@ To run this vignette, the following R packages should be installed and loaded: ```r library(CSTools) library(s2dv) -library(s2dverification) -library(multiApply) library(zeallot) library(easyVerification) +library(ClimProjDiags) ``` @@ -135,8 +134,7 @@ Finally, the probabilities of each tercile are computed by evaluating which terc ```r -PB <- ProbBins(Ano_Exp$data, fcyr = numyears, thr = c(1/3, 2/3), quantile = TRUE, - posdates = 3, posdim = 2, compPeriod = "Without fcyr") +PB <- ProbBins(Ano_Exp$data, fcyr = numyears, thr = c(1/3, 2/3), compPeriod = "Without fcyr") prob_map <- MeanDims(PB, c('sdate', 'member', 'dataset')) ``` @@ -191,8 +189,7 @@ From the RPSS, we create a mask: regions with RPSS <= 0 will be masked. ```r -mask_rpss <- lapply(RPSS[[1]], function(x) ifelse(x <= 0 | is.na(x), 1, x)) -mask_rpss <- lapply(mask_rpss, function(x) ifelse(x > 0 & x < 1, 0, x)) +mask_rpss <- ifelse((RPSS$data$skillscore <= 0) | is.na(RPSS$data$skillscore), 1, 0) ``` Finally, we plot the latest forecast, as in the previous step, but add the mask we just created. @@ -200,7 +197,7 @@ Finally, we plot the latest forecast, as in the previous step, but add the mask ```r PlotMostLikelyQuantileMap(probs = prob_map, lon = Lon, lat = Lat, coast_width = 1.5, - legend_scale = 0.5, mask = mask_rpss[[1]][,,1], + legend_scale = 0.5, mask = mask_rpss[ , , 1], toptitle = paste('Most likely tercile -', clim_var, '- ECMWF System5 - JJA 2020'), width = 10, height = 8) -- GitLab