Function for plotting PM2.5 concentration in polar coordinates
showing concentration by wind speed and direction. This function wraps the
openair polarPlot()
function.
sensor_polarPlot(
sensor = NULL,
windData = NULL,
statistic = "mean",
resolution = "fine",
colors = "default",
alpha = 1,
angleScale = 315,
normalize = FALSE,
key = TRUE,
keyPosition = "right",
ws_spread = 15,
wd_spread = 4,
verbose = TRUE
)
an 'airsensor' object
a dataframe containing columns "date", "ws", and "wd".
The statistic that should be applied to each wind speed/direction bin. Because of the smoothing involved, the colour scale for some of these statistics is only to provide an indication of overall pattern and should not be interpreted in concentration units e.g. for statistic = "weighted.mean" where the bin mean is multiplied by the bin frequency and divided by the total frequency. In many cases using polarFreq will be better. Setting statistic = "weighted.mean" can be useful because it provides an indication of the concentration * frequency of occurrence and will highlight the wind speed/direction conditions that dominate the overall mean. Can be: “mean” (default), “median”, “max” (maximum), “frequency”. “stdev” (standard deviation), “weighted.mean”
Two plot resolutions can be set: “normal” and “fine” (the default), for a smoother plot. It should be noted that plots with a “fine” resolution can take longer to render.
Colours to be used for plotting. Options include “default”, “increment”, “heat”, “jet” and RColorBrewer colours — see the openair openColours function for more details. For user defined the user can supply a list of color names recognised by R (type colors() to see the full list). An example would be color = c("yellow", "green", "blue"). Can also take the values "viridis", "magma", "inferno", or "plasma" which are the viridis colour maps ported from Python's Matplotlib library.
The alpha transparency to use for the plotting surface (a value between 0 and 1 with zero being fully transparent and 1 fully opaque).
The wind speed scale is by default shown at a 315 degree angle. Sometimes the placement of the scale may interfere with an interesting feature. The user can therefore set angleScale to another value (between 0 and 360 degrees) to mitigate such problems. For example angle.scale = 45 will draw the scale heading in a NE direction.
If TRUE concentrations are normalised by dividing by their mean value. This is done after fitting the smooth surface. This option is particularly useful if one is interested in the patterns of concentrations of PM2.5.
Fine control of the scale key via drawOpenKey. See drawOpenKey for further details.
Location where the scale key is to plotted. Allowed arguments currently include "top", "right", "bottom" and "left".
An integer used for the weighting kernel spread for wind speed when correlation or regression techniques are used. Default is 15.
An integer used for the weighting kernel spread for wind direction when correlation or regression techniques are used. Default is 4.
Logical controlling the generation of progress and error messages.
A plot and an object of class "openair".
# \donttest{
# Fail gracefully if any resources are not available
try({
library(AirSensor)
setArchiveBaseUrl("https://airsensor.aqmd.gov/PurpleAir/v1")
pas <- pas_load(archival = TRUE)
pat <- pat_loadMonth(label = "SCBB_02", pas = pas, datestamp = 202005)
sensor <- pat_createAirSensor(pat)
# Polar plot
sensor_polarPlot(sensor, resolution = "normal")
}, silent = FALSE)
#> ERROR [2023-04-03 16:31:33] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230403_archival.rda
#> ERROR [2023-04-03 16:31:33] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230402_archival.rda
#> ERROR [2023-04-03 16:31:33] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230401_archival.rda
#> ERROR [2023-04-03 16:31:33] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230331_archival.rda
#> ERROR [2023-04-03 16:31:33] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230330_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230329_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230328_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230327_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230326_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230325_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230324_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230323_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230322_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230321_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230320_archival.rda
#> ERROR [2023-04-03 16:31:34] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230319_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230318_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230317_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230316_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230315_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230314_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230313_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230312_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230311_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230310_archival.rda
#> ERROR [2023-04-03 16:31:35] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230309_archival.rda
#> ERROR [2023-04-03 16:31:36] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230308_archival.rda
#> ERROR [2023-04-03 16:31:36] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230307_archival.rda
#> ERROR [2023-04-03 16:31:36] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230306_archival.rda
#> ERROR [2023-04-03 16:31:36] data file could not be loaded from: https://airsensor.aqmd.gov/PurpleAir/v1/pas/2023/pas_20230305_archival.rda
#> Error : Data file could not be loaded after 30 tries
# }