Time series plots of climate change
plot_timeSeries.Rd
Time series plots of 20th and 21st century climate change for user-selected locations and climate variables. The purposes of the plot are to:
view differences in interannual variability and climate change trends among global climate models (GCMs),
view the differences between multiple simulations of each model,
compare simulated and observed climate change from 1901 to present, and
compare time series of two different variables.
All global climate model anomalies are bias-corrected to the 1961-1990 reference period normals.
Usage
plot_timeSeries(
X,
var1 = "Tmin_sm",
var2 = NULL,
showObserved = TRUE,
obs_ts_dataset = "climatena",
gcms = list_gcms()[c(1, 4, 5, 6, 7, 10, 11, 12)],
ssps = list_ssps()[1:3],
showrange = TRUE,
yfit = TRUE,
cex = 1,
mar = c(3, 3, 0.1, 4),
showmean = TRUE,
compile = TRUE,
simplify = TRUE,
refline = FALSE,
refline.obs = TRUE,
pal = "scenario",
label.endyear = FALSE,
endlabel = "change",
yearmarkers = TRUE,
yearlines = FALSE,
legend_pos = "topleft"
)
Arguments
- X
A
data.table
object produced using the functionplot_timeSeries_input()
. This table can include more models, scenarios, and variables than are used in individual calls toplot_timeSeries()
.- var1
character. A climate var. options are
list_vars()
.- var2
character. A second climate var to plot in combination with
var1
. options arelist_vars()
.- showObserved
logical. Plot a time series of observed climate.
- 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). Defaults toNULL
.- gcms
character. Vector of global climate model names. Options are
list_gcms()
. Defaults toNULL
.- ssps
character. Vector of SSP-RCP scenarios (representative concentration pathways paired with shared socioeconomic pathways). Options are
list_ssps()
. Defaults to all scenarios available.- showrange
logical. Plot a shaded region indicating the minimum and maximum of the selected ensemble of GCM simulations for each selected scenario.
- yfit
logical. Set the range of the y axis to the range of the visible data. If
FALSE
the y axis is the range of all values ofvar1
(andvar2
if applicable) in the input table defined byX
.- cex
Numeric. The magnification factor for text size. Default is 1.
- mar
A numerical vector of length 4, giving the margin sizes in number of lines of text: c(bottom, left, top, right). The default is c(3,3,0.1,4).
- showmean
logical. Plot the ensemble mean time series. Multi-model ensemble means are calculated from the mean of simulations for each model.
- compile
logical. Compile multiple global climate models into a multi-model ensemble. If
FALSE
the single-model ensembles are plotted individually.- simplify
logical. Simplify the ensemble range and mean using a smoothing spline.
- refline
logical. Plot the 1961-1990 reference period mean for the selected var and extend this line to the year 2100 as a visual reference.
- refline.obs
logical. Plot the 1961-1990 reference period mean for the observational data. This should be the same as the reference line for the GCM time series.
- pal
character. color palette. Options are "scenario", for use when comparing scenarios, and "gcms", for use when comparing GCMs.
- label.endyear
logical. Add a label of the final year of the observational time series.
- endlabel
character. Add a label to the end of each simulated time series. Options are "change", to indicate the change in year 2100 relative to the 1961-1990 baseline, or "gcms" to indicate the global climate model.
- yearmarkers
logical. Add white points to the observational time series as a visual aid.
- yearlines
logical. Add vertical lines on every fifth year as a visual reference
- legend_pos
character. Position of the legend. Viable options are c("bottomright", "bottomleft", "topleft", and "topright").
Details
The input table X
provides climate data for a single location or the average of multiple locations.
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()
without needing to generate the inputs each time.
Some combinations of var1
and var2
are not compatible or meaningful.
Examples of meaningful combinations are winter vs summer values of the same climate var or minimum vs.
maximum temperatures.
Downloads of GCM time series take a long time. The plot_timeSeries_input()
function can take >1hr
to run for the first time it is called for a location. We are looking into ways to speed this up, but until then
we recommend users dedicate some time to run this function in background. 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")
# compare observational time series
plot_timeSeries(my_data, var1 = "Tmin_sm", obs_ts_dataset = c("cru.gpcc", "climatena"))
# compare mean daily minimum and maximum temperatures
plot_timeSeries(my_data, var1 = "Tmin_sm", var2 = "Tmax_sm")
# compare summer and winter temperatures (without simplifying the ensemble range)
plot_timeSeries(my_data, var1 = "Tmax_sm", var2 = "Tmax_wt", simplify = FALSE)
# compare global climate models
plot_timeSeries(my_data, gcms = list_gcms()[c(7,13)], pal = "gcms", ssps = list_ssps()[2], showmean = FALSE, compile = FALSE, simplify = FALSE, endlabel = "gcms", mar=c(3,3,0.1,6), showObserved = FALSE)
# export plot to a temporary directory, including a title
figDir <- tempdir()
png(
filename = file.path(figDir, "plot_test.png"), type = "cairo", units = "in",
width = 6, height = 5, pointsize = 10, res = 300
)
plot_timeSeries(my_data, var1 = "Tmin_sm", mar=c(3,3,2,4))
title("Historical and projected summer night-time warming in the Bulkley Valley, BC")
dev.off()
}