2017-02-05 05:57:53 +01:00
|
|
|
import array
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
|
2018-01-18 11:58:03 +01:00
|
|
|
ppmshift = '1.1' #adjust this if you don't have a TCXO equipped RTLSDR
|
2017-02-21 09:48:04 +01:00
|
|
|
name = sys.argv[1].upper() #what satellite we're using
|
|
|
|
input_sample_rate = '48000' #actually the bandwidth of the audio sample we're taking from the RTLSDR
|
|
|
|
output_sample_rate = '11025' #what we downconvert to to play nicely with wxtoimg
|
2018-01-18 11:58:03 +01:00
|
|
|
gain = '35' #software gain
|
2017-02-21 09:48:04 +01:00
|
|
|
gain_lower_pass = gain #we can add more or less gain if a satellite is at a lower elevation, currently disabled
|
2017-02-05 05:57:53 +01:00
|
|
|
gain_lower_pass_requirement = 40
|
|
|
|
|
|
|
|
data = json.load(open('satpredict.txt'))
|
|
|
|
|
2018-01-18 11:58:03 +01:00
|
|
|
af_folder = 'tmp/'
|
|
|
|
output_folder = '/home/space/satstuff/PI_WXRX/sat_output/'
|
2017-02-05 05:57:53 +01:00
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
#this line is depreciated, make it a zero element array to do rtl_power surveys of the downline band
|
|
|
|
wxtoimg_options = ['HVCT', 'MCIR', 'NO']
|
2017-02-05 05:57:53 +01:00
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
#set options for various to-bash lines
|
|
|
|
#I don't recommend touching any of these
|
2017-02-05 05:57:53 +01:00
|
|
|
rtl_fm_options = { '-f':data[name]['frequency'],
|
|
|
|
'-M':'fm',
|
|
|
|
'-p':ppmshift,
|
|
|
|
'-F':'9',
|
|
|
|
'-s':input_sample_rate,
|
|
|
|
'-g':gain,
|
|
|
|
'-E': 'dc',
|
|
|
|
'-A': 'fast' }
|
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
rtl_power_options = { '-f':'136.9M:138.1M:4k',
|
2017-02-05 05:57:53 +01:00
|
|
|
'-g':gain,
|
|
|
|
'-i':'1s',
|
|
|
|
'-e':str(data[name]['duration_seconds']) + 's',
|
|
|
|
'-p':ppmshift,
|
|
|
|
'-c':'0.2' }
|
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
#I REALLY don't recommend touching these, stuff breaks without it and I can't explain why
|
2017-02-05 05:57:53 +01:00
|
|
|
sox_options = [ '-b16',
|
|
|
|
'-c1',
|
|
|
|
'-V1',
|
|
|
|
'-es',
|
|
|
|
'-r ' + input_sample_rate,
|
|
|
|
'-t raw' ]
|
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
#depreciated
|
2017-02-05 05:57:53 +01:00
|
|
|
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')
|
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
#gain adjustment based on pass elevationg
|
2017-02-05 05:57:53 +01:00
|
|
|
if( data[name]['elevation'] < gain_lower_pass_requirement ):
|
|
|
|
gain = gain_lower_pass
|
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
#a bash line
|
2017-02-05 05:57:53 +01:00
|
|
|
timeoutstr = 'timeout ' + str(data[name]['duration_seconds'])
|
2017-02-21 09:48:04 +01:00
|
|
|
#a filename
|
2017-02-05 06:55:56 +01:00
|
|
|
filename = datestamp(data[name]['start_unix']) + name + '_' + str(int(data[name]['elevation']))
|
2017-02-05 05:57:53 +01:00
|
|
|
|
2017-02-21 09:48:04 +01:00
|
|
|
#I may or may not have forgotten to specify you need the heatmap.py from the rtl_power page on keenerd.
|
2017-02-05 05:57:53 +01:00
|
|
|
if( len(wxtoimg_options) == 0 ):
|
|
|
|
|
2018-01-18 11:58:03 +01:00
|
|
|
# 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 + '_' + str(int(data[name]['elevation'])) + '_' + timestamp + '.csv ' + output_folder + name + '_' + data[name]['direction'] + str(int(data[name]['elevation'])) + '_' + timestamp + '.png'
|
2017-02-05 05:57:53 +01:00
|
|
|
|
|
|
|
print timeoutstr, rtlpower
|
|
|
|
print heatmap
|
2018-01-18 11:58:03 +01:00
|
|
|
# print 'bash ftp.sh ' + output_folder + name + '_' + str(int(data[name]['elevation'])) + '_' + timestamp + '.png'
|
2017-02-05 05:57:53 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-01-18 11:58:03 +01:00
|
|
|
print '/home/space/satstuff/rtl_biast/build/src/rtl_biast -b1'
|
2017-02-05 05:57:53 +01:00
|
|
|
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'
|
2017-02-21 09:48:04 +01:00
|
|
|
print 'bash', 'render.sh', af_folder + filename + '.wav'
|
2017-02-05 05:57:53 +01:00
|
|
|
|
|
|
|
f = open(name + '_sched.txt', 'w')
|
|
|
|
f.write(convert_time(data[name]['start_unix']))
|
|
|
|
|
2017-02-05 06:55:56 +01:00
|
|
|
#Depreciated, use render.sh
|
2017-02-05 05:57:53 +01:00
|
|
|
#for opt in wxtoimg_options:
|
2017-02-05 06:55:56 +01:00
|
|
|
# filename = datestamp(data[name]['start_unix']) + name + '_' + str(int(data[name]['elevation']))
|
2017-02-05 05:57:53 +01:00
|
|
|
#
|
2017-02-05 06:55:56 +01:00
|
|
|
# print 'wxtoimg' + ' -e', opt, af_folder + filename + '.wav', output_folder + filename + '_' + opt + '.png'
|
2017-02-05 05:57:53 +01:00
|
|
|
#
|
|
|
|
# print 'bash ftp.sh', output_folder + filename + '_' + opt + '.png'
|