Skip to content

Calculating wind u- and v-components from direction and speed #19

@mpvginde

Description

@mpvginde

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

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions