Re: Sort and Where - SOLVED! [message #20487] |
Fri, 30 June 2000 00:00 |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Simon de Vet wrote:
>
> I've managed to solve my problem.
>
> First I defined the array to remove all the negative values:
>
> nozero = where( pem1(flight, *, 6) gt 0.0 and pem1(flight, *, 9) gt 0.0)
>
> Then I sorted the filter array by the size of the y-coordinates, and
> applied it to the arrays:
>
> x-coordinates:
> pem1(flight, nozero(sort(pem1(flight, nozero, 6))), 9)
>
> y-coordinates:
> pem1(flight, nozero(sort(pem1(flight, nozero, 6))), 6)
>
> The problem lay in where I was sorting. I was originally trying to sort the
> array data itself, instead of trying to sort the index I had already
> created.
>
> Yay!
>
> Simon
Simon,
sounds like you may wish to try my ind_comb routine from my library
at
http://www.mpimet.mpg.de/~schultz.martin/idl/ . This allows you to
combine the results of sequential WHERE operations. In your example:
ok1 = where( pem1(flight, *, 6) gt 0.0)
ok2 = where( pem1(flight, *, 9) gt 0.0)
nozero = ind_comb(ok1, ok2, "AND")
I wrote this when I had to deal with data similar to yours and ran
into this kind of situation over and over again.
Regards,
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|
Re: Sort and Where - SOLVED! [message #20488 is a reply to message #20487] |
Fri, 30 June 2000 00:00  |
Simon de Vet
Messages: 36 Registered: May 2000
|
Member |
|
|
I've managed to solve my problem.
First I defined the array to remove all the negative values:
nozero = where( pem1(flight, *, 6) gt 0.0 and pem1(flight, *, 9) gt 0.0)
Then I sorted the filter array by the size of the y-coordinates, and
applied it to the arrays:
x-coordinates:
pem1(flight, nozero(sort(pem1(flight, nozero, 6))), 9)
y-coordinates:
pem1(flight, nozero(sort(pem1(flight, nozero, 6))), 6)
The problem lay in where I was sorting. I was originally trying to sort the
array data itself, instead of trying to sort the index I had already
created.
Yay!
Simon
|
|
|