[Thread Prev][Thread Next][Index]

Re: [ferret_users]wind frequency from zonal, meridional wind



Hey,
there was one huge mistake in what i posted earlier, so here is what i did to have wind frequency from zonal and meridional wind It works, though it still takes time :)
Cheers, Peter
-----------------------------------
use myfile.nc !the file comes with u and v variables (with axis named "lons" and "lats" and with many days in time direction)

!i define the sixteen wind directions after tangent function:
let W1= if (u gt 0 and v gt 0) and (v/u le 0.1989) then 1; let WSW=if (u gt 0 and v gt 0) and (v/u le 0.6682) and (v/u gt 0.1989) then 1; let SW=if (u gt 0 and v gt 0) and (v/u le 1.4966) and (v/u gt 0.6682) then 1; let SSW=if (u gt 0 and v gt 0) and (v/u le 5.0273) and (v/u gt 1.4966) then 1; let S1=if (u gt 0 and v gt 0) and (v/u ge 5.0273) then 1;\
let S2= if (u lt 0 and v gt 0) and (v/u lt -5.0273) then 1; let SSE=if (u lt 0 and v gt 0) and (v/u ge -5.0273) and (v/u lt -1.4966) then 1; let SE=if (u lt 0 and v gt 0) and (v/u ge -1.4966) and (v/u lt -0.6682) then 1; let ESE=if (u lt 0 and v gt 0) and (v/u ge -0.6682) and (v/u lt -0.1989) then 1; let E1=if (u lt 0 and v gt 0) and (v/u ge -0.1989) then 1;\
let E2= if (u lt 0 and v lt 0) and (v/u le 0.1989) then 1; let ENE=if (u lt 0 and v lt 0) and (v/u le 0.6682) and (v/u gt 0.1989) then 1; let NE=if (u lt 0 and v lt 0) and (v/u le 1.4966) and (v/u gt 0.6682) then 1; let NNE=if (u lt 0 and v lt 0) and (v/u le 5.0273) and (v/u gt 1.4966) then 1; let N1=if (u lt 0 and v lt 0) and (v/u gt 5.0273) then 1;\
let N2= if (u gt 0 and v lt 0) and (v/u lt -5.0273) then 1; let NNW=if (u gt 0 and v lt 0) and (v/u ge -5.0273) and (v/u lt -1.4966) then 1; let NW=if (u gt 0 and v lt 0) and (v/u ge -1.4966) and (v/u lt -0.6682) then 1; let WNW=if (u gt 0 and v lt 0) and (v/u ge -0.6682) and (v/u lt -0.1989) then 1; let W2=if (u gt 0 and v lt 0) and (v/u ge -0.1989) then 1;\

!in a loop i sum the number of the wind directions (i divided into half the main four directions, like W1+W2);
!i create a 3D variable "freq3d" from my 1D variable "freq" placed on t-axis (i use the same grid i have in my original file, except the t-axis);
!finally i write out to a new netcdf file (the variable with the wind frequency for the whole region for 16 directions) :

repeat/j=1:61:1 (repeat/i=1:97:1 (\
let wdir=w1[l=@sum]+w2[l=@sum]; let sdir=s1[l=@sum]+s2[l=@sum]; let edir=e1[l=@sum]+e2[l=@sum]; let ndir=n1[l=@sum]+n2[l=@sum]; let sedir=se[l=@sum]; let nedir=ne[l=@sum]; let swdir=sw[l=@sum]; let nwdir=nw[l=@sum]; let sswdir=ssw[l=@sum]; let nnwdir=nnw[l=@sum]; let wswdir=wsw[l=@sum]; let wnwdir=wnw[l=@sum]; let ssedir=sse[l=@sum]; let nnedir=nne[l=@sum]; let esedir=ese[l=@sum]; let enedir=ene[l=@sum];\
let freq=tsequence({`ndir`,`nnedir`,`nedir`,`enedir`,`edir`,`esedir`,`sedir`,`ssedir`,`sdir`,`sswdir`,`swdir`,`wswdir`,`wdir`,`wnwdir`,`nwdir`,`nnwdir`}) ;\
def axis/t=1:16:1 tax; let freqt = freq[gt=tax];\
def grid/t=tax/x=lons/y=lats ggg;\
let zero=0*u[g=ggg@asn]; let freq3d=zero+freqt[g=ggg@asn];\
save/file=myfreq.nc/append/clobber/ilimits=1:97/jlimits=1:61/i=`i`/j=`j` freq3d))
-----------------------------

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement