NCL Home> Application examples> Plot techniques || Data files for some examples

Example pages containing: tips | resources | functions/procedures

Animations

This page shows how to create animations with NCL.

If you just want to view the animation quickly and don't need to share it with somebody else, then you can send the graphical output to an NCGM file (using "ncgm" as the first argument to gsn_open_wks), and then use idt to animate it.

If you want to share the animation with other people, then you can convert from an NCL PS file to an animated GIF or MPEG file using the popular "convert" tool from ImageMagick, a graphical suite for image manipulation.

For example, to convert to an animated GIF with a delay of half a second between frames (50/100):

   convert -delay 50 *.ps anim.gif

You can then display "anim.gif" in your browser or other suitable viewer.

For more information, see:

http://www.imagemagick.org/Usage/anim_basics/

To convert to an mpeg file, you will need to first download the program "mpeg2encode" from http://www.mpeg.org/, and then you can use "convert" again:

   convert file.ps file.mpg
animate_1.ncl: Demonstrates how to efficiently create an animation with NCL. Instead of calling gsn_csm_contour_map every time inside the "do" loop, you can use a setvalues call to just change the data and the title.

This example creates a file called "animate.ncgm". You can use idt to animate it.

   idt animate.ncgm
Three panels should pop up, and one of them has an "animate" button. Click on this, and each frame will be loaded into memory. When this is done, click the ">>" or "<<" button to play the animation. Use "delay" to slow down the animation, or "loop" to repeat it.

[View the animation.]

animate_2.ncl: Demonstrates how to create an animated GIF from WRF data.

Note that it's important set the contours to a fixed set of levels, otherwise the contour levels will be recalculated for each frame, based on the range of the data for that frame.

The output is sent to a PostScript file, and then the following command is executed in the NCL script to produce the animation:

  convert -rotate -90 -delay 25 animate.ps animate_2.gif

[View the animation.]