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
 Origin Forum
 Pre-processing of gigantic time series data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

eno

Japan
34 Posts

Posted - 06/23/2003 :  04:21:38 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I'm a beginner of Origin 7.
I would like to pre-process gigantic time series data (170,000 rows),
such as moving average, turbulence intensity (standard deviation / mean value).
How do I have to descrive a LabTalk or Origin C script for these functions?

Thanks,
eno

Mike Buess

USA
3037 Posts

Posted - 06/24/2003 :  10:46:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi eno,

If your data are in column B of the active worksheet you can do the following.

1> Standard deviation/mean (use sum() function)...
sum(col(B));
// results show up in the following variables
sum.mean= mean value
sum.sd= standard deviation
sum.total= total value
sum.min= smallest value
sum.max= largest value
sum.n= number of values

2> Running average (use Average command). This command changes the dataset it operates on, so you might want to make a copy of it first...
win -c Ave; // create a column named Ave
copy col(B) col(Ave); // copy rows from col B to col Ave
Average -n 3 col(Ave); // replace col Ave with a running average of 7 values (i-3 to i+3)

Hope that helps.


Mike Buess
Origin WebRing Member
Go to Top of Page

eno

Japan
34 Posts

Posted - 06/25/2003 :  01:04:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,
Thank you for your advice.

Can you give me more information about Standard deviation/mean ?

If the length of column B is 24 hours(time series data), and I calculate Standard deviation/mean every ten-minute, I can get 24hours * 60minutes / 10minutes = 144 Standard deviation/mean values. That's what I want. How should I customize these scripts that you suggested.

Thanks,
eno



Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 06/25/2003 :  11:13:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
sum() can operate on a subset of a column...

set col(B) -b 5;
set col(B) -e 8;
sum(col(B)); // operate only on rows 5 through 8

Create 2 columns in the same worksheet and name them "mean" and "sd". To sum inc rows at a time...

get col(B) -e npt; // how many rows?
loop (i,1,npt/inc) {
j=inc*(i-1); k=j+inc; j++;
set col(B) -b j;
set col(B) -e k;
sum(col(B));
col(mean)[i]=sum.mean;
col(sd)[i]=sum.sd;
};
set col(B) -b 1; // reset display range to first row

Mike Buess
Origin WebRing Member
Go to Top of Page

easwar

USA
1965 Posts

Posted - 06/25/2003 :  12:09:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi eno,

And here is an Origin C solution for the same thing:
Cut and paste the code posted below to a new Origin C file.
Once you compile this file, you can then go to script window and enter a command such as
tscompute data1_b 10
which would then create a new worksheet, and compute min, max, mean, and std dev on groups of 10, for the data in data1_b

Easwar
OriginLab.


void tscompute(string strDatasetName, int iGroupSize)
{
// Declare dataset and verify
Dataset dsData(strDatasetName);
if(!dsData)
{
printf("Dataset is not valid!\n");
return;
}

// Check group size
int iSize = dsData.GetSize();
if ( iGroupSize < 0 || iGroupSize > (iSize/2) )
{
printf("Incorrect group size!\n");
return;
}

// Create new wks for results
Worksheet wks;
wks.Create("origin.otw");
// Delete all existing columns
while (wks.Columns(0))
wks.DeleteCol(0);
// Add new colums and assign them label names and set them wide enough
int iColIndex;
iColIndex = wks.AddCol();
wks.Columns(iColIndex).SetLabel("Group No.");
wks.Columns(iColIndex).SetType(OKDATAOBJ_DESIGNATION_X);
wks.Columns(iColIndex).SetWidth(11);
iColIndex = wks.AddCol();
wks.Columns(iColIndex).SetLabel("Group Min");
wks.Columns(iColIndex).SetWidth(11);
iColIndex = wks.AddCol();
wks.Columns(iColIndex).SetLabel("Group Max");
wks.Columns(iColIndex).SetWidth(11);
iColIndex = wks.AddCol();
wks.Columns(iColIndex).SetLabel("Group Mean");
wks.Columns(iColIndex).SetWidth(11);
iColIndex = wks.AddCol();
wks.Columns(iColIndex).SetLabel("Group Std Dev");
wks.Columns(iColIndex).SetWidth(11);
// Turn on label display for columns
wks.ShowLabels();

// Loop over dataset, set the range for each group, and compute stats
BasicStats stat;
int iSteps = iSize / iGroupSize;
for(int ii = 0; ii < iSteps; ii++)
{
int iBegin = ii * iGroupSize;
int iEnd = iBegin + iGroupSize - 1;
dsData.SetLowerBound(iBegin); // set begin marker for dataset
dsData.SetUpperBound(iEnd); // set end marker for dataset

Data_sum(&dsData, &stat); // compute stats
wks.SetCell(ii, 0, ii); // plug values into wks
wks.SetCell(ii, 1, stat.min);
wks.SetCell(ii, 2, stat.max);
wks.SetCell(ii, 3, stat.mean);
wks.SetCell(ii, 4, stat.sd);
}

dsData.SetLowerBound(0); // reset range to full
dsData.SetUpperBound(iSize - 1);
}




Edited by - easwar on 06/25/2003 12:10:44 PM
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