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 #52448 is a reply to message #20472] Thu, 08 February 2007 12:21 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Feb 8, 12:09 pm, "R.G. Stockwell" <n...@email.please> wrote:
> "Mick Brooks" <mick.bro...@gmail.com> wrote in message
>
> news:1170957886.387622.208430@l53g2000cwa.googlegroups.com.. .
> ...
>
>> ... 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?
>
> Not exactly. The key point is that structs.a is an EXPRESSION.
> Also, "struct" is an array of structures.
>
> You cannot do
> IDL> EXPRESSION(10)
> , you must first cast the expression
> IDL> (EXPRESSION)[10]
>
> It is not an operator precedence thing.
>
> Cheers,
> bob

I'm not sure that is an expression thing either. When I try to index
an expression, I get a syntax error:

IDL> print, findgen(10)[5]

print, findgen(10)[5]
^
% Syntax error.

which can be fixed by using parenthesis:

IDL> print, (findgen(10))[5]
5.00000

But Mick's error is giving the "out of bounds index" error. Using
parenthesis is not fixing a syntax error -- it's indexing something
else.

More poking around with a slight variation of Brian's weird example:

IDL> dat2 = replicate({a:findgen(25)}, 50)
IDL> help, dat2
DAT2 STRUCT = -> <Anonymous> Array[50]
IDL> help, dat2, /structures
** Structure <2614a44>, 1 tags, length=100, data length=100, refs=1:
A FLOAT Array[25]
IDL> help, dat2.a
<Expression> FLOAT = Array[25, 50]

OK, now try the unholy notation:

IDL> help, dat2.a[24]
<Expression> FLOAT = Array[50]
IDL> print, dat2.a[24]
24.0000 24.0000 ... (50 times)
IDL> help, dat2.a[25]
% Subscript range values of the form low:high must be >= 0, < size,
with low <= high: <No name>.
% Execution halted at: $MAIN$

I think that the only way to interpret this is that the structure dat2
is being dereferenced by a[24] (although I agree it seems inconsistent
with the precedence rules). Check out the example of:

CONTOUR, cat[5:50].inten[2:8]

in the online help:

http://idlastro.gsfc.nasa.gov/idl_html_help/
Arrays_of_Structures.html

Also,

On Feb 8, 10:03 am, "Mick Brooks" <mick.bro...@gmail.com> wrote:
> IDL> indices = [1, 3, 27]
> IDL> HELP, structs.a[indices]
> <Expression> INT = Array[3, 50]

> Where did that extra dimension come from?

Using the logic from above, I think the same place as:

IDL> k = 1
IDL> print, k[0]
1
IDL> print, k[1]
% Attempt to subscript K with <INT ( 1)> is out of range.
% Execution halted at: $MAIN$
IDL> print, k[[1]]
1
IDL> print, k[[1, 2, 3]]
1 1 1
IDL> help, k[[1, 2, 3]]
<Expression> INT = Array[3]

Mike
--
www.michaelgalloy.com
[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:23:44 PDT 2025

Total time taken to generate the page: 0.00441 seconds