Skip to content

Creating multi grids

miturbide edited this page Oct 6, 2016 · 6 revisions

Creating a multigrid from existing grids

An object formed by two or more variables sharing a common spatial grid and time span is termed a multigrid. The constructor makeMultiGrid allows creating a multigrid from a collection of grids. The spatial and temporal consistency of the different grids must be checked by the user, which can resort to the interpGrid and getGrid methods to this aim. Otherwise, the function will stop raising an error.

data(NCEP_Iberia_tas)
data(NCEP_Iberia_tp)
example.mg <- makeMultiGrid(NCEP_Iberia_tas, NCEP_Iberia_tp)

Note the behaviour of plotMeanGrid when a multigrid is given as input:

plotMeanGrid(example.mg)

For a more sophisticated plotting of grids in transformeR, functions plotClimatology and climatology are used (see section 2.2.Grid aggregation).

tas.clim <- climatology(NCEP_Iberia_tas, list(FUN = "mean", na.rm = T))
tp.clim <- climatology(NCEP_Iberia_tp, list(FUN = "mean", na.rm = T))
example.mg.clim <- makeMultiGrid(tas.clim, tp.clim)
plotClimatology(example.mg.clim, backdrop.theme = "countries")

The data structure of a multigrid incorporates a new dimension in the Data array, labelled var, along which the different variables composing the multigrid are stacked:

str(example.mg$Data)
 
## num [1:2, 1:903, 1:7, 1:9] 16.1 1 18.6 1 19.5 ...
## - attr(*, "dimensions")= chr [1:4] "var" "time" "lat" "lon"

The opposite operation (i.e. extracting a variable from a multigrid), can be done with function subsetGrid (Go to section 2.3. Grid subsetting for more examples of data subsetting).

tas <- subsetGrid(example.mg, var = "tas")

<-- Home page of the Wiki