The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Automating the Integration process (Newbie here)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

starpuma

USA
2 Posts

Posted - 04/20/2014 :  8:21:23 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 8.5
Operating System: Windows 7

Hey everybody,

I am doing research as an undergraduate and have no clue about programming so please bear with me. So, I need to integrate a an upwards of 100 graphs and each one of them have about 200 traces each. So, far I have been using the "Integrate" gadget in Origin but I am nowhere close to being done.

So the main problem is that we can only integrate one trace or curve at a time with the "integrate" gadget and since all my integrations have the same basic parameters I figured that it would be relatively easy to automate this rather daunting task because since this is such a repetitive task. I am basically doing an absolute integration over a specific X range. I found this LabTalk script "Integrate Active Curve in Graph over a Specific X Range" from the origin's website (http://www.originlab.com/doc/LabTalk/examples/Peaks-and-Baseline) that almost does what I want. Here is the code:


The following example shows how to integrate the active curve in a graph over a specific range of x values, using the integ1 X-Function.

// Purpose: This example demonstrates the following:
// 1. import a file
// 2. create a graph
// 3. integrate the curve over a specific x range


// Create new book and import a sample file
newbook;
string fname$ = system.path.program$ + "samples\curve fitting\multiple peaks.dat";
impasc;

// Plot 4th column against 1st column as a line plot
plotxy iy:=(1,4) plot:=200;

// Get row index for x values of 6.5 and 9.5, which covers the 3rd peak in the graph
int ix1=xindex(6.5,%c);
int ix2=xindex(9.5,%c);

// Integrate this range of the curve, and list the results of integration
range rr=(%c)[$(ix1): $(ix2)];
integ1 rr;
integ1.=;

______________________________________

So according to my understanding this basically does what the integration gadget does? But I don't know if this will give me a mathematical or absolute integration.
Here is what I need: I have all the graphs plotted so could somebody please help me modify this code so it would go through all the traces or curves in a graph and integrate them. I would love you forever


Thank you so much!

greg

USA
1378 Posts

Posted - 04/25/2014 :  3:58:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This should work in Origin 8.5

// BEGIN SCRIPT
// PROMPT for X range and calculation method
ix1 = 6.5;
ix2 = 9.5;
choice$ = Math Absolute;
ichoice = 1;
getn (From) ix1 (To) ix2 (Method) ichoice:choice$ (Integrate all plots);
// Setup
ichoice--; // math = 0, absolute = 1
newbook name:=Results;
layer.name$ = Areas;
range raData = 1;
range raArea = 2;
count = 0;
// Loop over all graphs then all plots in each graph
doc -e P
{
doc -e DY
{
count++;
range -w raC = %C;
xi1 = xindex(ix1,%C);
xi2 = xindex1(ix2,%C);
integ1 iy:=raC[xi1:xi2] baseline:=0 type:=$(ichoice) area:=myarea;
raData[count]$ = %C[x$(ix1):$(ix2)];
raArea[count] = myarea;
}
}
// END SCRIPT

REMINDER: LabTalk questions like this belong in the LabTalk Forum http://www.originlab.com/forum/forum.asp?FORUM_ID=10

Edited by - greg on 04/25/2014 4:01:44 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000