Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Re: index array...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 12 Topic 5535 of 6454
Post > Topic >>

Re: index arrays of structures

by Vince Hradil <hradilv@[EMAIL PROTECTED] > Mar 15, 2008 at 07:31 PM

On Mar 15, 4:07 pm, Vince Hradil <hrad...@[EMAIL PROTECTED]
> wrote:
> On Mar 15, 3:53 pm, Raghu <raghuram.narasim...@[EMAIL PROTECTED]
> wrote:
>
> > Hi,
>
> > With reference to my recent posting (IDL batch indexing), i understood
> > that i could structures. However, i haven't been able to figure out
> > one step.
>
> > Here is my code as of now:
> > ; I want to search for all the images(files) in the directory trials,
> > read them into the structure named data, and access each file within
> > the structure.
>
> > pro strcutres
> > dir1='D:\trials'
> > cd,dir1
> > files=FILE_SEARCH('*[^\.{hdr}]', /QUOTE,count=numfiles)
> > i=0
> > while i lt numfiles do begin
> > named=files(i)
> > print,named
> > data={ID:'a',sizes:fltarr(2179,761)}
> > data=replicate(data,numfiles)
> > data.sizes=findgen(numfiles)
> > openr,1,named
> > readu,1,data[i].sizes
> > close,1
> > i=i+1
> > endwhile
> > end
>
> > ERROR message- READU: Expression must be named variable in this
> > context: <FLOAT     Array[2179, 761]>.
>
> > I am getting the error here because it seems like i am not able to
> > read in the LUN 1 or named, into data[i].sizes.
>
> > Where am i going wrong ?
>
> > Raghu
>
> Hoo boy - here you go.
>
> 1-Yes, you need to use a named variable to readu
> 2-You already defined "sizes" (weird name, by the way, how about
> "values"), when you made the structure.
>
> How about this:
>
> pro strcutres
> dir1='D:\trials'
> cd,dir1
> files=FILE_SEARCH('*[^\.{hdr}]', /QUOTE,count=numfiles)
>
> data={ID:'a',values:fltarr(2179,761)}
> data=replicate(data,numfiles)
> tempval = fltarr(2179,761)
>
> for i=0L, numfiles-1 do begin
> named=files(i)
> print,named
>
> openr,1,named
> readu,1,tempval
> free_lun,1
> data[i].values = tempval
>
> endfor
>
> return
> end

BTW - why do you want to use a structure again?  The above code makes
all the data.id's = 'a'.

Why can't you just read the data into a matrix?  If you want the
structure to contain the filename then add data[i].id = named inside
the loop.
 




 12 Posts in Topic:
index arrays of structures
Raghu <raghuram.narasi  2008-03-15 13:53:47 
Re: index arrays of structures
Vince Hradil <hradilv@  2008-03-15 14:07:08 
Re: index arrays of structures
Vince Hradil <hradilv@  2008-03-15 19:31:19 
Re: index arrays of structures
Raghu <raghuram.narasi  2008-03-15 21:04:57 
Re: index arrays of structures
Vince Hradil <hradilv@  2008-03-16 05:49:23 
Re: index arrays of structures
Raghu <raghuram.narasi  2008-03-16 12:19:00 
Re: index arrays of structures
Vince Hradil <hradilv@  2008-03-16 12:29:43 
Re: index arrays of structures
Reimar Bauer <R.Bauer@  2008-03-17 15:44:07 
Re: index arrays of structures
David Fanning <news@[E  2008-03-17 09:03:48 
Re: index arrays of structures
Raghu <raghuram.narasi  2008-03-17 09:29:55 
Re: index arrays of structures
"R.G. Stockwell"  2008-03-17 11:57:03 
Re: index arrays of structures
Raghu <raghuram.narasi  2008-03-17 13:31:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 13:56:54 CST 2008.