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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Batch Processing of Spectral Smoothing

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Timpani Posted - 02/18/2010 : 06:42:45 AM
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.






2   L A T E S T    R E P L I E S    (Newest First)
rlewis Posted - 02/18/2010 : 7:58:25 PM
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;
		}
	}
}
greg Posted - 02/18/2010 : 3:06:48 PM
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.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000