-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Hi,
I think there is a mistake in the calculation of the wind u- and v-components from wind speed and direction:
Lines 49 to 63 in 9da2345
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
Metadata
Metadata
Assignees
Labels
No labels