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 for Programming
 LabTalk Forum
 faster import/plot/export ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

quickkk

Canada
23 Posts

Posted - 01/17/2005 :  2:58:49 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi everybody,

I was wondering if anyone had a quick answer for me. This is what I want to do:

-import some data from a file (which is allready organized as ascii columns)
-plot it
-change a few things on the plot (apply a theme, change title)
-export plot as gif
-do this 1000 times with different data files.

This is what I currently do:
I run a little origin LabTalk script:

for(jj = start; jj < stop; jj++)
{
open -w z:\home\amorris\work\oscillator\data\rotation\eig$(jj).dat;
%N=%H; #save the name of the worksheet
work -s 0 0 0 0;
work -p 201;
rrr=jj/1000; #rrr is some experimental parameter
label -s -q 2 -j 1 -n mytitle "r = $(rrr)";
image.FileName$ = "z:\home\amorris\work\oscillator\data\i_%N.gif";
Image.Export.PagePixel( gif, 640, 480, 24, 0 );
win -a %N; #make worksheet active so that I can import next graph
};


The problem is that this thing gets quite slow if I import large files. Is there anyway to bypass the actual plotting of the graph or data import? Ideally I would like origin to contruct a graph directly from my data file (since the first column is x, and the rest are y columns) . Then, instead of writting the results to the screen, I would like Origin to save the graph directly as a gif image file (kind of like writting to a file instead of the screen). This would bypass the slow plotting stage; all I want is the gif image so I don't care about Origin's graph.

Is there any way to do this with LabTalk? How about using OriginC? I'm not familiar with it so I don't want to spend a bunch of time learning OriginC if it can't help me!

Thanks!

Mike Buess

USA
3037 Posts

Posted - 01/17/2005 :  5:03:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I'm sure you need to plot the data but if your files all have the same number of columns you can save a lot of time by recycling the graph window as you've done with the worksheet window. It's best if you avoid renaming the worksheet on import. Open ASCII Options for your worksheet, select Other Options and uncheck the Rename Worksheet to Data File Name Option. Then save the template and run this script...

%B=Z:\home\amorris\work\oscillator\data\rotation\;
win -t D; %W=%H;
open -w %Beig$(start).dat;
wo -s 0 0 0 0;
wo -p 201;
%P=%H;
for(jj=start; jj<=stop; jj++) {
win -a %W;
%N=eig$(jj);
open -w %B%N.dat;
win -a %P;
plot -c; // might be necessary to update the plot
lay -a; // might also be necessary to rescale
rrr=jj/1000; #rrr is some experimental parameter
label -s -q 2 -j 1 -n mytitle "r = $(rrr)";
image.FileName$ = "z:\home\amorris\work\oscillator\data\i_%N.gif";
Image.Export.PagePixel( gif, 640, 480, 24, 0 );
};

That will be much faster than the method you're using now. Origin C will be even faster... if you feel like trying then I or someone else can start you off.

...The LabTalk script I gave you can probably be optimized further by importing in the background. Try replacing these lines in the for-loop...

win -a %W;
%N=eig$(jj);
open -w %B%N.dat;
win -a %P;

with these two lines...

%N=eig$(jj);
win -o %W {open -w %B%N.dat};

That way the graph window remains active the whole time.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/17/2005 5:15:05 PM

Edited by - Mike Buess on 01/17/2005 5:59:27 PM
Go to Top of Page

quickkk

Canada
23 Posts

Posted - 01/19/2005 :  10:03:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the reply! You're right that it's a lot faster to simply keep one graph. I also tried to do the background import, but for some reason it doesn't work... I'll look into it some more. THanks!
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/19/2005 :  10:12:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The background import should work but I've never actually tried. Might be something in the import routine that prevents it from working.

You'll probably gain a little speed if you can omit the update (plot -c) and/or rescale (lay -a) commands. You might try commenting out those lines and see what happens.

...Just tried win -o %W {open -w %Z} in Origin 7.5. Works fine regardless of which window is active as long as %W and %Z are defined properly.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/19/2005 11:24:34 AM
Go to Top of Page

quickkk

Canada
23 Posts

Posted - 01/20/2005 :  3:57:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
you're right, it did work. I just made a mistake in the path! Doh!

Thanks for the help
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