[ncl-talk] fatal:List subscripting used on non-list variable, can't continue . Finding a better way to read same named data in different files for further calculation.

grace 313695096 at qq.com
Mon Jun 20 01:03:35 MDT 2016


Hi:
  All,I have write a script to read and calculate .csv data according to the "Reading csv"example on the NCL website,but it appears warning and fatal:


fatal:List subscripting used on non-list variable, can't continue
fatal:["Execute.c":8567]:Execute: Error occurred at or near line 37 in file csv_read.ncl



 ........
.........
........
I think maybe there are some problems with the way my data stored,
I have 29 files which named with date like this:
 
Each file include some same named  csv data:
 



I can not figure a better way to read  data of the  Caotan.csv of the all date-files and calculate them,can anyone help me or give me some good idea?



This is my script:
   ;
begin


 filename1=systemfunc("ls /public/home/huanglei/cmaqdata/2016*/Caotan.csv")
  
	 time_al= new((/29,24/),float,"No_FillValue")
     oth_al = new((/29,24/),float,"No_FillValue")
     xa_al  = new((/29,24/),float,"No_FillValue")
     tc_al  = new((/29,24/),float,"No_FillValue")
     bj_al  = new((/29,24/),float,"No_FillValue")
     xy_al  = new((/29,24/),float,"No_FillValue")
     wn_al  = new((/29,24/),float,"No_FillValue")
     ya_al  = new((/29,24/),float,"No_FillValue")
	 hz_al  = new((/29,24/),float,"No_FillValue")
     yl_al  = new((/29,24/),float,"No_FillValue")
     ak_al  = new((/29,24/),float,"No_FillValue")
	 sl_al  = new((/29,24/),float,"No_FillValue")
     do i=0,28
           
          ;---Read in file as array of strings so we can parse each line.
       lines  = asciiread(filename1[i],-1,"string")
       nlines = dimsizes(lines)-1   ; First line is a header


    ;
    ; Start reading in the fields we care about:
    ; The first line is a header, so skip this.
    ;
      delim     = ","
      time = str_get_field(lines(1:25),1,delim)  
      oth  = str_get_field(lines(1:25),2,delim)  
      xa   = str_get_field(lines(1:25),3,delim)  
      tc   = str_get_field(lines(1:25),4,delim)  
	  bj   = str_get_field(lines(1:25),5,delim)  
      xy   = str_get_field(lines(1:25),6,delim)  
      wn   = str_get_field(lines(1:25),7,delim)  
      ya   = str_get_field(lines(1:25),8,delim)
	  hz   = str_get_field(lines(1:25),9,delim)  
      yl   = str_get_field(lines(1:25),10,delim)  
      ak   = str_get_field(lines(1:25),11,delim)  
      sl   = str_get_field(lines(1:25),12,delim)


            	
             time_al(i,:)= time  	
			 oth_al(i,:) = oth  
			 xa_al(i,:)  = xa  
			 tc_al(i,:)  = tc  
			 bj_al(i,:)  = bj  
			 xy_al(i,:)  = xy  
			 wn_al(i,:)  = wn  
			 ya_al(i,:)  = ya  
             hz_al(i,:)  = tc  
			 yl_al(i,:)  = bj  
			 ak_al(i,:)  = xy  
			 sl_al(i,:)  = wn
	
	 end do


              time_all=ndtooned(time_al)
			  oth_all=ndtooned(oth_al)
			  xa_all=ndtooned(xa_al)
			  tc_all=ndtooned(tc_al)
			  bj_all=ndtooned(bj_al)
			  xy_all=ndtooned(xy_al)
			  wn_all=ndtooned(wn_al)
              ya_all=ndtooned(xy_al)
			  hz_all=ndtooned(wn_al)
			  yl_all=ndtooned(ya_al)  
			  ak_all=ndtooned(ak_al)
			  sl_all=ndtooned(sl_al)




     print(time_all)


  ; calculate the avg


              oth_avg=avg(oth_al)
			  xa_avg=avg(xa_all)
			  tc_avg=avg(tc_all)
			  bj_avg=avg(bj_all)
			  xy_avg=avg(xy_all)
			  wn_avg=avg(wn_all)
              ya_avg=avg(xy_all)
			  hz_avg=avg(wn_all)
			  ya_avg=avg(ya_all)  
			  ak_avg=avg(ak_all)
			  sl_avg=avg(sl_all)


			  ssx = hz_avg + ak_avg + sl_avg
			  nsx = ya_avg + ya_avg




end




My NCL version is 6.2.0.
 How can I slove the problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160620/a839ee4b/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 14613 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160620/a839ee4b/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 14372 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160620/a839ee4b/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/octet-stream
Size: 13876 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160620/a839ee4b/attachment-0002.obj 


More information about the ncl-talk mailing list