5.4 ADVANCED MOVIE-MAKING
The REPEAT command is quite flexible. It allows you to repeat a sequence of commands, not just a single command as in the basic example above. You can give the GO command as an argument to REPEAT. The following examples demonstrate these techniques.
Note: MODE VERIFY must be SET (this is the default state) for loop counting to work.
Example 1
Note the method at the start of this chapter for making movies from a sequence of GIF files and the whirlgif utility.
Example 2
Here we give multiple arguments to REPEAT; note the semi-colon separation and the parentheses. Note that FRAME, in this example, is used as a stand-alone command.
yes? REPEAT/L=1:12 (FILL SST; GO fland; FRAME/file=my_movie.mgm)
Example 3
In this example we use the REPEAT command to pan and zoom over a sea surface temperature field.
SET DATA coads_climatology
SET REGION/L=1
SET REGION/X=120E:60W/Y=45S:45N
SHADE sst; GO fland
! ZOOM
REPEAT/K=1:5 (SET REGION/DX=+8:-8/DY=+8:-8; SHADE sst; GO fland; FRAME)
! PAN
REPEAT/K=1:5 (SET REGION/DX=+5; SHADE/LEV=(20,30,.5) sst; FRAME)
Example 4
In this example the user calls setup_movie.jnl (text included below), title.jnl, which creates a title frame, then repeats main_movie.jnl (text included below) for each time step desired. Finally, the user adds a frame of credits at the end of the movie. Each of the scripts would end with the FRAME command (except setup_movie). Using GO scripts as arguments to REPEAT allows you to customize the plot with many commands before finally issuing FRAME, as the text of main_movie.jnl below demonstrates.
yes? ! make the movie
yes? GO setup_movie
yes? GO title
yes? REPEAT/L=1:12 GO main_movie
yes? GO credits
! Setup_movie.jnl
SET WINDOW/SIZE=.45/ASPECT=0.7
SET MOVIE/file=my_movie.mgm
SET DATA coads_climatology
SET REGION/X=130E:75W/Y=8S:8N
SET MODE CALENDAR:months
GO bold
PPL SHAKEY ,,.15,.2
PPL AXLEN 8.8,4.8
! Main_movie.jnl
FILL/SET_UP/LEVELS=(16,31,1) sst
PPL LABS; PPL TITLE
PPL FILL
LABEL 210,9.5,0,0,.22 @TRCOADS MONTHLY CLIMATOLOGY (1946-1989)
LABEL 210,-12,0,0,.22 @TRSEA SURFACE TEMPERATURE (DEG C)
LABEL 130,11,-1,0,.22 @TR'LAB4'
FRAME
Note: If you use the FILL command, we suggest that you use SHADE while customizing and fine-tuning your movie, then use FILL for the final run. SHADE is much faster.
5.4.1.1 Initializing the color table
If you create a movie with a title frame, or a first frame which otherwise uses different colors than the rest of the movie, you should be aware of an HDF peculiarity: all the colors that you plan to use in your movie must be in the first frame, or else color behavior will be unpredictable when you animate.
To "reserve" the colors you need, use overlapping full-window viewports. Make a representative plot in the title frame, then cover over it with either a black or white rectangle and finally write the title text. Here is a script which initializes the color table while creating a title frame.
! define 3 identical full-frame viewports
DEFINE VIEW full1; DEFINE VIEW full2; DEFINE VIEW full3
! draw frame one of the movie in full color
SET VIEW full1
SET DATA coads_climatology
SHADE/LEVELS=(16,31,1)/L=1 sst ! dummy frame
! white-out over the picture
SET VIEW full2
GO setup_text
SHADE/PALETTE=white/NOLAB/NOKEY/i=1:2/j=1:2 (i+j)*0
!put on title frame labels (using [0,1] coordinate space)
SET VIEW full3
GO setup_text
PPL PLOT
LABEL .5,.7,0,0,.3 @TRMy Title
PLOT/VS/LINE/OVER/NOAX/NOLAB/COLOR=black {2,8}, {.55,.55}
PLOT/VS/LINE/OVER/NOAX/NOLAB/COLOR=black {2,8}, {.53,.53}
LABEL .5,.4,0,0,.2 @CRBy me
!capture the title frame and clean up
FRAME
GO cleanup_text
5.4.1.2 Making movies in batch mode
Ferret, like other Unix applications, can be run in "batch" mode by redirecting standard input and output. Thus
ferret -unmapped <movie_commands.jnl >&movie.log&
will make a movie running in background mode based on the commands in file movie_commands.jnl logging standard output and standard error in file movie.log.
Note, however, that when used in this mode to make a movie Ferret will still require access to an X windows display (as in "setenv DISPLAY node:0"). To eliminate this requirement we recommend the use of the X11R6 "virtual frame buffer" (Xvfb). This application permits the movie frames to be generated in the absence of any physical display device. Consult your system manager for the availability of X11R6 for your system.