comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Looping code for proccessing multiple files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Looping code for proccessing multiple files [message #78535] Wed, 30 November 2011 03:09
Rick Walton is currently offline  Rick Walton
Messages: 3
Registered: November 2011
Junior Member
Hi,

I'm very new to this game but would be grateful for some advice on
applying a simple process to multiple files.

See below for my code so far. The problem I am encountering is that
the routine will not run through the second for loop and attempts to
repeat the first for loop over and over on the first file that it
reads. Funnily enough, at first I accidentally used 'i' in both for
loops and this enabled both for loops to run but with the second
expression in the second for loop limited to the second expression in
the first for loop.

Please can anyone offer any help with this?

N = N_ELEMENTS(FINDFILE('*Norm.var'))
PRINT, 'Number of files: ', N

myfile_array = FINDFILE('*Norm.var')

FOR i = 0, N-1 DO BEGIN
mv = readvar(myfile_array(i), /sr) ;Reads
input file
PRINT, myfile_array(i)

mv2 = fltarr(31,31,252) ;Creates new array

FOR j=0,251 do begin mv2(*,*,j)=avg(mv(4:35,4:35,j)) ;Takes
the average of region between co-ordinates 4 and 35 in x and y axes

savevar, STRSUBST(myfile_array(i), '\\Norm.var', 'Norm Avg C1.var'),
mv2, /sr
;Saves new file (mv2) with
file name adapted from original file name

ENDFOR
ENDFOR
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDLDoc Error
Next Topic: Re: LONG64 in NetCDF-4 files

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:15:21 PDT 2025

Total time taken to generate the page: 0.00746 seconds