Author |
Topic |
|
reputs
5 Posts |
Posted - 11/26/2010 : 05:57:03 AM
|
hello,
my prob is that i have superimposed to curves (emission spectrum of a lamp and excitation spectrum of a substance), which are crossing each other several times. Now i want to want to quantify the area under both curves, i.e. the integral intersection. how could i do this? i'm working with version 8.5.
thanks and greets, reputs |
|
easwar
USA
1964 Posts |
Posted - 11/28/2010 : 10:47:08 PM
|
Hi reputs,
There is no gui tool to do this for such intersection, but this could be done with some calculation on the existing data.
For sake of simplicity let me assume your data is arranged as XYY, so that the two spectra share a common X column. Then to the worksheet add a fourth column, and do Set Column values on this newly added column and set the formula using ternary operator: col(2)<col(3)?col(2):col(3)
What this will do is fill the 4th col with value that is minimum of col2 and col3 for each row, and this should then give you the intersection curve. Then you can find the area under this new intersection curve using Analysis->Mathematics->Integrate tool to find the cross section area.
If your data is not organized this way, and is not easy to rearrange this way, then send us an example dataset/opj and we can look into this further.
Here's how to send us data: http://originlab.com/index.aspx?go=Support&pid=752
Easwar OriginLab |
|
|
reputs
5 Posts |
Posted - 11/29/2010 : 10:52:58 AM
|
hi easwar,
thanks for the answer. unfortunately my data is not organized with a common X column. The X values are similar but not equal. so your proposed method of searching for the minimum of the values in the two Y columns is an option, but not ideal. i'm sending a dataset via e-mail for further advice.
best regards, reputs |
|
|
larry_lan
China
Posts |
Posted - 11/30/2010 : 08:30:37 AM
|
Hi:
If the X data range of your two curves is close, maybe you can try the Simple Math tool to subtract two curve. This tool performs interpolation internally.
Let's simplify the problem and look at the below example. Supposed your data is:
And it should looks like:
Now, our target is calculate the area of Part C, the intersection of curve 1 and 2.
First, we can use the Simple Math tool (the vmathtool X-Function) to subtract these two curves. This can be found from "Analysis -> Mathematics -> Simple Curve Math". Let's say, curve 1, short for C1, is the cyan curve, and curve 2, short for C2, is the blue curve.
Note the logic that, if I do (C1 - C2), then integrate the Absolute area of the subtracted curve, I can get the area of (Part A + Part B). Then, the area of Part C can be calculate by:
(Area_of_C1 + Area_of_C2 - Area_of_Subtracted_Curve) / 2
You can try the below script to calculate the area of Part C using my sample data.
range rc1 = !col(4); range rc2 = !col(2); integ1 rc1 type:=abs oy:=<optional>; double c1_area = integ1.area; integ1 rc2 type:=abs oy:=<optional>; double c2_area = integ1.area; vmathtool ix1:=rc1 operator:=sub operand:=data ix2:=rc2 ox:=<new>; integ1 wcol(wks.ncols) type:=abs oy:=<optional>; double empty_area = integ1.area; double intersect_area = (c1_area + c2_area - empty_area) / 2; ty "Intersect Area is: $(intersect_area)";
For more information about running the script and the vmathtool X-Function, please read our Programming Help.
Thanks Larry OriginLab |
Edited by - larry_lan on 11/30/2010 08:44:29 AM |
|
|
reputs
5 Posts |
Posted - 12/02/2010 : 11:14:13 AM
|
hi larry_lan,
as far as I can see, the script is working. thanks for that. but i don't get the results in the form "Intersect Area is: ...", as written in the script. i only get the areas of C1 and C2 and of the subtracted curve in the results window. how can i visualize the final result?
thanks and regards,
reputs |
|
|
larry_lan
China
Posts |
Posted - 12/02/2010 : 10:03:15 PM
|
Hi:
Can you copy your output here? And you can type the variables to see which one is wrong:
range rc1 = !col(4); range rc2 = !col(2); integ1 rc1 type:=abs oy:=<optional>; double c1_area = integ1.area; integ1 rc2 type:=abs oy:=<optional>; double c2_area = integ1.area; vmathtool ix1:=rc1 operator:=sub operand:=data ix2:=rc2 ox:=<new>; integ1 wcol(wks.ncols) type:=abs oy:=<optional>; double empty_area = integ1.area; double intersect_area = (c1_area + c2_area - empty_area) / 2; c1_area = ; c2_area = ; empty_area = ; intersect_area = ; ty "Intersect Area is: $(intersect_area)";
If you organize your data in different workbooks/worksheets, please reorganize them like what I posted, or modify the data range in the script.
Thanks Larry |
|
|
reputs
5 Posts |
Posted - 12/03/2010 : 08:48:05 AM
|
Hi Larry,
I arranged the data in one worksheet, exactly as shown in your example.
here is what my results window tells me:
[12/3/2010 14:31:17 "" (2455533.605058)] integ1 Input iy = [Book1]Sheet1!(C,D) baseline = 0 type = 1 (abs:Absolute Area) plot = 0 Output x1 = 199.93 x2 = 700.01 i1 = 1 i2 = 501 area = 0.91929736198907 y0 = 0.03611 x0 = 199.93 dx = 20.244243666754
[12/3/2010 14:31:17 "" (2455533.605058)] integ1 Input iy = [Book1]Sheet1!(A"wavelength",B"intensity") baseline = 0 type = 1 (abs:Absolute Area) plot = 0 Output x1 = 200 x2 = 700 i1 = 1 i2 = 501 area = 0.99807039721343 y0 = 0.036921233327923 x0 = 436 dx = 326.41328594149
[12/3/2010 14:31:18 "" (2455533.605069)] integ1 Input iy = [Book1]Sheet1!(C,E"Math 1") baseline = 0 type = 1 (abs:Absolute Area) plot = 0 Output x1 = 199.93 x2 = 700.01 i1 = 1 i2 = 501 area = 1.4135766537561 y0 = -0.036891696558735 x0 = 436 dx = 283.11878978152
Don't consider me as experienced origin user, maybe I just place the script or search for the result at the wrong place.
Thanks and regards,
reputs |
|
|
larry_lan
China
Posts |
Posted - 12/05/2010 : 9:28:00 PM
|
From your output, I guess you just look at the Result Log? Please run the script and look the final result in the Script Window (menu: Window -> Script Window).
Thanks Larry |
|
|
reputs
5 Posts |
Posted - 12/06/2010 : 05:58:17 AM
|
Hi Larry,
your guess was right. Everything fine now. Thanks a lot.
Cheers, Markus |
|
|
|
Topic |
|
|
|