[R] Classification of wind events

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Tue May 19 12:58:18 CEST 2020


I was impressed by Jim's effort.
So, I thought I'd try to produce an exploratory plot.

I've adapted some of his code.
The following script produces a heatmap for a cylindrical density estimate.
Bright areas are (mathematical) regions of high density.
However, the interpretation is complicated by the fact that the data
uses max wind speed rather than wind speed, per se.

I note your subject line, "Classification of wind events".
I'm not sure what sort of classification is possible.

Could there be some sort of lagged effect...?
(i.e. Could wind direction or speed at time t, be related to wind
direction or speed at time t-1, t-2, etc ...?).

------------------------------------------------------
library (barsurf)
library (probhat)
set.bs.theme ("blue")

g <- c ("WSW", "WSW", "SW", "SW", "W", "WSW", "WSW", "WSW", "W", "W",
    "SW", "WSW", "SSW", "S", "SW", "SW", "WSW", "WNW", "W", "WSW",
    "WSW", "SE", "SE", "SE", "NW", "NNE", "ENE", "SE", "NNW", "NW",
    "NW", "NW", "NW", "NW", "NW", "NE", "NW", "NW", "NW", "NW", "NW",
    "N", "WNW", "NW", "NNW", "NNW", "NW", "NW", "NW", "WNW", "ESE",
    "W", "WSW", "SW", "SW", "SW", "WSW", "SW", "S", "S", "SSW", "SW",
    "WSW", "WSW", "WSW", "WSW", "WSW", "WSW", "WSW", "SW", "WSW",
    "WSW", "WSW", "WSW", "SW", "SW", "WSW", "WSW", "WSW", "WSW",
    "WSW", "SW", "SW", "SW", "SW", "SW", "SW", "SW", "SW", "SW",
    "WSW", "WSW", "WSW", "WSW", "SW", "SW", "SW", "SW", "WSW", "SW",
    "SW", "SW", "SW", "SW", "WSW", "SW", "SW", "W", "WSW", "WSW",
    "SSW", "S", "WNW", "SW", "W", "WSW", "WSW", "SE", "SE", "SE",
    "NW", "NNE", "ENE", "SE", "NNW", "NW", "NW", "NW", "NW", "NW",
    "NW", "NE", "NW", "NW", "NW", "NW", "NW", "N", "WNW", "NW", "NNW",
    "NNW", "NW", "NW", "NW")
levels <- c("E", "ENE", "NE", "NNE", "N", "NNW", "NW", "WNW",
    "W", "WSW", "SW", "SSW", "S", "SSE", "SE", "ESE")
g <- factor (g, levels=levels)

r <- seq (0, 337.5, by=22.5)
x <- r [as.integer (g)]

y <- c (4.6, 4.6, 3.4, 3.1, 4.8, 4.2, 4.1, 4.5, 4.7, 4.3, 2.4, 2.3,
    2.2, 2.1, 2.9, 2.8, 1.8, 2.7, 4.3, 3.3, 2.3, 2.3, 3.2, 3.2, 2.9,
    2.3, 1.5, 1.8, 2.9, 2.4, 1.8, 2.4, 2.3, 2.6, 1.8, 2.3, 1.9, 2.2,
    2.8, 2.4, 1, 1.1, 1.6, 2.3, 2.5, 3.3, 3.4, 3.2, 4.5, 3.9, 3.1,
    2.4, 6, 7.8, 6.3, 7.8, 8.1, 6.1, 7.4, 9.5, 8.9, 9.1, 10.1, 10.5,
    11.1, 10.1, 10.9, 11.3, 13.4, 13.5, 12.8, 11.5, 13.1, 13.5, 11.1,
    10.5, 8.5, 10.1, 10.7, 13.6, 11.9, 14.9, 10.9, 10.9, 12.8, 12.1,
    9.1, 8.3, 8.8, 7.4, 8.4, 10.3, 10, 7, 8.5, 8.4, 8.6, 6.7, 7.3,
    6.2, 5.9, 5.9, 5.1, 5.8, 5.6, 6.5, 6.6, 11.7, 11.3, 8.7, 7.1,
    6.9, 4.3, 3.8, 4.3, 3.3, 2.3, 2.3, 3.2, 3.2, 2.9, 2.3, 1.5, 1.8,
    2.9, 2.4, 1.8, 2.4, 2.3, 2.6, 1.8, 2.3, 1.9, 2.2, 2.8, 2.4, 1,
    1.1, 1.6, 2.3, 2.5, 3.3, 3.4, 3.2, 4.5)

data.frame (g, x, y)

x2 <- c (x - 360, x, x + 360)
y2 <- rep (y, times=3)

fh <- pdfmv.cks (cbind (x2, y2), bw = c (240, 9.5) )

N <- 64
u <- seq (270, -90, length.out=N)
v <- seq (0, 15, length.out=N)
fv <- outer (u, v, function (x, y) fh (cbind (x, y) ) )

#not necessary for exploratory purposes
Fh <- cdfmv.cks (cbind (x2, y2), bw = c (240, 9.5) )
scaling.factor <- probmv (Fh, c (0, 0), c (360, max (y) ) )
fv <- fv / scaling.factor

#currently problems with descending x/y coords
#(to fix in near future)
#so set x-axis to [0, 1]
u2 <- seq (0, 1, length.out=N)

plot_cfield (u2, v, fv,
    axes = c (FALSE, TRUE),
    main="Wind Speed\n(Cylindrical Density Estimate)",
    xlab="direction", ylab="max wind speed",
    hcv=TRUE)
axis (1, c (0.05, 0.275, 0.5, 0.725, 0.95), c ("South", "West",
"North", "East", "South"), FALSE)
abline (v=0.5, lty=2, col="white")

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wind_speed.png
Type: image/png
Size: 24321 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200519/dc6daff3/attachment.png>


More information about the R-help mailing list