Next Previous Up Contents
Next: Surface Types
Up: Plot Parameters
Previous: Layer Parameters

#### 8.1.3 Animation

The plotting commands can be used to produce animations. This is done by supplying an animation control table using the `animate` parameter (which has associated `afmt` and `acmd` parameters for specifying its file format and applying filters). One output image is produced for each row of the control table. The columns of the table have names which correspond to plot command parameters, and for each row, the basic plot command is executed with the parameters on the command line supplied or replaced by those from the table. This is most commonly used for providing a movie of the kind of navigation you can do interactively with the mouse, but other applications are possible.

For instance, given the following animation control table with the name "bounds.txt", in ASCII format:

      #  xmax  ymax
          4.0   2.0
          3.0   1.5
          2.0   1.0
          1.0   0.5

then this command:

       stilts plot2plane xmin=0 ymin=0
                         layer_1=mark in_1=gums_smc.fits x_1=ag y_1=av
                         animate=bounds.txt afmt=ascii

would produce a 4-frame animation zooming in towards the origin.

If output is to the screen (`omode=swing`, the default) the animation can be seen directly. If it is to an output file (`omode=out`) then a number of output files is written with sequence numbers, so adding the parameter "`out=x.png`" to the above command would produce 4 files, `x-1.png`, `x-2.png`, `x-3.png` and `x-4.png`. Padding zeros are used to keep the files in alphanumeric sequence, so for instance in a 500-frame animation the first one would be named `x-001.png`. STILTS does not actually turn these files into a single animated output file, but you can use other tools to do this, for instance using ImageMagick:

       convert x-*.png xmovie.gif

or ffmpeg:

       ffmpeg -i 'x-%03d.png' -framerate 15 -pix_fmt yuv420p xmovie.webm

You can create the animation control table any way you like, but you may find the `tloop` command convenient. For instance the above table can be written like this:

       stilts tloop xmax 4 0 -1 ocmd='addcol ymax xmax*0.5' ofmt=ascii out=bounds.txt

Alternatively, you can generate a table like this inline using the loop scheme. A common requirement is to produce an animation of rotating a 3-d plot, here's an example of how to do that:

       stilts plot2sphere layer_1=mark in_1=hip_main.fits lon_1=radeg lat_1=dedeg r_1=plx \
                          animate=:loop:15,375,2 acmd='colmeta -name phi $1'

The `phi` parameter controls the angle from which the 3D plot is viewed, and here it is incremented by 2 degrees for each frame. The same thing would work for `plot2cube` as well as `plot2sphere`.

Note that producing animations in this way is usually much more efficient than writing a shell script which invokes STILTS multiple times. The plot commands also employ multi-threading when animating to output files, so should make efficient use of multi-core machines (though currently animations to the screen are not multi-threaded).

Next Previous Up Contents
Next: Surface Types
Up: Plot Parameters
Previous: Layer Parameters

STILTS - Starlink Tables Infrastructure Library Tool Set
Starlink User Note256
STILTS web page: http://www.starlink.ac.uk/stilts/
Author email: m.b.taylor@bristol.ac.uk
Mailing list: topcat-user@jiscmail.ac.uk