<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) 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=""> dir0 = new(ntimes,float) ; creation of a Wind-direction array</div><div class=""><br class=""></div><div class="">…</div><div class=""> do it = 0,ntimes-1<span class="Apple-tab-span" style="white-space:pre">        </span> ;Loop for the time: it= starting time</div><div class=""><br class=""></div><div class="">…</div><div class=""> </div><div class=""> ; Wind direction at 0 Meters</div><div class=""> <span class="Apple-tab-span" style="white-space:pre">                </span>r2d = 45.0/atan(1.0) <span class="Apple-tab-span" style="white-space:pre">        </span>; conversion factor (radians to degrees)</div><div class=""> <span class="Apple-tab-span" style="white-space:pre">                </span>dir = atan2(u_plane,v_plane) * r2d + 180</div><div class=""> <span class="Apple-tab-span" style="white-space:pre">                </span>;dir0 = dir(x,y) ;<== a single-valued dynamic variable</div><div class=""> <span class="Apple-tab-span" style="white-space:pre">                </span>dir0(it) = dir(x,y) ;<== 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=""> print (sprintf ("%5.0f",it) +" " \</div><div class=""> <span class="Apple-tab-span" style="white-space:pre">        </span> +sprintf (" %4.1f", dir0(it)) +" " \ </div><div class=""> +sprintf("%23.2f", windspd0(it)) +" " )</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">end do ; 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=""> “print(windspd0)”</div><div class=""> “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 <<a href="mailto:isakhar.inside13@gmail.com" class="">isakhar.inside13@gmail.com</a>> 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=""><<a href="mailto:jack.ogaja@gmail.com" target="_blank" class="">jack.ogaja@gmail.com</a>></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="">
do it = 0,ntimes-1 ;Loop for the time: it= starting time<br class="">
time = it<br class="">
…<br class="">
; Calculate Wind Speed from Vectors<br class="">
spd = (u_plane*u_plane + v_plane*v_plane)^(0.5)<br class="">
windspd0(it)=spd(x,y) ;<=== instantaneous[compare to “dir0” below]<br class="">
<br class="">
; Wind direction at 0 Meters<br class="">
r2d = 45.0/atan(1.0) ; conversion factor (radians to degrees)<br class="">
dir = atan2(u_plane,v_plane) * r2d + 180<br class="">
dir0 = dir(x,y) ;<=== is always overwritten[compare to “windspd0(it)” above]<br class="">
****<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="">
> On 20 Oct 2015, at 08:56, isakhar sakhar isakhar <<a href="mailto:isakhar.inside13@gmail.com" class="">isakhar.inside13@gmail.com</a>> wrote:<br class="">
><br class="">
> Dear NCL Team<br class="">
><br class="">
> 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="">
><br class="">
> Regards,<br class="">
> Soares<br class="">
</div></div>> <output.txt><wrf_script.ncl>_______________________________________________<br class="">
> ncl-talk mailing list<br class="">
> <a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
> List instructions, subscriber options, unsubscribe:<br class="">
> <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>