[ncl-talk] need Help

yohanan sweet marsilas23 at gmail.com
Wed Oct 25 23:23:30 MDT 2017


dear ncl talk

I need help if there is anyone can help me.

I was using grid data of my country with NetCDF format. but I cannot
understand what the error is if anyone can help me.this is my code and the
error it gives me is.

begin
;--------------------------------------------------------------------------
f =   "Sweetheart.nc"
;f = "mon.precip.nc"
fin  = addfile(f, "r")
timet = fin->time
ymd = round(timet, 3)

;ymd = cd_calendar(timet,2)
iTim =  ind (ymd.ge.19830101.and.ymd.lt.20100101)
precpi = fin->precip(iTim,{4:8},{34:39})
;==============================================================================
timem =precpi&time
rain = rmMonAnnCycTLL(precpi)
prec_jjas1 = rain(2::12,:,:)
rf1= runave_Wrap(rain(lat|:,lon|:,time|:),4,0)
arr_jjas1= (/rf1(time|2::12,lat|:,lon|:)/)

arr_jjas1!0 = "time"
arr_jjas1!1  = "lat"
arr_jjas1!2 = "lon"
arr_jjas1&time = prec_jjas1&time
arr_jjas1&lat = prec_jjas1&lat
arr_jjas1&lon = prec_jjas1&lon
printVarSummary(arr_jjas1)

yene = dim_avg_Wrap (arr_jjas1(time|:,lat|:,lon|:))
 yene2 = dim_avg_Wrap(yene)
 stand = dim_standardize_Wrap(yene2,1)
;printVarSummary(stand)
;*************************************************************************
 fil = "Sweetheart.nc"
 ;fil = "mon.precip.nc"
  fin1 =addfile(fil,"r")
  timep = fin1->time
ymd1 = round(timet, 3)

  ;ymd1 = cd_calendar(timep,2)
  iTim = ind(ymd1.ge.19830101.and.ymd1.lt.20100101)
  precip = fin1->precip(iTim,:,:)
;***************************************************************************
mare =rmMonAnnCycTLL(precip)
time = mare&time
prec_jjas = mare(3::12,:,:)
rf= runave_Wrap(mare(lat|:,lon|:,time|:),3,0)
arr_jjas= (/rf(time|3::12,lat|:,lon|:)/)

arr_jjas!0 = "time"
arr_jjas!1  = "lat"
arr_jjas!2 = "lon"
arr_jjas&time = prec_jjas&time
arr_jjas&lat = prec_jjas&lat
arr_jjas&lon = prec_jjas&lon
printVarSummary(arr_jjas)
;===========calculate corelation==========================================
ccr = escorc(stand,arr_jjas(lat|:,lon|:,time|:))
copy_VarCoords(prec_jjas(0,:,:),ccr)
printVarSummary(ccr)
printMinMax(ccr,0)
;========================================================================
siglvl =0.05
test = rtest(ccr(lat|:,lon|:),34,0)
test = where(ismissing(ccr),test at _FillValue,test)

test!0 =  "lat"
test!1 ="lon"
test&lat = ccr&lat
test&lon =ccr&lon
printVarSummary(test)
;==============================================================================
wks = gsn_open_wks("x11","Correlation")
gsn_define_colormap(wks,"precip_diff_12lev")
res = True
res at cnFillOn     = True
;res at cnLineOn =   True
res at cnLevelSelectionMode = "ManualLevels"
res at mpCenterLonF =180
res at cnMinLevelValF       = -0.6
res at cnMaxLevelValF       =  0.6
res at cnLineLabelsOn = False

res at cnLevelSpacingF      = 0.1
;res at gsnSpreedColors = True
res at mpPerimOn =False
res at tiMainString         = " (a) Corr (SERI ,MAM  precipitation and 850-hpa
winds) "
res at mpFillOn  = False
res at gsnDraw =False
res at cnLinesOn            = False
res1 =True
res1 at gsnDraw =False
res1 at gsnFrame     =  False

res1 at cnLevelSelectionMode = "ManualLevels"
res1 at cnMinLevelValF       = 0.00       ; min level
res1 at cnMaxLevelValF       =  1.05
res1 at cnLevelSpacingF      = 0.05
res1 at cnInfoLabelOn = False
res1 at cnLinesOn = False
res1 at cnLineLabelsOn = False
 ;res at mpMinLatF            = 3     ; range to zoom in on

       ;res at mpMaxLatF            = 15
       ;res at mpMinLonF             = 33
       ;res at mpMaxLonF            = 48
       ;res at mpOutlineBoundarySets = "National"
       ;res at mpAreaMaskingOn =True

res1 at cnLineLabelOn  = False
res1 at cnFillScaleF = 0.6 ;add extra density
res1 at gsnDraw      =  False                   ; do not draw the plot
res1 at gsnFrame     =  False                   ; do not advance the frame
;res at tiMainString =   "Correlation between NIO  and rainfall 9month led "
plot0    = gsn_csm_contour_map(wks,ccr,res)

opt =True
opt at gsnShadeFillType = "pattern"
opt at gsnShadeLow = 17
opt at gsnShadeDotSizeF = 0.6
plot1    = gsn_csm_contour(wks,test,res1)
plot1    = gsn_contour_shade(plot1,0.05,0.75,opt)
;=========================================================================================
ECMWF   = "/home/cyoo/scratch/reanl/ecmwf/monthly/"
fileU   = systemfunc ("ls "+ECMWF+"uwnd/u.mon.*.nc")
F    =  addfiles (fileU, "r")
timeu = F[:]->time
ymds = cd_calendar(timeu,2)
iTim1 =  ind (ymds.ge.19790101.and.ymds.lt.20120101)
uwind  = F[:]->u (iTim1,{850},:,:)
;======================================================================
Uanom =rmMonAnnCycTLL(uwind)
;T = Uanom&time
 T = uwind&time

;ym1 =cd_calendar(T,0)
 ;month1 = tointeger(ym1(:,1))
 ;imon1 = ind(month1.ge.02.and.month1.le.05)

U1 = Uanom(2::12,:,:)
ub1= runave_Wrap(Uanom(lat|:,lon|:,time|:),4,0)
uu21= (/ub1(time|2::12,lat|:,lon|:)/)
uu21!0 = "time"
uu21!1  = "lat"
uu21!2 = "lon"
uu21&time = U1&time
uu21&lat = U1&lat
uu21&lon = U1&lon
;printVarSummary(uu21)

U = dim_avg_Wrap(uu21(lat|:,lon|:,time|:))

;=====================================================================
fileV   = systemfunc ("ls "+ECMWF+"vwnd/v.mon.*.nc")
fv      =  addfiles (fileV, "r")
time2 = fv[:]->time
ymd2 = cd_calendar(time2,2)
iTim2 =  ind (ymd2.ge.19790101.and.ymd2.lt.20120101)
vwind =  fv[:]->v (iTim2,{850},:,:)
Vanom =rmMonAnnCycTLL(vwind)
;T1 = Vanom&time
;T1 = vwind&time
V1 = Vanom(2::12,:,:)
vb1= runave_Wrap(Vanom(lat|:,lon|:,time|:),4,0)
vu21= (/vb1(time|2::12,lat|:,lon|:)/)
vu21!0 = "time"
vu21!1  = "lat"
vu21!2 = "lon"
vu21&time = V1&time
vu21&lat = V1&lat
vu21&lon = V1&lon
V = dim_avg_Wrap(vu21(lat|:,lon|:,time|:))


  res2           = True
  res2 at vcMinFracLengthF     = 0.3
  res2 at vcRefMagnitudeF       = 20               ; define vector ref mag
  res2 at vcRefLengthF          =   0.04      ; define length of vec ref
res2 at vcGlyphStyle               = "LineArrow"
res2 at vcMinDistanceF        = 0.02           ; thin out vectors
  ;res2 at vcGlyphStyle          = "CurlyVector"        ; turn on curley
vectors
  res2 at gsnDraw               = False                ; don't draw yet
  res2 at gsnFrame              = False                ; don't advance frame
yet
  res2 at vcLineArrowThicknessF      = 1.5
  res2 at gsnLeftString         = ""                   ; turn off strings
  res2 at gsnRightString        = ""

plotV = gsn_csm_vector(wks,U,V,res2)





overlay(plot0,plot1)                       ; overlay the U-wind plot on the
rainfall plot
overlay(plot0,plotV)
draw(plot0)                                  ; draw the rainfall plot (with
the U-wind plot overlaid)
frame(wks)
end

fatal:["NclFile.c":2099]:Subscript out of range, error in subscript #0
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 22 in file
stan
dardizerain.ncl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171026/114013be/attachment.html>


More information about the ncl-talk mailing list