Looping code for proccessing multiple files [message #78535] |
Wed, 30 November 2011 03:09 |
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
|
|
|