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

Home » Public Forums » archive » IDL Question - Opposite of WHERE?
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
IDL Question - Opposite of WHERE? [message #35320] Wed, 11 June 2003 15:28 Go to next message
suicidal_10 is currently offline  suicidal_10
Messages: 1
Registered: June 2003
Junior Member
is there a command that does the opposite of the WHERE command?
Instead of returning the indeces of elements that satisfy a condition,
it returns the ones that dont satisfy it


any idea how i can do that?
Re: IDL Question - Opposite of WHERE? [message #35451 is a reply to message #35320] Thu, 12 June 2003 07:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
R.G. Stockwell writes:

> The WHERE function is quite useful, but often I find myself really needing
> a WHY function.

Yes, I notice this is conspicuously absent in the new IDL 6.0
version, too, where I find myself wishing for it a LOT! :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: IDL Question - Opposite of WHERE? [message #35455 is a reply to message #35320] Thu, 12 June 2003 04:37 Go to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"Craig Markwardt" <craigmnet@cow.physics.wisc.edu> wrote in message
news:onvfvcrsz4.fsf@cow.physics.wisc.edu...
>
> Chad Bender <cbender@hapuna.ess.sunysb.edu> writes:
>> zygnus <suicidal_10@yahoo.com> wrote:
>> : is there a command that does the opposite of the WHERE command?
>> : Instead of returning the indeces of elements that satisfy a condition,
>> : it returns the ones that dont satisfy it
>>
>> Try using the 'COMPLEMENT' keyword with where. It should return
>> an array containing the elements not returned in the result output.
>
> Adding my tidbit:
>
> COMPLEMENT is really useful when you want to know the indices of
> *both* the true and the false values of your selection. If you just
> want the false values, then as James said, you can simply negate the
> selection expression.
>
> Craig
>
> --
> ------------------------------------------------------------ --------------
> Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
> Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
> ------------------------------------------------------------ --------------

The WHERE function is quite useful, but often I find myself really needing
a WHY function. And of course, it's opposite, the WHYNOT function.

-bob
Re: IDL Question - Opposite of WHERE? [message #35461 is a reply to message #35320] Wed, 11 June 2003 18:21 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Chad Bender <cbender@hapuna.ess.sunysb.edu> writes:
> zygnus <suicidal_10@yahoo.com> wrote:
> : is there a command that does the opposite of the WHERE command?
> : Instead of returning the indeces of elements that satisfy a condition,
> : it returns the ones that dont satisfy it
>
> Try using the 'COMPLEMENT' keyword with where. It should return
> an array containing the elements not returned in the result output.

Adding my tidbit:

COMPLEMENT is really useful when you want to know the indices of
*both* the true and the false values of your selection. If you just
want the false values, then as James said, you can simply negate the
selection expression.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: IDL Question - Opposite of WHERE? [message #35464 is a reply to message #35320] Wed, 11 June 2003 17:25 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"James Kuyper" <kuyper@saicmodis.com> wrote in message
news:3EE7B26D.AD5E4A35@saicmodis.com...
> Instead of where(x eq 4), just use where(x ne 4). There's a
> corresponding way to re-write any condition, to become it's reverse. And
> of course, there's always the brute-force method of reversing your
> condition with the NOT operator, but I find that a less elegant
> solution.

Not to mention the fact that NOT does *not* work as expected with WHERE. See

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

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: IDL Question - Opposite of WHERE? [message #35466 is a reply to message #35320] Wed, 11 June 2003 16:41 Go to previous message
Chad Bender is currently offline  Chad Bender
Messages: 21
Registered: July 2001
Junior Member
zygnus <suicidal_10@yahoo.com> wrote:
: is there a command that does the opposite of the WHERE command?
: Instead of returning the indeces of elements that satisfy a condition,
: it returns the ones that dont satisfy it

Try using the 'COMPLEMENT' keyword with where. It should return
an array containing the elements not returned in the result output.

Chad Bender
Re: IDL Question - Opposite of WHERE? [message #35468 is a reply to message #35320] Wed, 11 June 2003 15:51 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
zygnus wrote:
>
> is there a command that does the opposite of the WHERE command?
> Instead of returning the indeces of elements that satisfy a condition,
> it returns the ones that dont satisfy it
>
> any idea how i can do that?

Instead of where(x eq 4), just use where(x ne 4). There's a
corresponding way to re-write any condition, to become it's reverse. And
of course, there's always the brute-force method of reversing your
condition with the NOT operator, but I find that a less elegant
solution.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Request for help using IDL in ENVI
Next Topic: Re: ION_IMAGE 8bit/24bit color

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

Current Time: Wed Oct 08 16:01:02 PDT 2025

Total time taken to generate the page: 0.01019 seconds