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
 Integrate over several regions in a spectrum
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Dr.Klein

Germany
Posts

Posted - 03/11/2004 :  08:41:57 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello again,
I have a lot of single spectra as ASCII files (strName_a ist wavelength, strName_b is intensity). So far, I managed so import them and integrate the whole spectrum (or, cut off the part(s) that I don`t need and integrate then) using:

Curve cc(strName+"_a",strName+"_b" );
IntegrationResult result;
Curve_integrate(&cc, &result);

and for cutting :

wks.DeleteRange(0,0,798,1);
wks.DeleteRange(101,0,300,1);

but all of that ist not very satisfactory, as I really want to integrate over several regions in that spectrum. It seemed too complicated to do it in OriginC,

So I tried to incorporate LabTalk, using

LT_execute("Integrate %s_B -b 800 -e 900 ");
double integratedarea;
LT_get_var("integ.area", &integratedarea);

but with that "%s", it does it only for the first spectrum, but I am looping through a lot of spectra.

What is the easiest way to do this in OriginC, with or without LabTalk?

Oliver

cpyang

USA
1406 Posts

Posted - 03/11/2004 :  09:22:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Current Origin C support for range based calculation is quite tricky. Best would be to make a copy of the curve to do analysis, the following code will do,



// nFrom and nTo are inclusive index (0 offset) to integrate, nTo = -1 to integrate to the end
bool integrate(curvebase& cuv, IntegrationResult& result, int nFrom = 0, int nTo = -1)
{
if(0 == nFrom && -1 == nTo)
return Curve_integrate(&cuv, &result);

// if range specified, must make local copy
// to ensure that the original range is not modified
int nNumMissingInCopy, nSrcOffset;
Curve cc(cuv, nNumMissingInCopy, nSrcOffset,
CURVECOPY_SCAN_OVER_MISSING_FROM_LEFT | CURVECOPY_SCAN_OVER_MISSING_FROM_RIGHT | CURVECOPY_SKIP_MISSING_INSIDE,
nFrom, nTo);

return Curve_integrate(&cc, &result);
}


void test(int i1, int i2)
{
IntegrationResult aa;
if(integrate(Project.ActiveCurveBase(), aa, i1, i2))
{
printf("From %f to %f, area = %f\n", aa.x1, aa.x2, aa.Area);
}
}





CP




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