[ncl-talk] Need Help
Jack Ogaja
jack.ogaja at gmail.com
Thu Oct 22 03:58:30 MDT 2015
Soares,
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.
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.
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);
;———————
dir0 = new(ntimes,float) ; creation of a Wind-direction array
…
do it = 0,ntimes-1 ;Loop for the time: it= starting time
…
; Wind direction at 0 Meters
r2d = 45.0/atan(1.0) ; conversion factor (radians to degrees)
dir = atan2(u_plane,v_plane) * r2d + 180
;dir0 = dir(x,y) ;<== a single-valued dynamic variable
dir0(it) = dir(x,y) ;<== changed to a single-dimesional array
…
do it = 0,ntimes-1
print (sprintf ("%5.0f",it) +" " \
+sprintf (" %4.1f", dir0(it)) +" " \
+sprintf("%23.2f", windspd0(it)) +" " )
end do ; end of time loop
;———————-
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);
;——
“print(windspd0)”
“print(dir0)”
;——
you would easily see the differences between the two variables.
Jack.
> On 21 Oct 2015, at 06:09, isakhar sakhar isakhar <isakhar.inside13 at gmail.com> wrote:
>
> Dear Mr.Jack
>
> I didn't catch it. Could you please explain more detail?
>
>
> Best regards,
> Soares
>
> On Tue, Oct 20, 2015 at 10:20 AM, Jack Ogaja <jack.ogaja at gmail.com <mailto:jack.ogaja at gmail.com>> wrote:
> Assuming that ‘everything’ else in your code is correct, the snippet(of your code) below simply explains your concern;
>
> ****
> do it = 0,ntimes-1 ;Loop for the time: it= starting time
> time = it
> …
> ; Calculate Wind Speed from Vectors
> spd = (u_plane*u_plane + v_plane*v_plane)^(0.5)
> windspd0(it)=spd(x,y) ;<=== instantaneous[compare to “dir0” below]
>
> ; Wind direction at 0 Meters
> r2d = 45.0/atan(1.0) ; conversion factor (radians to degrees)
> dir = atan2(u_plane,v_plane) * r2d + 180
> dir0 = dir(x,y) ;<=== is always overwritten[compare to “windspd0(it)” above]
> ****
> i.e. your directions will always be the last direction calculated in the loop.
>
> Jack.
>
> > On 20 Oct 2015, at 08:56, isakhar sakhar isakhar <isakhar.inside13 at gmail.com <mailto:isakhar.inside13 at gmail.com>> wrote:
> >
> > Dear NCL Team
> >
> > 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.
> >
> > Regards,
> > Soares
> > <output.txt><wrf_script.ncl>_______________________________________________
> > ncl-talk mailing list
> > ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151022/1f266b3d/attachment.html
More information about the ncl-talk
mailing list