Newer
Older
#! /bin/csh -f
#
# Automated script to produce a time animation.
# Included steps (from PJT original instructions):
# $ xxx.csh > xxx.sh # create async script for partiview
# $ chmod +x xxx.sh
# $ xxx.cf # run partiview
# Cmd: async xxx.sh
# ... (recording window, do not mess with screen or overlay
# other windows here)
# <ESC> to quit partiview when all snapshots have been recorded
# $ gifsicle -d 10 --colors 256 snap*gif > xxx.gif
#
# See http://bima.astro.umd.edu/nemo/amnh/movies/ for the results
#
# Note: You need partiview, and ImageMagic, at least to complete it
# the way the example was written.
#
# This script uses the existing kira output datafile xxx.out and
# configuration file xxx.cf (which we assume references xxx.out, hence
# the symlink). The user can create the file xxx.mov which defines
# the initial time, timestep, and number of frames of the movie.
# Format:
#
# set t = 0.0
# set dt = 0.05
# set n = 401
#
# These may be overridden (or replaced) by command-line arguments 2--4.
# If extra .cf commands are needed to modify the original configuration
# file for use in the movie format, place them in the file xxx.cf+.
#
# Also, we use the file winsize_movie.cf to define the size of our
# movie frames (may be different from the interactive display size).
# Format:
#
# eval winsize 400x400
#
# The present version creates a temporary work subdirectory, and cleans
# up after itself.
#
# History:
# 17-oct-2001 Added to CVS Peter Teuben
# 18-oct-2001 Automated Steve McMillan
echo "Usage: $0 run-id [initial-time [delta-time [nframes]]]"
set mov = $1.mov # init file for this cf
set cf = $1.cf # cf file to use
set out = $1.out # kira data file
set gif = $1.gif # name of movie file
# Check that all necessary files exist.
if (! -e $file) then
echo "Can't find $file"
exit
endif
end
# Create and cd into a temporary work directory.
set dirid = __mkmovie
set dir = {$dirid}$$
mkdir $dir
cd $dir
# Initialize the movie loop counters.
set mov = 0
if (-e ../$mov) then
source ../$mov
set mov = 1
endif
if ($mov == 0 && $#argv < 4) then
echo "No .mov file. Must specify 3 movie parameters on the command line."
exit
endif
if ($#argv > 1) set t = $2
if ($#argv > 2) set dt = $3
if ($#argv > 3) set n = $4
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Create the async script for partiview.
set scr = $1.sh
if (-e $scr) then
rm -f $scr
endif
touch $scr
while ($n > 0)
@ n--
echo "echo step $t" >> $scr
echo "echo update" >> $scr
echo "echo snapset snap%03d.gif" >> $scr
echo "echo snapshot" >> $scr
set t=`echo $t+$dt|bc -l`
end
echo "echo exit" >> $scr
chmod a+x $scr
ln -s ../$out
# Create a modified .cf file.
cp ../$cf .
echo "eval async $scr" >> $cf
# Check for extra commands to add/modify the standard configuration file.
if (-e ../$1.cf+) then
cat ../$1.cf+ >> $cf
endif
# Bring in some explicitly named files...
if (-e ../winsize_movie.cf) then
cp ../winsize_movie.cf ./winsize.cf # name is used in the .cf file
endif
if (-e ../std_binary.cf) then
cp ../std_binary.cf .
endif
echo " " >! run.sh # in case of autostart in .cf
# Clean up any old snapshots.
rm -f snap*gif >& /dev/null
# Run partiview to create the individual frames.
$cf
# Combine the frames into a movie.
gifsicle -d 10 --colors 256 snap*gif >! $gif
if (-e ../$gif) then
mv ../$gif ../$gif.save
endif
# Print statistics on the uncombined/uncompressed total size.
set size = `du -k -c snap*gif | grep total | awk '{print $1}'`
# Clean up and exit.