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

Home » Public Forums » archive » Re: Array definition
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: Array definition [message #55271] Wed, 08 August 2007 10:53
Bob[3] is currently offline  Bob[3]
Messages: 60
Registered: December 2006
Member
On Aug 8, 1:38 pm, Conor <cmanc...@gmail.com> wrote:
> On Aug 8, 1:18 pm, Yaswant Pradhan <Yaswant.Prad...@gmail.com> wrote:
>> avoid FOR loop, use WHERE
>> indices = where(array GT value, n_wh)
>
> specifically:
>
> array_size = size(array1, /dimensions)
> array2 = fltarr(array_size)
> w = where( array1 gt value, c )
> if c gt 0 then array2[w] = array1[w]

w will be an array of the indices, sized to the number of elements of
array1 gt value (given by c), which is what Melanie was looking for
afaict.
array2 will be the same size as array1, but will have masked out any
elements le value. (mask should be 0.0).
Re: Array definition [message #55273 is a reply to message #55271] Wed, 08 August 2007 10:38 Go to previous message
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Aug 8, 1:18 pm, Yaswant Pradhan <Yaswant.Prad...@gmail.com> wrote:
> On Aug 8, 6:00 pm, Melanie <mkjone...@gmail.com> wrote:
>
>> Hi,
>> I am trying to check an array of about 19000 elements for values that
>> are above a certain value. I then want to save only the index of the
>> larger values in a new array.
>
> avoid FOR loop, use WHERE
> indices = where(array GT value, n_wh)
>
>
>
>> So, I am going through the original array with a for loop and checking
>> if each value is greater than 19:
>> for i=0, nelements-1 do begin
>> if (array1[i] gt 19) then...
>
>> Next, if the value in array1 is in fact greater than 19, I want to
>> save the value of i into a new array such as
>
>> if(array1[i] gt 19) then array2[...]=i
>
>> But I'm not sure how to make this work such that I can write each
>> subsequent i value for which the value in array1 is gt 19 into each
>> subsequenbt space in array2...
>
>> Any ideas? Please let me know if this question is not clear...

specifically:

array_size = size(array1, /dimensions)
array2 = fltarr(array_size)
w = where( array1 gt value, c )
if c gt 0 then array2[w] = array1[w]
Re: Array definition [message #55275 is a reply to message #55273] Wed, 08 August 2007 10:18 Go to previous message
yp is currently offline  yp
Messages: 42
Registered: February 2005
Member
On Aug 8, 6:00 pm, Melanie <mkjone...@gmail.com> wrote:
> Hi,
> I am trying to check an array of about 19000 elements for values that
> are above a certain value. I then want to save only the index of the
> larger values in a new array.

avoid FOR loop, use WHERE
indices = where(array GT value, n_wh)

>
> So, I am going through the original array with a for loop and checking
> if each value is greater than 19:
> for i=0, nelements-1 do begin
> if (array1[i] gt 19) then...
>
> Next, if the value in array1 is in fact greater than 19, I want to
> save the value of i into a new array such as
>
> if(array1[i] gt 19) then array2[...]=i
>
> But I'm not sure how to make this work such that I can write each
> subsequent i value for which the value in array1 is gt 19 into each
> subsequenbt space in array2...
>
> Any ideas? Please let me know if this question is not clear...
Re: Array definition [message #55276 is a reply to message #55275] Wed, 08 August 2007 10:15 Go to previous message
Bob[3] is currently offline  Bob[3]
Messages: 60
Registered: December 2006
Member
On Aug 8, 1:00 pm, Melanie <mkjone...@gmail.com> wrote:
> Any ideas? Please let me know if this question is not clear...

Look at the WHERE command.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Mac OS x IDL font handling
Next Topic: byte offset in POINT_LUN

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

Current Time: Fri Oct 10 16:11:50 PDT 2025

Total time taken to generate the page: 0.05973 seconds