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

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Thu Jul 19 13:39:24 MDT 2018


Dilip,

The message "possibly an undefined procedure" is an important clue.  This
sometimes means that you forgot to load a library function.  (The other
common meaning is a spelling mistake.)  This load statement was in the
example that I showed you earlier, so you need to add this at the top of
your script:

load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"

Also for this to work, you must have "begin" and "end" at the top and
bottom of your code, and load statements must be placed *before* the begin
statement.  Like this:

load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
begin
    ... your main code ...
end

--Dave


On Thu, Jul 19, 2018 at 1:07 PM, Dilip V <dilip.v at students.iiserpune.ac.in>
wrote:

> 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/20180719/bcd1cd45/attachment.html>


More information about the ncl-talk mailing list