setGridUnits: Set grid units

View source: R/helpers.R

setGridUnitsR Documentation

Set grid units

Description

Set the "units" attribute of a grid

Usage

setGridUnits(grid, unit.string, var = NULL)

Arguments

grid

An input grid

unit.string

Character string: a udunits-parseable character string vector. See details.

var

In case of multigrids, the names of the variables whose units attribute is to be updated (see examples).

Details

The length of the unit.string vector should match the number of variables within the grid (in case of multiGrids), i.e., that of getVarNames(grid) or the length of var, in case the latter is used.

Value

Retunrs (invisible) the same input grid with the new "units" attribute in "$Variable" list element.

Author(s)

J Bedia

See Also

Other get.helpers unit.helpers: getGridUnits()

Examples

 
require(climate4R.datasets)
data(NCEP_Iberia_hus850, NCEP_Iberia_psl, NCEP_Iberia_ta850)
getGridUnits(NCEP_Iberia_hus850)
getGridUnits(NCEP_Iberia_psl)
mf <- makeMultiGrid(NCEP_Iberia_hus850, NCEP_Iberia_psl, NCEP_Iberia_ta850)
getGridUnits(mf)
mf2 <- setGridUnits(mf, unit.string = c("1", "Pa", "Kelvin"))
getGridUnits(mf2)
# Arbitrary subsets of variables within the multigrid can be updated:
getVarNames(mf)
mf3 <- setGridUnits(mf, unit.string = c("1", "Pa"), var = c("hus@850", "psl"))
getGridUnits(mf3)


SantanderMetGroup/transformeR documentation built on Oct. 28, 2023, 5:26 a.m.