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

Home » Public Forums » archive » Arrays of Structures
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: Arrays of Structures [message #52455 is a reply to message #20472] Thu, 08 February 2007 10:59 Go to previous messageGo to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
Mick,

>
> (I think) I'm following you to here...
>
>> Meaning that structs.a[23] doesn't make sense because structs.a is an
>> int.
>
> ... but this is where you lose me. Doesn't the the first line that you
> showed say that structs.a is an array of 50 ints?
> Maybe I just can't read the output of HELP properly, but struts.a
> certainly sometimes behaves as an array. Try PRINTing it, for
> instance.
> Or let's compare the output of HELP on a real array of 50 ints:

True, this is a little odd. I like to think of structures as a
container holding things like a. In this case a is an integer and you
have an array of the containers. The other way to do it would be
IDL> structs = {a:intarr(50)}
IDL> help, structs
STRUCTS STRUCT = -> <Anonymous> Array[1]
IDL> help, structs, /str
** Structure <84bd4a4>, 1 tags, length=100, data length=100, refs=1:
A INT Array[50]

Where the thing in the container, a, is an integer array and you only
have one container.

The way that I use structures on a day to day basis is that I read in
a satellite data file that has a bunch of fields in certain coordinate
systems, I store all that in a structure, I then call routines to
change around the coordinate systems and add the parameters to the
structure in that routine so that the container now has more stuff in
it. Then I repeat this for lots of things. So the original structure
is not an array but has arrays and scalars in it, then if I want more
files I read them into the same structure making the structure an
array, that still contains scalars and vectors.

IDL> dat=read_sim('2001101131206.sim')
IDL> help, dat
DAT STRUCT = -> <Anonymous> Array[1]
IDL> help, dat, /str
** Structure <82731ec>, 7 tags, length=301112, data length=301108,
refs=1:
THETA FLOAT Array[12540]
R FLOAT Array[12540]
INTENSITY FLOAT Array[12540]
FIELD4 FLOAT Array[12540]
HEADER STRUCT -> <Anonymous> Array[1]
X FLOAT Array[12540]
Y FLOAT Array[12540]

Of course to make it more confusing still there is a structure header
inside my structure dat

IDL> help, dat.header
<Expression> STRUCT = -> <Anonymous> Array[1]
IDL> help, dat.header, /str
** Structure <84d4ccc>, 21 tags, length=152, data length=148, refs=2:
TIME STRING '2001101131206'
FORMAT STRING 'PT'
NITER INT 6
SDEV FLOAT 0.490877
XSTART FLOAT -3.14159
XEND FLOAT 3.14159
YSTART FLOAT 1.00000
YEND FLOAT 7.00000
XLENGTH INT 209
YLENGTH INT 60
XSTORAGE STRING 'POINT'
YSTORAGE STRING 'POINT'
GSTORAGE STRING 'ROW'
ZEROS STRING 'IGNORE'
ORDER STRING 'NEW'
UNFILLED INT 0
BAD FLOAT -5.00000
GMIN FLOAT 0.00000
GMAX FLOAT 1.00000e+30
XCYCLIC STRING 'YES'
YCYCLIC STRING 'NO'

So I print those elements like this:
IDL> print, dat.header.time
2001101131206


We'll get to the bottom of this.


Brian

------------------------------------------------------------ ---------
Brian A. Larsen
Dept. of Physics
Space Science and Engineering Lab (SSEL)
Montana State University - Bozeman
Bozeman, MT 59717
[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
Previous Topic: image rotation Fits headers?
Next Topic: .sav format

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

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

Total time taken to generate the page: 0.00448 seconds