PlotWindProfile: Plot wind speed and direction

View source: R/RNomadsTools.R

PlotWindProfileR Documentation

Plot wind speed and direction

Description

Creates a polar plot showing the azimuth, elevation, and magnitude of winds.

Usage

PlotWindProfile(zonal.wind, meridional.wind, height, magnitude = NULL,
    magnitude.range = c(0, 50), height.range = c(0, 50000), points = TRUE, lines = FALSE,
    radial.axis = TRUE, elev.circles = NULL, elev.labels = NULL, radial.lines = NULL,
    colorbar = TRUE, colorbar.label = NULL, north.label = TRUE, invert = FALSE, ...)

Arguments

zonal.wind

A vector or list of vectors of zonal (East-West) winds, west negative.

meridional.wind

A vector or list of vectors of meridional (North-South) winds, south negative.

height

A vector or list of vectors of height at which each wind measurement was taken.

magnitude

A vector or list of vectors of magnitudes to plot at each wind azimuth, instead of using the wind magnitudes. This allows plotting of other data (such as the speed of sound) along the wind vectors. Defaults to NULL.

magnitude.range

Ranges of wind speed to plot. Values greater or lesser than these will be saturated. Defaults to c(0, 50).

height.range

Ranges of heights to plot, values outside of this will not appear. Defaults to c(0, 50000).

points

Whether to plot measurements as points. Defaults to TRUE.

lines

Whether to connect measurements together with lines. Defaults to FALSE.

radial.axis

Whether to plot an axis at the outer edge of the diagram. Defaults to TRUE.

elev.circles

Plot a dashed circles as elevation scales. Defaults to NULL, which plots nothing.

elev.labels

What labels to put on the elevation scales. Defaults to NULL, which means no labels.

radial.lines

Plot lines radiating from the center of the plot showing azimuth directions. Defaults to NULL, which plots nothing.

colorbar

If TRUE, plot a color bar. Defaults to TRUE.

colorbar.label

What label to put on the colorbar. Defaults to NULL, which means no label.

north.label

If TRUE, put a label denoting the north direction. Defaults to TRUE.

invert

Reverses the edge and the center of the plot, making elevations decrease towards the center. Defaults to FALSE.

...

This function supports some optional parameters as well:

  • r.axis - radius of plot axis

  • tick.len - length of azimuth ticks

  • r.axis.ticks - Whether or not to put tick marks on the outer axis

  • max.az - If plotting lines and the difference between two segments is greater than this value, interpolate between them to make things smooth

  • color.map - A list of colors to use, defaults to rainbow(n.cols, start=0, end=5/6)

  • n.cols - Number of color bins in color map

  • sub.col - Color of internal (elevation and azimuth) axes as a vector of length 2

  • sub.lty - Type of internal axes, as a vector of length 2

  • sub.lwd - Width of internal axes, as a vector of length 2

  • elev.labels.az - Which azimuth to plot elevation labels on

  • point.cex - size of points, if plotted

  • pch - Plot character of points, if plotted

  • lty - Line style, if lines are selected

  • lwd - Line thickness, if lines are selected

  • colorbar.tick - Where to put labels on colorbar

Author(s)

Daniel C. Bowman danny.c.bowman@gmail.com

Examples


## Not run: 
download.file("http://www.gmail.com/~haksaeng/rNOMADS/myTA.RDATA", 
   destfile = "myTA.RDATA")
load("myTA.RDATA")
#Find the latest Global Forecast System model run
model.urls <- GetDODSDates("gfs_0p50")
latest.model <- tail(model.urls$url, 1)
model.runs <- GetDODSModelRuns(latest.model)
latest.model.run <- tail(model.runs$model.run, 1)

#Get model nodes

lons <- seq(0, 359.5, by = 0.5)
lats <- seq(-90, 90, by = 0.5)
lon.ind <- which(lons <= (max(myTA$lon + 360) + 1) & lons >= (min(myTA$lon + 360) - 1))
lat.ind <- which(lats <= (max(myTA$lat) + 1) & lats >= (min(myTA$lat) - 1))
levels <- c(0, 46)
time <- c(0, 0)

#Get data 
variables <- c("hgtprs", "ugrdprs", "vgrdprs")
model.data <- DODSGrab(latest.model, latest.model.run,
   variables, time, c(min(lon.ind), max(lon.ind)), 
   c(min(lat.ind), max(lat.ind)), levels)

#Build profiles
profile <- BuildProfile(model.data, myTA$lon + 360, myTA$lat, 
    spatial.average = FALSE)

#Build profiles
zonal.wind      <- NULL
meridional.wind <- NULL 
height          <- NULL

for(k in 1:length(profile)) {
   hgt  <- profile[[k]]$profile.data[, which(profile[[k]]$variables == "hgtprs"),]
   ugrd <- profile[[k]]$profile.data[, which(profile[[k]]$variables == "ugrdprs"),]
   vgrd <- profile[[k]]$profile.data[, which(profile[[k]]$variables == "vgrdprs"),]

   synth.hgt <- seq(min(hgt),
       max(hgt), length.out = 1000)
   ugrd.spline <- splinefun(hgt, ugrd, method = "natural")
   vgrd.spline <- splinefun(hgt, vgrd, method = "natural")
   zonal.wind[[k]] <- ugrd.spline(synth.hgt)
   meridional.wind[[k]] <- vgrd.spline(synth.hgt)
   height[[k]] <- synth.hgt
}

#Plot them all
PlotWindProfile(zonal.wind, meridional.wind, height, lines = TRUE, 
    points = FALSE, elev.circles = c(0, 25000, 50000), elev.labels = c(0, 25, 50), 
    radial.lines = seq(45, 360, by = 45), colorbar = TRUE, invert = FALSE, 
    point.cex = 2, pch = 19, lty = 1, lwd = 1, 
    height.range = c(0, 50000), colorbar.label = "Wind Speed (m/s)")

## End(Not run)

rNOMADS documentation built on Sept. 6, 2022, 5:06 p.m.