Structure Arrays [message #50350] |
Thu, 28 September 2006 08:44  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Hi,
It's one of those days. You think you know IDL but you really don't.
Well, may be someone can help.
I have an array of structures created like
s1={a:0,b:0,c:0}
s2=replicate(s1,10)
Is there a way to expand this array by another tag "d" so that
essentially every array index contains the structure {a,b,c,d}?
The reason why I don't include "d" right away is thatI read the
structure content from files, where the additional variable is not
available.
I have looked at struct_assign and create_struct, but I don't think
they can do what I want.
Does anyone have any idea except copying every freakin' tag
separately???
Thanks,
Haje
|
|
|
Re: Structure Arrays [message #50477 is a reply to message #50350] |
Fri, 29 September 2006 05:28  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Thanks, Greg, it does indeed work. As noted in my double post (sorry) I
tried to simply append the structure, which did not succeed. I am not
memory constrained, so your solution will work. Haje
greg michael wrote:
> I think struct_assign does it...
>
> IDL> t1={a:0,b:0,c:0,d:4}
> IDL> t2=replicate(t1,10)
> IDL> print,t2
> { 0 0 0 4}{ 0 0 0 4}{
> 0 0 0 4}{ 0 0 0 4}{
> 0 0 0 4}{ 0 0 0 4}{ 0
> 0 0
> 4}{ 0 0 0 4}{ 0 0 0
> 4}{ 0 0 0 4}
> IDL> s1={a:1,b:2,c:3}
> IDL> s2=replicate(s1,10)
> IDL> print,s2
> { 1 2 3}{ 1 2 3}{ 1 2
> 3}{ 1 2 3}{ 1 2 3}{ 1
> 2 3}{ 1 2 3}{ 1 2 3}{
> 1 2 3
> }{ 1 2 3}
> IDL> struct_assign,s2,t2,/nozero
> IDL> print,t2
> { 1 2 3 4}{ 1 2 3 4}{
> 1 2 3 4}{ 1 2 3 4}{
> 1 2 3 4}{ 1 2 3 4}{ 1
> 2 3
> 4}{ 1 2 3 4}{ 1 2 3
> 4}{ 1 2 3 4}
>
> regards,
> Greg
|
|
|
Re: Structure Arrays [message #50479 is a reply to message #50350] |
Fri, 29 September 2006 04:45  |
greg michael
Messages: 163 Registered: January 2006
|
Senior Member |
|
|
I think struct_assign does it...
IDL> t1={a:0,b:0,c:0,d:4}
IDL> t2=replicate(t1,10)
IDL> print,t2
{ 0 0 0 4}{ 0 0 0 4}{
0 0 0 4}{ 0 0 0 4}{
0 0 0 4}{ 0 0 0 4}{ 0
0 0
4}{ 0 0 0 4}{ 0 0 0
4}{ 0 0 0 4}
IDL> s1={a:1,b:2,c:3}
IDL> s2=replicate(s1,10)
IDL> print,s2
{ 1 2 3}{ 1 2 3}{ 1 2
3}{ 1 2 3}{ 1 2 3}{ 1
2 3}{ 1 2 3}{ 1 2 3}{
1 2 3
}{ 1 2 3}
IDL> struct_assign,s2,t2,/nozero
IDL> print,t2
{ 1 2 3 4}{ 1 2 3 4}{
1 2 3 4}{ 1 2 3 4}{
1 2 3 4}{ 1 2 3 4}{ 1
2 3
4}{ 1 2 3 4}{ 1 2 3
4}{ 1 2 3 4}
regards,
Greg
|
|
|