getVarNames: Get grid variable names

View source: R/helpers.R

getVarNamesR Documentation

Get grid variable names

Description

Get the names of the variables of a (multi)grid

Usage

getVarNames(grid, type = c("short", "long"), append.level = TRUE)

Arguments

grid

A grid or station data

type

Character. Should either the "short" (default) or the "long" variable name(s) be returned?. See Details.

append.level

Append the vertical level to the short name string?. Default to TRUE, ignored when type = "long"). See details.

Details

About short names

Note that for variables with vertical levels, if the option append.level is set to TRUE (the default), the function will "construct" the shortname following the climate4R convention, that defines the code of the variable plus its vertical level, separated by a “@” symbol. This way, when querying grid variable names, the behaviour of getVarNames is different than directly accessing the varName element of the grid structure as in, e.g.: grid$Variable$varName. Using getVarNames with append.level = TRUE is recommended in most applications when the variable string is needed.

About long names

The long name is an optional attribute of a grid (not so the short name), and it is sometimes undefined (particularly in station datasets). In this case, the function returns NULL.

Value

A character vector with the variable name(s) in the indicated type format.

Author(s)

J Bedia

See Also

Other get.helpers: get2DmatCoordinates(), getCoordinates(), getDim(), getGrid(), getGridProj(), getGridVerticalLevels(), getRefDates(), getSeason(), getShape(), getStationID(), getWT(), getYearsAsINDEX(), setGridProj(), typeofGrid(), which.leap()

Examples

 
require(climate4R.datasets)
data("CFS_Iberia_pr")
getVarNames(CFS_Iberia_pr)
grid <- CFS_Iberia_pr
getVarNames(CFS_Iberia_pr, "long")
## Example with a multigrid
data(NCEP_Iberia_hus850, NCEP_Iberia_psl, NCEP_Iberia_ta850)
mg <- makeMultiGrid(NCEP_Iberia_hus850, NCEP_Iberia_psl, NCEP_Iberia_ta850)
getVarNames(mg)
# The level can be removed id needed:
getVarNames(mg, append.level = FALSE)
data("CFS_Iberia_tas", "CFS_Iberia_pr")
mg <- makeMultiGrid(CFS_Iberia_tas, CFS_Iberia_pr)
getVarNames(mg)
getVarNames(mg, "long")
## Example with station data
data("VALUE_Iberia_tas")
## The long name is an optional attribute, and might be undefined:
getVarNames(VALUE_Iberia_tas, "long")


SantanderMetGroup/transformeR documentation built on Aug. 29, 2024, 6:42 a.m.