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
 Integration script
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

neutrondude

Brunei
Posts

Posted - 01/08/2007 :  11:57:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi!
Im trying to analyse some data and I want to faciliate the analysis. I want to integrate the data within a given interval and then paste the area directly into the graph. I.e. Im trying to make a graph template with a button which takes whatever I have inside and integrate within a given row interval and pastes the information (you normally get from using the integrate analysis option) into the worksheet.
What is the commands I need to put in the script?
e.g. integ Data1_B -b 159 -e 200;
copy ??

If I then want to paste for example the area obtained into a a new data file together with for example the time given in the colloun description- how can I do this for all data without subsequently overwriting. I wanted to write a A B data set with Time vs area.

Thank you very much for your help

Best regards

Mike Buess

USA
3037 Posts

Posted - 01/08/2007 :  10:21:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The integral curve is saved as a temporary dataset called _integ_area and uses the same X values as the original data. The area is saved as integ.area and is also the last value of of the integral curve. One way to save integral and area is to create a column in Data1 and copy the integral curve to that column. You could also save the area to the column label if you want.

%W=Data1;
integ %W_B -b 159 -e 200;
%W!wks.AddCol(Integ);
icol=%W!wks.ncols;
%(%W,icol) = _integ_area;
%W!page.label$ = "area: $(integ.area)";

I'm not sure what you mean by pasting into a new data file but you can export the worksheet to an ASCII file with save -w %W fileName;

Mike Buess
Origin WebRing Member
Go to Top of Page

larry_lan

China
Posts

Posted - 01/08/2007 :  10:25:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:

Maybe you can use a script to run through all graph windows on your project? the doc -e p command execute the script for all graph windows in the project and the label command past text notes on the plot:

ii = 1;
doc -e p
{
integ -q %C -b 30 -e 50;
%T = Area: $(integ.area);
system.font.labelSize = 28;
label -d 1400 800 -s %T;
result_a[$(ii)]$ = %H;
Result_B[$(ii)] = $(integ.area);
i++;
}



Larry
OriginLab Technical Services

Edited by - larry_lan on 01/08/2007 10:39:14 PM
Go to Top of Page

neutrondude

Brunei
Posts

Posted - 01/09/2007 :  09:21:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear all, thank you very much for the help!
I have some problems though to get the script that Larry suggested to run- even though it works on individual worksheet. When I write the following script in the script window it says "#Command Error!
i = 1; doc -e p
{
integ -q %C -b 159 -e 200;
%T = %C,
Area: $(integ.area);
system.font.labelSize = 28;
label -d 1400 800 -s %T;
result_a[$(ii)]$ = %H;
Result_B[$(ii)] = $(integ.area);
i++;
} ;
#Command Error!




If I would like to paste the file name i a coloumn say A and the area values in say B- how can I modify this?


Thank you very much for all help!



quote:

Hi:

Maybe you can use a script to run through all graph windows on your project? the doc -e p command execute the script for all graph windows in the project and the label command past text notes on the plot:

ii = 1;
doc -e p
{
integ -q %C -b 30 -e 50;
%T = Area: $(integ.area);
system.font.labelSize = 28;
label -d 1400 800 -s %T;
result_a[$(ii)]$ = %H;
Result_B[$(ii)] = $(integ.area);
i++;
}



Larry
OriginLab Technical Services

Edited by - larry_lan on 01/08/2007 10:39:14 PM

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/09/2007 :  1:39:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I suspect the command error arises because the index ii is not defined. You should be incrementing ii rather than i... corrections below are in red.

ii = 1;
doc -e p
{
integ -q %C -b 159 -e 200;
%T = %C,
Area: $(integ.area);
system.font.labelSize = 28;
label -d 1400 800 -s %T;
result_a[ii]$ = %H; // $() notation is unnecessary
Result_B[ii] = integ.area; // ditto
ii++;
};
quote:
If I would like to paste the file name i a coloumn say A and the area values in say B- how can I modify this?
Your code already pastes the area to column B. I assume you want the imported file in column A and don't see how unless you saved the filename somewhere on the worksheet. Did you do that? Some import methods do that automatically so it would help to know how you perform your imports.

...If you mean worksheet instead of file just replace Result_A[ii]$ = %H with Result_A[ii]$ = %[%C,'_'].

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/09/2007 1:43:29 PM

Edited by - Mike Buess on 01/09/2007 2:11:20 PM
Go to Top of Page

neutrondude

Brunei
Posts

Posted - 01/10/2007 :  12:39:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Mike Buess,
ive tried to run the script you suggest but I cant see it working..
I wanted to write the filename in the coloumn of the Results worksheet(a created Results worksheet with A and B as columns).
The file name is stored in the label of the worksheet. How can I call this name and write in the graph or in the result worksheet

By the way I'm trying to create an import filter to import files that has the structure Kin_163K_431_*.DAT and to rename them to a shorter name lets say: Kin431*.DAT (because they are too long)- Can I do this in a simple way?

thank you very much

quote:

I suspect the command error arises because the index ii is not defined. You should be incrementing ii rather than i... corrections below are in red.

ii = 1;
doc -e p
{
integ -q %C -b 159 -e 200;
%T = %C,
Area: $(integ.area);
system.font.labelSize = 28;
label -d 1400 800 -s %T;
result_a[ii]$ = %H; // $() notation is unnecessary
Result_B[ii] = integ.area; // ditto
ii++;
};
quote:
If I would like to paste the file name i a coloumn say A and the area values in say B- how can I modify this?
Your code already pastes the area to column B. I assume you want the imported file in column A and don't see how unless you saved the filename somewhere on the worksheet. Did you do that? Some import methods do that automatically so it would help to know how you perform your imports.

...If you mean worksheet instead of file just replace Result_A[ii]$ = %H with Result_A[ii]$ = %[%C,'_'].

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/09/2007 1:43:29 PM

Edited by - Mike Buess on 01/09/2007 2:11:20 PM



Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/10/2007 :  1:46:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
The file name is stored in the label of the worksheet. How can I call this name and write in the graph or in the result worksheet.
The imported worksheet name is %[%C,'_'] so its label text (file name) is %[%C,'_']!page.label$. You can remove the underscore character from the file name with this Origin C function...

string strip_char(string str, char ch)
{
str.Remove(ch);
return str;
}

Use the function in your LabTalk script like this...

ii = 1;
doc -e P
{
integ -q %C -b 159 -e 200;
%A = %[%C,'_']!page.label$;
%A = strip_char(%A, '_')$;
%T = File: %A
Area: $(integ.area);
label -d 1400 800 -s %T;
result_a[ii]$ = %A;
Result_B[ii] = integ.area;
ii++;
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/10/2007 1:58:11 PM

Edited by - Mike Buess on 01/10/2007 2:08:56 PM
Go to Top of Page

neutrondude

Brunei
Posts

Posted - 01/17/2007 :  10:17:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear all,

sorry to bother you again but it just doesnt work as I want.
Im trying to use the the Import wizard to do the following:

1. Import a ascii file with name structure: Kin_159-2049-****.DAT and rename it to : K159-****.DAT (**** is a 4 digit number). AND put the whole original file name in the resulting worksheet label of coloumn B.

2. Then I would like to plot the 2 column data on a graph data template that I have called Diff_cryst

3. Then I would like to Perform an integration within a certain limit and paste the worksheet name AND the calculated area on the plot.

4. As well I want to paste the File name (or coloumn name) and the calculated area in a worksheet called "Results" in the A and B columns respectively.

Im trying to do in the import wizard by running a script after import. Or how can I do this.


When I run the following script for a single plot- it doesnt no write anything in any worksheet..

integ %C -b 159 -e 200;
%T = %C,
Area: $(integ.area);
system.font.labelSize = 28;
label -d 1400 800 -s %T;
result_a[$(ii)]$ = %H;
Result_B[$(ii)] = $(integ.area);


If I want to write the label name of the current worksheet instead of the worksheet name- what do I write instead of %C?

Sorry Im completely lost in the declaration and syntax...of both Origin C & labtalk..

Thank you very much!

quote:

quote:
The file name is stored in the label of the worksheet. How can I call this name and write in the graph or in the result worksheet.
The imported worksheet name is %[%C,'_'] so its label text (file name) is %[%C,'_']!page.label$. You can remove the underscore character from the file name with this Origin C function...

string strip_char(string str, char ch)
{
str.Remove(ch);
return str;
}

Use the function in your LabTalk script like this...

ii = 1;
doc -e P
{
integ -q %C -b 159 -e 200;
%A = %[%C,'_']!page.label$;
%A = strip_char(%A, '_')$;
%T = File: %A
Area: $(integ.area);
label -d 1400 800 -s %T;
result_a[ii]$ = %A;
Result_B[ii] = integ.area;
ii++;
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/10/2007 1:58:11 PM

Edited by - Mike Buess on 01/10/2007 2:08:56 PM





Edited by - neutrondude on 01/17/2007 10:19:27 AM

Edited by - neutrondude on 01/17/2007 10:33:16 AM
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/17/2007 :  11:03:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use the latest doc -e P script that I gave you. Note that a worksheet named Result must already exist and you must add the strip_char() function I gave you to CodeBuilder's workspace (http://www.originlab.com/www/support/resultstech.aspx?language=english&ID=777).

ii=1;
integ -q %C -b 159 -e 200; // integrate active dataset (%C)
%A = %[%C,'_']!page.label$; // file name from wks page label
%A = strip_char(%A, '_')$; // strip file name as desired
%T = File: %A
Area: $(integ.area);
label -d 1400 800 -s %T; // create label for graph window
result_a[ii]$ = %A; // put file name in column A of Result wks
Result_B[ii] = integ.area; // put area in column B

Mike Buess
Origin WebRing Member
Go to Top of Page

diffra_q

Russia
1 Posts

Posted - 07/19/2014 :  06:54:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear all,
Couldn't you help me to write script for numerical integration hundreds of .dat files (two columns x, y), and then paste values of integrals into the column in worksheet?


Thank you very much for your help

Best regards
Go to Top of Page

greg

USA
1378 Posts

Posted - 07/22/2014 :  11:36:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
dlgfile gr:=*.* mu:=1;
newbook name:=IntegResults;
range raFile = 1, raArea = 2;
row = 1;
loop(ii,1,fname.GetNumTokens(CRLF))
{
file$ = fname.GetToken(ii,CRLF)$;
newbook;
impasc fname:=file$;
integ1 2;
raFile[row]$ = file$;
raArea[row] = integ1.area;
win -cd %H;
row++;
}
Go to Top of Page

iil888

Spain
1 Posts

Posted - 07/26/2014 :  12:41:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks. This is definitely going to come help me to solve my problem. I have been trying to integrate my data and was having a similar issue. Let's just say that numerical integration isn't my area of expertise.


Edited by - iil888 on 07/26/2014 12:42:59 AM
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