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
 Integration script

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
neutrondude Posted - 01/08/2007 : 11:57:52 AM
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
11   L A T E S T    R E P L I E S    (Newest First)
iil888 Posted - 07/26/2014 : 12:41:09 AM
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.

greg Posted - 07/22/2014 : 11:36:50 AM
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++;
}
diffra_q Posted - 07/19/2014 : 06:54:59 AM
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
Mike Buess Posted - 01/17/2007 : 11:03:24 AM
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
neutrondude Posted - 01/17/2007 : 10:17:06 AM
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
Mike Buess Posted - 01/10/2007 : 1:46:46 PM
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
neutrondude Posted - 01/10/2007 : 12:39:37 PM
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



Mike Buess Posted - 01/09/2007 : 1:39:05 PM
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
neutrondude Posted - 01/09/2007 : 09:21:37 AM
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

larry_lan Posted - 01/08/2007 : 10:25:41 PM
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
Mike Buess Posted - 01/08/2007 : 10:21:30 PM
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

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