create.thresholds.file: Creates Climdex thresholds output file.

View source: R/create.thresholds.file.R

create.thresholds.fileR Documentation

Creates Climdex thresholds output file.

Description

Creates Climdex thresholds output file.

Usage

create.thresholds.file(
  thresholds.file,
  f,
  ts,
  v.f.idx,
  variable.name.map,
  base.range,
  dim.size,
  dim.axes,
  threshold.dat,
  author.data
)

Arguments

thresholds.file

The filename to be used for the thresholds file.

f

The file(s) being used as sources for metadata.

ts

The associated time data, as created by nc.get.time.series.

v.f.idx

A mapping from variables to files, as created by get.var.file.idx.

variable.name.map

A mapping from standardized names (tmax, tmin, prec) to NetCDF variable names.

base.range

The base range; a vector of two numeric years.

dim.size

Dimension sizes for the input.

dim.axes

Dimension axes for the input.

threshold.dat

Threshold metadata, as provided by get.thresholds.metadata.

author.data

A vector containing named elements describing the author; see create.indices.from.files.

Details

This function creates a file suitable for outputting thresholds to, with all variables that can be created with the input data present in the file.

Value

An object of class ncdf4.

Examples


## Establish basic inputs.
author.data <- list(institution="Looney Bin", institution_id="LBC")
input.files <- c("pr_NAM44_CanRCM4_ERAINT_r1i1p1_1989-2009.nc")

## Prepare derived inputs.
f <- lapply(input.files, ncdf4::nc_open)
variable.name.map <- c(tmax="tasmax", tmin="tasmin", prec="pr")
f.meta <- create.file.metadata(f, variable.name.map)
threshold.dat <- get.thresholds.metadata(names(f.meta$v.f.idx))

## Create output file
thresh.file <- create.thresholds.file("thresh.nc", f, f.meta$ts, f.meta$v.f.idx, variable.name.map,
                                      c(1981,1990), f.meta$dim.size, f.meta$dim.axes,
                                      threshold.dat, author.data)



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