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

Home » Public Forums » archive » array referencing problem ...
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
array referencing problem ... [message #42954] Tue, 08 March 2005 08:43 Go to next message
Andreas Brunn is currently offline  Andreas Brunn
Messages: 3
Registered: April 2003
Junior Member
dear listland
I have a problem referencing a three dimensional array with a two
dimensional mask. One solution I�m well aware of is building a two
dimensional array and copy this in each channel of the three dimensional.
But there must be a more elegant and memory saving method doing this, so i
tried the following and ran in an in my eyes a little bit strange behaviour:

ENVI> a=findgen(5,5,5)
ENVI> ma=where(a le 10)
ENVI> print, (a(*,*,1))(ma)
25.0000 26.0000 27.0000 28.0000 29.0000 30.0000 31.0000 32.0000 33.0000
34.0000 35.0000
thats what I hoped and expected as a result

but if I try the following:
ENVI> (a(*,*,1))(ma) = 2
% Expression must be named variable in this context: <FLOAT Array[5, 5]>.
% Execution halted at: $MAIN$

I only get that error message, where is my mistake ?

Is there a way applying this mask on each of the channels without copying
each channel in a two dimensional array ?

thanx a lot in advance

Andi
Re: array referencing problem ... [message #43036 is a reply to message #42954] Wed, 09 March 2005 23:01 Go to previous message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
> Here is an article that might help:
>
> http://www.dfanning.com/code_tips/tempvar.html

While this article is still covers the point, its a little bit
outdated:
IDL now correctly complains about the expression.

IDL> p = ptr_new( {a:1, b:2, s:{x:0,y:0, a:[256,256,48]} } )
IDL> ((*p).s.a)[2] = ((*p).s.a)[2] * 4
% Expression must be named variable in this context: <INT
Array[3]>.
% Execution halted at: $MAIN$


But there is still another bug in IDL:

function ret,a
return,a
end

IDL> a=1
IDL> ++(ret(a[0]))
IDL> print,a
1
But this only happens if used as a statement:

IDL> print,++(ret(a[0]))
% Expression must be named variable in this context: <INT (
1)>.
% Execution halted at: $MAIN$


Ah, and did I mention that GDL
(http://gnudatalanguage.sourceforge.net/)
behaves correctly in all cases :-)

Cheers,
marc
Re: array referencing problem ... [message #43045 is a reply to message #42954] Tue, 08 March 2005 16:02 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Andreas Brunn writes:

> I have a problem referencing a three dimensional array with a two
> dimensional mask. One solution I�m well aware of is building a two
> dimensional array and copy this in each channel of the three dimensional.
> But there must be a more elegant and memory saving method doing this, so i
> tried the following and ran in an in my eyes a little bit strange behaviour:
>
> ENVI> a=findgen(5,5,5)
> ENVI> ma=where(a le 10)
> ENVI> print, (a(*,*,1))(ma)
> 25.0000 26.0000 27.0000 28.0000 29.0000 30.0000 31.0000 32.0000 33.0000
> 34.0000 35.0000
> thats what I hoped and expected as a result
>
> but if I try the following:
> ENVI> (a(*,*,1))(ma) = 2
> % Expression must be named variable in this context: <FLOAT Array[5, 5]>.
> % Execution halted at: $MAIN$
>
> I only get that error message, where is my mistake ?

Too many parentheses. :-)

Here is an article that might help:

http://www.dfanning.com/code_tips/tempvar.html


> Is there a way applying this mask on each of the channels without copying
> each channel in a two dimensional array ?

I would have a look at the Dimensional Juggling Tutorial:

http://www.dfanning.com/tips/rebin_magic.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: calling c from idl
Next Topic: Extract an image

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

Current Time: Wed Oct 08 14:00:59 PDT 2025

Total time taken to generate the page: 0.00562 seconds