Hello Setareh,
the documentation about the "gsn_csm_xy" function
<http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_xy.shtml>
is pretty clear.
I copy and paste parts here:
function gsn_csm_xy (
wks [1] : graphic,
x : numeric,
y : numeric,
res [1] : logical
)
x
y
The X and Y coordinates of the curve(s). If x and/or y are two-dimensional, then the leftmost dimension determines the number of curves.
So, in your case, what are the dimensions of your x and y, i.e. yrfrac,spia(n,:,:)?
Hint: the documentation allows for two dimensional variables at most. It seems your spia is at least 3D...
If spia is indeed 3D, then pretending it is anything else, such as
> spia(n), spia(n,:), spia(n,:,:,:)
certainly will not correct the error.
It may help to ask yourself how many curves you are trying to produce...
Hope this helps!
--
Alessandra Giannini
IRI for Climate and Society - The Earth Institute at Columbia University
P.O. Box 1000, Palisades NY 10964-8000
phone/fax: +1 845 680-4473/4864 - email: alesall@iri.columbia.edu
On Aug 2, 2013, at 1:16 PM, Setareh Rahimi <setareh.rahimi@gmail.com> wrote:
> 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
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 2 11:28:28 2013
This archive was generated by hypermail 2.1.8 : Wed Aug 07 2013 - 13:59:00 MDT