IDL Question - Opposite of WHERE? [message #35320] |
Wed, 11 June 2003 15:28  |
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  |
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  |
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  |
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 #35466 is a reply to message #35320] |
Wed, 11 June 2003 16:41  |
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  |
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.
|
|
|