Wind Direction Change

Ivan Toman ivtoman at INET.HR
Sun Feb 21 05:54:33 EST 2010


Dear GrADS users,

I need some help with scripting. I have to calculate change in wind
direction in degrees between two different times. I do this this way:

'define hwd0 = 57.3*atan2(ugrd10m(t='i'),vgrd10m(t='j'))'
'define hwd1 = 57.3*atan2(ugrd10m(t='j'),vgrd10m(t='j'))'
'define hwdc = hwd0-hwd1'

where hwd0 is present wind direction, and hwd1 is wind direction in past time.

The problem arises when there is, for example, hwd0=10deg, hwd1=350deg, the
result of this equation is of course -340 degrees. This is not good, because
I have to get something like +20 degrees as result (by words: wind changed
direction for 20 degrees to the right).

In fact, when wind is backing result should be negative value (from 0 to
-180), and when wind is veering the result must be positive value (from 0 to
180), and never < -180 or > 180 degrees.

I hope you got the point? Can somebody help me please here? I feel this is a
trivial problem but I'm stuck unfortunately. Thanks a lot.



More information about the gradsusr mailing list