# [ncl-talk] Frequency to days conversion and draw a vertical line in the plot

Nanda Kishore Reddy nandu.eng at gmail.com
Thu Mar 10 05:32:21 MST 2016

```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.

begin

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)

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160310/1bb52f54/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spec.png
Type: image/png
Size: 56814 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160310/1bb52f54/attachment.png
```