forked from pfranchini/weather-satellites
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule.sh
executable file
·130 lines (93 loc) · 3.5 KB
/
schedule.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
#!/bin/bash
####################
source config.cfg
####################
cd $dir
# Check the config.cfg file
if [ ! -f $where ]; then
echo "Location file does not exist. Check config.cfg"
fi
if [ ! -f $demod ]; then
echo "Meteor demodulator wrong location. Check config.cfg"
fi
if [ ! -f $decoder ]; then
echo "Meteor decoder wrong location. Check config.cfg"
fi
if [ ! -d $wxdir ]; then
echo "WxToImg wrong location. Check config.cfg"
fi
if [ ! -d $dir ]; then
echo "Wrong code directory. Check config.cfg"
fi
rm -fr passages.*
# Update Satellite Information
echo -e "\nUpdate Weather Satellite Information..."
wget -qr https://www.celestrak.com/NORAD/elements/weather.txt -O weather.txt
if [ "$?" -eq "0" ]; then
grep "NOAA 15" weather.txt -A 2 > filtered_tle.tle
grep "NOAA 18" weather.txt -A 2 >> filtered_tle.tle
grep "NOAA 19" weather.txt -A 2 >> filtered_tle.tle
grep "METEOR-M 2" weather.txt -A 2 >> filtered_tle.tle
grep "METEOR-M2 2" weather.txt -A 2 >> filtered_tle.tle
rm -rf weather.txt
echo "...done"
else
echo "...no network"
fi
echo -e "\nUpdate ISS Satellite Information..."
wget -qr https://www.celestrak.com/NORAD/elements/stations.txt -O stations.txt
if [ "$?" -eq "0" ]; then
grep "ISS (ZARYA)" stations.txt -A 2 >> filtered_tle.tle
rm -rf stations.txt
echo "...done"
else
echo "...no network"
fi
echo -e "\nMinimum elevation:" $min_el
today=`date +'%Y%m%d'`
for sat in "NOAA 15" "NOAA 18" "NOAA 19" "METEOR-M 2" "METEOR-M2 2" "ISS (ZARYA)"; do
#for sat in "NOAA 15" "NOAA 18" "NOAA 19" "METEOR-M 2" "METEOR-M2 2"; do
time=`date +%s`
while [ `date -d @$time +%Y%m%d` -eq "$today" ]; do
max_el=0
max_el=`$predict -q $where -t weather.tle -p "${sat}" "$time" | awk '{if($5>max){max=$5}}END{print max}'`
if [[ -n "$max_el" ]] && [[ "$max_el" -gt "$min_el" ]]; then
# Acquisition of Signal - Lost of Signal
AOS=`$predict -q $where -t weather.tle -p "${sat}" "$time" | head -1 | awk '{print $1 " " $3 " " $4}'`
LOS=`$predict -q $where -t weather.tle -p "${sat}" "$time" | tail -1 | awk '{print $1 " " $3 " " $4}'`
# Day of the passage
day=`$predict -q $where -t weather.tle -p "${sat}" "$time" | head -1 | awk '{print $1}'`
# saves only the passages in the current day
if [ `date --date=@${day} +%Y%m%d` -eq "$today" ]; then
echo -e $AOS " " $LOS " " $sat "\t" $max_el >> passages.tmp
fi
fi
end_time=`$predict -q $where -t weather.tle -p "${sat}" "$time" | tail -1 | awk '{print $1}'`
time=$[$end_time+60]
done
done
if [ -f passages.tmp ]; then
echo -e "\nStart Stop Satellite Max El"
echo "========================================================="
sort passages.tmp | uniq > passages.txt
rm passages.tmp
# Kill any 'rtl_fm' that might be still running (any midnight passage??)
pkill -9 rtl_fm
# Remove old 'at' jobs
for i in `atq | awk '{print $1}'`; do atrm $i; done
# Submit new jobs
while read line; do
echo "$line" | awk '{print $2 " " $3 " " $5 " " $6 " " $7 "" $8 "\t " $9}'
# pass the unix time
sat=`echo $line | awk '{print $7 " " $8}'`
start=`echo $line | awk '{print $1}'`
stop=`echo $line | awk '{print $4}'`
elevation=`echo $line | awk '{print $9}'`
source submit_job.sh $sat $start $stop $elevation
done < passages.txt
less recordings.log | sort | uniq > recordings.tmp
mv recordings.tmp recordings.log
else
echo -e "\nNo passages for today"
fi
echo " "