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

Home » Public Forums » archive » Re: Trailing singular dimensions disappearing. Call for discussion.
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
Re: Trailing singular dimensions disappearing. Call for discussion. [message #3731] Tue, 28 February 1995 10:38
afl is currently offline  afl
Messages: 51
Registered: December 1994
Member
In article <3ius72$52g@hermod.uio.no>, steinhh@amon.uio.no (Stein Vidar Hagfors
Haugan) writes:
|>
|>
|> I have come across the following annoying "feature" of IDL through
|> a programming project: If you type e.g.,
|>
|> IDL> HELP, fltarr(10,1,1) ; you get:
|> <Expression> FLOAT = Array(10)
|>
|> But if you say
|>
|> IDL> HELP, fltarr(1,1,10) ; you get:
|> <Expression> FLOAT = Array(1, 1, 10)
|>
|> In our applications, it matters that the data arrays retain the
|> correct number of dimensions, as we have e.g., axis names for each
|> dimension. The above behaviour is clearly inconsistent, and IDL
|> is definitely doing something that is not intuitively obvious,
|> nor is it desirable at all times.
|>
|> The behaviour I would like is:
|>
|> Whenever I create an array with so and so many dimensions
|> (singular as well..), I'd like it to stay that way, until explicitly
|> told otherwise.



Although cumbersome, I think the solution below accomplishes what you want.
This may work when creating arrays with fltarr, etc., but it is easy to
conceive of cases where this would not work (i.e., when data arrays
are created through manipulations other than an initialization statement).

im=10 & jm=1 & km=1
a = reform( fltarr(im, jm, km), im, jm, km )
help, a



|>
|> When I'm indexing an array with a scalar, I'd like the dimension to
|> disappear ("reformed away"), e.g.:
|>
|> IDL> a=fltarr(10,10)
|> IDL> help,a(1,1)
|> <Expression> FLOAT = 0.00000
|>
|> This is OK, and it's what happens with today's version, but if I do
|> the following:
|>
|> IDL> help,a(1,*)
|> <Expression> FLOAT = Array(1, 10)
|>
|> or, to make the example complete, we try:
|>
|> IDL> help,a(*,1)
|> <Expression> FLOAT = Array(10)
|>
|> Here I would have liked both expressions (a(1,*) and a(*,1)) to
|> return the same thing (an Array(10)). I'd still like to be able to
|> retain a singular dimension by indexing with an array, e.g.:
|>
|> IDL> help,a(*,[1])
|> <Expression> FLOAT = Array(10, 1)
|>


Here is another solution that works, but would not be very useful for
writing general-purpose code unless maybe you wrote your own function.

a = fltarr(10,10)
sza = size(a)
help, reform( a(1,*), sza(2) )
help, reform( a(*,1), sza(1) )

--

Andrew F. Loughe email: afl@cdc.noaa.gov
University of Colorado, CIRES voice: (303) 492-0707
Campus Box 449 fax: (303) 497-7013
Boulder, CO 80309-0449 USA
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Reversed color table
Next Topic: Routine on the gridding with continuous curvature splines

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

Current Time: Wed Oct 08 19:22:17 PDT 2025

Total time taken to generate the page: 0.00536 seconds