Skip to content

Grid subsetting

miturbide edited this page Oct 6, 2016 · 10 revisions

Function subsetGrid in transformeR allows to make subsets of grid data, hence, the needed data can be loaded at once and then make subsets of the geographic domain or the time period creating several objects from the same loaded object.

Time period:

data(NCEP_Iberia_tas)
range(NCEP_Iberia_tas$Dates)

## [1] "1990-12-01 GMT" "2000-03-01 GMT"
sub.time <- subsetGrid(NCEP_Iberia_tas, years = 1995:1998)
range(sub.time$Dates)

## [1] "1994-12-01 GMT" "1998-03-01 GMT"

Geographic domain:

data(NCEP_Iberia_tas)
plotClimatology(climatology(NCEP_Iberia_tas, clim.fun = list(FUN = "mean", na.rm = T)),
                backdrop.theme = "countries", 
                scales = list(draw = T))

sub.geo <- subsetGrid(NCEP_Iberia_tas, lonLim = c(-1, 3), latLim = c(39,43))
plotClimatology(climatology(sub.geo, clim.fun = list(FUN = "mean", na.rm = T)),
                backdrop.theme = "countries", 
                scales = list(draw = T))

subsetGrid can be applied to a multigrid:

data(NCEP_Iberia_tp)

multi <- makeMultiGrid(NCEP_Iberia_tas, NCEP_Iberia_tp)

plotMeanGrid(multi)

sub.geo.multi <- subsetGrid(multi, lonLim = c(-1, 3), latLim = c(39,43))
plotMeanGrid(sub.geo.multi)

Grid from a multigrid:

sub.Grid <- subsetGrid(multi, var = "tp")
plotClimatology(climatology(sub.Grid, list(FUN = "mean", na.rm = T)), 
                backdrop.theme = "countries", 
                main = attr(sub.Grid$Variable, "longname"))

Members:

If the data is multimember, function subsetGrid can also be applied to select some members.

data(S4_Iberia_tas)
sub.mem <- subsetGrid(S4_Iberia_tas, members = c(1, 3, 5,))
plotClimatology(climatology(sub.mem, list(FUN = "mean", na.rm = T))) 


<-- Home page of the Wiki