<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Soares,<div class=""><br class=""></div><div class="">What I’ve written in the following paragraph is not what ncl-talk was meant for(I hope), but I hope it will be helpful to you. So, please keep that in mind.</div><div class=""><br class=""></div><div class="">Your wind speeds “windspd0(it)” are calculated at each time ( time=it ) according to the time loop in your code, which means the values of the “windspd0” is likely to be different from time to time and that is what is shown in your output file. However, unlike “windspd0” which is an array of numbers or an 'indexed variable’, your wind directions "dir0" - as shown in your code - happened to be just a number or ‘a single valued dynamic variable’ which is taking a new value you pass to it at each time (time=it) &nbsp;but forget about what its old value was. So, at the end of your time loop, “windspd0” will be an array of rank one with “ntimes” values and “spd0” will just be a number or a single value(the last value you assigned to it). That is exactly what is shown in your output file.</div><div class=""><br class=""></div><div class="">To change your wind direction variable from a single-valued dynamic variable to an array like the wind speed variable, you can change the following part of your code as shown (only add what is not in your code);</div><div class=""><br class=""></div><div class="">;———————</div><div class=""><div class="">&nbsp;dir0 = new(ntimes,float) &nbsp; &nbsp; &nbsp; ; creation of a Wind-direction array</div><div class=""><br class=""></div><div class="">…</div><div class="">&nbsp; &nbsp;do it = 0,ntimes-1<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; ;Loop for the time: it= starting time</div><div class=""><br class=""></div><div class="">…</div><div class="">&nbsp;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; ; Wind direction at 0 Meters</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">                </span>r2d = 45.0/atan(1.0) &nbsp; &nbsp; &nbsp; <span class="Apple-tab-span" style="white-space:pre">        </span>; conversion factor (radians to degrees)</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">                </span>dir = atan2(u_plane,v_plane) * r2d + 180</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">                </span>;dir0 = dir(x,y) &nbsp; &nbsp; ;&lt;== a single-valued dynamic variable</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">                </span>dir0(it) = dir(x,y) &nbsp;;&lt;== changed to a single-dimesional array</div><div class="">…</div><div class="">do it = 0,ntimes-1</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; print (sprintf &nbsp;("%5.0f",it) &nbsp; &nbsp; &nbsp; &nbsp; +" " &nbsp; &nbsp; &nbsp;\</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;+sprintf (" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %4.1f", dir0(it)) &nbsp; &nbsp; &nbsp;+" &nbsp;" \ &nbsp;&nbsp;</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +sprintf("%23.2f", windspd0(it)) +" &nbsp;" )</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">end do &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; end of time loop</div></div><div class="">;———————-</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Remember, as always recommended, you should use "print statements" to debug your code. For example, by adding the following statement to your original code(after the loop);</div><div class=""><br class=""></div><div class="">;——</div><div class="">&nbsp; &nbsp; “print(windspd0)”</div><div class="">&nbsp; &nbsp; “print(dir0)”</div><div class="">;——</div><div class=""><br class=""></div><div class="">you would easily see the differences between the two variables.</div><div class=""><br class=""></div><div class="">Jack.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 21 Oct 2015, at 06:09, isakhar sakhar isakhar &lt;<a href="mailto:isakhar.inside13@gmail.com" class="">isakhar.inside13@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Dear Mr.Jack<br class=""><br class=""></div>I didn't catch it. Could you please explain more detail?<br class=""><br class=""><br class=""></div>Best regards,<br class=""></div>Soares<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Oct 20, 2015 at 10:20 AM, Jack Ogaja <span dir="ltr" class="">&lt;<a href="mailto:jack.ogaja@gmail.com" target="_blank" class="">jack.ogaja@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Assuming that ‘everything’ else in your code is correct, the snippet(of your code) below simply explains your concern;<br class="">
<br class="">
****<br class="">
&nbsp; do it = 0,ntimes-1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;Loop for the time: it= starting time<br class="">
&nbsp; &nbsp;time = it<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; …<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; Calculate Wind Speed from Vectors<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; spd = (u_plane*u_plane + v_plane*v_plane)^(0.5)<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;windspd0(it)=spd(x,y) ;&lt;=== instantaneous[compare to “dir0” below]<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; Wind direction at 0 Meters<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r2d = 45.0/atan(1.0)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; conversion factor (radians to degrees)<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dir = atan2(u_plane,v_plane) * r2d + 180<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dir0 = dir(x,y)&nbsp; &nbsp; &nbsp; &nbsp; ;&lt;=== is always overwritten[compare to “windspd0(it)” above]<br class="">
&nbsp;****<br class="">
i.e. your directions will always be the last direction calculated in the loop.<br class="">
<br class="">
Jack.<br class="">
<div class=""><div class="h5"><br class="">
&gt; On 20 Oct 2015, at 08:56, isakhar sakhar isakhar &lt;<a href="mailto:isakhar.inside13@gmail.com" class="">isakhar.inside13@gmail.com</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt; Dear NCL Team<br class="">
&gt;<br class="">
&gt; I use the script in attachment to find Wind Speed and Wind Direction in a location. I can get the wind speed but I get odd result for wind direction because all same. The output also in the attachment.<br class="">
&gt;<br class="">
&gt; Regards,<br class="">
&gt; Soares<br class="">
</div></div>&gt; &lt;output.txt&gt;&lt;wrf_script.ncl&gt;_______________________________________________<br class="">
&gt; ncl-talk mailing list<br class="">
&gt; <a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
&gt; List instructions, subscriber options, unsubscribe:<br class="">
&gt; <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br class="">
<br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>