compute.indices.for.stripe: Compute Climdex indices for a subset / stripe

View source: R/compute.indices.for.stripe.R

compute.indices.for.stripeR Documentation

Compute Climdex indices for a subset / stripe

Description

Compute Climdex indices for a subset / stripe

Usage

compute.indices.for.stripe(
  subset,
  metadata.config,
  cdx.funcs,
  ts,
  base.range,
  dim.axes,
  v.f.idx,
  variable.name.map,
  src.units,
  t.f.idx,
  thresholds.name.map,
  projection = NULL,
  f,
  thresholds.netcdf
)

Arguments

subset

The subset to use.

cdx.funcs

The functions to be applied to the data, as created by get.climdex.functions.

ts

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

base.range

The base range; a vector of two numeric years.

dim.axes

The dimension axes for the input data.

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.

src.units

The source units to convert data from.

t.f.idx

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

thresholds.name.map

A mapping from standardized names (tx10thresh, tn90thresh, etc) to NetCDF variable names.

projection

A proj4 string representing the projection the data is in.

f

A list of objects of type ncdf4, consisting of the open input files. If missing, will be pulled from the global namespace.

thresholds.netcdf

A list of objects of type ncdf4, consisting of the open threshold files. If missing, will be pulled from the global namespace.

dest.units

The destination units to convert to.

Details

Given a subset, a set of Climdex functions (as created by get.climdex.functions), and ancillary data, load and convert data, create a climdexInput object for each point, run all of the functions in cdx.funcs on that data, and return the result.

Note

This function relies on an object named 'f' and containing the opened NetCDF files being part of the global namespace.

Examples


## Define mappings and filenames.
author.data <- list(institution="Looney Bin", institution_id="LBC")
input.files <- c("pr_NAM44_CanRCM4_ERAINT_r1i1p1_1989-2009.nc")
variable.name.map <- c(tmax="tasmax", tmin="tasmin", prec="pr")

## Open files, etc.
cdx.funcs <- get.climdex.functions(get.climdex.variable.list("tmax"))
f <- lapply(input.files, ncdf4::nc_open)
f.meta <- create.file.metadata(f, variable.name.map)
climdex.var.list <- get.climdex.variable.list(names(f.meta$v.f.idx), "all", NULL)
cdx.meta <- get.climdex.variable.metadata(climdex.var.list, input.files[1])

## Compute indices for stripe
cdx <- compute.indices.for.stripe(list(Y=1), cdx.funcs, f.meta$ts, c(1981, 1990), f.meta$dim.axes,
                           f.meta$v.f.idx, variable.name.map, f.meta$src.units, f.meta$dest.units,
                           t.f.idx, NULL, f=f, thresholds.netcdf=NULL)



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