va7eex
8 years ago
committed by
GitHub
3 changed files with 220 additions and 0 deletions
@ -0,0 +1,90 @@ |
|||||
|
import predict |
||||
|
import json |
||||
|
import sys |
||||
|
import datetime |
||||
|
|
||||
|
frequencies = {'NOAA-15':'137.620M', 'NOAA-18':'137.9125M', 'NOAA-19':'137.10M', 'METEOR-M2':'137.925M', 'ISS':'145.80M' } #Meteor M2 is also on 137.1M |
||||
|
|
||||
|
tle_data = json.load(open('sat_tle.txt')) |
||||
|
default_predictions = 1 |
||||
|
default_min_elevation = 30 |
||||
|
suppress_low_passes = False |
||||
|
|
||||
|
|
||||
|
pass_elevation = default_min_elevation |
||||
|
if( len(sys.argv) > 1 ): |
||||
|
pass_elevation = int(sys.argv[1]) |
||||
|
|
||||
|
if( pass_elevation == '' ): |
||||
|
pass_elevation = default_min_elevation |
||||
|
|
||||
|
predictions = default_predictions |
||||
|
if( len(sys.argv) > 2): |
||||
|
predictions = int(sys.argv[2]) |
||||
|
|
||||
|
if( predictions == '' ): |
||||
|
predictions = default_predictions |
||||
|
|
||||
|
if( len(sys.argv) > 3 ): |
||||
|
suppress_low_passes = True |
||||
|
|
||||
|
def convert_time( unixtime ): |
||||
|
return datetime.datetime.fromtimestamp( |
||||
|
int(unixtime) |
||||
|
).strftime('%H:%M %Y-%m-%d') |
||||
|
|
||||
|
def convert_time_short( unixtime ): |
||||
|
return datetime.datetime.fromtimestamp( |
||||
|
int(unixtime) |
||||
|
).strftime('%M') |
||||
|
|
||||
|
def get_sat( sat ): |
||||
|
return sat + '\n' + tle_data[sat] |
||||
|
|
||||
|
qth = (49.32, 123.42, 49) # lat (N), long (W), alt (meters) |
||||
|
qth_nw = (51.32, 125.42, 49) |
||||
|
qth_se = (47.32, 121.42, 49) |
||||
|
|
||||
|
data = {} |
||||
|
|
||||
|
for sat, freq in frequencies.iteritems(): |
||||
|
|
||||
|
name = predict.observe(get_sat(sat), qth)['name'].strip() |
||||
|
t = predict.transits(get_sat(sat), qth) |
||||
|
t_nw = predict.transits(get_sat(sat), qth_nw) |
||||
|
t_se = predict.transits(get_sat(sat), qth_se) |
||||
|
|
||||
|
count = 0 |
||||
|
while ( count < predictions ): |
||||
|
p = t.next() |
||||
|
p_nw = t_nw.next() |
||||
|
p_se = t_se.next() |
||||
|
|
||||
|
while (p.peak()['elevation'] < default_min_elevation): |
||||
|
p = t.next() |
||||
|
p_nw = t_nw.next() |
||||
|
p_se = t_se.next() |
||||
|
if( not suppress_low_passes ): |
||||
|
print name, "pass too low, recalculating" |
||||
|
|
||||
|
data[name] = {} |
||||
|
data[name]['frequency'] = freq |
||||
|
data[name]['start_unix'] = p.start |
||||
|
data[name]['start'] = convert_time(data[name]['start_unix']) |
||||
|
data[name]['duration_seconds'] = int(p.duration()) |
||||
|
data[name]['duration_minutes'] = convert_time_short(data[name]['duration_seconds']) |
||||
|
data[name]['elevation'] = p.peak()['elevation'] |
||||
|
|
||||
|
data[name]['direction'] = 'S' #Assume northbound |
||||
|
if( int(p_nw.start) > int(p.start) and int(p.start) > int(p_se.start) ): #This is the direction the satellite is travelling TO, not from. |
||||
|
|
||||
|
data[name]['direction'] = 'N' |
||||
|
|
||||
|
print name, 'next pass at:', data[name]['start'], 'at', data[name]['elevation'], 'degrees.', data[name]['direction'] + '-bound' |
||||
|
count = count + 1 |
||||
|
|
||||
|
import json |
||||
|
|
||||
|
with open('satpredict.txt', 'w') as fp: |
||||
|
json.dump(data, fp, indent=4) |
||||
|
|
@ -0,0 +1,26 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
SAT=$1 |
||||
|
TIEMSTAMP=$(date +%s) |
||||
|
FILENAME="sat_schedules/schd-${SAT}-${TIEMSTAMP}" |
||||
|
|
||||
|
rm reschd-$SAT.txt |
||||
|
|
||||
|
echo "#!/bin/bash" > $FILENAME |
||||
|
|
||||
|
echo 'bash wol_fastserv.sh' >> $FILENAME |
||||
|
|
||||
|
python satpredict.py 25 1 true |
||||
|
python satschedule.py $SAT >> $FILENAME |
||||
|
|
||||
|
echo "sleep 30" >> $FILENAME |
||||
|
echo "echo bash sats.sh ${SAT} > reschd-${SAT}.txt" >> $FILENAME |
||||
|
echo "at now + 30 minutes -q z -M -f reschd-${SAT}.txt" >> $FILENAME |
||||
|
|
||||
|
echo "rm ${FILENAME}" >> $FILENAME |
||||
|
|
||||
|
TIEM=$(<"${SAT}_sched.txt") |
||||
|
echo $TIEM |
||||
|
|
||||
|
at -M -m $TIEM < $FILENAME |
||||
|
rm "${SAT}_sched.txt" |
@ -0,0 +1,104 @@ |
|||||
|
import array |
||||
|
import json |
||||
|
import sys |
||||
|
import time |
||||
|
import datetime |
||||
|
|
||||
|
|
||||
|
ppmshift = '1' |
||||
|
name = sys.argv[1].upper() |
||||
|
input_sample_rate = '48000' |
||||
|
output_sample_rate = '11025' |
||||
|
gain = '40' |
||||
|
gain_lower_pass = gain |
||||
|
gain_lower_pass_requirement = 40 |
||||
|
|
||||
|
data = json.load(open('satpredict.txt')) |
||||
|
|
||||
|
af_folder = '/tmp/' |
||||
|
output_folder = '~/sat_output/' |
||||
|
|
||||
|
wxtoimg_options = ['HVCT', 'MCIR', 'NO'] #['ZA', 'HVCT', 'therm'] |
||||
|
|
||||
|
rtl_fm_options = { '-f':data[name]['frequency'], |
||||
|
'-M':'fm', |
||||
|
'-p':ppmshift, |
||||
|
'-F':'9', |
||||
|
'-s':input_sample_rate, |
||||
|
'-g':gain, |
||||
|
'-E': 'dc', |
||||
|
'-A': 'fast' } |
||||
|
|
||||
|
rtl_power_options = { '-f':'137M:138M:4k', |
||||
|
'-g':gain, |
||||
|
'-i':'1s', |
||||
|
'-e':str(data[name]['duration_seconds']) + 's', |
||||
|
'-p':ppmshift, |
||||
|
'-c':'0.2' } |
||||
|
|
||||
|
sox_options = [ '-b16', |
||||
|
'-c1', |
||||
|
'-V1', |
||||
|
'-es', |
||||
|
'-r ' + input_sample_rate, |
||||
|
'-t raw' ] |
||||
|
|
||||
|
def filename(satname, part): |
||||
|
if(part != ''): |
||||
|
return satname + '_' + part + '.wav' |
||||
|
return satname + '.wav' |
||||
|
|
||||
|
def datestamp( unixtime ): |
||||
|
return datetime.datetime.fromtimestamp( |
||||
|
int(unixtime) |
||||
|
).strftime('%Y%m%d-%H%M_') |
||||
|
|
||||
|
def convert_time( unixtime ): |
||||
|
return datetime.datetime.fromtimestamp( |
||||
|
int(unixtime) |
||||
|
).strftime('%H:%M %Y-%m-%d') |
||||
|
|
||||
|
if( data[name]['elevation'] < gain_lower_pass_requirement ): |
||||
|
gain = gain_lower_pass |
||||
|
|
||||
|
timeoutstr = 'timeout ' + str(data[name]['duration_seconds']) |
||||
|
filename = datestamp(data[name]['start_unix']) + name + '_' + data[name]['direction'] + str(int(data[name]['elevation'])) |
||||
|
|
||||
|
if( len(wxtoimg_options) == 0 ): |
||||
|
|
||||
|
rtlpower = 'rtl_power -f 137M:138M:4k -g ' + gain + ' -i 1s -e ' + str(data[name]['duration_seconds']) + 's -p ' + ppmshift + ' -c 0.2 ' + output_folder + filename + '.csv' |
||||
|
heatmap = 'python heatmap.py ' + output_folder + name + '_' + data[name]['direction'] + str(int(data[name]['elevation'])) + '_' + timestamp + '.csv ' + output_folder + name + '_' + data[name]['direction'] + str(int(data[name]['elevation'])) + '_' + timestamp + '.png' |
||||
|
|
||||
|
print timeoutstr, rtlpower |
||||
|
print heatmap |
||||
|
print 'bash ftp.sh ' + output_folder + name + '_' + data[name]['direction'] + str(int(data[name]['elevation'])) + '_' + timestamp + '.png' |
||||
|
|
||||
|
else: |
||||
|
|
||||
|
timeoutstr = 'timeout ' + str(data[name]['duration_seconds']) |
||||
|
|
||||
|
rtlstr = 'rtl_fm' |
||||
|
for k, v in rtl_fm_options.iteritems(): |
||||
|
rtlstr = rtlstr + ' ' + k + ' ' + v |
||||
|
|
||||
|
soxstr = 'sox' |
||||
|
for v in sox_options: |
||||
|
soxstr = soxstr + ' ' + v |
||||
|
|
||||
|
print timeoutstr, rtlstr, af_folder + filename + '.raw' |
||||
|
print soxstr, af_folder + filename + '.raw', af_folder + filename + '.wav', 'rate 11025' |
||||
|
print 'touch -r', af_folder + filename + '.raw', af_folder + filename + '.wav' |
||||
|
print 'bash', 'fastserv_sat_render.sh', af_folder + filename + '.wav', data[name]['start_unix']+60 |
||||
|
|
||||
|
f = open(name + '_sched.txt', 'w') |
||||
|
f.write(convert_time(data[name]['start_unix'])) |
||||
|
|
||||
|
#for opt in wxtoimg_options: |
||||
|
# filename = datestamp(data[name]['start_unix']) + name + '_' + data[name]['direction'] + str(int(data[name]['elevation'])) |
||||
|
# |
||||
|
# print 'wxtoimg -' + data[name]['direction'] + ' -e', opt, af_folder + filename + '.wav', output_folder + filename + '_' + opt + '.png' |
||||
|
# |
||||
|
# if( data[name]['direction'] == "S" ): #southbound images are upside down |
||||
|
# print 'convert', output_folder + filename + '_' + opt + '.png', '-rotate 180', output_folder + filename + '_' + opt + '.png' |
||||
|
# |
||||
|
# print 'bash ftp.sh', output_folder + filename + '_' + opt + '.png' |
Loading…
Reference in new issue