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
 Batch Processing of Spectral Smoothing
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Timpani

Singapore
1 Posts

Posted - 02/18/2010 :  06:42:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver.8 and Service Release (Select Help-->About Origin):
Operating System: Vista

Hi, I am an undergraduate working on my FYP.

I have about 409 spectra that requires smoothing using the Savitzky Golay algorithm and i noticed that origin pro only takes in one dataset at a time.

I am not familiar with C and seriously require help to automate this because i think this should be trival for you guys.

I tried this but i get errors.



void please_smooth()

{

Worksheet wks= Project.Activelayer ();

foreach (column col in wks.columns)

{

smooth iy:=,<active> method:=SG npts:=5 polyorder:=2 oy:=<new>
}


}


i get the below errors.

compiling...
test_smoothing.c
D:\Program Files (x86)\OriginLab\Origin8\M4verick\OriginC\test_smoothing.c(32) :Error, Member function Project::Activelayer not defined or does not have matching prototype.
D:\Program Files (x86)\OriginLab\Origin8\M4verick\OriginC\test_smoothing.c(32) :Error, error(s) found in compiling method
D:\Program Files (x86)\OriginLab\Origin8\M4verick\OriginC\test_smoothing.c(36) :Error, Member function not defined or does not have matching prototype.
D:\Program Files (x86)\OriginLab\Origin8\M4verick\OriginC\test_smoothing.c(36) :Error, general compile error
D:\Program Files (x86)\OriginLab\Origin8\M4verick\OriginC\test_smoothing.c(32) :Error, error(s) found in compiling function please_smooth

Compiling errors found, linking cannot start!


PLease help.

Much thanks.






greg

USA
1378 Posts

Posted - 02/18/2010 :  3:06:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You cannot use LabTalk inside of Origin C unless you use the LT_execute( ) function. smooth is an X-Function callable from LabTalk.

The LabTalk equivalent of your OC code is

loop(ii,1,wks.ncols) {smooth iy:=$(ii) meth:=sg npts:=5 poly:=2;};

To do this entirely in Origin C is much more work. To begin with, the loop command 'reads' wks.ncols only once, so even if the smooth output is adding columns, the loop stops at the original last column. foreach is dynamic in that after processing one column it looks to see if there are any more to process and if you are adding columns, well ... you get the picture.
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 02/18/2010 :  7:58:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following OriginC function should do what you want ...

#include <GetNBox.h>
void SmoothWksCols()
{
	Worksheet Wks(Project.ActiveLayer());
	if(Wks.IsValid()==true)
	{

		int ptsLeft=3;
		int ptsRight=3;
		int iPolyOrder=2;
		int imethod;
		GETN_TREE(myTree)
		GETN_LIST(Method,"Smoothing Method",1,"Adjacent Averaging|Savitzky-Golay|Median Filter")
		GETN_NUM(LeftPts, "Points to Left", ptsLeft)
		GETN_NUM(RightPts,"Points to Right",ptsRight)
		GETN_NUM(PolyOrder,"Ploynomial Order",iPolyOrder)
		if(GetNBox(myTree, "Enter Smoothing Parameters"))
		{
			if (myTree.LeftPts.dVal>0)
			{
				ptsLeft=myTree.LeftPts.dVal;
			}
			if (myTree.RightPts.dVal>0)
			{
				ptsRight=myTree.RightPts.dVal;
			}
			if (myTree.PolyOrder.dVal>0)
			{
				iPolyOrder=myTree.PolyOrder.dVal;
			}
			imethod=myTree.Method.dVal;
		}		
		foreach (Column wCol in Wks.Columns)
		{
			Dataset dS;
			if(dS.Attach(wCol)==false) return;
			if(smooth(dS,imethod,ptsLeft,ptsRight,iPolyOrder )==false) return;
		}
	}
}
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