autoplot_forecast_spi: Wrapper function to calculate and plot timerseries of SPI...

Description Usage Arguments Details References See Also Examples

View source: R/autoplot_spi_forecast.R

Description

The function returns a plot with the historical SPI values as a barplot and the ensemble forecasts as boxplots. The function works with station data only and needs a observational time series and an ensemble forecast as input. To see some example outputs of this function, look at the vignette "autoplot-functions" accessible through the package help main page or by typing
vignette("autoplot-functions",package="ClimIndVis") into the console.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
autoplot_forecast_spi(
  obs_p,
  fc_p,
  index = "spi_forecast",
  index_args,
  selpoints = NULL,
  output = NULL,
  plotdir,
  plotname = "",
  plotstart,
  plot_title = TRUE,
  title = "",
  text_cex = 1,
  ...
)

Arguments

obs_p

Station observations. Climindvis-object with type = "p" generated by make_object.

fc_p

Forecasts at stations. Climindvis-object with type = "fc_p" generated by make_object.

index

Character string. This is set to index="spi_forecast" and does not have to be provided.

index_args

List of arguments for index. For arguments see index_arguments.spi_forecast

selpoints

Array to select subset of points to plot. There are two options:

  • Character array of station names (works only if names are defined in climindvis_index objects ...$data_info$pnames and if they are the same for all objects in climindvis_index_list)

  • Integer array of station indices (works only if coordinates of all objects in climindvis_index_list are the same)

output

Format of image to be plotted ("png", "jpeg", "tiff", "pdf","dev.new"). Default = NULL, output to null device (getOption("device") will show you the null device. If you are not using RStudio, NULL and dev.new will give the same output).

plotdir

Character string of path of directory for saving plots. Ignored if output is NULL or "dev.new".

plotname

Optional. Character string. First part of plot name followed by character string containing index name/aggregation/time period/... depending on the autoplot function. Default = "".

plotstart

Numeric. Chosen start year of historic time series plot. For a reference period of e.g. 1981-2010 and a forecast for 2011, plotstart can be set to 2009 and only 2009-2010 and the forecast 2011 is displayed.

plot_title

Logical. Add plot title to graphic. Default = TRUE.

title

Optional. Character string. If provided added above the plot in addition to default information from the respective function (e.g. index name/aggregation/time period/...). Default = "", no additional title is written.

trendplots.

No trendplots implemented in this graphic. Set to FALSE.

Details

For the SPI calculation, aggt needs to be set to "monthly". For further arguments see index_arguments.spi_forecast

The forecast dates need to continue the time series of the historical dataset. If the observational data ends on 2010-04-30, the forecast data needs to start 2010-05-01. Thus, the SPI is calculated for the overlapping period. If there is a time gap between forecast and historical data, no overlapping period is calculated.
The function can only be applied to station data and not to gridded data. Note, that you have to provide the same amount of station data in the two climdindvis-objects forecast and observation (obs_p, fc_p). No checks are executed, whether the coordinates of the observational data corresponds to the coordinates of the forecast data.

The SPI calculation is based on the SCI package from Lukas Gudmundsson & James Stagge. For the argument distribution, provide a distribution for which the corresponding density function (dname), the corresponding distribution function (pname) and the quantile function (qname) must be defined (see for example GammaDist). Distributions are listed in the package stats.

For SPI with forecast no trend can be calculated at the moment.

References

Stagee, J.H. ; Tallaksen, L.M.; Gudmundsson, L.; van Loon, A.; Stahl, K.: Candidate Distributions for Climatological Drought Indices (SPI and SPEI), 2015, International Journal of Climatology, 35, 4027-4040, doi:10.1002/joc.4267.

See Also

Other autoplot_functions: autoplot_anomaly_map(), autoplot_anomaly_ts(), autoplot_climatology_map(), autoplot_forecast_map(), autoplot_forecast_stations(), autoplot_overview_stations(), autoplot_trend_map(), autoplot_ts_stations(), autoplot_verification_map()

Examples

1
2
3
4
5
6
#' ## Load example climindvis objects:
data(object_st, object_fc_st)

autoplot_forecast_spi(
     obs_p = object_st,fc_p = object_fc_st, index = "spi_forecast",
     index_args = list(aggt = "monthly", timescale= 3),plotstart=2008)

Climandes/ClimIndVis documentation built on Oct. 24, 2021, 10:52 a.m.