comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Simple animation?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Simple animation? [message #32076] Wed, 11 September 2002 09:26 Go to next message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 11 Sep 2002 07:47:49 -0700, Liam E. Gumley wrote:

> David Fanning wrote:
>> Liam E. Gumley (Liam.Gumley@ssec.wisc.edu) writes:
>>
>>> Shawn wrote:
>>>> I recently tried to animate the change in my data with time. I
>>>> found that if I plotted to the same window, it would over plot the
>>>> old data, which was good, but it also redraws the axis every time
>>>> as well, which causes a lot of "flashing". Is it possible to tell
>>>> IDL to only redraw the data and to leave the axis alone?
>>>
>>> Try plotting the first dataset with PLOT, and subsequent datasets
>>> with OPLOT.
>>
>> Well, that wouldn't animate the plot, really. Just show more and more
>> data piled on top of it.
>>
>> Try this. Create a pixmap window the same size as your display window.
>> Draw your plots in the pixmap window, then use the DEVICE COPY
>> technique to copy the contents of the pixmap window to the display
>> window. This will result in a flicker-free animation. :-)
>
> I initially started writing a reply that included this exact advice. But
> on rereading the original post, I thought a simpler solution might be
> required.
>
> However as David says, DEVICE COPY will give you true animation. Here's
> an example of Brownian motion animation from chapter 5 of my book:
>
>

Liam:

I was interested to see that you don't use true double buffering, but
instead are just "erasing" the plot axes using the pixmap version of the
dataless plot. For such a simple example, this gets the job done (in
fact, just using

erase & plot, [0], /nodata, xrange=[-1, 1], yrange=[-1, 1]

would also do it about as well, except the axes would flicker a bit more).
However, if you had a much more complicated plot, or a multiple command
plot sequence, the plot drawing commands would themselves cause flicker
and lag. This is especially noticeable if driven by motion events. In
that case, it pays to use double buffering, i.e. draw *everything* to a
pixmap, and, when finished, copy over to the visible window in one go.
This produces by far the smoothest animation and motion for multi-element
plots. It would go something like:

wset,pixwin
plot,...
countour,..,/noerase
oplot,.....
tv,...,/noerase
wset,viswin
device,copy=[0, 0, xsize, ysize, 0, 0, pixwin]

Obviously, if you can avoid redrawing certain things by offloading them to
another pixmap and zapping that into the double-buffer pixmap, you can
increase frame rates, but I find this simple technique excels for even
very complicated plots.

JD
Re: Simple animation? [message #32079 is a reply to message #32076] Wed, 11 September 2002 13:52 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
David Fanning wrote:

> Reimar Bauer (R.Bauer@fz-juelich.de) writes:
>
>> This examples show in different to pixmap which is described by Liam the
>> usage of displaying a series of images stored in a 3-d Array.
>> Device copy and pixmap is the fastest way but there is a limitation of
>> 128 possible pixmap windows.
>
> Uh, I think Liam's example uses *one* pixmap window. :-)

Oh, I should read more carefully.

Reimar




--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
Re: Simple animation? [message #32081 is a reply to message #32076] Wed, 11 September 2002 13:11 Go to previous message
radbelt_res is currently offline  radbelt_res
Messages: 2
Registered: September 2002
Junior Member
Thank you David and Liam!

I found both of your answers useful. I am going to keep David's
answer in my back pocket until I decide to take the time to learn how
to use pixmap windows. I used Liam's idea, modified of course, but it
worked. I made the first plot, using "plot", then succesive plots
were done using oplot in a 2 step fashion. First I overplotted the
previous plot with the background color, then plotted the next array
using the forground color. Not very elegant, but simple, and it was
fast enough that I had to put wait statements in to slow the animation
down.

Thanks again,
Shawn


David Fanning <david@dfanning.com> wrote in message news:<MPG.17e860152c7ca76e9899a5@news.frii.com>...
> Liam E. Gumley (Liam.Gumley@ssec.wisc.edu) writes:
>
>> Shawn wrote:
>>> I recently tried to animate the change in my data with time. I
>>> found that if I plotted to the same window, it would over plot the old
>>> data, which was good, but it also redraws the axis every time as well,
>>> which causes a lot of "flashing". Is it possible to tell IDL to only
>>> redraw the data and to leave the axis alone?
>>
>> Try plotting the first dataset with PLOT, and subsequent datasets with
>> OPLOT.
>
> Well, that wouldn't animate the plot, really. Just
> show more and more data piled on top of it.
>
> Try this. Create a pixmap window the same size
> as your display window. Draw your plots in the
> pixmap window, then use the DEVICE COPY technique
> to copy the contents of the pixmap window to the
> display window. This will result in a flicker-free
> animation. :-)
>
> Cheers,
>
> David
Re: Simple animation? [message #32087 is a reply to message #32076] Wed, 11 September 2002 09:53 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
How about a 2 s download and two lines of code:

IDL> display, findgen(100), name='this'
IDL> for i =1, 100 do display, sin(findgen(100)/(1000./i)), name='this', /over

http://www.ainaco.com/idl/idl_library/display.pro

Cheers,
Pavel


Shawn wrote:
>
> Hello,
> I recently tried to animate the change in my data with time. I
> found that if I plotted to the same window, it would over plot the old
> data, which was good, but it also redraws the axis every time as well,
> which causes a lot of "flashing". Is it possible to tell IDL to only
> redraw the data and to leave the axis alone?
> Thanks,
> Shawn
Re: Simple animation? [message #32089 is a reply to message #32076] Wed, 11 September 2002 09:24 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Reimar Bauer (R.Bauer@fz-juelich.de) writes:

> This examples show in different to pixmap which is described by Liam the
> usage of displaying a series of images stored in a 3-d Array.
> Device copy and pixmap is the fastest way but there is a limitation of
> 128 possible pixmap windows.

Uh, I think Liam's example uses *one* pixmap window. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Simple animation? [message #32090 is a reply to message #32089] Wed, 11 September 2002 09:09 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Shawn wrote:
> Hello,
> I recently tried to animate the change in my data with time. I
> found that if I plotted to the same window, it would over plot the old
> data, which was good, but it also redraws the axis every time as well,
> which causes a lot of "flashing". Is it possible to tell IDL to only
> redraw the data and to leave the axis alone?
> Thanks,
> Shawn


Dear Shawn,

if you have a look at this example from our idl exercises
http://www.fz-juelich.de/vislab/idl-beispiele/Darstellung/An imation/bar_go.pro

The full link is
http://www.fz-juelich.de/vislab/software/idl_samples/IDL-Bei spielsammlung.html

Follow IDL-Beispielsammlung->Darstellung->Animation


This examples show in different to pixmap which is described by Liam the
usage of displaying a series of images stored in a 3-d Array.
Device copy and pixmap is the fastest way but there is a limitation of
128 possible pixmap windows.

regards

Reimar




--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
Re: Simple animation? [message #32095 is a reply to message #32090] Wed, 11 September 2002 07:47 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
David Fanning wrote:
> Liam E. Gumley (Liam.Gumley@ssec.wisc.edu) writes:
>
>> Shawn wrote:
>>> I recently tried to animate the change in my data with time. I
>>> found that if I plotted to the same window, it would over plot the old
>>> data, which was good, but it also redraws the axis every time as well,
>>> which causes a lot of "flashing". Is it possible to tell IDL to only
>>> redraw the data and to leave the axis alone?
>>
>> Try plotting the first dataset with PLOT, and subsequent datasets with
>> OPLOT.
>
> Well, that wouldn't animate the plot, really. Just
> show more and more data piled on top of it.
>
> Try this. Create a pixmap window the same size
> as your display window. Draw your plots in the
> pixmap window, then use the DEVICE COPY technique
> to copy the contents of the pixmap window to the
> display window. This will result in a flicker-free
> animation. :-)

I initially started writing a reply that included this exact advice. But
on rereading the original post, I thought a simpler solution might be
required.

However as David says, DEVICE COPY will give you true animation. Here's
an example of Brownian motion animation from chapter 5 of my book:

PRO BROWNIAN

;- Create visible window, and initialize plot
xsize = 640
ysize = 512
window, /free, xsize=xsize, ysize=ysize
viswin = !d.window
plot, [0], /nodata, xrange=[-1, 1], yrange=[-1, 1]

;- Create pixmap window, and copy the visible window
window, /free, /pixmap, xsize=xsize, ysize=ysize
pixwin = !d.window
device, copy=[0, 0, xsize, ysize, 0, 0, viswin]

;- Set animation parameters
nframes = 250
npoints = 50
temp = 0.02
seed = -1L
x = randomn(seed, npoints) * 0.1
y = randomn(seed, npoints) * 0.1

;- Create Brownian motion animation in visible window
wset, viswin
for i = 1L, nframes do begin
device, copy=[0, 0, xsize, ysize, 0, 0, pixwin]
plots, x, y, psym=1
x = x + temp * randomn(seed, npoints)
y = y + temp * randomn(seed, npoints)
endfor

END

You can play with the values of NFRAMES, NPOINTS, and TEMP to vary the
length and fluidity of the animation.

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
Re: Simple animation? [message #32108 is a reply to message #32095] Tue, 10 September 2002 20:02 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Liam E. Gumley (Liam.Gumley@ssec.wisc.edu) writes:

> Shawn wrote:
>> I recently tried to animate the change in my data with time. I
>> found that if I plotted to the same window, it would over plot the old
>> data, which was good, but it also redraws the axis every time as well,
>> which causes a lot of "flashing". Is it possible to tell IDL to only
>> redraw the data and to leave the axis alone?
>
> Try plotting the first dataset with PLOT, and subsequent datasets with
> OPLOT.

Well, that wouldn't animate the plot, really. Just
show more and more data piled on top of it.

Try this. Create a pixmap window the same size
as your display window. Draw your plots in the
pixmap window, then use the DEVICE COPY technique
to copy the contents of the pixmap window to the
display window. This will result in a flicker-free
animation. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Simple animation? [message #32112 is a reply to message #32108] Tue, 10 September 2002 14:26 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Shawn wrote:
> I recently tried to animate the change in my data with time. I
> found that if I plotted to the same window, it would over plot the old
> data, which was good, but it also redraws the axis every time as well,
> which causes a lot of "flashing". Is it possible to tell IDL to only
> redraw the data and to leave the axis alone?

Try plotting the first dataset with PLOT, and subsequent datasets with
OPLOT.

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: having IDL output to another X11 window
Next Topic: Re: Ascii-import

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 06:03:27 PDT 2025

Total time taken to generate the page: 0.00843 seconds