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

Home » Public Forums » archive » Re: Reading multiple ASCII files in as 2d arrays and putting them into a 3d array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Reading multiple ASCII files in as 2d arrays and putting them into a 3d array [message #65187 is a reply to message #65185] Mon, 16 February 2009 09:22 Go to previous messageGo to previous message
polystethylene is currently offline  polystethylene
Messages: 28
Registered: February 2009
Junior Member
On Feb 16, 4:59 pm, Spon <christoph.b...@gmail.com> wrote:
> On Feb 16, 4:46 pm, polystethylene <polystethyl...@hotmail.com> wrote:
>
>
>
>> I've run into a strange problem with this:
>
>> FOR i=0,nfiles-1 do begin
>> infile = string(filefolder)+string(i+1,format='("/",i3.3,".dump")')
>> OPENR,lun,infile,/GET_LUN
>> rows = FILE_LINES(infile)
>> data = fltarr(10,nstar,nfiles)
>> framearray = fltarr(10,rows)
>> READF,lun,format ='(I2,1x,I2,1x,I2,2x,F0,2x,I0,5F0.3)',framearray
>> close,lun
>> free_lun,lun
>> data[0,0,i] = framearray
>> print,i
>> print,data[*,*,i]
>> ENDFOR
>> print,data
>> RETURN
>> END
>
>> I've stuck a print statement within the loop to check that each 2-d
>> array is being written to the 3-d array with each pass of the loop,
>> and it seemed to be working fine.
>> However, when I came to pass the variable 'data' out to another
>> procedure, I noticed it was (mainly) full of zeros. A quick print
>> statement outside the loop within the above procedure revealed that I
>> had zeros throughout the entireity of 'data', except for the final
>> value of i.
>
>> I.e. there were only values for data[*,*,124], where 124 is the last
>> value of the loop index.
>
>> Has anyone come across such behaviour before?
>
> Hi Stefan,
>
> you need to stick this line:
> data = fltarr(10,nstar,nfiles)
>
> outside your FOR loop, so you don't keep re-defining it (full of
> zeroes) at every iteration.
>
> Regards,
> Chris

Ahha of course!

Good spot. Thanks guys

I love this place :D

I have a feeling it'll be some time before I'll be able to contribute
anything back to it though =/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Creating a composite image, avoid fill data values
Next Topic: Re: another IDL oddity

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

Current Time: Fri Oct 10 15:47:25 PDT 2025

Total time taken to generate the page: 1.43794 seconds