[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.

Alan Brammer abrammer at albany.edu
Mon Jun 20 09:45:17 MDT 2016


Mary already answered this in her email prior to this one?

Assuming that "filename1" is a list of 29 files, you will also need to change this line:

       lines  = asciiread(fin1[i],-1,"string")

to be:

       lines  = asciiread(filename1(i),-1,"string")

—Mary


x[i]   -> list
x(i)  -> array








> On 20 Jun 2016, at 03:03, grace <313695096 at qq.com> wrote:
> 
> 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:
> <F8416A17 at 55B5D06B.47956757.png>
> Each file include some same named  csv data:
> <BE4949AD at 55B5D06B.47956757.png><BE44186F at 55B5D06B.47956757.png>
> 
> 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?
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

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


More information about the ncl-talk mailing list