create.indices.from.files: Create Climdex indices from NetCDF input files.

View source: R/create.indices.from.files.R

create.indices.from.filesR Documentation

Create Climdex indices from NetCDF input files.

Description

Create Climdex indices from NetCDF input files.

Usage

create.indices.from.files(
  input.files,
  out.dir,
  output.filename.template,
  author.data,
  climdex.vars.subset = NULL,
  climdex.time.resolution = c("all", "annual", "monthly", "seasonal", "halfyear"),
  axis.to.split.on = "Y",
  fclimdex.compatible = TRUE,
  base.range = c(1961, 1990),
  parallel = 4,
  verbose = FALSE,
  thresholds.files = NULL,
  max.vals.millions,
  cluster.type = "SOCK"
)

Arguments

input.files

A list of filenames of NetCDF files to be used as input. A NetCDF file may contain one or more variables.

out.dir

The directory to put the output files in.

output.filename.template

The output filename to be used as a template, which must follow the CMIP5 file naming conventions.

author.data

Data describing the author; a character vector with 0 or more of the following named values:

institution

The institution generating the data.

institution_id

An abbreviation for the institution generating the data.

indices_archive

The URL the data is published at, if applicable.

contact

The email address or contact info for the author.

references

What to reference when citing this work.

climdex.vars.subset

A character vector of lower-case names of Climdex indices to calculate (eg: tr, fd, rx5day). See the list of 27 indices in the References section.

climdex.time.resolution

The time resolution to compute indices at; one of "all" (both monthly and annual), "annual" (only annual), or "monthly" (only monthly).

axis.to.split.on

The axis to split up the data on for parallel / incremental processing.

fclimdex.compatible

Whether the thresholds should be created to match fclimdex thresholds; affects padding at the ends of the base period.

base.range

Vector of two numeric years specifying the start and end years.

parallel

The number of parallel processing threads, or FALSE if no parallel processing is desired.

verbose

Whether to be chatty.

thresholds.files

A character vector of files containing thresholds to be used.

max.vals.millions

The number of data values to process at one time (length of time dim * number of values * number of variables).

cluster.type

The cluster type, as used by the snow library.

Details

This function computes Climdex indices from NetCDF input files, writing out one file per variable named like the template.filename, which must follow the CMIP5 file naming conventions (this is a deficiency which will be corrected in later versions).

The indices to be calculated can be specified; if not, they will be determined by data availability. Thresholds can be supplied (via thresholds.files) or, if there is data within the base period, calculated and used as part of the process. Note that in-base thresholds are separate from out-of-base thresholds; this is covered in more detail in the help for the climind package.

The metadata is stored in JSON files that are included with the pacakge. Right now, the metadata relevant to EOBS is used by default. To switch to another set of metadata, use the metadata.id global option:

options(metadata.id = 'eobs')

Note that currently only EOBS metadata is available (metadata.id = 'eobs').

Note

NetCDF input files may contain one or more variables, named as per variable.name.map in the json config file. The code will search the files for the named variables. The same is true of thresholds files; one file may be supplied, or multiple files may be supplied, via the thresholds.files argument; and the name mapping may be supplied via the thresholds.name.map argument.

References

http://etccdi.pacificclimate.org/list_27_indices.shtml

Examples

## Not run: 
## Prepare input data and calculate indices for a single file
## with a single thread (no parallelism).
input.files <- c("pr_NAM44_CanRCM4_ERAINT_r1i1p1_1989-2009.nc")
author.data <- list(institution="Looney Bin", institution_id="LBC")
create.indices.from.files(input.files, "out_dir/", input.files[1], author.data,
                          base.range=c(1991, 2000), parallel=FALSE)

## Prepare input data and calculate indices for two files
## in parallel given thresholds.
input.files <- c("pr_NAM44_CanRCM4_ERAINT_r1i1p1_1989-2009.nc",
                 "tasmax_NAM44_CanRCM4_ERAINT_r1i1p1_1989-2009.nc")
author.data <- list(institution="Looney Bin", institution_id="LBC")
create.indices.from.files(input.files, "out_dir/", input.files[1], author.data,
                          base.range=c(1991, 2000), parallel=8, thresholds.files="thresh.nc")

## End(Not run)


ECA-D/ecad_indices_grid documentation built on Nov. 23, 2022, 6:04 a.m.