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
 Origin Forum
 Smoothing external data possible?

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
Steve_t Posted - 07/08/2005 : 06:12:49 AM
Origin Version (Select Help-->About Origin): 7.5SR4
Operating System: Win XP SP2

Hello, i've got a bigger number of files (several hundred *.txt) here. Each has 2 Columns, X-Y, space-seperated.

I have to smooth them using Savitzky-Golay. Is this possible somehow from Origin?
I'd like to do the smoothing (if possible on a selected number of files) before importing the data... (or do i have to use Matlab or something like that?)

Thanks in advance for the trouble.
Bye,
Steffen
8   L A T E S T    R E P L I E S    (Newest First)
Steve_t Posted - 07/08/2005 : 7:12:41 PM
Hello,

thank you for the fast Answer. I'll try it Monday morning when i'm back in office.

Have a nice Weekend!

Bye,
Steffen
Mike Buess Posted - 07/08/2005 : 11:33:46 AM
Try this...

string strPath,strName;
strPath = GetFilePath(saFilePaths[i]);
strName = GetFileName(saFilePaths[i],true); // strip extension
wks.ExportASCII(strPath + strName + "_smooth.txt", WKS_EXPORT_ALL);

Mike Buess
Origin WebRing Member
Steve_t Posted - 07/08/2005 : 10:37:58 AM
Hello,

Script worked fine (just changed it to: smooth(cv, 2, 20,20,1 ); ).
Thanks alot!

But i have another problem: The script will overwrite the original files (okay, backup is possible), but would it be possible to save the new files in a way like that (e.g. insert string "_smooth"):
test.txt --> test_smooth.txt

I tried around with lstrcat, but didn't get a working solution. I also couldn't find something like String-split...

Does anyone have another idea?

Thanks and sorry for the trouble.
Greets,
Steffen

Edited by - Steve_t on 07/08/2005 10:40:17 AM
Steve_t Posted - 07/08/2005 : 09:01:38 AM
Thanks to you both,

I'll try both ways. Thank you.

I'm not too experienced in programming in Origin, but i think i've gotta change that in the nearest future...

Steffen
Leo_Li Posted - 07/08/2005 : 08:57:42 AM
Hi Steffen,

Try to following automating routine:
1. In Origin7.5, open "Code Builder"
2. File->New a C file, copy and paste codes (in below) into it, then File->Add to Workspace
3. Tools->Compile
4. In Origin7.5, Open "Script Window"
5. Type "dosmooth", and then press "Enter"
6. In the "Open ASCII" dialog, select multiple files (e.g. 600)...
7. The program will import, smooth, close your ASCII files one by one...


void dosmooth()
{
// Open file dialog box
int iNumSelFiles;
StringArray saFiletypes, saFilePaths;
saFiletypes.SetSize(2);
saFiletypes[0]="[All Files (*.*)] *.*";
saFiletypes[1]="[ASCII Text (*.DAT)] *.DAT";

iNumSelFiles = GetMultiOpenBox(saFilePaths, saFiletypes, "", "", "Import ASCII");

// Hanle ASCII files one by one
for (int i = 0; i < saFilePaths.GetSize(); i++)
{
ASCIMP ascimp;
if(AscImpReadFileStruct(saFilePaths[i], &ascimp)==0)
{
// Read to worksheets
Worksheet wks;
wks.Create("Origin");
wks.ImportASCII(saFilePaths[i], ascimp);

// Smooth it
Curve cv(wks, 0, 1);
// BOOL smooth(Curve &cc, int method, int leftpts , int rightpts, int polydeg)
// mothed = 2: Savitzky-Golay; ileftpts = 3; irightpts = 3; ipolydeg = 2;
smooth(cv, 2);

// Save
wks.ExportASCII(saFilePaths[i], WKS_EXPORT_ALL);

// Close
wks.Destroy();
}
}
}


Note that X must be equi-spaced, or Origin will report run time error.

Edited by - Leo_Li on 07/08/2005 09:01:58 AM
Mike Buess Posted - 07/08/2005 : 08:57:01 AM
If you intend to import the data to Origin there is no advantage to smoothing first. Batch processing is done frequently in Origin (I do a lot myself). For example, see the following sample project in your Origin folder...

\Samples\Programming\Automation\AutomationExample.opj

Mike Buess
Origin WebRing Member
Steve_t Posted - 07/08/2005 : 07:54:05 AM
quote:

...but I don't understand why you want to smooth before importing.


The reason is that i have about 600 files files (each 5MB in Size) and i would like to have done this in an automatic process. I hoped, there would be an easy way (for a newbie ;-) ).

Thanks for the script (i found that also yesterday evening), but i tried to do it without importing the data.

Steffen
Mike Buess Posted - 07/08/2005 : 07:09:46 AM
Hi Steffen,

Savitzky-Golay smoothing is available in both LabTalk and Origin C but I don't understand why you want to smooth before importing. Here's an example for smoothing data in a worksheet...

http://www.originlab.com/forum/topic.asp?TOPIC_ID=3432

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/08/2005 07:10:30 AM

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