cf_quadrant: Calculate climate futures based on their quadrant

Description Usage Arguments Value Examples

View source: R/cf_quadrant.R

Description

Designates climate futures of "Warm Wet", "Warm Dry", "Hot Wet", "Hot Dry" and "Central" and calculates mean values for each GCM. Will additionally calculate the most extreme of each quadrant if calculation method is "corner". Calculates summary of threshold values based off of selected summarization parameter and calculation method.

Usage

1
2
3
4
5
6
7
8
9
cf_quadrant(
  SiteID = "unnamed_site",
  data = NULL,
  future_year = 2040,
  past_years = c(1950, 2000),
  method = "quadrant",
  summarize_by = "year",
  directory = tempdir()
)

Arguments

SiteID

chosen name to use in file names, attributes, and directories. (character)

data

Default data set to use for .csv creation. Must be created prior to running function. Follow vignette for example data set creation (data frame)

future_year

year to center changes from historical data around. Defaults to 2040 (numeric)

past_years

years to base past data off of. Cannot be any earlier than 1950. Must be written as c(past_start, past_end). Defaults to 1950-2000 (numeric)

method

method for calculating resulting .csv. Options "quadrant" and "corner". "quadrant" will return a data frame in which all models are labeled in their respective quadrants "hot wet" "hot dry" "warm wet" "warm dry" and "central "corner" will do the same, but additionally return the model that represents the most extreme scenario in each quadrant. Defaults to quadrant.

summarize_by

how to summarize the data, options are "month", "season", "year". Defaults to year.

directory

where to save files to. Per CRAN guidelines, this defaults to a temporary directory and files created will be lost after R session ends. Specify a path to retain files.

Value

Two (2) .csv files: 1.SiteID_future_means_x.csv - future means of all models calculated on central year 2. SiteID_y_summary_x.csv - Summary of threshold values calculated based on method (x) and summary metric (y). Means are taken based on month/season/year and either all models in a quadrant for quadrant method, or most extreme model in each quadrant for corner method x: c = corner, q = quadrant y: month, season or year

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
## Not run: 
# Generate sample data

data <- data.frame(
date = sample(seq(as.Date('1950/01/01'), as.Date('2099/12/31'), by="day"), 1000),
yr = rep(c(1980, 2040, 1980, 2040, 1980, 2040, 1980, 2040, 1980, 2040, 1980, 2040, 1980,
           2040, 1980, 2040, 1980, 2040, 1980, 2040), each = 50),
gcm = rep(c("bcc-csm1-1.rcp45", "BNU-ESM.rcp45", "CanESM2.rcp85", "CCSM4.rcp45",
            "CSIRO-Mk3-6-0.rcp45"), each = 200),
precip = rnorm(1000),
tmin = rnorm(1000),
tmax = rnorm(1000),
rhmax = rnorm(1000),
rhmin = rnorm(1000),
tavg = rnorm(1000),
heat_index = rnorm(1000),
heat_index_ec = rnorm(1000),
heat_index_dan = rnorm(1000),
temp_over_95_pctl =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
temp_over_99_pctl =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
temp_over_95_pctl_length =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000,
                                              replace = TRUE)),
temp_under_freeze =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
temp_under_freeze_length =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000,
                                              replace = TRUE)),
temp_under_5_pctl =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
no_precip  =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
no_precip_length =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
precip_95_pctl =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
precip_99_pctl =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
precip_moderate =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
precip_heavy =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
freeze_thaw =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
gdd =  as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
gdd_count = rnorm(1000),
not_gdd_count = rnorm(1000),
frost = as.logical(sample(x = c("TRUE","FALSE"), size = 1000, replace = TRUE)),
grow_length = rnorm(1000),
units = rep("imperial", each = 1000)
)

cf_quadrant("SCBL", data = df, future_year = 2040, past_years = c(1950, 2000),
method = "corner", summarize_by = "year")

## End(Not run)

nationalparkservice/rcf documentation built on Dec. 22, 2021, 12:01 a.m.