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

Home » Public Forums » archive » Re: Non-linear data selection
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: Non-linear data selection [message #70996] Sun, 16 May 2010 06:16
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gianguido Cianci writes:

>
> On May 15, 7:27 pm, David Fanning <n...@dfanning.com> wrote:
>> aboveIndices = Where((y GE yfit) EQ 1, count)
>
> David, why didn't you use one of the following?
>
> aboveIndices2 = Where(y GE yfit, count)
> aboveIndices3 = Where(y[*] GE yfit[*], count)
>
> I have this vague memory/nightmare that I "need" to do the [*] part in
> order not to get crazy results sometimes (though I can't come up with
> a crazy example right now) so I always use aboveIndices3...
>
> So *are* there differences among these three lines? Cos they all seem
> to work for the example of the original poster. :-|

The second line (aboveIndices2) is what I originally
wrote in my code, but I changed it to give more clues
to the user about what I was doing. (I was too busy working
on my rock garden yesterday to explain myself.)

The third line is totally unnecessary and, at least with
large arrays, will cost you a big memory penalty:

http://www.dfanning.com/misc_tips/submemory.html

But, yes, they should all be equivalent in this case.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Non-linear data selection [message #70997 is a reply to message #70996] Sun, 16 May 2010 00:18 Go to previous message
cgguido is currently offline  cgguido
Messages: 195
Registered: August 2005
Senior Member
On May 15, 7:27 pm, David Fanning <n...@dfanning.com> wrote:
> aboveIndices = Where((y GE yfit) EQ 1, count)

David, why didn't you use one of the following?

aboveIndices2 = Where(y GE yfit, count)
aboveIndices3 = Where(y[*] GE yfit[*], count)

I have this vague memory/nightmare that I "need" to do the [*] part in
order not to get crazy results sometimes (though I can't come up with
a crazy example right now) so I always use aboveIndices3...

So *are* there differences among these three lines? Cos they all seem
to work for the example of the original poster. :-|

Thanks,
Gianguido
Re: Non-linear data selection [message #70998 is a reply to message #70997] Sat, 15 May 2010 19:18 Go to previous message
Joe Daal is currently offline  Joe Daal
Messages: 9
Registered: May 2010
Junior Member
This is it.
Thanks a lot, David!
Re: Non-linear data selection [message #71000 is a reply to message #70998] Sat, 15 May 2010 17:27 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Joe Daal writes:

> There is an interesting problem that I often come across.....
> I have a scattered dataset of x and y, say 1000 elements each. The
> data could be of any shape, for now, let's assume it is scattered
> allover the X-Y window.
>
> There is straight line (y=mx+b, could be some other curve as well)
> that that crosses the plot, I need to select all data points this
> line.
> If it is just a one value for y, the WHERE statement is ok, but how to
> do this?

x = Randomu(-3L, 100) * 10
y = Randomu(-5L, 100) * 10
m = 0.5
b = 3.25
yfit = m*x+b
aboveIndices = Where((y GE yfit) EQ 1, count)
Print, StrTrim(count,2) + ' points lie above the line.'

Plot, x, y, /NoData, Background=FSC_Color('white')
OPlot, x, y, PSYM=2, SYMSIZE=0.5, Color=FSC_Color('sky blue')
OPLOT, x[aboveIndices], y[aboveIndices], PSYM=4, Color=FSC_Color('red')
OPlot, x, yfit, LINESTYLE=2


Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Non-linear data selection [message #71001 is a reply to message #71000] Sat, 15 May 2010 17:01 Go to previous message
Joe Daal is currently offline  Joe Daal
Messages: 9
Registered: May 2010
Junior Member
Sorry, I meant to say: ...I need to select all the point ABOVE this
line...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Vertical Data in Google Earth KML
Next Topic: Viewing Shapefiles in IDL

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

Current Time: Wed Oct 08 15:23:29 PDT 2025

Total time taken to generate the page: 0.00700 seconds