Learn R Programming

openair (version 0.3-8)

polarFreq: Function to plot wind speed/direction frequencies and other statistics

Description

polarFreq primarily plots wind speed-direction frequencies in bins. Each bin is colour-coded depending on the frequency of measurements. Bins can also be used to show the concentration of pollutants using a range of commonly used statistics.

Usage

polarFreq(polar,
    pollutant = "",
    statistic = "frequency",
    ws.int = 1,
    breaks = seq(0, 5000, 500),
    cols = "default",
    trans = TRUE,
    type = "default",
    min.bin = 1,
    border.col = "transparent",
    main = "",
    key.header = statistic,
    key.footer = pollutant,
    key.position = "right",
    key = NULL,
    auto.text = TRUE, ...)

Arguments

polar
A data frame minimally containing ws, wd and date.
pollutant
Mandatory. A pollutant name corresponding to a variable in a data frame should be supplied e.g. pollutant = "nox"
statistic
The statistic that should be applied to each wind speed/direction bin. Can be "frequency", "mean", "median", "max" (maximum), "stdev" (standard deviation) or "weighted.mean". The option "frequency" (the default) is the simplest and plots the frequency
ws.int
Wind speed interval assumed. In some cases e.g. a low met mast, an interval of 0.5 may be more appropriate.
breaks
The user can provide their own scale. breaks expects a sequence of numbers that define the range of the scale. The sequence could represent one with equal spacing e.g. breaks = seq(0, 100, 10) - a scale from 0-10 in inte
cols
Colours to be used for plotting. Options include "default", "increment", "heat", "jet" and user defined. For user defined the user can supply a list of colour names recognised by R (type colours() to see the full list). An example wo
trans
Should a transformation be applied? Sometimes when producing plots of this kind they can be dominated by a few high points. The default therefore is TRUE and a square-root transform is applied. This results in a non-linear scale and (usual
type
The type of analysis to be done. The default is will produce a single plot using the entire data. Other types include "hour" (for hour of the day), "weekday" (for day of the week), "month" (for month of the year) and "year". There is an option "site",
min.bin
The minimum number of points allowed in a wind speed/wind direction bin. The default is 1. A value of two requires at least 2 valid records in each bin an so on; bins with less than 2 valid records are set to NA. Care should be taken when using
border.col
The colour of the boundary of each wind speed/direction bin. The default is transparent. Another useful choice sometimes is "white".
main
Title of plot.
key.header, key.footer
Adds additional text/labels to the scale key. For example, passing options key.header = "header", key.footer = "footer" adds addition text above and below the scale key. These arguments are passed to drawOpenKey via <
key.position
Location where the scale key is to plotted. Allowed arguments currently include "top", "right", "bottom" and "left".
key
Fine control of the scale key via drawOpenKey. See drawOpenKey for further details.
auto.text
Either TRUE (default) or FALSE. If TRUE titles and axis labels will automatically try and format pollutant names and units properly e.g. by subscripting the 2 in NO2.
...
Other graphical parameters.

Details

polarFreq is its default use provides details of wind speed and direction frequencies. In this respect it is similar to windRose, but considers wind direction intervals of 10 degrees and a user-specified wind speed interval. The frequency of wind speeds/directions formed by these bins is represented on a colour scale. The polarFreq function is more flexible than either windRose or polarPlot. It can, for example, also consider pollutant concentrations (see examples below). Instead of the number of data points in each bin, the concentration can be shown. Further, a range of statistics can be used to describe each bin - see statistic above. Plotting mean concentrations is useful for source identification and is the same as polarPlot but without smoothing, which may be preferable for some data. Plotting with statistic = "weighted.mean" is particularly useful for understanding the relative importance of different source contributions. For example, high mean concentrations may be observed for high wind speed conditions, but the weighted mean concentration may well show that the contribution to overall concentrations is very low. polarFreq also offers great flexibility with the scale used and the user has fine control over both the range, interval and colour.

References

~put references to the literature/web site here ~

See Also

See Also as windRose, polarPlot

Examples

Run this code
# basic wind frequency plot
polarFreq(mydata)

# wind frequencies by year
polarFreq(mydata, type = "year")

# drop the date strip at the top
polarFreq(mydata, strip = FALSE)

# mean SO2 by year, showing only bins with at least 2 points
polarFreq(mydata, pollutant = "so2", type = "year", statistic = "mean", min.bin = 2)

# weighted mean SO2 by year, showing only bins with at least 2 points
polarFreq(mydata, pollutant = "so2", type = "year", statistic = "weighted.mean", min.bin = 2)

#windRose for just 2000 and 2003 with different colours
polarFreq(subset(mydata, format(date, "%Y") %in% c(2000, 2003)), type = "year", cols = "jet")

# user defined breaks from 0-700 in intervals of 100 (note linear scale)
polarFreq(mydata, breaks = seq(0, 700, 100))

# more complicated user-defined breaks - useful for highlighting bins with a certain number of data points
polarFreq(mydata, breaks = c(0, 10, 50, 100, 250, 500, 700))

Run the code above in your browser using DataLab