Learn R Programming

ensembleBMA (version 5.1.8)

plotProbcast: Surface plots for forecast information.

Description

Produces contour, image, or perspective plot of a forecast using loess prediction on a grid.

Usage

plotProbcast( forecast, longitude, latitude, nGrid = 65,
                 type = c("image", "contour", "persp"), ..., 
                 interpolate = FALSE, span = 0.75, maps = NULL)

Value

An image, contour, or perspective plot of the forecast.

Arguments

forecast

Numeric vector of forecasts.

longitude

Numeric vector giving the longitude of each forecast location.

latitude

Numeric vector giving the latitude of each forecast location.

nGrid

Number of grid points for loess interpolation. (Binning and interpolation are done on an nGrid by nGrid grid).

type

A character string indicating the desired plot type. Should be one of either "contour", "image", or "persp".

...

Additional arguments to be passed to the plotting method.

interpolate

A logical variable indicating whether or not a loess fit should be used to interpolate the data to points on a grid. The default is to determine grid values by binning, rather than interpolation.

span

Smoothing parameter for loess (used only when interpolate = TRUE). The default value is 0.75, which is the default for loess.

maps

A logical value indicating whether or not to include a map outline. The default is to include an outline if type = "image" and the fields library is loaded.

Details

If the fields library is loaded, a legend (and optionally a map outline) will be included in image plots.

References

C. Fraley, A. E. Raftery, T. Gneiting and J. M. Sloughter, ensembleBMA: An R Package for Probabilistic Forecasting using Ensembles and Bayesian Model Averaging, Technical Report No. 516R, Department of Statistics, University of Washington, 2007 (revised 2010).

See Also

quantileForecast

Examples

Run this code
  data(srft)

  labels <- c("CMCG","ETA","GASP","GFS","JMA","NGPS","TCWB","UKMO")

  srftData <- ensembleData( forecasts = srft[,labels],
                            dates = srft$date, observations = srft$obs,
                            latitude = srft$lat, longitude = srft$lon,
                            forecastHour = 48, initializationTime = "00")

if (FALSE)  # R check

  bmaFit <- ensembleBMA( srftData, date = "2004012900", trainingDays = 25,
                         model = "normal")

  bmaForc <- quantileForecast( bmaFit, srftData, date = "2004012900",  
                                  quantiles = c(.1, .5, .9))

  obs <- srftData$date == "2004012900"
  lat <- srftData$latitude[obs]
  lon <- srftData$longitude[obs]

  plotProbcast( bmaForc[,"0.5"], lat, lon, 
                   type = "contour", interpolate = TRUE)
  title("Median Forecast")

  plotProbcast( srftData$obs[obs], lat, lon, 
                  type = "contour", interpolate = TRUE)
  title("Observed Surface Temperature")

  data(srftGrid)

  memberLabels <- c("CMCG","ETA","GASP","GFS","JMA","NGPS","TCWB","UKMO")
 
  srftGridData <- ensembleData(forecasts = srftGrid[,memberLabels],
      latitude = srftGrid[,"latitude"], longitude = srftGrid[,"longitude"],
                            forecastHour = 48, initializationTime = "00")

  gridForc <- quantileForecast( bmaFit, srftGridData, 
                    date = "2004021400", quantiles = c( .1, .5, .9))

  library(fields)

  plotProbcast(gridForc[,"0.5"],lon=srftGridData$lon,
     lat=srftGridData$lat,type="image",col=rev(rainbow(100,start=0,end=0.85)))
  title("Median Grid Forecast for Surface Temperature", cex = 0.5)

  probFreeze <- cdf( bmaFit, srftGridData,  date = "2004021400", 
                             value = 273.15)

  plotProbcast(probFreeze, lon=srftGridData$lon, lat=srftGridData$lat,
                   type="image",col=gray((32:0)/32))
  title("Probability of Freezing", cex = 0.5)

Run the code above in your browser using DataLab