var.subset {M3}R Documentation

Subset the array resulting from a call to get.M3.var.

Description

Subset the array resulting from a call to get.M3.var using projection units and/or human-readable dates and times.

Usage

var.subset(var.info, llx, urx, lly, ury, ldatetime, udatetime,
           hz.strict=TRUE)

Arguments

var.info

Variable list given by function get.M3.var.

llx

Lower x-coordinate bound for the subsetted grid using the same units given in element hz.units of var.info. Default is the left boundary of the grid.

urx

Upper x-coordinate bound for the subsetted grid using the same units given in element hz.units of var.info. Default is the right boundary of the grid.

lly

Lower y-coordinate bound for the subsetted grid using the same units given in element hz.units of var.info. Default is the lower boundary of the grid.

ury

Upper y-coordinate bound for the subsetted grid using the same units given in element hz.units of var.info. Default is the upper boundary of the grid.

ldatetime

Beginning date-time (either Date or POSIX class) bound for the subset. Default is earliest date-time.

udatetime

Ending date-time (either Date or POSIX class) bound for the subset. Default is latest date-time.

hz.strict

If TRUE (default), to be allowed in the subset, the whole grid cell must fit within the bounds given by llx, urx, lly, and ury. If FALSE, grid cells will be included in the subset if any portion of the grid cell's area falls within the given bounds.

Details

If the user wants to subset the variable by row, column, layer, or time step number, this can be accomplished easily using standard R methods for subsetting the array of variable values. This function was written to help the user who does not know the row, column, or time step numbers, but who wants to subset according to human-readable dates and times or according to projection units.

Value

Subsetted array of variable values. (The array's format is preserved.)

Author(s)

Jenise Swall

References

https://www.cmascenter.org/ioapi/documentation/all_versions/html/VBLE.html,
https://www.cmascenter.org/ioapi/documentation/all_versions/html/DATETIME.html

See Also

get.M3.var

Examples

## Find the path to the demo file.
polar.file <- system.file("extdata/surfinfo_polar.ncf", package="M3")

## Read in the terrain elevation variable.
elev <- get.M3.var(file=polar.file, var="HT")
## Make a plot.
image(elev$x.cell.ctr, elev$y.cell.ctr, elev$data[,,1],
      xlab="Projection x-coord (km)", ylab="Projection y-coord (km)",
      zlim=range(elev$data[,,1]), col=heat.colors(15))

## Subset to a smaller geographic area in southwestern U.S.
subset.elev <- var.subset(elev, llx=-2000, urx=0, lly=-6500, ury=-4000)
## Make a plot of this subset.
image(subset.elev$x.cell.ctr, subset.elev$y.cell.ctr,
      subset.elev$data[,,1], xlab="Projection x-coord (km)",
      ylab="Projection y-coord (km)", zlim=range(subset.elev$data[,,1]),
      col=heat.colors(15))

## Superimpose U.S. state boundaries on the plot.
state.bds <- get.map.lines.M3.proj(file=polar.file)$coords
lines(state.bds)

[Package M3 version 0.4 Index]