Plot s2dv verification skill scores
Description
Plots s2dv_cube verification skill scores for gridded, polygon and point data generated by c4h_verify . It is used for the following statistics: BSS, RPSS, CRPSS, AbsBiasSS, MSSS, RMSSS and ROCSS. For MSE and RMSE, please use the function c4h_plot .
c4h_plotskill(
skill,
sign = NULL,
time = NULL,
boundaries = NULL,
mask_boundaries = FALSE,
title = NULL,
legend = NULL,
palette = "SunsetDark",
noskillcol = "#b7d6ff",
coordgrid = FALSE,
...
)Arguments
skill: s2dv_cube object with the skill data to be plotted.sign: An additional optional binary s2dv_cube indicating significance.time: Numerical index of the time to be plotted. Defaults to NULL (all times).boundaries: Polygon boundaries to add to the map. Set to NULL for no boundaries (default), otherwise supply a polygonsfobject or set to “countries” for coarse country boundaries.mask_boundaries: If TRUE (default), mask the data to the provided boundaries.title: Optional plot title.legend: Optional legend title. If NULL (default), it uses the variable names.palette: GHR, RColorBrewer or colorspace palette. Use “-” before the palette name (e.g., “-Reds”) to reverse it. Alternatively, a vector of hex codes to create a continuous interpolated palette.noskillcol: Colour for skill scores < 0 depicting a skill lower than climatologies.coordgrid: If TRUE, display coordinate grids on the map....: Extra arguments indicating fixed aesthetics to be passed tostars::geom_stars, includinglwd,alpha,sizeandcolour.
Returns
A ggplot2 plot with the verification skill scores.
See Also
c4h_verify for calculating forecast skill and c4h_plot
for general plotting of s2dv objects.
Examples
# DISCLAIMER: The purpose of these examples is to show the functionality
# of the different functions. To perform a meaningful verification, a much
# larger time series is required.
# Load data
hcst <- c4h_load(
system.file("extdata", "hindcast", package = "clim4health"),
variable = "t2m",
year = 2010:2012,
month = 1,
leadtime_month = 1:3,
ext = "nc"
)
lats <- hcst$coords$latitude
lons <- hcst$coords$longitude
obs <- c4h_load(
system.file("extdata", "reanalysis", package = "clim4health"),
variable = "t2m",
year = 2010:2012,
month = 1,
leadtime_month = 1:3,
bbox = c(max(lats), min(lons), min(lats), max(lons)),
ext = "nc"
)
# Example with gridded data
dwn <- c4h_downscale(
"Interpolation",
exp = hcst,
obs = obs,
method_remap = "bilinear",
target_grid = system.file(
"extdata",
"reanalysis/t2m_201001.nc",
package = "clim4health"
)
)
hcst_dwn <- dwn$exp
skill_grid <- c4h_verify(exp = hcst_dwn, obs = obs, metrics = "BSS")
c4h_plotskill(skill_grid$BSS10$bss, skill_grid$BSS10$sign)
# Make some artificial significance for testing
skill_grid$BSS10$sign$data[,,,,, 3:8, 15:25] <- TRUE
c4h_plotskill(skill = skill_grid$BSS10$bss, sign = skill_grid$BSS10$sign)
# Example with polygon data
areas <- sf::read_sf(system.file("extdata", "areas", "munip_vallecauca.gpkg",
package = "clim4health"))
obs_area <- c4h_space(obs,
areas = areas,
fun = "mean",
areas_id = "munip_code")
hcst_area <- c4h_space(hcst,
areas = areas,
fun = "mean",
areas_id = "munip_code")
skill_area <- c4h_verify(exp = hcst_area,
obs = obs_area,
metrics = "CRPSS",
brier_thresholds = c(0.1, 0.9))
c4h_plotskill(skill_area$CRPSS$crpss, skill_area$CRPSS$sign)
# Make some artificial significance for testing
skill_area$CRPSS$sign$data[1, 1, 1, 1:3, 1, sample(1:42, 10)] <- TRUE
c4h_plotskill(skill = skill_area$CRPSS$crpss, sign = skill_area$CRPSS$sign)
# Example with station data
point_locs <- clim4health::c4h_load(system.file("extdata",
"stations",
package = "clim4health"),
ext = "csv",
year = 2010:2012,
month = 1,
leadtime_month = 1:3,
variable = "temp_mean")
points <- list(latitude = point_locs$attrs$location$latitude,
longitude = point_locs$attrs$location$longitude)
point_locs <- c4h_time(point_locs,
time_aggregation = "monthly",
dim_aggregation = "sdate",
fun = "mean")
dwn <- c4h_downscale("Interpolation", exp = hcst,
points = points, method_point_interp = "bilinear")
hcst_dwn <- dwn$exp
skill_point <- c4h_verify(exp = hcst_dwn,
obs = point_locs,
metrics = "BSS")
c4h_plotskill(skill = skill_point$BSS10$bss, boundaries = areas)
# Make some artificial significance for testing
skill_point$BSS10$sign$data[1, 1, 1, 1:3, 1, 4:6] <- TRUE
c4h_plotskill(skill = skill_point$BSS10$bss,
sign = skill_point$BSS10$sign,
boundaries = areas)