subsetVALUE: Select an arbitrary subset from a VALUE object along one or...

View source: R/subsetVALUE.R

subsetVALUER Documentation

Select an arbitrary subset from a VALUE object along one or more of its dimensions

Description

Creates a new predictions/observations VALUE object that is a subset of the input object along the selected dimensions

Usage

subsetVALUE(valueObj, stationID = NULL, members = NULL, season = NULL,
  dates = NULL, years = NULL, lonLim = NULL, latLim = NULL)

Arguments

valueObj

The input object to be subset. This is either an observation, as returned by loadValueStations, , or a predictions object as returned by loadValuePredictions.

stationID

Character string. Station codes.

members

An integer vector indicating the position of the members to be subset. Default to NULL.

season

An integer vector indicating the months to be subset.

dates

A vector of dates for subsetting on arbitrary dates. This is a character (or POSIXct) vector following the format “YYYY-MM-DD” (i.e., format = "%Y-%m-%d" as in strptime). This is directly passed by the element valueObject$Dates$start, for instance.

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 NULL (no subsetting is performed on the time dimension).

lonLim

Vector of length = 2, with minimum and maximum longitude coordinates, in decimal degrees, of the bounding box defining the subset. For single-station subsets, a numeric value with the longitude coordinate. If NULL (default), no subsetting is performed on the longitude dimension

latLim

Same as lonLim argument, but for latitude.

Details

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.

Spatial slicing

Spatial subset definition is done via the lonLim and latLim arguments, in the same way as in the loadValueStations function. It is also possible to make single-station selections from a multi-station object, 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) indicates 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 both cases, the function operates by finding the nearest (euclidean distance) stations to the coordinates introduced (either north/south or east/westward).

Value

A new VALUE stations/predictions object that is a logical subset of the input object along the specified dimensions.

Author(s)

J. Bedia


SantanderMetGroup/R_VALUE documentation built on July 4, 2023, 4:27 a.m.