redim: Complete missing dimensions of Grid objects

View source: R/redim.R

redimR Documentation

Complete missing dimensions of Grid objects

Description

Add missing dimensions to the 'Data' array as singletons. For internal usage mainly.

Usage

redim(
  grid,
  member = TRUE,
  runtime = FALSE,
  var = FALSE,
  time = TRUE,
  loc = FALSE,
  drop = FALSE
)

Arguments

member

logical. Add 'member' dimension (default = TRUE)

runtime

logical. Add 'runtime' dimension (default = FALSE)

var

logical. Add 'var' dimension (default = FALSE)

loc

logical. Only if obj is a stations dataset. If TRUE, the "loc" dimension is not replaced by fake "lat" and "lon" dimensions (default is FALSE).

drop

logical. Drop dimensions of length = 1 (default = FALSE)

obj

A regular or irregular (e.g. station data) grid

Details

The function does not handle multigrids (i.e. "var" dimension). Thus, multigrids need to be subsetted along "var" prior to redimensioning via subsetGrid.

Value

The same object with all the dimensions (i.e. member, time, loc)

Author(s)

M. Iturbide, J. Bedia

See Also

Other internal.helpers: array3Dto2Dmat(), array3Dto2Dmat.stations(), bindGrid.member(), bindGrid.spatial(), bindGrid.time(), grid3Dto2Dmatrix(), mat2Dto3Darray.stations(), sortDim.spatial(), sortDim.time()

Examples


require(climate4R.datasets)
data("EOBS_Iberia_tas")
getShape(EOBS_Iberia_tas)
a <- redim(EOBS_Iberia_tas)
getShape(a)
b <- redim(EOBS_Iberia_tas, var = TRUE)
getShape(b)
# This one is probably never needed, but for illustration:
y <- redim(EOBS_Iberia_tas, member = FALSE, var = TRUE)
getShape(y)
# 'drop = TRUE' performs the reverse operation:
z <- redim(b, drop = TRUE)
getShape(z)

# Example with station data
data("VALUE_Iberia_pr")
getShape(VALUE_Iberia_pr)
# By default, the internal data array is converted to the time.lat-lon structure.
# This is a conveninet behaviour for internal usage:
getShape(redim(VALUE_Iberia_pr, member = TRUE))
# Use the argument 'loc=TRUE' to avoid this behaviour:
getShape(redim(VALUE_Iberia_pr, member = TRUE, loc = TRUE))


SantanderMetGroup/transformeR documentation built on Nov. 25, 2024, 1:25 p.m.