Skip to contents

Input data for the plot_timeSeries() function. Since these inputs are time-consuming to generate, the purpose of conducting the generation of the input table in a separate function is to allow users to make multiple calls to plot_timeSeries() (e.g., for comparing different climate variables) without needing to generate the inputs each time.

Usage

plot_timeSeries_input(
  xyz,
  gcms = list_gcms(),
  ssps = list_ssps(),
  max_run = 10,
  obs_ts_dataset = c("cru.gpcc", "climatena"),
  obs_years = list_obs_years(),
  gcm_hist_years = list_gcm_hist_years(),
  gcm_ssp_years = list_gcm_ssp_years(),
  vars = list_vars()
)

Arguments

xyz

a terra::SpatRaster with a single layer containing elevation values in metres, or a data.frame with the following columns "long", "lat", "elev", and a unique "id". Any extra columns will be ignored and not output.

gcms

character. Vector of global climate model names. Options are list_gcms().

ssps

character. Vector of SSP-RCP scenarios (representative concentration pathways paired with shared socioeconomic pathways). Options are list_ssps(). Defaults to all scenarios available.

max_run

integer. Maximum number of model runs to include, not including the ensemble mean. Runs are included in the order they are found in the models data until max_run is reached. Defaults to 0L.

obs_ts_dataset

character. The dataset to use for observational time series data. Options are "climatena" for the ClimateNA gridded time series or "cru.gpcc" for the combined Climatic Research Unit TS dataset (for temperature) and Global Precipitation Climatology Centre dataset (for precipitation).

obs_years

integer. Vector of years to obtain individual years or time series of observational climate data. See list_obs_years() for available years.

gcm_hist_years

character. Timeseries years for GCM simulations of the historical scenario. See list_gcm_hist_years() for available years.

gcm_ssp_years

character. Timeseries years for GCM simulations of future scenarios specified by ssps. See list_gcm_ssp_years() for available years.

vars

character. A vector of climate variables to compute. Supported variables can be obtained with list_vars(). Definitions can be found in this package variables dataset. Default to monthly PPT, Tmax, Tmin.

Value

data.table of average downscaled climate variables for all locations.

Details

This function generates standardized inputs for one or multiple locations at any spatial scale. If multiple locations are specified, the output is the average of the climate variables for all locations.

Downloads of GCM time series take some time. The plot_timeSeries_input() function can take ~5 minutes to run for the first time it is called for a location. Once the time series are cached, they don't need to be downloaded again.

Examples

if (FALSE) {
  # data frame of arbitrary points
  my_points <- data.frame(
    lon = c(-127.7300, -127.7500),
    lat = c(55.34114, 55.25),
    elev = c(711, 500),
    id = 1:2
  )

  # generate the input data
  my_data <- plot_timeSeries_input(my_points)

  # use the input to create a plot
  plot_timeSeries(my_data, var1 = "Tmin_sm")
}
#'