[ncl-talk] Frequency to days conversion and draw a vertical line in the plot
Nanda Kishore Reddy
nandu.eng at gmail.com
Mon Mar 14 01:30:44 MDT 2016
Thanks Dennis. I have got the plot what exactly I need.
With Kind Regards
Nanda Kishore reddy. B
Senior Research Fellow
Ocean Observation Systems
NIOT
On Sat, Mar 12, 2016 at 1:42 AM, Dennis Shea <shea at ucar.edu> wrote:
> See Example 5 at:
> http://www.ncl.ucar.edu/Applications/spec.shtml
>
> Good Luck
>
> On Thu, Mar 10, 2016 at 5:32 AM, Nanda Kishore Reddy <nandu.eng at gmail.com>
> wrote:
>
>> Hi ncl-users,
>>
>> I am very new to the NCL software and I would like to do
>> spectrum analysis with confidence levels. I have tried with the existing
>> code and plotted, but, I just need some help like how to plot x-axis in the
>> form of *Days *(i.e. 1/frequency) instead of the *frequency (days/cycle)
>> *otherwise top axis should be in Days and bottom axis should be in
>> frequency (if it is possible).
>> I have, just need one more help like how to draw a
>> vertical line in the plot (x=0.05,y=1000) from the below attached figure.
>>
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>>
>> begin
>> buoy = asciiread("ad08_sw_mons_2014_wspd_davg.txt",(/122,1/),"float")
>>
>> d = 0 ; detrending opt: 0=>remove mean 1=>remove mean + detrend
>> sm = 0 ; smooth: should be at least 3 and odd
>> pct = 0.1 ; percent taper: (0.0 <= pct <= 1.0) 0.10 common.
>>
>> ;************************************************
>> ; calculate spectrum
>> ;************************************************
>> sdof = specx_anal(buoy(:,0),d,sm,pct)
>> ;print (sdof)
>> ;exit
>> ;************************************************
>> ; calculate confidence interval [here 5 and 95%]
>> ; return 4 curves to be plotted
>> ;************************************************
>> splt = specx_ci (sdof, 0.05, 0.99)
>>
>> ;************************************************
>> ; plotting
>> ;************************************************
>> wks = gsn_open_wks("x11","spec") ; Opens a ps file
>>
>> r = True ; plot
>> mods desired
>> r at tiMainString = "AD08 wind speed" ; title
>> r at tiXAxisString = "Frequency (cycles/Days)" ; xaxis
>> r at tiYAxisString = "Variance" ; yaxis
>> r at trYLog = True ; log scaling
>> ;r at trXMinF = 0
>> ;r at trXMaxF = 0.2
>> ;r at trYMinF = 1 ; manually set
>> lower limit
>> ;r at trYMaxF = 1000.0 ; " upper
>> r at gsnFrame = False ; do not advance frame
>> r at xyLineThicknesses = (/2.,1.,1.,1./)
>> r at xyDashPatterns = (/0,0,1,1/)
>> r at xyLineColors = (/"foreground","green","blue","red"/)
>> plot = gsn_csm_xy(wks,sdof at frq, splt,r)
>> lnid =
>> gsn_add_polyline(wks,plot,(/0.05,0.1,0.1,0.1/),(/0.0001,0,0,1000/),r)
>>
>> xf = (/0.40, 0.40+sdof at bw/) ; Create band width line
>> ys = 0.60*max(sdof at spcx) ; 75% up Y axis
>> yv = (/ys,ys/)
>> rpl = True ; resources
>> for polyline
>> rpl at gsLineThicknessF = 2 ; Define line thickness
>> ;gsn_polyline(wks,plot,xf,yv,rpl) ; Draw BandWidth
>>
>> txres= True ; label BW line
>> txres at txFontHeightF = 0.015 ; font height
>> txres at txJust = "CenterLeft" ; Set lable location
>> ;gsn_text(wks,plot,"BW",0.41+sdof at bw,ys,txres) ; Label
>> frame (wks)
>> end
>>
>>
>>
>>
>> With Kind Regards
>> Nanda Kishore reddy. B
>> Senior Research Fellow
>> Ocean Observation Systems
>> NIOT, INDIA
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160314/22d34f17/attachment.html
More information about the ncl-talk
mailing list