Tick mark based on converted values

From: Hyacinth Nnamchi <hyacinth.1_at_nyahnyahspammersnyahnyah>
Date: Sat May 19 2012 - 12:03:38 MDT

Hello,

I'm trying to plot spectrum analysis using the script below. When the frequencies are converted to periods and then setting the res@tmXBMode = "Explicit" . But the ticks don't appear and there is no error message. Does someone know what could be wrong here?

Thanks in advance.

Hyacinth

;*************************************************
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"
begin

; ==============================================================
; User defined parameters that specify region of globe and
; ==============================================================
; latS = -50.
; latN = 20.
; lonL = -70.
; lonR = 40.

  yrStrt = 1900
  yrLast = 2011

  season = "JJA" ; choose Dec-Jan-Feb seasonal mean
  
; ==============================================================
; Open the file: Read only the user specified period
; ==============================================================

 f = addfile ("sst.mnmean.nc", "r")

  TIME = f->time
  YYYY = cd_calendar(TIME,-1)/100 ; entire file
  iYYYY = ind(YYYY.ge.yrStrt .and. YYYY.le.yrLast)
  sst = short2flt(f->sst(iYYYY,:,:))
  printVarSummary(sst)
  
 ;;=================================================;
; Remove the annual cycle
;=================================================;
   xClm = clmMonTLL(sst)
   printVarSummary(xClm) ; (12,nlat,nlon)
   sst = calcMonAnomTLL (sst, xClm) ; replace with anonamlies
   sst@long_name = "ANOMALIES: "+sst@long_name

; Re-order the longitutes
   sst = lonFlip(sst)
   printVarSummary(sst) ; note the longitude coord
; ==============================================================
; compute desired global seasonal mean: month_to_season (contributed.ncl)
; ==============================================================
  SST = month_to_season (sst, season)
  nyrs = dimsizes(SST&time)
  printVarSummary(SST)
;;========================================================
 
   atl3 = wgt_areaave_Wrap(SST(time |:, {lon|-20:0}, {lat | -5:5}),1.0, 1.0, 0) ;Atlantic Nino

  print(atl3)

;;Normalize time series

 ; atl3 = dim_standardize_n(atl3,0,0)
     
;*********************************,
;************************************************
; set function arguments to calculate spectrum
;************************************************
  d = 0 ; detrending opt: 0=>remove mean 1=>remove mean + detrend
  sm = 5 ; smooth: should be at least 3 and odd
  pct = 0.10 ; percent taper: (0.0 <= pct <= 1.0) 0.10 common.
;************************************************
; calculate spectrum
;************************************************
  nino3spec = specx_anal(atl3,d,sm,pct)
;************************************************
; plotting parameters
;************************************************
   wks = gsn_open_wks("pdf","atl3_spec_default") ; Opens a ps file
   plot = new(1,graphic) ; create graphic array

   r = True ; plot mods desired
   r@gsnDraw = False ; do not draw
   r@gsnFrame = False ; do not advance frame
  ; r@trYLog = True
   r@trYMinF = 0 ; manually set lower limit
   r@trYMaxF = 6 ; " upper
   r@xyLineThicknesses = (/3/) ; Define line thicknesses
   r@xyDashPatterns = (/0/) ; Dash patterns
   r@xyLineColors = (/"blue"/)
   r@tiMainString = "Default plot" ; title
   ;r@tiXAxisString = "Frequency (cycles/year)" ; xaxis
   ;r@tiYAxisString = "Variance" ; yaxis

   cc1 = (1/(/0.02,0.1,0.2,0.3,0.4,0.5,1/)) ;Divide by 1/f to convert frequency to periods (years)

   print(cc1)
   
    r@tmXBMode = "Explicit"
    r@tmXBValues = (/cc1/)
   ; r@tmXBMinorValues = (/cc1/)
    r@tmXBLabels = (/cc1/)
  
  ; r@tmXBLabels = (/"50","45","40","30","20","10","5","4","3","2","1"/)
  

;************************************************
;Create plot
;************************************************
 
   plot = gsn_csm_xy(wks, nino3spec@frq, nino3spec@spcx, r) ; create plot
   
   draw(plot)
   frame(wks)
end

                                               

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Sat May 19 12:03:53 2012

This archive was generated by hypermail 2.1.8 : Fri May 25 2012 - 08:35:50 MDT