[ncl-talk] unable to plot contour map using 'time_axis_labels' function

Dilip V dilip.v at students.iiserpune.ac.in
Thu Jul 19 13:07:43 MDT 2018


I tried keeping my time coordinates as it is and then tried to plot. It
gave me an error in that says
------------------------------------------------------------
-------------------------------------------
fatal:syntax error: line 242 in file pract7.ncl before or near \n
time_axis_labels(oxn&time,res,restick)
--------------------------------------^

fatal:syntax error: possibly an undefined procedure
------------------------------------------------------------
--------------------------------------------

*I am not able to plot my contour with the 'time_axis_labels' function. *

Here is my code,
------------------------------------------------------------
---------------------------------------------
f = addfile("precip_2005.nc","r")
p1 = f->precip(:,{16.25:26.75},{74.75:86.25})
pr1 = p1(lat|:,lon|:,time|:)
g = addfile("precip.day.ltm.nc","r")
prm = g->precip(:,{16.25:26.75},{74.75:86.25})
prmq = prm(lat|:,lon|:,time|:)
time = f->time
prnew1 = new((/22,24,365/),float)

;computing anomoly at all points
do i = 0,21
    do j = 0,23
        do k = 0,364
            prnew1(i,j,k) = pr1(i,j,k)-prmq(i,j,k)
        end do
    end do
end do
prnew1!0 = "lat"
prnew1!1 = "lon"
prnew1!2 = "time"
prn = prnew1(time|:,lat|:,lon|:)
copy_VarAtts(p1,prn)
copy_VarCoords(p1,prn)
prn at long_name = "Daily Anomoly (data-clim)"
prn1 = prn(lon|:,lat|:,time|:)
pn = prn1(time|:,lat|:,lon|:)


;applying fft over anomoly at all points
ft1 = new((/2,365,22,24/),float)
do h = 0,21
    do k = 0,23
        gt = cfftf(pn(:,h,k),0.0,0)
        ft1(0,:,h,k) = gt(0,:)
        ft1(1,:,h,k) = gt(1,:)
    end do
end do


;filtering out unwanted frequencies
do h = 0,21
    do k = 0,23
        ft1(0,13:352,h,k) = 0.0
        ft1(1,13:352,h,k) = 0.0
        ft1(0,360:,h,k)   = 0.0
        ft1(1,360:,h,k)   = 0.0
        ft1(0,0:5,h,k)    = 0.0
        ft1(1,0:5,h,k)    = 0.0
    end do
end do

;ifft of required frequencies
ift1 = new((/365,22,24/),float)
do h = 0,21
    do k = 0,23
        kt = cfftb(ft1(:,:,h,k),1)
        ift1(:,h,k) = kt(:)
    end do
end do
copy_VarAtts(pn,ift1)
copy_VarCoords(pn,ift1)
oxn = ift1(lon|:,lat|:,time|:)
oxn at long_name = "30-60 day anomaly of precipitation"

wks   = gsn_open_wks ("png", "lat_time3" )  ; send graphics to PNG file
 res                  = True                ; plot mods desired
 res at cnFillOn         = True                ; color on
 res at lbLabelStride    = 2                ; every other label
 res at lbOrientation    = "Vertical"          ; vertical label bar
 res at pmLabelBarOrthogonalPosF = -0.04       ; move label bar closer to axis
 res at cnLinesOn        = False               ; turn off contour lines
 res at cnFillPalette    = "ViBlGrWhYeOrRe"    ; set color map

 res at tiMainString     = "Anomalies at 80.25E central india"  ; title

 res at vpXF             = 0.12                ; default is 0.2 (aspect ratio)
 res at vpYF             = 0.8                 ; default is 0.8
 res at vpHeightF        = 0.4                 ; default is 0.6
 res at vpWidthF         = 0.75                ; default is 0.6

 res at cnLevelSelectionMode = "AutomaticLevels" ; manual levels

 restick = True
 restick at ttmFormat = "%d %c %Y"
time_axis_labels(oxn&time,res,restick)
plot = gsn_csm_contour(wks,oxn({80.25},:,200:215), res)
------------------------------------------------------------
-----------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180720/3e4393fa/attachment.html>


More information about the ncl-talk mailing list