-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.sh
executable file
·334 lines (268 loc) · 7.39 KB
/
main.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#!/bin/bash
################################################################################
# Copyright 2014 Samuel Gongora Garcia (s.gongoragarcia@gmail.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
# Author: s.gongoragarcia[at]gmail.com
# Description: Comparison of the results obtained by using different propagators
# agains STK simulations.
################################################################################
#Remove old data
{
cd TLEs/
rm COPY*
rm xa*
cd ../results/predict
rm SAT*
rm temp
cd ../PyEphem
rm SAT*
rm temp
cd ../PyOrbital
rm SAT*
rm temp
cd ../..
} &> /dev/null
clear
ACTUALDIR=`pwd`
TLESDIR="/TLEs/"
wget -q --tries=10 --timeout=20 --spider http://google.com
if [[ $? -eq 0 ]]; then
if [ ! -d $ACTUALDIR$TLESDIR ]; then
# If directory doesn't exist,
# create it.
mkdir TLEs/
cd TLEs/
# chmod +x update_tles.sh
# ./update_tles.sh
elif [ -d $ACTUALDIR$TLESDIR ]; then
# If directory exist,
# check last TLE's update.
cd TLEs/
# Check if amateur.txt exist
if [ ! -f amateur.txt ]; then
# amateur.txt doesn't exist.
# Update all data.
# TO-DO. Update only files needed.
cd ..
# chmod +x update_tles.sh
# ./update_tles.sh
elif [ -f amateur.txt ]; then
# amateur.txt exist
# Check file's date
file_month=`ls -Ald amateur.txt | awk '{print $6}'`
system_month=`date +"%m"`
file_day=`ls -Ald amateur.txt | awk '{print $7}'`
system_day=`date +"%d"`
cd ..
if [ "$file_month" = "jan" ]; then
declare month=1
elif [ "$file_month" = "ene" ]; then
declare month=1
elif [ "$file_month" = "feb" ]; then
declare month=2
elif [ "$file_month" = "mar" ]; then
declare month=3
elif [ "$file_month" = "apr" ]; then
declare month=4
elif [ "$file_month" = "abr" ]; then
declare month=4
elif [ "$file_month" = "may" ]; then
declare month=5
elif [ "$file_month" = "jun" ]; then
declare month=6
elif [ "$file_month" = "jul" ]; then
declare month=7
elif [ "$file_month" = "aug" ]; then
declare month=8
elif [ "$file_month" = "ago" ]; then
declare month=8
elif [ "$file_month" = "sep" ]; then
declare month=9
elif [ "$file_month" = "oct" ]; then
declare month=10
elif [ "$file_month" = "nov" ]; then
declare month=11
elif [ "$file_month" = "dec" ]; then
declare month=12
else
echo "Invalid Month"
fi
if [ $month -lt $system_month ]; then
# chmod +x update_tles.sh
# ./update_tles.sh
echo "Database updated."
else
if [ $file_day -lt $system_day ]; then
# chmod +x update_tles.sh
# ./update_tles.sh
echo "Database updated."
else
echo "Database updated."
fi
fi
fi
fi
else
echo "Offline - Update canceled."
fi
# TO-DO Test if predict.qth exists
echo " "
LOCATION=`awk 'NR==1' ~/.predict/predict.qth`
LATITUDE=`awk 'NR==2' ~/.predict/predict.qth`
LONGITUDE=`awk 'NR==3' ~/.predict/predict.qth`
ELEVATION=`awk 'NR==4' ~/.predict/predict.qth`
echo "In first place you must specify your location."
echo "Current location is: $LOCATION"
echo "Latitude: $LATITUDE"
echo "Longitude: $LONGITUDE"
echo -e "Elevation: $ELEVATION\n"
echo -e "Want to change it?"
CHANGES="No Yes"
select change in $CHANGES; do
if [ "$change" = "Yes" ]; then
# Absolut path because predict need it.
rm ~/.predict/predict.qth
echo -e "New location: \c"
read -e NEW_LOCATION
echo "New location...: $NEW_LOCATION"
echo $NEW_LOCATION > ~/.predict/predict.qth
echo -e "Latitude: \c"
read -e NEW_LATITUDE
echo $NEW_LATITUDE >> ~/.predict/predict.qth
echo -e "Longitude: \c"
read -e NEW_LONGITUDE
echo $NEW_LONGITUDE >> ~/.predict/predict.qth
echo -e "Elevation: \c"
read -e ELEVATION
echo $ELEVATION >> ~/.predict/predict.qth
break
elif [ "$change" = "No" ]; then
echo -e "Location $LOCATION approved!"
break
else
echo "Invalid Selection."
fi
done
echo " "
echo "============================================================="
echo "Specify simulation start time."
echo "============================================================="
OPTIONSTIME="Now Another"
select opt_time in $OPTIONSTIME; do
if [ "$opt_time" = "Now" ]; then
echo -e "Simulation will start right now!\n"
# Unix time
DATE=`date +%s`
echo $DATE
break
elif [ "$opt_time" = "Another" ]; then
echo -e "The starting date and time should be entered now."
echo ""
# Date
echo -e "Day: \c"
read -e DAY
echo -e "Month: \c"
read -e MONTH
echo -e "Year: \c"
read -e YEAR
# Time
echo -e "Hours (Two digits. 24 hours format.): \c"
read -e HOURS
echo -e "Minutes (Two digits): \c"
read -e MINUTES
echo -e "Seconds (Two digits): \c"
read -e SECONDS
DATE=`date -d "$YEAR-$MONTH-$DAY $HOURS:$MINUTES:$SECONDS" "+%s"`
# Local time, i need universal time
echo $DATE
echo ""
break
else
echo "Wrong chosen"
fi
done
echo "============================================================="
echo "Set the simulation's interval."
echo "============================================================="
OPTIONSINTERVAL="1hour 1day user_defined"
select opt_interval in $OPTIONSINTERVAL; do
if [ "$opt_interval" = "1hour" ]; then
echo -e "1 hour time.\n"
END_TIME=`expr $DATE + 3600`
break
elif [ "$opt_interval" = "1day" ]; then
echo -e "1 day time.\n"
END_TIME=`expr $DATE + 86400`
break
elif [ "$opt_interval" = "user_defined" ]; then
echo -e "Set the simulation's range in seconds: \c"
read -e USER_INTERVAL
END_TIME=`expr $DATE + $USER_INTERVAL`
echo " "
break
else
echo ">>> Invalid Selection"
fi
done
echo "============================================================="
echo "Choose a family!"
echo "============================================================="
cd TLEs/
select d in *; do
FAMILY=$d
break
done
cp $FAMILY COPY$FAMILY
cd ..
# Extract satellite names
python get_names.py $FAMILY
# Predict data
echo " "
echo "predict data"
chmod +x predict_sims.sh
bash predict_sims.sh $FAMILY $DATE $END_TIME
# PyEphem data
python pyephem_sims.py $FAMILY $DATE $END_TIME
# pyorbital data
python pyorbital_sims.py $FAMILY $DATE $END_TIME
# Orbitron data
echo -e "\nPerfom Orbitron simulations"
echo -e "Parameters:"
echo -e "Family $FAMILY"
echo "Family $FAMILY"
echo -e "Introduce Orbitron simulations folder: \c"
read -e ORBITRON_FOLDER
# wine "C:\\Program Files\Orbitron\Orbitron.exe"
# Request for STK data
echo "Perfom STK simulations"
echo -e "Introduce STK simulations folder: \c"
read -e STK_FOLDER
echo " "
echo "$FAMILY family simulations done!"
python gui.py $FAMILY $STK_FOLDER $ORBITRON_FOLDER
# Remove garbage
cd TLEs/
rm $FAMILY
rm xa*
mv COPY$FAMILY $FAMILY
cd ../results/predict
rm *
cd ../PyEphem
rm *
cd ../PyOrbital
rm *
cd ..