[ncl-talk] Plot wavelet with "Months" as X-axis

Lyndon Mark Olaguera olagueralyndonmark429 at gmail.com
Thu Jan 12 23:16:31 MST 2017


Hi All,

I'm plotting a wavelet based from this example
https://www.ncl.ucar.edu/Document/Functions/Built-in/wavelet.shtml

Is there an easy way to make the x-axis in terms of months (Jan to Dec)?

Here's my code:

begin
;************************************
; create pointer to file and read in variables
;************************************
  f    = addfile ("hpass_SCS.nc","r")
  prec  = f->PREC(:,0,0)                     ; one value/year
  time = prec&time
  N    = dimsizes(time)
;************************************
; Remove mean and linear trend (recommended, not required)
; Missing values are not allowed.
;************************************
  prec  = dtrend(prec,False)
;************************************
; compute wavelet (Missing values not allowed due to use of FFT)
;************************************
  mother  = 0
  param   = 6.0
  dt      = 1.
  s0      = 0.25
  dj      = 0.25
  jtot    = 44
  npad    = N
  nadof   = new(2,float)
  noise   = 1
  siglvl  = .05
  isigtest= 1

  w =
wavelet(prec,mother,dt,param,s0,dj,jtot,npad,noise,isigtest,siglvl,nadof)
;************************************
; create coodinate arrays for plot
;************************************
  power            = onedtond(w at power,(/jtot,N/))
  power!0          = "period"                        ; Y axis
  power&period     = w at period

  power!1          = "time"                          ; X axis
  power&time       = time

  power at long_name  = "Power Spectrum"
  power at units      = "unit^2"


;************************************
; initial resource settings
;************************************
  wks = gsn_open_wks("png","wavelet")             ; send graphics to PNG
file
  res                     = True                  ; plot mods desired
  res at cnFillOn            = True                  ; turn on color
  res at cnFillPalette       = "BlAqGrYeOrReVi200"   ; set color map
  res at cnFillMode          = "RasterFill"          ; turn on raster mode
  res at cnRasterSmoothingOn = True                  ; turn on raster smoothing
  res at cnLinesOn           = False                 ; turn off contour lines
  res at lbOrientation       = "Vertical"            ; vertical label bar
  res at trYReverse          = True                  ; reverse y-axis
  ;res at tmLabelAutoStride   = True
  res at cnLevelSelectionMode = "ManualLevels"       ; set manual contour
levels
  res at cnMinLevelValF       = 0.0                  ; set min contour level
  res at gsnLeftString       = "Wavelet Power"
  plot = gsn_csm_contour(wks,power({0:120},:),res)
end


I'll appreciate any help.

Many thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170113/d19d2047/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wavelet.png
Type: image/png
Size: 86439 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170113/d19d2047/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hpass_SCS.nc
Type: application/x-netcdf
Size: 102956 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170113/d19d2047/attachment-0001.nc 


More information about the ncl-talk mailing list