[ncl-talk] An error occurred reading times

grace 313695096 at qq.com
Thu Jan 8 01:01:57 MST 2015


Hello:
 I want to add  lightning data on a plot,which is drawn with wrfout data,but it report errors as fellow:
fatal:Subscript out of range, error in subscript #0
fatal:An error occurred  reading times
fatal:["Execute.c":8567]:Execute: Error occurred at or near  line 49 in file /home/Huanglei/wrf_Cloudgraup_add_L.ncl‍

Here is my script,could you guys give me some tips?Any information will be appreciated.
;   Example script to produce plots for a WRF real-data run,
;   with the ARW coordinate dynamics option.


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/wrf/WRFUserARW.ncl"


begin
;
; The WRF ARW input file.  
; This needs to have a ".nc" appended, so just do it.
  a = addfile("/home/Huanglei/data/wrfoutd032013080521"+".nc","r")            




; We generate plots, but what kind do we prefer?
 ; type = "eps"
 type = "pdf"
; type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"20130806plt_Cloudgraup1020")


  gsn_define_colormap(wks,"precip_11lev")
; Set some basic resources
  res = True
  res at MainTitle = "REAL-TIME WRF"
 ; res at gsnDraw      =  False                  
  ;res at gsnFrame     =  False


  mpres  = True  ; Map resources
  mpres at mpOutlineOn = False  ; Turn off map outlines
  mpres at mpFillOn    = False  ; Turn off map fill
  mpres at mpGridAndLimbOn = True
  pltres = True ; Plot resources
  pltres at PanelPlot  = True   ; Tells wrf_map_overlays not to remove overlays




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; What times and how many time steps are in the data set?
  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;  do it =1, ntimes-1,1        ; TIME LOOP
   it = 136
    print("Working on time: " + times(it) )
    res at TimeLabel = times(it)   ; Set Valid time to use on plots
   ; print(it + (/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14/))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need        
    if(isfilevar(a,"QGRAUP"))
	  qi = wrf_user_getvar(a,"QGRAUP",it )
      qi = qi*1000.
      qi at units = "g/kg"   
    end if


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    do level = 13,15,2      ; LOOP OVER LEVELS


      display_level = level + 2
      opts = res
      opts at cnFillOn         = True
      opts at gsnSpreadColors  = False
      opts at ContourParameters       = (/ 1, 19, 2 /)
      opts at PlotLevelID      = "Eta Level  " + display_level
	  opts at gsnDraw      =  False                  
      opts at gsnFrame     =  False




      if (isvar("qi"))
        qis  = qi(level + (/0,1,2,3,4,5,6/),:,:)
        qisum = dim_sum_n_Wrap(qis, 0)
        contour = wrf_contour(a,wks,qisum,opts)
        plot = wrf_map_overlays(a,wks,(/contour/),pltres,mpres)


        delete(contour)
      end if
;>============================================================<
;                      add  map
;>------------------------------------------------------------<


     
  shp_name1    = "/home/Huanglei/map/China/diquJie_polyline.shp"


  lnres                  = True
  lnres at gsLineColor      = "gray25"
  lnres at gsLineThicknessF = 0.5   


 id = gsn_add_shapefile_polylines(wks,plot,shp_name1,lnres)
  shp_name2    = "/home/Huanglei/map/China/cnmap/cnhimap.shp"


  prres=True
  prres at gsLineThicknessF = 2.0       
  prres at gsLineColor = "black"
  plotcn3 = gsn_add_shapefile_polylines(wks,plot,shp_name2,prres)


   txres2  = True
   txres2 at txFont  = 10
   txres2 at txFontHeightF =0.01
   txres2 at txFontColor = "Blue"
   txdum1 =gsn_add_text(wks, plot, "Chengdu", 104.06,30.67, txres2)


  draw(plot)       ; This will draw the map and the shapefile outlines.




   delete(opts)
;>============================================================<
;                      add  lightning
;>------------------------------------------------------------<‍

ascii_filename = "/home/Huanglei/data/20130806/utc11.txt"
  seismic = asciiread(ascii_filename,(/183,3/),"float")   
  
    y = seismic(:,0)  ; Column 1 of file contains X values.
    x = seismic(:,1)  ; Column 2 of file contains Y values.
    z = seismic(:,2)  ; Column 3 of file contains Z values.
  txres2  = True
  txres2 at txFont  = 0.01
  txres2 at txFontHeightF =0.01
  txres2 at txFontColor = "Red"
 idx = ind(z .gt. 0)
 print(idx)
if .not. all(ismissing(idx))
    str = new(dimsizes(idx), "string")
    str = "+"
    txdum1 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if


txres2 at txFontColor = "Blue"


idx := ind(z .lt. 0)
if .not. all(ismissing(idx))
    str := new(dimsizes(idx), "string")
    str = "-"    
    txdum2 = gsn_add_text(wks, plot, str, x(idx),y(idx), txres2)
end if
   draw(plot) 
  frame(wks)
    end do      ; END OF LEVEL LOOP


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;  end do        ; END OF TIME LOOP     


end

‍
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150108/df4a8eea/attachment.html 


More information about the ncl-talk mailing list