-
Notifications
You must be signed in to change notification settings - Fork 7
/
apt.sh
executable file
·163 lines (126 loc) · 4.44 KB
/
apt.sh
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
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
######################
source config.cfg
######################
enhancement() {
option=$1
name=$2
echo -e ${option}":"
$wxdir/wxtoimg -m ${file}-map -k "%N" -k "%d/%m/%Y - %H:%M UTC" -k "fontsize=14 %D %E %z" -k "fontsize=14 ${option}" -e ${option} -c -y low -o ${file}_res.wav ${file}-${name}.png &> ${name}.log
touch -r ${file}.wav ${file}-${name}.png
cat ${name}.log
# Remove a wrong enhancement for missed channel
error=`cat ${name}.log | grep -i "warning: enhancement ignored"`
if [ ! -z "$error" ]; then
rm ${file}-${name}.png
echo ${file} $error >> errors.log
else
# Preserve in /deleted any other warning
error=`cat ${name}.log | grep -i "warning"`
if [ ! -z "$error" ]; then
mv ${file}-${name}.png $output/noaa/deleted/
echo ${file} $error >> errors.log
fi
fi
rm -rf ${name}.log
}
enhancement_HVC() {
option=$1
name=$2
echo -e ${option}":"
if [[ "$direction" == "northbound" ]]; then
$wxdir/wxtoimg -N -k "%N" -k "%d/%m/%Y - %H:%M UTC" -k "fontsize=14 %D %E %z" -k "fontsize=14 ${option}" -e ${option} -c -o ${file}_res.wav ${file}-${name}.png &> ${name}.log
# $wxdir/wxtoimg -k "%N" -k "%d/%m/%Y - %H:%M UTC" -k "fontsize=14 %D %E %z" -k "fontsize=14 ${option}" -e ${option} -c -y low -o ${file}_res.wav ${file}-${name}.png &> ${name}.log
else
$wxdir/wxtoimg -S -k "%N" -k "%d/%m/%Y - %H:%M UTC" -k "fontsize=14 %D %E %z" -k "fontsize=14 ${option}" -e ${option} -c -o ${file}_res.wav ${file}-${name}.png &> ${name}.log
fi
touch -r ${file}.wav ${file}-${name}.png
cat ${name}.log
# Remove a wrong enhancement for missed channel
error=`cat ${name}.log | grep -i "warning: enhancement ignored"`
if [ ! -z "$error" ]; then
rm ${file}-${name}.png
echo ${file} $error >> errors.log
else
# Preserve in /deleted any other warning
error=`cat ${name}.log | grep -i "warning"`
if [ ! -z "$error" ]; then
mv ${file}-${name}.png $output/noaa/deleted/
echo ${file} $error >> errors.log
fi
fi
rm -rf ${name}.log
}
enhancement_IR() {
option=$1
name=$2
echo -e ${option}":"
$wxdir/wxtoimg -m ${file}-map -k "%N" -k "%d/%m/%Y - %H:%M UTC" -k "fontsize=14 %D %E %z" -k "fontsize=14 ${name}" -b -e ${option} -c -o ${file}_res.wav ${file}-${name}.png &> ${name}.log
touch -r ${file}.wav ${file}-${name}.png
cat ${name}.log
# Remove a wrong enhancement for missed channel
error=`cat ${name}.log | grep -i "warning: enhancement ignored"`
if [ ! -z "$error" ]; then
rm ${file}-${name}.png
echo ${file} $error >> errors.log
else
# Preserve in /deleted any other warning
error=`cat ${name}.log | grep -i "warning"`
if [ ! -z "$error" ]; then
mv ${file}-${name}.png $output/noaa/deleted/
echo ${file} $error >> errors.log
fi
fi
rm -rf ${name}.log
}
######################
file=$1 # full path without extension
filename=`basename ${file}` # filename used to extract variables for the map
echo -e "\n\033[1m${file}\033[0m"
if [ ! -f "${file}.wav" ]; then
echo "Wrong audio file name... exit"
exit
fi
if [ `wc -c <${file}.wav` -le 1000000 ]; then
echo "Audio file ${file}.wav too small, probably wrong recording"
exit
fi
# variables for the map
satellite=`echo $filename | awk -F_ '{print $2}'`
satellite=`echo "NOAA" ${satellite:4:2}`
start=`echo $filename | awk -F_ '{print $filename}'`
start=`echo ${start:0:8} ${start:9:2}:${start:11:2}:${start:13:2}`
start=`date -d "${start}" +%s`
tle=$dir/weather.tle
# resampling
rm -rf ${file}.png
rm -rf ${file}_res.wav
sox ${file}.wav -r 11025 ${file}_res.wav
touch -r ${file}.wav ${file}_res.wav
# map to overlay
$wxdir/wxmap -c g:dark-cyan -c C:light-green -a -T "$satellite" -H $tle -p 0 -l 1 -o $start ${file}-map &> wxtoimg.log
cat wxtoimg.log
direction=`less wxtoimg.log | grep Direction | awk '{print $2}'`
# IR:
enhancement_IR histeq IR
# VIS:
enhancement_HVC HVC HVC
#enhancement MSA MSA
enhancement MSA-precip MSA-precip
#enhancement HVCT HVCT
# clean up
rm -rf ${file}-map
rm -rf ${file}_res.wav
rm -rf wxtoimg.log
# delete used audio files
if [ "$purge" = "true" ]; then
rm -f ${file}.wav
fi
#if [[ "$direction" == "southbound" ]]; then
# echo "Rotate: "
# convert -rotate 180 $file-IR.png $file-IR.png
# convert -rotate 180 $file-HVC.png $file-HVC.png
#fi
#convert -rotate 180 ${file}-map ${file}-map
#convert -rotate 180 $file.png $file.png
#eog $file.png