-
Notifications
You must be signed in to change notification settings - Fork 8
/
spec_animator
executable file
·151 lines (144 loc) · 2.71 KB
/
spec_animator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
function do_help
{
cat <<!EOF!
Usage: spec_animator [options] input-files
Where [options] are:
-f <outfile> Set output filename (Default: $OUTFILE)
-p <slices> Set slices-per-hour to <slices> (Default: $SLPER)
-b <beginhour> Set begin hour to <beginhour> (Default: $START)
-e <endhour> Set end hour to <endhour> (Default: $END)
-s Set sidereal processing
-u Set UTC processing
-t <title> Set plot title to <title> (Default: $TITLE)
-fc <fc> Override center frequency extracted from data
-rn <range> Set Y axis range in spectral processing st:end
-sm <alpha> Apply smoothing constant <alpha>
!EOF!
}
OUTFILE=animation.mov
SLPER=4
START=0
END=24
SU=-s
TITLE="Animation"
FC_OPT=""
while [ $# -ge 1 ]
do
case $1 in
-f)
OUTFILE=$2
shift 2
;;
-p)
SLPER=$2
shift 2
;;
-b)
START=$2
shift 2
;;
-e)
END=$2
shift 2
;;
-s)
SU="-s"
shift
;;
-u)
SU="-u"
shift
;;
-t)
TITLE=$2
shift 2
;;
-fc)
FC_OPT="-fc "${2}
shift 2
;;
-rn)
RN_OPT="-rn "${2}
shift 2
;;
-sm)
SM_OPT="-sm "${2}
shift 2
;;
-*)
echo "Unknown option: $1"
do_help
exit
;;
*)
break
;;
esac
done
if [ $# -lt 2 ]
then
do_help
exit 1
fi
START=`expr $START '*' $SLPER`
END=`expr $END '*' $SLPER`
SLICES=`expr $END - $START`
cnt=$START
axcnt=0
echo Processing a total of $SLICES FFT plot frames
while [ $cnt -lt $END ]
do
awk -v cnt=$cnt -v slper=$SLPER '
BEGIN {
hr=cnt/slper
hr2=(cnt+1)/slper
uth=int(hr)
printf ("tvb=%05.3f; tve=%05.3f; uth=%02d; uth2=%d\n", hr, hr2, uth, uth)
exit
}' </dev/zero >shtmp$$
. ./shtmp$$
rm -f shtmp$$
#
# Handle format weirdness
#
slist=`grep -l "..:..:.... $uth:..:.." $*`
if [ "@$slist@" = "@@" ]
then
slist=`grep -l "..:..:.... $uth2:..:.." $*`
fi
ulist=`grep -l "$uth:..:.... ..:..:.." $*`
if [ "@$ulist@" = "@@" ]
then
ulist=`grep -l "$uth:..:.... .:..:.." $*`
fi
case $SU in
-s)
thelist=$slist
;;
-u)
thelist=$ulist
;;
esac
if [ "@@" = "@thelist@" ]
then
cnt=`expr $cnt + 1`
continue
fi
fnc=`awk -v cnt=$axcnt 'BEGIN { printf ("%03d\n", cnt)}'`
process_simple_specdat $FC_OPT $RN_OPT $SM_OPT -t "$TITLE" -f slice-$$-${fnc}.png $SU \
$tvb $tve \
$thelist >/dev/null 2>&1
rem=`expr $fnc '%' 10`
if [ $rem == 0 ]
then
echo Done processing FFT plot frame $fnc at $tvb
fi
cnt=`expr $cnt + 1`
axcnt=`expr $axcnt + 1`
done
rm -f $OUTFILE
echo Doing frames-to-movie conversion
ffmpeg -qscale 6 -s 800x600 -r $SLPER -metadata title="$TITLE" -i slice-$$-%03d.png $OUTFILE >/dev/null 2>&1
rm -f slice-$$-*.png
echo FFT movie is available in $OUTFILE