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

Home » Public Forums » archive » When you can't concatenate structures like you expect....
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
When you can't concatenate structures like you expect.... [message #15538] Fri, 21 May 1999 00:00
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
Figure this one out.

Create a structure:

IDL>
t={latitude:0.0,longitude:0.0,decimal_time:0.0,c_date:'21-Ma y-1999'}
IDL> HELP, t, /STRUCT
** Structure <10375708>, 4 tags, length=20, refs=1:
LATITUDE FLOAT 0.00000
LONGITUDE FLOAT 0.00000
DECIMAL_TIME FLOAT 0.00000
C_DATE STRING '21-May-1999'

Now replicate it into some structure arrays:

IDL> t1=REPLICATE( t, 5 )
IDL> t2=REPLICATE( t, 10 )
IDL> HELP, t1, t2, /STRUCT
** Structure <10375708>, 4 tags, length=20, refs=3:
LATITUDE FLOAT 0.00000
LONGITUDE FLOAT 0.00000
DECIMAL_TIME FLOAT 0.00000
C_DATE STRING '21-May-1999'
** Structure <10375708>, 4 tags, length=20, refs=3:
LATITUDE FLOAT 0.00000
LONGITUDE FLOAT 0.00000
DECIMAL_TIME FLOAT 0.00000
C_DATE STRING '21-May-1999'

Concatenation is no problem:

IDL> HELP, [ t1, t2 ]
<Expression> STRUCT = -> <Anonymous> Array[15]

Now create a different structure with *exactly* the same fields and
*exactly* the same data types and dimensions, and replicate it:

IDL>
s={latitude:0.0,longitude:0.0,decimal_time:0.0,c_date:'21-Ma y-1999'}
IDL> HELP, s, /STRUCT
** Structure <1031e108>, 4 tags, length=20, refs=1:
LATITUDE FLOAT 0.00000
LONGITUDE FLOAT 0.00000
DECIMAL_TIME FLOAT 0.00000
C_DATE STRING '21-May-1999'
IDL> s1=REPLICATE( s, 10 )
IDL> HELP, s1, /STRUCT
** Structure <1031e108>, 4 tags, length=20, refs=2:
LATITUDE FLOAT 0.00000
LONGITUDE FLOAT 0.00000
DECIMAL_TIME FLOAT 0.00000
C_DATE STRING '21-May-1999'

Can't concatenate those two structures now:

IDL> HELP, [ t1, s1 ]
% Conflicting data structures: S1,concatenation.
% Execution halted at: $MAIN$
IDL>

Bummer. If you note the structure names, the hex strings 10375708 and
1031e108, this seems to distinguish what structures you can and cannot
concatenate - is this what tells IDL about the strucutre *type*?

Anyway, my first workaround didn't work (as I expected, but..):

IDL> HELP, t1, s1
T1 STRUCT = -> <Anonymous> Array[5]
S1 STRUCT = -> <Anonymous> Array[10]
IDL> s2 = REPLICATE( s, 5 )
IDL> s3 = [ s1, s2 ]
IDL> HELP, s3
S3 STRUCT = -> <Anonymous> Array[15]
IDL> s3[10:14]=t1[*]
% Conflicting data structures: <STRUCT Array[5]>,S3.
% Execution halted at: $MAIN$

Using "relaxed" structure assignment:

IDL> STRUCT_ASSIGN, s3[10:14], t1

Works fine.

Still, it's a pain in the butt when the internal representation of
structures dictates what you can and cannot concatenate. The discussion
of relaxed structure assignment in the IDL online help explains why it
is needed but the examples are for different structures where the tag
names are the same, but the data types/sizes are all different. Seems to
me that the "relaxed" assignment capability is great for those
situations where structures are quite different, but not for the simple
concatenation of structure arrays.

Anyway,

cheers,

paulv

--
Paul van Delst
Space Science and Engineering Center | Ph/Fax: (608) 265-5357, 262-5974
University of Wisconsin-Madison | Email:
paul.vandelst@ssec.wisc.edu
1225 W. Dayton St., Madison WI 53706 | Web:
http://airs2.ssec.wisc.edu/~paulv
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: 3D Puzzle
Next Topic: Basic colors for plot

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

Current Time: Wed Oct 08 19:21:23 PDT 2025

Total time taken to generate the page: 0.00608 seconds