subscripits error

From: Setareh Rahimi <setareh.rahimi_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 02 2013 - 11:16:14 MDT

Dear all,

I run below codes to have a xy plot. Once running I get an error saying the
number of subscripts do not match the dimentions of variable. "spia" has 2
dimensions.The error is related to this line :plt(n) = gsn_csm_xy
(wks,yrfrac,spia(n,:,:),res) . I have also tried spia(n), spia(n,:),
spia(n,:,:,:) ,but those are wrong.Would you please help me to fix this
problem.

______________________________________________________________________________________________________________________________________

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

    f = addfile("precip.mon.total.v6.nc","r")
    prc2 = f->precip({62456:77035},{-35:37},{344:50})
    time = f->time({62456:77035} )

    yyyymm_i = cd_calendar(time, -2)

    ntim = dimsizes(time)

    year = yyyymm_i/100
    firstyr = year(0)
    lastyr = year(ntim-1)
    nyear = lastyr-firstyr+1
    YYYYMM = yyyymm_time(firstyr,lastyr , "integer")
    yrfrac = yyyymm_to_yyyyfrac(YYYYMM,0.0)
    printVarSummary(yrfrac)

    dimp = dimsizes(prc2)
    ntim = dimp(0)
    nlat = dimp(1)
    mlon = dimp(2)
    len = (/3,6,12,24/)
    klen = dimsizes(len)
    spi = new((/klen,ntim,nlat,mlon/),float)

    do k=0,klen-1
      spi(k,:,:,:) = dim_spi_n(prc2, len(k), False, 0)
    end do

    spia = dim_avg_n_Wrap(spi,(/1,2/))
    printVarSummary(spia)

    wks = gsn_open_wks ("ps","spia")
    res = True
    res@gsnDraw = False
    res@gsnFrame = False
    res@vpHeightF = 0.4
    res@vpWidthF = 0.8
    res@vpXF = 0.1
    res@trYMinF = -3.0
    res@trYMaxF = 3.0
    res@gsnYRefLine = 0.0
    res@xyMonoDashPattern = True
    res@xyLineThicknessF = 1
    plt = new ( klen, "graphic")
    xyLineColors = (/"black","red","blue","green"/)
    do n=0,klen-1
     res@xyLineColors = xyLineColors(n)
       res@gsnCenterString = "run="+len(n)
       plt(n) = gsn_csm_xy (wks,yrfrac,spia(n,:,:),res)
   end do
   resP = True ; modify the panel plot
   resP@txString = "SPI: Boulder: 1894-2010"
   resP@gsnMaximize = True
   ;gsn_panel(wks,plt,(/2,2/),resP)

end

-- 
S.Rahimi

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 2 11:16:23 2013

This archive was generated by hypermail 2.1.8 : Wed Aug 07 2013 - 13:59:00 MDT