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

Home » Public Forums » archive » help with - count in where() function
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: help with - count in where() function [message #90872 is a reply to message #90868] Fri, 01 May 2015 07:33 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Thursday, April 30, 2015 at 12:32:32 PM UTC-5, g.na...@gmail.com wrote:
> Hi
>
> I wrote a simple example of my code to understand the behaviour of count in the where() function but I still don't understand something.
>
> My example:
>
> array = [[-1,2,3,4,5],[6,-7,8,9,10]]
> mask =bytarr(5,5)
> for i=0L,4 do begin
> for j=0L, 4 do begin
> IF (TOTAL(ARRAY GT 5.)+ TOTAL(Array LT 0.)) EQ 0 THEN mask[i,j]=1
> endfor
> endfor
>
> ind = where(mask EQ 1,count)

>
> I was expecting the answers in the two last prints. I don't understand why when I print out the count it's zero.

Why do expect that to be the answer? Look at your loop again:

> for i=0L,4 do begin
> for j=0L, 4 do begin
> IF (TOTAL(ARRAY GT 5.)+ TOTAL(Array LT 0.)) EQ 0 THEN mask[i,j]=1
> endfor
> endfor

When, i=0, j=0, the total of `array GT 5` is 4 and the total of `array LT 0` is two.
When i=0, j=1, the total of `array GT 5` is 4 and the total of `array LT 0` is two.
When i=0, j=2, the total of `array GT 5` is 4 and the total of `array LT 0` is two.

See a pattern? ;-)

So, TOTAL(ARRAY GT 5.)+ TOTAL(Array LT 0.)) is never 0, as PaulV said.

Now, what exactly is the problem you're trying to solve?
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Copying contents of a function graphics window
Next Topic: Mapping southern in Northern map

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

Current Time: Fri Oct 10 10:02:40 PDT 2025

Total time taken to generate the page: 1.19817 seconds