<div dir="ltr">Hello,<div>That error message usually tells you exactly what is wrong: "<span style="font-size:12.8px">Subscript out of range, error in subscript #2" and "</span><span style="font-size:12.8px">Error occurred at or near line 51"</span></div><div>Based on what you sent ncl-talk, I do not think you sent the complete script. Can you tell ncl-talk what specific line the error is occurring?</div><div>As always, please respond to the ncl-talk email list only.</div><div>Adam </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 17, 2016 at 1:09 PM, Adv <span dir="ltr"><<a href="mailto:advita6@gmail.com" target="_blank">advita6@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,<br></div><div>I am getting this error. Could someone help me to fix this bug?<br><br></div><div>Thanks<br><br></div>fatal:["NclFile.c":2103]:Subscript out of range, error in subscript #2<br>fatal:["Execute.c":8575]:Execute: Error occurred at or near line 51 in file regress_dennis.ncl<br>load "./contributed.ncl_beta_640"<br><br>begin<br><br>;************************************************<br>; Specify geographical region and time span (year-month start and end<br>;************************************************<br><br> latS = 40<br>; latS = 0 <br> latN = 49<br> lonL = -116<br> lonR = -90<br><br> ymStrt = 195101<br> ymLast = 201012<br><br> pltType = "x11"<br> pltName = "regress"<br> pltTitle = "Globe: "+(ymStrt/100)+"-"+(ymLast/100)<br><br>;************************************************<br>; Read from netCDF file: variable is type short...unpack<br>;************************************************<br> version= "v2" ; "v2", "v2c"<br><br> diri = "./"<br>; fili = "air.sig995.mon.mean."+version+".nc"<br> fili = "<a href="http://air.sig995.mon.mean.nc" target="_blank">air.sig995.mon.mean.nc</a>"<br> f = addfile(diri+fili,"r")<br><br> YYYYMM = cd_calendar( f->time, -1)<br>yyy = yyyymm/100<br><br> dimx = dimsizes(x)<br> ntim = dimx(0) ; all years and months<br> nlat = dimx(1)<br> mlon = dimx(2)<br><br> year = ispan(yyyy(0), yyyy(ntim-1), 1)<br> nyrs = dimsizes(year)<br><br>;************************************************<br>; Areal averages: cos(lat) is good enough<br>;************************************************<br> wgt = cos(0.01745329*x&lat)<br> xann = month_to_annual(x , 1) ; [year| 60]x[lat| 91]x[lon| 180]<br> xavg = wgt_areaave_Wrap(xann , wgt, 1.0, 1) ; [year| 110] <br><br> xann&year = year<br> xann@long_name = "Annual Air Temperature ("+version+": sigma=0.995)"<br> printVarSummary(xann)<br> printMinMax(xann,0)<br>;return<br>;************************************************<br>; Calculate the regression coefficients (slopes) <br>;************************************************<br> rc = regCoef(year,xann(lat|:,lon|:,year|:)) <br><br> rc@long_name = "Trend"<br>rc@units = "degC/"+nyrs+"_year"<br> printMinMax(rc,0)<br><br><br>;************************************************<br>; plotting parameters <br>;************************************************<br> wks = gsn_open_wks("x11","regress_4_"+version) ; specifies a ps plot<br><br> res = True<br> res@gsnMaximize = True ; make large<br> res@cnFillOn = True ; turn on color<br> res@cnLinesOn = False ; turn off contour lines<br> res@cnLineLabelsOn = False ; turn off contour line labels<br> ;;res@cnFillMode = "RasterFill"<br><br> res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels<br>; res@cnMinLevelValF = -2.0 ; set min contour level<br> res@cnMinLevelValF = -3.0 ; set min contour level<br>; res@cnMaxLevelValF = 2.0 ; set max contour level<br> res@cnMaxLevelValF = 5.0 ; set max contour level<br>; res@cnLevelSpacingF = 0.2 ; set contour interval<br> res@cnLevelSpacingF = 0.5 ; set contour interval<br> res@mpFillOn = False ; turn off default background gray<br> ;res@mpCenterLonF = 180<br><br> res@gsnCenterString = year(0)+"-"+year(nyrs-1)<br><br> res@tiMainString = "20th Century Reanalysis ("+version+"): sig995" ; fili<br> plot = gsn_csm_contour_map_ce(wks,rc,res)<br><br><br>;************************************************<br>; Perform linear regression on selected annual mean<br>;************************************************<br><br><br> rcTest = regline_stats(year, xavg) ; degC/year<br>; rcTest@long_name = "trend: ("+toint(LAT)+","+toint(LON)+")"<br> rcTest@long_name = "trend:"<br> rcTest@units = "degC/year"<br> rcTest = rcTest*nyrs ; (C/year)*(nyrs)<br> rcTest@units = "degC/"+nyrs+"_year"<br><br> pltarry = new ( (/2,nyrs/), typeof(xann))<br> pltarry(0,:) = xavg ; use markers<br> pltarry(1,:) = rcTest@Yest ; regression values<br><br> resxy = True ; plot mods desired<br> resxy@xyMarkLineModes = (/"Markers","Lines"/); choose which have markers<br> resxy@xyMarkerColors = (/"Red", "Blue" /); choose which have markers<br> resxy@xyMarkers = 16 ; choose type of marker <br> resxy@xyMarkerSizeF = 0.0075 ; Marker size (default 0.01)<br><br> resxy@xyDashPatterns = 0 ; solid line <br> resxy@xyLineThicknesses = (/2,3/)<br> resxy@xyLineColors = (/ "blue" , "black" /)<br> resxy@tmYLFormat = "f" ; not necessary but nicer labels <br><br> ;;resxy@trXMinF = min(year)<br> resxy@trXMaxF = max(year)<br> resxy@tiMainString = "regline: 20th Renalysis ("+version+"): trend="+sprintf("%5.2f", rcTest)<br><br> ;---Make legend smaller and move into plot<br> resxy@pmLegendDisplayMode = "Always" ; turn on legend<br> resxy@pmLegendSide = "Top" ; Change location of <br> resxy@pmLegendParallelPosF = 0.225 ; move units Leftt<br> resxy@pmLegendOrthogonalPosF = -0.30 ; move units down<br> resxy@pmLegendWidthF = 0.10 ; Change width and<br> resxy@pmLegendHeightF = 0.100 ; height of legend.<br> resxy@lgPerimOn = True ; turn off/on box around<br> resxy@lgLabelFontHeightF = .015 ; label font height<br> resxy@xyExplicitLegendLabels = (/"data" , "regline" /)<br> plot = gsn_csm_xy (wks,year,pltarry,resxy) ; create plot<br><br> end<br><br></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist, </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a> </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</div>