[ncl-talk] Plot wavelet with "Months" as X-axis
Mary Haley
haley at ucar.edu
Fri Jan 13 10:39:50 MST 2017
Lyndon,
You might be able to use the time_axis_labels procedure. It does what
Dennis suggested, but instead of you having to provide the labels and the
values, you tell the procedure what format you want and it should set these
resources for you.
Right before you call your plotting function, try this:
restick = True
restick at ttmFormat = "%c"
time_axis_labels(prec&time,res,restick)
This will attach tmXBValues, tmXBLabels, and tmXBMode to your "res"
variable, with the appropriate values.
This does depend on your "time" array being in the same type of units
expected by functions like cd_calendar.
To see what formats are available, go to:
http://www.ncl.ucar.edu/Document/Functions/User_contributed/time_axis_labels.shtml
Also see some examples at:
http://www.ncl.ucar.edu/Applications/time_labels.shtml
--Mary
On Fri, Jan 13, 2017 at 10:28 AM, Dennis Shea <shea at ucar.edu> wrote:
> That should be:
>
> res at tmXBMode = "Explicit"
> res at tmXBValues = (/3000,3500,4000,.....,8000/) ; whatever
> res at tmXBLabels = (/"Jan","Feb",.....,"Dec"/)
>
>
>
> On Fri, Jan 13, 2017 at 9:12 AM, Dennis Shea <shea at ucar.edu> wrote:
>
>> You will have to put in the correct numbers. ncl-talk has no idea to what the 'time' axis refers refers
>>
>>
>> res at tmYLMode = "Explicit"
>> res at tmYLValues = (/3000,3500,4000,.....,8000/)
>> res at tmYLLabels = (/"Jan","Feb",.....,"Dec"/)
>>
>>
>> On Thu, Jan 12, 2017 at 11:16 PM, Lyndon Mark Olaguera <
>> olagueralyndonmark429 at gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> I'm plotting a wavelet based from this example https://www.ncl.ucar.e
>>> du/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,
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
> _______________________________________________
> 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/20170113/e01ac2ee/attachment.html
More information about the ncl-talk
mailing list