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

Home » Public Forums » archive » Re: WHERE approaching Flatland
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: WHERE approaching Flatland [message #34083] Wed, 19 February 2003 04:50 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
I always use the function WHERETOMULTI below. (Sorry about the line spacing)

Haje

;************************ Beginning of wheretomulti.pro
************************


PRO WhereToMulti, Array, Indices, Col, Row, Frame

;+

; NAME: wheretomulti.pro

;

; FUNCTION: Convert WHERE output to 2d or 3d indices

;

; USAGE: WhereToMulti, Array, Indices, Col, Row, Frame

;

; INPUT ARGUMENTS:

; Array: the array that was WHERE'd

; Indices: the indices returned by WHERE

;

; OUTPUT ARGUMENTS:

; Col: Indices to first dimension.

; Row: Indices to second dimension.

; Frame: Indices to third dimension. Returned only for 3-d array.

;

; OPTIONAL ARGUMENTS:

;

; KEYWORDS:

;

; REQUIRED MODULES:

;

; SIDE EFFECTS:

;

; ERROR HANDLING:

; If Array is not a vector or matrix, all return values are set to zero

; and a message is written to the screen.

;

; NOTES:

;

; HISTORY:

; 1998 Sept 15 J.L.Saba Developed based on code from David Fanning's

; web site.

;

;- End of
prologue ------------------------------------------------------------ -


s = SIZE ( Array )


NCol = s[1]

Col = Indices MOD NCol


IF s[0] EQ 2 THEN BEGIN ; 2-d array

Row = Indices / NCol

ENDIF ELSE IF s[0] EQ 3 THEN BEGIN ; 3-d array

NRow = s(2)

Row = ( Indices / NCol ) MOD NRow

Frame = Indices / ( NRow * NCol )

ENDIF ELSE BEGIN ; neither 2d or 3d

Col = 0

Row = 0

Frame = 0

PRINT, 'WhereToMulti called with bad input. Array not a vector or matrix.'

HELP, Array

ENDELSE


RETURN

END


;*************************** End of wheretomulti.pro
***************************






--
Dr. Haje Korth
Space Physics Group
The Johns Hopkins University
Applied Physics Laboratory
MS MP3-E128
11100 Johns Hopkins Road
Laurel, MD 20723-6099
USA
Phone: 240-228-4033 (Washington), 443-778-4033 (Baltimore)
Fax: 240-228-0386 (Washington), 443-778-0386 (Baltimore)


"Sean Raffuse" <sean@me.wustl.edu> wrote in message
news:b2u1d0$1nc$1@newsreader.wustl.edu...
> Hello,
>
> Is there are 2-d version of where?
>
> I would like to do this:
>
> bad = where(Array[*,*,0] GT Array[*,*,5])
>
> Array[bad,1:5] = Array[bad,0]
>
> I know that doesn't work, but after having spent some time with IDL, I'm
> allergic to loops.
>
> Thanks in advance,
>
> Sean
>
>
>
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: UNIQ without SORT
Next Topic: differences idl5.5 and idl5.6

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

Current Time: Wed Oct 08 15:55:48 PDT 2025

Total time taken to generate the page: 0.00403 seconds