<div>Ivan,</div>
<div>I've tried to do this in the past and have encountered the same problem. I have not yet found a solution to it. You'd really need to do those calculations in a few DO loops (in FORTRAN or something like it) using an IF statement in the calculation. Grads does not do that kind of thing unfortunately. You might be able to use the maskout function, however, but that is just speculation. Good luck.</div>
<div> </div>
<div>Jeff Duda<br><br></div>
<div class="gmail_quote">On Sun, Feb 21, 2010 at 4:54 AM, Ivan Toman <span dir="ltr"><<a href="mailto:ivtoman@inet.hr">ivtoman@inet.hr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Dear GrADS users,<br><br>I need some help with scripting. I have to calculate change in wind<br>direction in degrees between two different times. I do this this way:<br>
<br>'define hwd0 = 57.3*atan2(ugrd10m(t='i'),vgrd10m(t='j'))'<br>'define hwd1 = 57.3*atan2(ugrd10m(t='j'),vgrd10m(t='j'))'<br>'define hwdc = hwd0-hwd1'<br><br>where hwd0 is present wind direction, and hwd1 is wind direction in past time.<br>
<br>The problem arises when there is, for example, hwd0=10deg, hwd1=350deg, the<br>result of this equation is of course -340 degrees. This is not good, because<br>I have to get something like +20 degrees as result (by words: wind changed<br>
direction for 20 degrees to the right).<br><br>In fact, when wind is backing result should be negative value (from 0 to<br>-180), and when wind is veering the result must be positive value (from 0 to<br>180), and never < -180 or > 180 degrees.<br>
<br>I hope you got the point? Can somebody help me please here? I feel this is a<br>trivial problem but I'm stuck unfortunately. Thanks a lot.<br></blockquote></div><br><br clear="all"><br>-- <br>Jeff Duda<br>Iowa State University<br>
Meteorology Graduate Student<br>3134 Agronomy Hall<br><a href="http://www.meteor.iastate.edu/~jdduda">www.meteor.iastate.edu/~jdduda</a><br>