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
 LabTalk Forum
 A script to filter (Bandpass)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

thomas-brunet

France
Posts

Posted - 11/30/2005 :  08:29:35 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin):
Operating System:

Hello !

I would like to make a script to filter (bandpass: 20kHz-30kHz) several signals. First, how could I filter a signal with a labtalk script with "ftt_bandpass(curve..., DFlow,DFhigh)" ?
The worksheet's name is "data1" and contains two columns. First one is "time(X)" and the second one "A(Y)" corresponding to the signal. After, I would like to use this script to filter automatically many columns (B(Y), C(Y), D(Y),..).
Thank you very much!

Thomas.

Mike Buess

USA
3037 Posts

Posted - 11/30/2005 :  1:45:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Thomas,

I'm not sure OriginC's fft_bandpass() function is fully implemented in Origin 7.5 but the following approach seems to work in SR5...

1. Open CodeBuilder and select File > New.
2. Select C File on the list at left.
3. Check the Add to Workspace and Fill with Default Contents options.
4. Enter a filename and path, then click OK.
5. Insert #Include <fft_utils.h> under the line #Include <Origin.h> near the top of the new file.
6. Scroll to the bottom, enter a new line and paste the following bandpass filter function to the file.
7. Select File > Open, check the Add to Workspace option at the bottom of the dialog and open the file fft_utils.c in the OriginC\OriginLab subfolder on Origin's program path.
8. Select Tools > Rebuild All to compile. If you get a compiler error apply the SR5 patch and try again.
9. Close CodeBuilder and execute by typing run_fft_bandpass(dFLow, dFHigh) in the script window and pressing Enter. (dFLow and dFHigh are the low and high cutoff frequencies.) The function will filter all Y columns in the active worksheet.
// Bandpass filter for LabTalk
int run_fft_bandpass(double dFLow, double dFHigh)
{
Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("A worksheet must be active.");
return 1;
}
int iErr;
for(int i=1;i<wks.GetNumCols();i++)
{
if(wks.Columns(i).GetType()==OKDATAOBJ_DESIGNATION_Y)
{
Curve crv(wks,i);
iErr = fft_bandpass(crv, dFLow, dFHigh);
if(iErr<0) break;
}
}
switch(iErr)
{
case -3:
out_str("Invalid cutoff frequency.");
break;
case -2:
out_str("Invalid curve.");
break;
case -1:
out_str("Curve does not meet time resolution criterion.");
default:
break;
}
return iErr;
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/30/2005 1:49:39 PM
Go to Top of Page

thomas-brunet

France
Posts

Posted - 12/01/2005 :  10:34:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much for your help, it works nice !
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