Learn R Programming

SpatialVx (version 0.1-5)

hoods2dPrep: Set up a List Object that can be used by the hoods2d function.

Description

Creates a list object with all of the information needed to run the hoods2d function, as well as other neighborhood approach functions.

Usage

hoods2dPrep(Vx.name, Fcst.name, thresholds = NULL, Pe = NULL, levels = NULL, max.n = NULL,
            subset = NULL, loc = NULL, qs = NULL, field.type = "", units = NULL,
            smooth.fun = "hoods2dsmooth", smooth.params = NULL, mapit = FALSE)

## S3 method for class 'hoods2dPrep': plot(x, ...)

## S3 method for class 'hoods2dPrep': hist(x, ...)

Arguments

Vx.name,Fcst.name
character giving the name of verification and forecast matrix objects. Must have the same dimensions as each other.
x
list object as returned by hoods2dPrep.
thresholds
(optional) numeric vector of length q >= 1, or or q by 2 matrix giving the thresholds to be applied. If a matrix, the first column are thresholds to be applied to the forecast field, and the second column for the observed field. If NULL, then thresholds
Pe
(optional) numeric vector of length q >= 1 to be applied to the fields sPy and possibly sPx (see help file for hoods2d). If NULL, then it is taken to be the most relaxed requirement (i.e., that an event occurs at least once in a neighborhood
levels
numeric vector giving the successive values of the smoothing parameter. For example, for the default method, these are the neighborhood lengths over which the levels^2 nearest neighbors are averaged for each point. Values should make sense for the speci
max.n
(optional) single numeric giving the maximum neighborhood length to use. Only used if levels are not passed.
subset
(optional) numeric vector indicating a subset of points over which to calculate the final statistics. If given, then fields will be smoothed over the entire forecast/observed field, but resulting statistics will only be computed on the subset. The subse
loc
(optional) numeric n*m by 2 matrix giving lon/lat coordinates for the verification set. Currently, this is not used for anything, but may have a use in the future, e.g., for adding a map to plots of neighborhood smoothed fields.
qs
(optional) character vector giving the values of the thresholds. This is primarily used, e.g., if the thresholds differ for the forecast and observed fields (e.g., if quantiles are used instead of hard values). This information is used by hoods2dP
field.type
character naming the type of field given by the verification set (e.g., precipitation, wind speed, etc.).
units
(optional) character giving the name of the units of the verification set.
smooth.fun
character giving the name of a smoothing function to be applied. Default is an average over the n^2 nearest neighbors, where n is taken to be each value of the levels argument.
smooth.params
additional arguments to kernel2dsmooth (kenrel2dmeitsjer) for the specific smoothing function. The default method does not take any extra parameters.
mapit
logical stating whether or not the loc argument corresponds to lon/lat coordinates (TRUE) or not (FALSE). Used by plot method function to add a map to the plots if TRUE. Note that maps placed on the plot will generally not have the correct
...
optional arguments to the hist function. Not used by the plot method function.

Value

  • A list object with components:
  • data.namecharacter vector giving the name of the verification and forecast fields, resp., of the verification set.
  • xdimnumeric vector of length 2 giving the dimensions of the verification set.
  • Nxynumeric giving the total number of grid points in the verification set (i.e., prod(xdim)).
  • levelsnumeric vector giving the desired neighborhood lengths.
  • max.nnumeric giving the largest neighborhood length to be applied.
  • thresholdsq by 2 matrix whose columns give the thresholds for the forecast and observed fields, reps.
  • qsSame as in Arguments above.
  • Penumeric vector of length q >= 1 (i.e., same as number of rows of threshold) giving the thresholds for the smoothed binary fields.
  • subsetSame as in Arguments above.
  • locSame as in Arguments above.
  • field.typeSame as in Arguments above.
  • unitsSame as in Arguments above.
  • mapSame as mapit in Arguments above.
  • The plot and hist method functions do not return anything. Plots are created.

Details

This function is simply used to simplify later analyses and plotting. It gathers all of the information needed to run hoods2d, plot.hoods2d and hoods2dPlot.

The plot method function makes image plots of the verification set with gray contours showing the chosen thresholds for each field. It will try to add a map if the map component is TRUE and the loc coordinates are lon/lat and in the correct format (see the map function from package maps).

The hist method function creates several histograms in two columns. The first column correspond to the verification field and the second to the forecast field. The first row shows the histogram for all values in the fields, and each successive row shows histograms for the field only where values are >= each threshold from the thresholds component of the hoods2dPrep object. That is, (N+1) by 2 panels of histograms are displayed where N is the number of thresholds.

See Also

hoods2d

Examples

Run this code
data(UKobs6)
data(UKfcst6)
data(UKloc)
hold <- hoods2dPrep( "UKobs6", "UKfcst6", thresholds=c(0.01,20.01),
    levels=c(1, 3, 5, 9, 17),
    loc=UKloc, field.type="QPF", units="mm/h", mapit=TRUE)
plot(hold)
hist(hold, col="darkblue")

data(geom001)
data(geom000)
data(ICPg240Locs)
hold <- hoods2dPrep( "geom000", "geom001", thresholds=c(0.01,50.01),
    levels=c(1, 3, 5, 9, 17, 33, 65, 129),
    loc=ICPg240Locs, field.type="QPF", units="in/100", mapit=TRUE)
plot(hold)
hist(hold, col="darkblue")

Run the code above in your browser using DataLab