get_models_data: Get CMIP Phase 3 or 5 Data from Stored Data

View source: R/models.R

get_models_dataR Documentation

Get CMIP Phase 3 or 5 Data from Stored Data

Description

Retrieves temperature data of CMIP3 or CMIP5 models from files of individual model runs, with or without saving a combined data set, or from a combined R data set.

Usage

get_models_data(
  ensemble = c("cmip3", "cmip5"),
  baseline = NULL,
  save = FALSE,
  data_dir,
  subdir = NULL,
  cmip3_raw = FALSE,
  center_fun = "mean",
  convert_fun = kelvin_to_celsius
)

Arguments

ensemble

One of "cmip3" or "cmip5" coresponding to the appropriate IPCC model ensemble.

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 string "raw_" will be appended to the ensemble string before the model data is saved or loaded.

save

If NULL, retrieve model data without saving it; if TRUE, retrieve model data and save it as a combined R data set; if FALSE, load model data from a combined R data set. The default is FALSE.

subdir

Corresponds to a subdirectory containing a specific set of model runs, with the CMIP3+ default "all members" almost always being preferred; likewise the CMIP5 default "all models".

cmip3_raw

Logical. The CMIP3+ "all models" data contains SRES A2 and SRES B1 scenario runs that typically begin in Jan. 2001, so they need to be centered differently from SRES B1; also, the 20C3M scenario runs typically end in Dec. 2000, which needs to be accounted for. If the ensemble = "cmip3" and cmip3_raw = FALSE, then these issues are handled automatically in the returned (NOT saved) data set.

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. It is used here specifically to line up some CMIP3+ scenario runs on a common baseline if ensemble = "cmip3" and cmip3_raw = FALSE, and should match the argument given to the parameter of the same name in a call to plot_models_and_climate_data, if plotting is done.

Value

A data frame of CMIP model runs. (Obivously I should give more detail here.)

Examples

## Not run: 
## The most common uses:
cmip5 <- get_models_data(ensemble="cmip5", baseline=1981:2010, save=FALSE)
cmip3 <- get_models_data(baseline=1981:2010, save=FALSE)

## Other common uses:
cmip3 <- get_models_data(baseline=1981:2010, save=NULL) # Retrieve CMIP3 data without saving combined data set.
cmip3 <- get_models_data(baseline=1981:2010, save=TRUE) # Retrieve CMIP3 data and save as combined data set.
cmip3 <- get_models_data(baseline=1981:2010, save=FALSE) # Load CMIP3 data from combined R data set.
cmip3 <- get_models_data(baseline=NULL, save=TRUE) # Retrieve "raw" CMIP3 data and save as combined data set.
cmip3 <- get_models_data(baseline=NULL, save=FALSE) # Load "raw" CMIP3 data from combined R data set.
cmip5 <- get_models_data(ensemble="cmip5", baseline=1981:2010, save=TRUE, subdir="all members") # Save CMIP5 data from "all members" data set.
cmip5 <- get_models_data(ensemble="cmip5", baseline=1981:2010, save=TRUE, subdir="1 member per model") # Save CMIP5 data from "1 member per model" data set.

## Copy this to the R command line to redo all the data:
cmip3 <- get_models_data(baseline=1981:2010, save=TRUE)
cmip3 <- get_models_data(baseline=NULL, save=TRUE)
cmip3 <- get_models_data(baseline=1981:2010, save=TRUE, subdir="all models")
cmip3 <- get_models_data(baseline=NULL, save=TRUE, subdir="all models")
cmip3 <- get_models_data(baseline=1981:2010, save=TRUE, subdir="multi-model mean")
cmip3 <- get_models_data(baseline=NULL, save=TRUE, subdir="multi-model mean")
cmip5 <- get_models_data(ensemble="cmip5", baseline=1981:2010, save=TRUE)
cmip5 <- get_models_data(ensemble="cmip5", baseline=NULL, save=TRUE)
cmip5 <- get_models_data(ensemble="cmip5", baseline=1981:2010, save=TRUE, subdir="1 member per model")
cmip5 <- get_models_data(ensemble="cmip5", baseline=NULL, save=TRUE, subdir="1 member per model")
cmip5 <- get_models_data(ensemble="cmip5", baseline=1981:2010, save=TRUE, subdir="all members")
cmip5 <- get_models_data(ensemble="cmip5", baseline=NULL, save=TRUE, subdir="all members")
cmip5 <- create_cmip5_tas_tos_data(save_to_package=TRUE)

## Create "meta" files to match up model runs with emissions scenarios. In each model-set directory, double-click on file "cmip(3|5).RData" and run the following code:
x <- "cmip3" # Or:
x <- "cmip5"
write.csv(eval(substitute(data.frame(model=names(attr(cmip, "scenario")), scenario=attr(cmip, "scenario")),
  list(cmip=as.symbol(x)))), file=paste(x, "_meta.csv", sep=""), row.names=FALSE)

## End(Not run)


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