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

Home » Public Forums » archive » Re: Indexing structures of different type
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: Indexing structures of different type [message #15914] Thu, 17 June 1999 00:00
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Donglai Gong Rm3110 x1569 <donglai@eden.rutgers.edu> writes:
>
> Hi, does anyone know how to index structures of different types in IDL?
>
> REPLICATE won't work since it creates an array of the same structure, so
> I'm thinking of doing a structure of structures. However I don't know
> how to index them for use in a loop. Thanks in advance.

If you are *really* trying to glue a bunch of different types
together, you should probably structures as you say.

How to loop over them? This is easily done with a little magic:

;; Initialize your structure
s = {u:0L, v:0D, w:intarr(5), x:{a:1, b:2}, y:'hello'}

n = n_tags(s)
for i = 0L, n-1 do begin
;; The magic is here:
f = s.(i)

;; Operate on f here:
print, f
endfor

However, you should be aware that IDL structures are pretty slow to
operate on, especially when you build large ones. [ Some versions of
IDL have a limit on the number of elements in a structure too. ]

Good luck,
Craig



--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Indexing structures of different type [message #15916 is a reply to message #15914] Thu, 17 June 1999 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Donglai Gong Rm3110 x1569 wrote:
> Hi, does anyone know how to index structures of different types in IDL?
> REPLICATE won't work since it creates an array of the same structure, so
> I'm thinking of doing a structure of structures. However I don't know
> how to index them for use in a loop. Thanks in advance.

Perhaps the following example might help:

a = {name:'test', value:intarr(10)}
b = {time:0L, lat:0.0, lon:0.0}
c = {part1:replicate(a, 100), part2:replicate(b, 20)}
help, a, b, c, /structure

print, c.part1[10].name
print, c.part1[10].value[0:5]
print, c.part2[15:*].time

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
Re: Indexing structures of different type [message #15917 is a reply to message #15914] Thu, 17 June 1999 00:00 Go to previous message
Donglai Gong Rm3110 x is currently offline  Donglai Gong Rm3110 x
Messages: 2
Registered: June 1999
Junior Member
David Fanning wrote:
>
> Donglai Gong Rm3110 x1569 (donglai@eden.rutgers.edu ) writes:
>
>> Hi, does anyone know how to index structures of different types in IDL?
>
> Uh, pointers?
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438 E-Mail: davidf@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155

I don't know pointer very well, if you could kindly show me how to
approach this problem(or pointer in general) I'd appreciate it.

Thanks,
Donglai
Re: Indexing structures of different type [message #15919 is a reply to message #15914] Thu, 17 June 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Donglai Gong Rm3110 x1569 (donglai@eden.rutgers.edu ) writes:

> Hi, does anyone know how to index structures of different types in IDL?

Uh, pointers?

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: heap and stack
Next Topic: Re: RedHat 6.0, lmgrd error?

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

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

Total time taken to generate the page: 0.00664 seconds