Re: Loop over files variables in list

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 23 2011 - 07:37:25 MST

; Read all file names in directory
    diri = "./" ; input directory
    fili = systemfunc("cd "+diri+" ; ls foo*nc")
    print(fili) ; all file names
    nfili = dimsizes(fili)
; Establish list of all possible files; *no* reading is done
; 'f' is a variable of type 'list'; index via [...]
    f = addfiles(diri+fili, "r")

    do nf=0,nfili-1
       x = f[n]->WIND

    end do


alternatively, do a standard loop

    do nf=0,nfili-1
       f = addfile(diri+fili(nf), "r")
       x = f->WIND

    end do

On 11/23/11 3:01 AM, Davis, Neil wrote:
> I am trying to write a routine which needs to loop over a file list
> created by addfiles. Running the command dimsizes on the list returns a
> value of 1 no matter how many elements are in the list. I see when I use
> printVarSummary that there is a variable output as Total Items which
> gives the correct number of items in the list.
> Is there any NCL function which would allow me to obtain that value or
> provide another method to loop over the files in the list.
> Thank you,
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Wed Nov 23 07:37:31 2011

This archive was generated by hypermail 2.1.8 : Wed Nov 23 2011 - 16:46:19 MST