Re: union or overlap of two plots [message #61607] |
Tue, 22 July 2008 09:26 |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Jul 22, 3:59 pm, kedmond <kedm...@gmail.com> wrote:
> Chris,
>
> Thanks for the quick response. Your solution worked amazingly
> well....now I have to sit and figure out why!
All I'm doing is finding out which is the lower of the two values for
each point in the dataset with the MIN call, and storing the result in
YMin. Then I'm using integration to find the area under the new YMin
curve.
> To make the min()
> function work, I had to set y1 and y2 equal to their transpose() since
> min() wants the data to be in vector form. Once I did that, your
> instructions work as stated.
Yes, I had forgotten that PLOT will automatically 'flatten out' the
input in a way that array concatenation won't.
I guess to make the solution more general you could add in the Reform
command before the concatenation:
ny = N_Elements(y1)
FlatY1 = Reform(y1, ny)
FlatY2 = Reform(y2, ny)
YMin = Min([[FlatY1], [FlatY2]], Dim = 2)
Here's some tutorials to help you figure out what IDL's doing here:
http://www.dfanning.com/tips/rebin_magic.html
http://www.dfanning.com/tips/array_concatenation.html
The second one explains what all the square brackets are doing, but
I've found it's far easier to get your head around if you take the
time to read the first one beforehand!
>
> Thanks again.
>
> -Kazem
All the best,
Chris
|
|
|
Re: union or overlap of two plots [message #61610 is a reply to message #61607] |
Tue, 22 July 2008 07:59  |
kedmond
Messages: 8 Registered: July 2008
|
Junior Member |
|
|
Chris,
Thanks for the quick response. Your solution worked amazingly
well....now I have to sit and figure out why! To make the min()
function work, I had to set y1 and y2 equal to their transpose() since
min() wants the data to be in vector form. Once I did that, your
instructions work as stated.
Thanks again.
-Kazem
On Jul 22, 4:31 am, Spon <christoph.b...@gmail.com> wrote:
> On Jul 22, 3:00 am, kedmond <kedm...@gmail.com> wrote:
>
>> Hello,
>> I have two plots of data on the same axes. I need to figure out
>> the area of their overlap. I think defining the data as two polygons
>> and using polyfillv() would help, but I'm not sure about how to do
>> this. I was also considering finding all of the interceptions between
>> the two plots, and using tsum() to calculate the area of each
>> subsection of overlap. Anyways, if there's an easier way, I'd
>> appreciate it.
>
>> -kedmond
>
> How about something like this:
>
> plot, x, y1
> oplot, x, y2
>
> ymin = min( [[y1], [y2]], dim=2)
> oplot, x, ymin, thick = 2
>
> auc = int_tabulated(x, ymin)
>
> Regards,
> Chris
|
|
|
Re: union or overlap of two plots [message #61615 is a reply to message #61610] |
Tue, 22 July 2008 01:31  |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Jul 22, 3:00 am, kedmond <kedm...@gmail.com> wrote:
> Hello,
> I have two plots of data on the same axes. I need to figure out
> the area of their overlap. I think defining the data as two polygons
> and using polyfillv() would help, but I'm not sure about how to do
> this. I was also considering finding all of the interceptions between
> the two plots, and using tsum() to calculate the area of each
> subsection of overlap. Anyways, if there's an easier way, I'd
> appreciate it.
>
> -kedmond
How about something like this:
plot, x, y1
oplot, x, y2
ymin = min( [[y1], [y2]], dim=2)
oplot, x, ymin, thick = 2
auc = int_tabulated(x, ymin)
Regards,
Chris
|
|
|