Author |
Topic  |
|
circumvent
Posts |
Posted - 06/20/2007 : 09:08:27 AM
|
Origin Version (Select Help-->About Origin): 7.5 Operating System:XP
Hi,
I have a question related to control the sequence of a labtalk script when I pick up data points in graph.
The idea is, when I run the script, it first import a dataset, then plot it in a new window, and then pause, waiting for some input. After it reads the input, it perform other script based on the input.
Can anyone tell me how to implement the work? Thanks a lot.
#####################################
win -t data;//Open worksheet open -w filename;//import ascii file to worksheet, data are two column, XY %N=%H;//remember the name of the worksheet win -t plot line.otp;//open a graph window layer -i %(%Q, 2);
############################### Now, I want to pick range of interest.
For example, pick up two points (or more), get the (x,y) value, and also find out the index.
The script must pause here and will run after I trigger another button. ################################
type $(index1); //check if index1 really holds my pickup
|
|
Mike Buess
USA
3037 Posts |
Posted - 06/20/2007 : 12:56:31 PM
|
You can use the GETPTS command and I suggest that you read this technical article first. http://www.originlab.com/index.aspx?s=9&pid=541
Once you understand how the command works you can try the following script to select points from a graph.
// your import & plotting script win -t data;//Open worksheet open -w filename;//import ascii file to worksheet, data are two column, XY %N=%H;//remember the name of the worksheet win -t plot line.otp;//open a graph window layer -i %(%Q, 2);
// point selection script del -a; // delete temporary datasets del -v index*; // delete previous indices done=0; // initialize script getpts 4; // select 4 points;
// pointproc macro runs each time a point is selected def pointproc { index$(getpts.count)=getpts.index; // point index if( getpts.count==getpts.max ) { {endtoolbox}; dotool 0; }; };
// endtoolbox macro runs after all points are selected def endtoolbox { done=1; index0=getpts.count; // save the point count %A=xof(%C); // X data for(i=1;i<=index0;i++) { index$(i)=; %A[index$(i)]=; // X value %C[index$(i)]=; // Y value }; };
// wait until designated number of points is selected for(ii=1;ii>0;) { if( done ) break; sec -p 1; // pause 1 second }; //}; extraneous end-bracket
ty -n $(index0) points are selected. Continue?;
// insert the rest of your script here
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 06/20/2007 12:59:48 PM
Edited by - Mike Buess on 06/20/2007 3:15:02 PM |
 |
|
circumvent
Posts |
Posted - 06/20/2007 : 3:23:44 PM
|
Hi Mike,
First, I own many thanks to you.
I think I get the essence of using GETPTS and I can do some work with it. My next question is if it is possible to use origin C for this work?
My plan is to write some routines to merge two curves of x, y data to produce one data set. This is commonly used for spectral data, where the experiment measures several overlapping ranges. It is a big project for me and I have to break them into several steps.
For example, I have file1 over range10-100, file 2 over 80-180, file 3 over 150-400, etc. Each file is two column xy dataset. For simplicity, I only start with merge file 1 and file 2.
1. Import file1 and file2, plot them in one graph window.
2. Use cursors to select the merging region. (You have given a good example in the previous post. Can we do this in Origin C?).
3. Suppose the interested region is 85-95. file2 will be scaled so that the integrated area below file1 and file2 in range 85-95 are the same. (file2_B*=(inte file1)/(inte file2))
4. Another worksheet, filemiddle will be created. Data 10-85 will be copied from file1, data 85-95 will be weighted average from file1&file2, and data 95-180 will be copied from file2.
5. The weighted average that start with 100% file1 and ends with 100% file2. For example, I choose the equation y=(x1-x)/(x1-x2)*y2+(x-x2)/(x1-x2)*y1. When x=x1, y=y1; When x=x2, y=y2.
6. Interpolation: no worry about the data in region 10-85 and 95-108. (just simply copy and paste). But the data 85-95 interval may be different in file1 and file2. I will choose interpolate file2 according to file2 in this region.
Extension:
We already have a DOS program for the above merging technique. By switching to Origin, we hope to gain more flexibility.
1. After picking the regions (two points, 85-95 in the above example), the third curve should be calculated automatically and show up in the graph windows, waiting for inspection. If not satisfied, I will pick up another two different points and Origin will repeat the work until satisfied.
2. After merging file1 and file 2 to filemiddle and we are satisfied with the merging, we can continue to merge file3, file 4, using same technique as before.
3. If two files have no overlap, file1 and file 2 will extrapolate (2nd order polynomial) and merge with the previous technique.
Jinbo
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 06/20/2007 : 5:16:22 PM
|
quote: 2. Use cursors to select the merging region. (You have given a good example in the previous post. Can we do this in Origin C?).
Why use cursors? Isn't the overlap (merge) region clearly defined by the X values in the two files?
Mike Buess Origin WebRing Member |
 |
|
circumvent
Posts |
Posted - 06/21/2007 : 09:30:56 AM
|
In real measurement, we have to throw away some data near the edge. In my example, the overlap is 80-100, but the final merge region may be 85-90, depending the quality of the experimental data.
Using cursor give us a chance to inspect which part of the data we really want to merge.
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 06/21/2007 : 10:17:41 AM
|
There is no Origin C equivalent to the GETPTS command but you can embed much of the LabTalk code I gave you into your OC code. See the Programming Guide> Programming in Origin C> LabTalk Access section of Help> Programming.
Mike Buess Origin WebRing Member |
 |
|
|
Topic  |
|
|
|