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

Home » Public Forums » archive » Re: 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
Re: Looping code for proccessing multiple files [message #78523] Wed, 30 November 2011 12:52
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Yngvar Larsen writes:

> Apart from that, this code looks like 20-year old IDL code. It will
> not even run on IDL 8.0 and newer (or maybe with a compile option for
> backwards compability?) due to use of () instead of [] for array
> access. () was deprecated already in IDL 5.0 about 15 years ago... The
> function FINDFILE was also deprecated in IDL 5.5 about 10 years ago,
> but still works. Use FILE_SEARCH instead.

I thought this was the normal way graduate students learn
to program from their advisors. ;-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Looping code for proccessing multiple files [message #78525 is a reply to message #78523] Wed, 30 November 2011 12:44 Go to previous message
Yngvar Larsen is currently offline  Yngvar Larsen
Messages: 134
Registered: January 2010
Senior Member
On Nov 30, 12:09 pm, Rick Walton <r.d.wal...@leeds.ac.uk> wrote:
> 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

First of all, as another poster commented already, SAVEVAR should not
be inside the second loop. (I assume READVAR, SAVEVAR and STRSUBST are
user defined functions that do what they should.) Second, why is there
a user defined function AVG for averaging? IDL already contains a
function MEAN to do that.

Apart from that, this code looks like 20-year old IDL code. It will
not even run on IDL 8.0 and newer (or maybe with a compile option for
backwards compability?) due to use of () instead of [] for array
access. () was deprecated already in IDL 5.0 about 15 years ago... The
function FINDFILE was also deprecated in IDL 5.5 about 10 years ago,
but still works. Use FILE_SEARCH instead.

--
Yngvar
Re: Looping code for proccessing multiple files [message #78534 is a reply to message #78525] Wed, 30 November 2011 06:23 Go to previous message
edward.s.meinel@aero. is currently offline  edward.s.meinel@aero.
Messages: 52
Registered: February 2005
Member
Just curious, how do you know it doesn't run through the j loop? Also,
why is SAVEVAR inside the loop?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: X window requirement for batch jobs: not just for plotting
Next Topic: 3D view of DEM

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

Current Time: Wed Oct 08 13:44:03 PDT 2025

Total time taken to generate the page: 0.00586 seconds