plot_models_and_climate_data: Plot Climatological Time Series with Model Results

View source: R/plot-series.R

plot_models_and_climate_dataR Documentation

Plot Climatological Time Series with Model Results

Description

Readily displays annotated climate time series (usually temperature) on a common plot along with CMIP Phase 3 or Phase 5 model projections.

Usage

plot_models_and_climate_data(
  instrumental,
  models,
  series = NULL,
  scenario = NULL,
  start = 1880,
  end = NULL,
  ma = NULL,
  ma_i = ma,
  baseline = NULL,
  yearly = FALSE,
  ma_sides = 1L,
  ylim = c(-1, 1),
  bg = scales::alpha("gray", 0.1),
  scenario_text = "Scenario Realizations",
  center_fun = "mean",
  smooth_center = FALSE,
  envelope_coverage = 0.95,
  envelope_type = c("quantiles", "range", "normal"),
  plot_envelope = TRUE,
  smooth_envelope = TRUE,
  smooth_span = NULL,
  unit = NULL,
  col_m = NULL,
  col_m_mean = NULL,
  alpha_envelope = 0.1,
  envelope_text = "model coverage",
  legend... = list(),
  plot_i... = list(),
  col_i_fun = colorspace::rainbow_hcl,
  col_i_fun... = list(l = 65),
  alpha_i = 0.9,
  conf_int_i = FALSE,
  ci_alpha_i = 0.3,
  make_standardized_plot_filename... = list(),
  start_callback = NULL,
  sign = TRUE,
  sign_callback = rlang::expr(text(graphics::par("usr")[2], graphics::par("usr")[3],
    labels = "@priscian", adj = c(1, -0.5))),
  end_callback = NULL,
  save_png = FALSE,
  save_png_dir,
  png... = list(),
  ...
)

Arguments

instrumental

An instrumental-temperature dataset (down)loaded by function get_climate_data.

models

A modeled-temperature dataset loaded by function get_models_data.

series

A vector containing the column names of the instrumental temperature series to be plotted. If NULL, all the series in instrumental are plotted; if NA, plotting of the instrumental temperature series is suppressed.

scenario

A character vector corresponding to specific radiative-forcing pathways represented in subsets of the modeled temperature data. If NULL, all pathways are included. The options for CMIP3+ data are any subset of c("20C3M", "SRES B1", "SRES A1B", "SRES A2"); options for CMIP5 include any subset of c("RCP 2.6", "RCP 4.5", "RCP 6.0", "RCP 8.5").

start, end

Integer values of the starting and ending years of the plot, respectively; if either is given as NULL, the minimum or maximum date in models is used instead.

ma, ma_i

The sizes in months of the moving averages for smoothing the modeled and instrumental temperature series, respectively. If ma_i is not given, its value is the same as ma. A value of NULL means that no moving-average smoothing is done.

baseline

An integer year or, more typically, range of years on which the temperature anomalies will be centered. If NULL, no baseline centering is done, and the "baseline" attribute of models (if it exists) is used instead.

ylim

The y limits of the plot, i.e. the plot range of the temperature anomalies.

center_fun

The function used to calculate the central tendency of the model runs at each time point; the default of "mean" is usually sufficient.

smooth_center

Logical; if TRUE, LOESS-smooth the plot of the models' central tendency.

envelope_coverage

Sets the "coverage" of the models-envelope calculated as envelope_type; e.g. for envelope_coverage = 0.95 and envelope_type = "range", the envelope covers 95% of the difference between the maximum model value and the minimum, for each time point.

envelope_type

A character vector matching one of several methods (e.g. "quantiles", "range", "normal") for calculating the envelope_coverage envelope characterizing the spread of the models. The default value is "quantiles".

plot_envelope

Logical; if TRUE, plot the envelope of 95% model coverage.

smooth_envelope

Logical; if TRUE, LOESS-smooth the plot of the envelope of 95% model coverage.

col_m

A vector of colors for each model scenario. If NULL (the default), a series of grays is used; if a single value, vary_brightness is called with that value to get a range of colors based on it.

col_m_mean

The color of the central-tendency line for all the included model runs. The default of NULL causes a darkish gray to be used; ; if a single value, vary_brightness is called with that value to get a range of colors based on it.

alpha_envelope

Sets the color transparency of the model envelopes to a new level in [0, 1]. If alpha_envelope is NA, existing alpha values are preserved. If alpha_envelope is NULL, the model envelopes are not color-filled.

legend...

Takes a list of arguments to be passed to function legend, possibly overriding default values.

plot_i...

Takes a list of arguments to be passed to function plot.zoo, possibly overriding default values, for the instrumental series.

col_i_fun

A color palette for series is generated from the function value of col_i_fun. Note that the colors created for the instrumental series here can be entirely overridden by including a col argument in plot_i...; or, better, by specifying a function like function(...) "red" (which also affects the legend).

col_i_fun...

Takes a list of arguments to be passed to function col_i_fun, possibly overriding default values. E.g. to get colors from function brewer.pal, use col_i_fun = RColorBrewer::brewer.pal and col_i_fun... = list(name="Paired").

alpha_i

Sets the color transparency of the temperature series to a new level in [0, 1]. If alpha is NA, existing alpha values are preserved.

conf_int_i

Logical; if TRUE, plot 95% confidence intervals for those series with CI data.

ci_alpha_i

Sets the color transparency of the temperature-series CIs to a new level in [0, 1]. If ci_alpha_i is NA, existing alpha values are preserved.

...

Passed to plot.zoo for the models.

omit_series

A vector containing the column names of the climate series NOT to be plotted if series = NULL. This has been added to leave out the Keeling Curve data, but it could later include other regularly updated time-series data, related to climate, which wouldn't normally be plotted in the same window.

Examples

## Not run: 
inst <- get_climate_data(download=FALSE, baseline=TRUE)
cmip5 <- get_models_data(ensemble="cmip5", baseline=1981:2010, save=FALSE) # Load CMIP5 data from combined R data set.

## Plot all CMIP5 scenario realizations, no instrumental temperature series.
plot_models_and_climate_data(inst, cmip5, series=NA, scenario=NULL, start=1950, end=2100, ma=12, baseline=NULL,
  center_fun="mean", smooth_envelope=TRUE, col_m_mean="red", ylim=c(-1, 5))

## CMIP5 RCP 4.5 scenario realizations compared to the GISTEMP land+SST series.
series <- c("GISTEMP Global")
plot_models_and_climate_data(inst, cmip5, series=series, scenario="RCP 4.5", start=1880, end=2020, ma=12, ma_i=12,
  baseline=1951:1980, center_fun="mean", smooth_envelope=TRUE, envelope_type="quantiles", envelope_text="quantiles",
  ylim=c(-1.0, 1.5), conf_int_i=FALSE, col_i_fun="topo.colors", col_i_fun...=list())

## Same plot, different baseline:
plot_models_and_climate_data(inst, cmip5, series=series, scenario="RCP 4.5", start=1880, end=2020, ma=12, ma_i=12,
  baseline=1981:2010, center_fun="mean", smooth_envelope=TRUE, envelope_type="quantiles", envelope_text="quantiles",
  ylim=c(-1.5, 1.0), conf_int_i=TRUE, col_i_fun=function(...) "red")

## End(Not run)

priscian/climeseries documentation built on March 9, 2024, 9:24 p.m.