Hi,
I think there is a mistake in the calculation of the wind u- and v-components from wind speed and direction:
|
wind.uv <- function(wspeed, wdir, fieldname=c("U","V"), rad=FALSE){ |
|
if (missing(wdir) && is.list(wspeed)){ |
|
wdir <- wspeed$wdir |
|
wspeed <- wspeed$wspeed |
|
} |
|
if (!rad) wdir <- wdir*pi/180. |
|
u <- wspeed*cos(wdir) |
|
v <- wspeed*sin(wdir) |
|
if (is.geofield(wdir)) { |
|
attr(u, "info")$name <- fieldname[1] |
|
attr(v, "info")$name <- fieldname[2] |
|
} |
|
if (is.vector(wspeed)) return(data.frame(U=u,V=v)) |
|
else return(list(U=u,V=v)) |
|
} |
The cos and sin directly use the direction as angle.
But this is the direction the wind is blowing from (meteorological convection).
The true angle to be used for the cos and sin function should be:
270 - direction (rotate wind 180 degrees + 90 degrees to account for the fact that the N/S axis is used as reference in stead of E/W axis)
As it is now, if you apply wind.dirspeed and then again wind.uv the original u an v are swapped and have the opposite sign.
Michiel
Hi,
I think there is a mistake in the calculation of the wind u- and v-components from wind speed and direction:
meteogrid/R/geowind.R
Lines 49 to 63 in 9da2345
The
cosandsindirectly use thedirectionas angle.But this is the direction the wind is blowing from (meteorological convection).
The true angle to be used for the
cosandsinfunction should be:270 - direction(rotate wind 180 degrees + 90 degrees to account for the fact that the N/S axis is used as reference in stead of E/W axis)As it is now, if you apply
wind.dirspeedand then againwind.uvthe originaluanvare swapped and have the opposite sign.Michiel