Author |
Topic |
|
bafaneh
USA
49 Posts |
Posted - 07/27/2011 : 5:52:57 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): 8.5 Operating System:xp
Hello,
I was wondering if anyone can help me in making a program in Labtalk that will take in multiple file names and plot the data in them and aggregate the plots.
I have a sample of what I am talking about if I am not giving enough information.
Thanks in advance. -Basheer |
|
bafaneh
USA
49 Posts |
Posted - 07/28/2011 : 5:24:37 PM
|
Ok, for simplicity's sake, I want to use "file:import and export:batchProcess" to repeatedly import txt files filled with data into workbooks and automatically make plots of them, and aggregate the plots as well.
The data simply consists of random numbers that I am using to learn how to do this. I think I need to create an analysis template. The tutorial on the analysis template is not sufficient to help me to learn it as well. Where can I learn how to create the code for this, (or you can simply tell me the required functions/code yourself).
Thanks in advance, Basheer |
|
|
easwar
USA
1964 Posts |
Posted - 08/01/2011 : 11:10:27 AM
|
Hi Basheer,
The built-in Batch Processing tool in Origin is tailored for repeat analysis, not graphing. So with this tool one can create an Analysis Template (which has to include some analysis - even if it is say some column value computation) and then use it to process multiple datasets/files.
Looks like in your case you simply want to import and plot data, and then "aggregate the plots" in some manner. For this it is best to write LabTalk script or Origin C code.
What do you mean by "aggregate the plots"?
Easwar OriginLab |
|
|
bafaneh
USA
49 Posts |
Posted - 08/01/2011 : 3:22:11 PM
|
Hello,
Thank you for your response. I mean simply to compile them all in one graph instead of having individual graphs for each one.
Could you walk me through how to write the code for such a task? I am familiar with some of the Labtalk functions and language, but not proficient enough to write code myself. This would be greatly appreciated.
Thanks, Basheer |
|
|
bafaneh
USA
49 Posts |
Posted - 08/01/2011 : 4:17:30 PM
|
I was searching through the labtalk scripting guide, and I found two lines of code that might be useful:
Plotting using worksheet column designations:
The following example plots all columns in the active worksheet, using the worksheet column plotting designations, as a column plot. '?' indicates to use the worksheet designations; '1:end' indicates to plot all the columns.
plotxy iy:=(?,1:end) plot:=203;
Plotting into an existing graph layer:
The following example plots columns 10-20 in the active worksheet, using column plotting designations, into the second layer of Graph1. These columns can all be Y columns and they will still plot against the associated X column in the worksheet.
plotxy iy:=(?,10:20) ogl:=[Graph1]2!;
I'm thinking to use the first line to plot the first dataset, then use the second to keep adding to the graph.
If this works, I will need to create a loop so it does it automatically.
~~Your thoughts?
Best, Basheer |
|
|
easwar
USA
1964 Posts |
Posted - 08/01/2011 : 5:15:15 PM
|
Hi Basheer,
You have to try a few things to see what works best for your situation. Here is an example where three sample files are imported into three sheets in same book, and the data from the three sheets are plotted into one graph in one layer.
Note that in this case I just loop over the sheets and plot to "layer 1" and that works fine as the graph is created for the first plot and then stays active and so adding to layer1 for the remaining files works fine.
Easwar OriginLab
// Find files in samples folder
string path$ = system.path.program$ + "Samples\Curve Fitting";
findfiles ext:="Sensor*.dat";
// Import all the files into one book, putting file name into comments header row
newbook;
impasc Options.Impmode:=4 Options.Names.FNameToColComm:=1 Options.Names.FPathToComm:=0;
// save the book name
string strBkName$ = page.name$;
// Loop over all sheets in book and plot the data
int nSheets = page.nlayers;
for(int isheet=1; isheet<=nSheets; isheet++)
{
// Just plot into layer 1, for all files
plotxy iy:=[%(strBkName$)]$(isheet)!(1,2) plot:=202 ogl:=1;
}
// group the plots in the layer and update legend
layer -g;
legendupdate;
|
|
|
bafaneh
USA
49 Posts |
Posted - 08/02/2011 : 7:09:30 PM
|
Hello,
Thank you for your response. I was wondering how I would implement that code for the file locations on my desktop.
Instead of: string path$ = system.path.program$ + "Samples\Curve Fitting";
Would I use?: string path$ = system.path.C:\Documents and Settings\akudsi\Desktop\Basheer"; <---File location of the text files I wish to import
Also, should I replace: findfiles ext:="Sensor*.dat";
With: findfiles ext:="[Textfile1],[Textfile2],etc..";
Because, I don't know the syntax to insert multiple files there.
I do not know if there is anything else in that code that I must personalize. Could you help me out in that regard?
Thanks again, Basheer
|
|
|
bafaneh
USA
49 Posts |
Posted - 08/02/2011 : 8:35:28 PM
|
Hello,
On another note, I would like to perform an FFT on all of the columns in one file. Could you help me create the script for this?
I will show you what I have so far:
int nSheets = page.nlayers; for(int icol=1; icol<=3; icol++) { fft1 ix:=[Tcw]Col($(icol)) psd:=1 norm:=ssa st:=oneside; }
However, this is wrong, because I noticed that it takes the first column,performs a correct FFT, then uses the column of the new sheet as the operating column.
Thoughts? -Basheer |
|
|
bafaneh
USA
49 Posts |
Posted - 08/04/2011 : 6:28:33 PM
|
Hello,
I am trying to import a .csv file full of statistical data, and I succeeded except for the comments row which doesn't import the title of the columns correctly.
In the following code, what can I insert to put all of the titles I had in the file into my comments row? // Find files in samples folder string path$ = "C:\Documents and Settings\akudsi\Desktop\Basheer\Data for Basheer"; findfiles ext:="U7*.csv";
// Import all the files into one book, newbook; impasc Options.Impmode:=4 Options.Names.FPathToComm:=0; // save the book name string strBkName$ = page.name$;
Thanks, Basheer |
|
|
|
Topic |
|
|
|