Compare climate data between a reference and target period. This can be useful to understand how projected future climate differs from historical conditions. The `compare_periods` function generates climate summary statistics for each period, and computes the difference in values between the target and reference period. Uses the output of `cftdata()` as an input.

compare_periods(
  df,
  agg_fun = "mean",
  var1 = "tasmax",
  var2 = "pr",
  months1 = 1:12,
  months2 = 1:12,
  target_period = c(2080, 2099),
  reference_period = c(1990, 2019),
  scenarios = c("rcp45", "rcp85")
)

Arguments

df

A data frame output from a `cft_df()` run. (data.frame)

agg_fun

The aggregating function to applied to the model variables (e.g., "mean"). (character)

var1

The x-axis variable, see cft::argument_reference (e.g., "pr"). (character).

var2

The y-axis variable, see cft::argument_reference (e.g., "tasmax"). character)

months1

The months of the year with which to include in the aggregation of variable 1 (e.g., 5:7 for May, June, and July. (int vector)

months2

The months of the year with which to include in the aggregation of variable 2 (e.g., 5:7 for May, June, and July. (int vector)

target_period

The time period within which to apply the aggreating value function (e.g., c(2050, 2075)). (vector)

reference_period

The time period with which to compare the target period (e.g., c(1980, 2010)). (vector)

scenarios

A vector of representative concetration pathway keys (e.g., c("rcp45", rcp85")). (vector)

Value

A data.frame with columns containing `target_summary` and `reference_summary` values, and their difference (the column `diff_summary`).