a set of script to predict passes and make automated recordings of satellites. Intended to be run headless on an SoC. Original forked from https://github.com/va7eex/Pi_WXRX Improvements made for https://keet.space
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.7 KiB

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