[ncl-talk] Sub: Set lonL/lonR error

Adam Phillips asphilli at ucar.edu
Tue May 17 14:55:20 MDT 2016


Hello,
That error message usually tells you exactly what is wrong: "Subscript out
of range, error in subscript #2"  and "Error occurred at or near line 51"
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?
As always, please respond to the ncl-talk email list only.
Adam

On Tue, May 17, 2016 at 1:09 PM, Adv <advita6 at gmail.com> wrote:

> Hi,
> I am getting this error. Could someone help me to fix this bug?
>
> Thanks
>
> fatal:["NclFile.c":2103]:Subscript out of range, error in subscript #2
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 51 in
> file regress_dennis.ncl
> load "./contributed.ncl_beta_640"
>
> begin
>
> ;************************************************
> ; Specify geographical region and time span (year-month start and end
> ;************************************************
>
>   latS     = 40
> ;  latS     = 0
>   latN     =  49
>   lonL     =  -116
>   lonR     = -90
>
>   ymStrt   = 195101
>   ymLast   = 201012
>
>   pltType  = "x11"
>   pltName  = "regress"
>   pltTitle = "Globe: "+(ymStrt/100)+"-"+(ymLast/100)
>
> ;************************************************
> ; Read from netCDF file: variable is type short...unpack
> ;************************************************
>    version= "v2"         ; "v2", "v2c"
>
>    diri   = "./"
> ;   fili   = "air.sig995.mon.mean."+version+".nc"
>    fili   = "air.sig995.mon.mean.nc"
>    f      = addfile(diri+fili,"r")
>
>    YYYYMM = cd_calendar( f->time, -1)
> yyy   = yyyymm/100
>
>    dimx = dimsizes(x)
>    ntim = dimx(0)                ; all years and months
>    nlat = dimx(1)
>    mlon = dimx(2)
>
>    year  = ispan(yyyy(0), yyyy(ntim-1), 1)
>    nyrs  = dimsizes(year)
>
> ;************************************************
> ; Areal averages: cos(lat) is good enough
> ;************************************************
>  wgt   = cos(0.01745329*x&lat)
>    xann  = month_to_annual(x , 1)                 ; [year| 60]x[lat|
> 91]x[lon| 180]
>   xavg  = wgt_areaave_Wrap(xann , wgt, 1.0, 1)   ; [year| 110]
>
>    xann&year  = year
>    xann at long_name = "Annual Air Temperature ("+version+": sigma=0.995)"
>    printVarSummary(xann)
>    printMinMax(xann,0)
> ;return
> ;************************************************
> ; Calculate the regression coefficients (slopes)
> ;************************************************
>    rc           = regCoef(year,xann(lat|:,lon|:,year|:))
>
>    rc at long_name = "Trend"
> rc at units     = "degC/"+nyrs+"_year"
>    printMinMax(rc,0)
>
>
> ;************************************************
> ; plotting parameters
> ;************************************************
>    wks  = gsn_open_wks("x11","regress_4_"+version)       ; specifies a ps
> plot
>
>    res                       = True
>    res at gsnMaximize           = True             ; make large
>    res at cnFillOn              = True             ; turn on color
>    res at cnLinesOn             = False            ; turn off contour lines
>    res at cnLineLabelsOn        = False            ; turn off contour line
> labels
>  ;;res at cnFillMode            = "RasterFill"
>
>    res at cnLevelSelectionMode  = "ManualLevels"   ; set manual contour
> levels
> ;   res at cnMinLevelValF        =  -2.0            ; set min contour level
>    res at cnMinLevelValF        =  -3.0            ; set min contour level
> ;   res at cnMaxLevelValF        =   2.0            ; set max contour level
>    res at cnMaxLevelValF        =   5.0            ; set max contour level
> ;   res at cnLevelSpacingF       =   0.2            ; set contour interval
>    res at cnLevelSpacingF       =   0.5            ; set contour interval
>   res at mpFillOn              = False            ; turn off default
> background gray
>   ;res at mpCenterLonF          = 180
>
>    res at gsnCenterString       = year(0)+"-"+year(nyrs-1)
>
>    res at tiMainString          = "20th Century Reanalysis ("+version+"):
> sig995"    ; fili
>    plot = gsn_csm_contour_map_ce(wks,rc,res)
>
>
> ;************************************************
> ; Perform linear regression on selected annual mean
> ;************************************************
>
>
>    rcTest = regline_stats(year, xavg)           ; degC/year
> ;   rcTest at long_name = "trend: ("+toint(LAT)+","+toint(LON)+")"
>    rcTest at long_name = "trend:"
>    rcTest at units     = "degC/year"
>    rcTest           = rcTest*nyrs                       ; (C/year)*(nyrs)
>    rcTest at units         = "degC/"+nyrs+"_year"
>
>    pltarry      = new ( (/2,nyrs/), typeof(xann))
>    pltarry(0,:) = xavg              ; use markers
>    pltarry(1,:) = rcTest at Yest                           ; regression
> values
>
>    resxy                     = True                   ; plot mods desired
>    resxy at xyMarkLineModes     = (/"Markers","Lines"/); choose which have
> markers
>  resxy at xyMarkerColors      = (/"Red", "Blue"    /); choose which have
> markers
>    resxy at xyMarkers           = 16                     ; choose type of
> marker
>    resxy at xyMarkerSizeF       = 0.0075                 ; Marker size
> (default 0.01)
>
>    resxy at xyDashPatterns      = 0                      ; solid line
>    resxy at xyLineThicknesses   = (/2,3/)
>    resxy at xyLineColors        = (/ "blue" , "black" /)
>    resxy at tmYLFormat          = "f"                    ; not necessary but
> nicer labels
>
>  ;;resxy at trXMinF                =  min(year)
>    resxy at trXMaxF                =  max(year)
>    resxy at tiMainString           = "regline: 20th Renalysis
> ("+version+"):  trend="+sprintf("%5.2f", rcTest)
>
>  ;---Make legend smaller and move into plot
>    resxy at pmLegendDisplayMode    = "Always"            ; turn on legend
>    resxy at pmLegendSide           = "Top"               ; Change location
> of
>    resxy at pmLegendParallelPosF   = 0.225               ; move units Leftt
>    resxy at pmLegendOrthogonalPosF = -0.30               ; move units down
>    resxy at pmLegendWidthF         = 0.10                ; Change width and
>    resxy at pmLegendHeightF        = 0.100               ; height of legend.
>    resxy at lgPerimOn              = True                ; turn off/on box
> around
>  resxy at lgLabelFontHeightF     = .015                ; label font height
>    resxy at xyExplicitLegendLabels = (/"data" , "regline" /)
>    plot                       = gsn_csm_xy
> (wks,year,pltarry,resxy)           ; create plot
>
>    end
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160517/e39050cb/attachment.html 


More information about the ncl-talk mailing list