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

Home » Public Forums » archive » Arrays in structures; workarounds?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Arrays in structures; workarounds? [message #19967] Thu, 04 May 2000 00:00 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
We've seen this one before, but it still astounds me that it stays
around from version to version of IDL.

IDL routinely drops the last dimension if the length is 1. We know
that and can deal with it for the most part. For example, we can
ensure the dimensions by REFORMing the array. The thing that gets me
is when a structure element is a one-element array, like this:

IDL> z1 = {x:reform(dblarr(1,1),1,1)}
IDL> help, /struct, z1
** Structure <40047208>, 1 tags, length=8, refs=1:
X DOUBLE Array[1, 1]

Sure enough, it's a 1x1 element array, containing just one value of
course. But when you try to extract that element, it comes out like
this:

IDL> help, z1.x
<Expression> DOUBLE = 0.0000000

Huh? A scalar? This is worse than IDL dropping the last dimensions.
It's dropping *all* the dimensions. This can be a problem, if for
example, you will be passing the value to PLOT, which takes only
arrays. And it aggravates me to h*ll!

Does anybody know a way to work around this? I've thought of some
pretty wierd things to try, like passing the struct as _EXTRA. The
only thing I can come up with is to parse the result of HELP,
OUTPUT=out, but that seems like the crappiest solution ever.

Any ideas?

Craig

P.S. ... and it goes without saying that I don't necessarily know the
tag name ahead of time.

P.P.S.
IDL> print, !version
{ alpha OSF unix 5.2 Oct 30 1998}

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: unexpected colors
Next Topic: circle plot symbol

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

Current Time: Wed Oct 08 19:42:14 PDT 2025

Total time taken to generate the page: 0.00421 seconds