Description Usage Arguments Details Value Author(s) See Also Examples

Create a new grid/multigrid that is a subset of the input grid along the selected dimensions

1 2 3 |

`grid` |
The input grid or station data to be subset. This is either a grid (or station data), as
returned e.g. by |

`var` |
Character vector indicating the variables(s) to be extracted. (Used for multigrid subsetting). See details. |

`cluster` |
An integer vector indicating |

`runtime` |
An integer vector indicating |

`members` |
An integer vector indicating |

`years` |
The years to be selected. Note that this can be either a continuous or discontinuous
series of years, the latter option often used in a cross-validation framework.
See details for year-crossing seasons. Default to |

`season` |
An integer vector indicating the months to be subset. |

`lonLim` |
Vector of length = 2, with minimum and maximum longitude coordinates, in decimal degrees,
of the bounding box defining the subset. For single-point subsets, a numeric value with the
longitude coordinate. If |

`latLim` |
Same as |

`outside` |
if TRUE subset coordinates outside the grid extent are allowed. Default is FALSE. |

`station.id` |
Station ID (check |

`drop` |
Logical (default is TRUE). Drop or keep dimensions of length 1. |

The attribute `subset`

will be added to the different slots corresponding to the subset dimensions, taking
the value of the subroutine called in each case (e.g.: attribute subset will have the value `subsetSpatial`

in the xyCoords slot after spatial subsetting...).

**Time slicing by years**

In case of year-crossing seasons (e.g. boreal winter (DJF), `season = c(12,1,2)`

),
the season is assigned to the years of January and February
(i.e., winter of year 2000 corresponds to Dec 1999, Jan 2000 and Feb 2000). Thus,
the `years`

argument must be introduced accordingly (See e.g. `getYearsAsINDEX`

function for details).

**Spatial slicing**

Spatial subset definition is done via the `lonLim`

and `latLim`

arguments, in the same way as
for instance the `loadGridData`

function, from package loadeR, with the exception that several checks are undertaken
to ensure that the subset is actually within the current extent of the input grid. It is also possible to
make single-point selections from a grid, just by specifying a single coordinate instead of a range
as the argument value. For instance `lonLim = c(-10,10)`

and `latLim = c(35,45)`

indicate a
rectangular window centered in the Iberian Peninsula), and single grid-cell values
(for instance `lonLim = -3.21`

and `latLim = 41.087`

for retrieving the data in the closest grid
point to the point coordinate -3.21E, 41.087N. In the last two cases, the function
operates by finding the nearest (euclidean distance) grid-points to the coordinates introduced.

**Extracting grids from multigrids**

One or several variables from a multigrid object can be extracted. Note that argument `var`

is
insensitive to the order of the variables, i.e.: variables will be always returned in the same order
they are in the original multigrid.

A new grid object that is a logical subset of the input grid along the specified dimensions.

J. Bedia, M. Iturbide, J. A. Fernandez

Other subsetting: `getTemporalIntersection`

,
`intersectGrid.spatial`

,
`intersectGrid.time`

,
`intersectGrid`

, `limitArea`

,
`subsetCluster`

,
`subsetDimension`

,
`subsetMembers`

, `subsetRuntime`

,
`subsetSeason`

, `subsetSpatial`

,
`subsetStation`

, `subsetVar`

,
`subsetYears`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ```
## Not run:
# Example 1 - Spatial / member subset
data("CFS_Iberia_tas")
# Selection of a smaller domain over the Iberian Peninsula and members 3 and 7
sub <- subsetGrid(CFS_Iberia_tas,
members = c(3,7),
lonLim = c(-10,-5),
latLim = c(36,43))
require(visualizeR)
spatialPlot(climatology(sub), tol = 0.005, contour = TRUE,
backdrop.theme = "coastline", rev.colors = TRUE)
## Example 2 - Subsetting a multimember multigrid by variables
# Multimember multigrid creation
data("CFS_Iberia_pr", "CFS_Iberia_hus850")
mm.mf <- makeMultiGrid(CFS_Iberia_tas, CFS_Iberia_pr, CFS_Iberia_hus850)
# Extracting just minimum temperature
sub1 <- subsetGrid(mm.mf, var = "tas", members = 1:4)
spatialPlot(climatology(sub1, by.member = TRUE), backdrop.theme = "coastline",
rev.colors = TRUE)
# Extracting precipitation and maximum temperature
# (Note that the grid variables are NOT re-ordered)
sub2 <- subsetGrid(mm.mf, var = c("pr", "tas"))
getShape(sub2)
getVarNames(sub2)
## Example 3 - Subsetting stations by their codes
data("VALUE_Iberia_pr")
getStationID(VALUE_Iberia_pr)
central_ib <- subsetGrid(VALUE_Iberia_pr, station.id = c("000229", "000231", "000232"))
getStationID(central_iberia)
central_iberia$Metadata
VALUE_Iberia_pr$Metadata
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.