How to calculate wind direction from U and V wind components in R

前端 未结 3 1271
一向
一向 2020-12-15 00:35

I have U and V wind component data and I would like to calculate wind direction from these values in R.

I would like to end up with wind direction data on a scale o

3条回答
  •  醉梦人生
    2020-12-15 01:19

    There are three problems with this:

    1. You cannot convert m/s to radians. In order to input wind components into atan2, you must normalize them, but you don't do this by multiplying m/s by pi/180 (which you did to get u_rad and v_rad). You should make a column of absolute windspeed (sqrt(u_ms^2 + v_ms^2)) and take atan2(u_ms/wind_abs, v_ms/wind_abs). (also note that atan2 takes y component first - make sure that's what you want)
    2. atan2 will give you an answer in the unit circle coordinates, which increase counterclockwise and have a zero on the x-axis. You want an answer in cardinal coordinates which increase clockwise and have a zero on the y-axis. To convert unit circle to cardinal coordinates, you must subtract the unit circle angle from 90.
    3. You must know whether the wind info refers to the direction the wind is coming from (standard for cardinal coordinates) or the direction the wind is blowing (standard for trig/vector operations)

    If you are given u_ms = = -3.711 and v_ms = -1.471 (on the unit circle it is blowing down and slightly to the left, so it is coming from the northeast), then:

    wind_abs = sqrt(u_ms^2 + v_ms^2)
    wind_dir_trig_to = atan2(u_ms/wind_abs, v_ms/wind_abs) 
    wind_dir_trig_to_degrees = wind_dir_trig_to * 180/pi ## -111.6 degrees
    

    Then you must convert this wind vector to the meteorological convention of the direction the wind is coming from:

    wind_dir_trig_from_degrees = wind_dir_trig_to_degrees + 180 ## 68.38 degrees
    

    Then you must convert that angle from "trig" coordinates to cardinal coordinates:

    wind_dir_cardinal = 90 - wind_dir_trig_from_degrees
    [1] 21.62284 #From the northeast.
    

提交回复
热议问题