From c19f70e9bc6fb5742bf2ac1449f2ba2bf02dfc29 Mon Sep 17 00:00:00 2001 From: cyber-atomus Date: Fri, 11 Mar 2016 15:05:14 +0100 Subject: [PATCH] -> predict TLE, QTH and database simplified to NOAA, ISS and NO-44 sats -> premiliminary support for doppler tool -> changes to recent linux rtl_fm tools --- noaacapture.py | 86 +++++++++++++++++++++++++++++++++++++------------- update-keps.sh | 18 +++++------ 2 files changed, 73 insertions(+), 31 deletions(-) diff --git a/noaacapture.py b/noaacapture.py index 7c2f9bf..5390b23 100755 --- a/noaacapture.py +++ b/noaacapture.py @@ -1,14 +1,20 @@ import time +from time import gmtime, strftime import pypredict import subprocess -satellites = ['NOAA-18','NOAA-19','NOAA-15'] -freqs = [137912500, 137100000, 137620000] -sample = '44100' +satellites = ['NOAA 18','NOAA 19','NOAA 15'] +freqs = [137912500, 137100000, 137625000] +sample ='48000' wavrate='11025' +location='lon=53.3404,lat=-15.0579,alt=20' +recdir='/opt/wxsat/rec' +specdir='/opt/wxsat/spectro' +imgdir='/opt/wxsat/img' def runForDuration(cmdline, duration): try: + #child = subprocess.Popen(cmdline, stdin=-subprocess.PIPE, shell=True) child = subprocess.Popen(cmdline) time.sleep(duration) child.terminate() @@ -16,33 +22,57 @@ def runForDuration(cmdline, duration): print "OS Error during command: "+" ".join(cmdline) print "OS Error: "+e.strerror -def recordFM(freq, fname, duration): +def recordFM(freq, fname, duration, xfname): # still experimenting with options - unsure as to best settings + #print freq + #print fname + #print duration + #print xfname + cmdline = ['rtl_fm',\ - '-f',str(freq),\ - '-s',sample,\ - '-g','43',\ - '-F','9',\ - '-A','fast',\ - '-E','dc',\ - fname+'.raw'] + '-f',str(freq),\ + '-s',sample,\ + '-g','43',\ + '-F','9',\ + '-A','fast',\ + '-E','dc',\ + '-p','-135',\ + recdir+'/'+fname+'.raw' ] + + #print cmdline + runForDuration(cmdline, duration) def transcode(fname): - cmdline = ['sox','-t','raw','-r',sample,'-es','-b','16','-c','1','-V1',fname+'.raw',fname+'.wav','rate',wavrate] + cmdline = ['sox','-t','raw','-r',sample,'-es','-b','16','-c','1','-V1',recdir+'/'+fname+'.raw',recdir+'/'+fname+'.wav','rate',wavrate] + subprocess.call(cmdline) + +def doppler(fname,emergeTime): + #cmdline = ['sox','-t','raw','-r',sample,'-es','-b','16','-c','1','-V1',recdir+'/'+fname+'.raw',recdir+'/'+fname+'.wav','rate',wavrate] + cmdline = ['doppler', + '-d','',\ + '--tlefile', '~/.predict/predict.tle',\ + '--tlename', xfname,\ + '--location', location,\ + '--freq ', +str(freq),\ + '-i', 'i16',\ + '-s', sample ] subprocess.call(cmdline) def decode(fname): - cmdline = ['/root/atpdec-1.7/atpdec',fname+'.wav'] + cmdline = ['/usr/local/bin/wxtoimg','-A',recdir+'/'+fname+'.wav', imgdir+'/'+fname+'.jpg'] subprocess.call(cmdline) def recordWAV(freq,fname,duration): - recordFM(freq,fname,duration) + recordFM(freq,fname,duration,xfname) transcode(fname) + spectrum(fname) -def spectrum(fname,duration): - cmdline = ['rtl_power','-f','137000000:138000000:1000','-i','1m','-g','40',fname+'.csv'] - runForDuration(cmdline,duration) +def spectrum(fname): + #cmdline = ['rtl_power','-f','137000000:138000000:1000','-i','1m','-g','40',fname+'.csv'] + cmdline = ['sox',recdir+'/'+fname+'.wav', '-n', 'spectrogram','-o',specdir+'/'+fname+'.png'] + #runForDuration(cmdline,duration) + subprocess.call(cmdline) def findNextPass(): predictions = [pypredict.aoslos(s) for s in satellites] @@ -56,15 +86,27 @@ while True: (satName, freq, (aosTime, losTime)) = findNextPass() now = time.time() towait = aosTime-now + aosTimeCnv=strftime('%H:%M:%S', time.localtime(aosTime)) + emergeTimeUtc=strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(aosTime)) + losTimeCnv=strftime('%H:%M:%S', time.localtime(losTime)) + dimTimeUtc=strftime('%Y-%m-%dT%H:%M:%S', time.gmtime(losTime)) + #print emergeTimeUtc + #aosTimeCnv=time.ctime(int(aosTime)) + #print freq if towait>0: - print "waiting "+str(towait)+" seconds for "+satName + print "waiting "+str(towait).split(".")[0]+" seconds (emerging "+aosTimeCnv+") for "+satName time.sleep(towait) # dir= sat name and filename = start time - fname='./'+satName+'/'+str(aosTime) - print "beginning pass "+fname+" predicted end "+str(losTime) - recordWAV(freq,fname,losTime-aosTime) + if aosTime=now: + recordTime=losTime-aosTime + fname=str(aosTime) + xfname=satName + print "beginning pass "+fname+" predicted start "+aosTimeCnv+" and end "+losTimeCnv+". Will record for "+str(recordTime)+" seconds." + recordWAV(freq,fname,recordTime) decode(fname) # make picture # spectrum(fname,losTime-aosTime) - print "finished pass "+fname+" at "+str(time.time()) + print "finished pass of "+satName+" at "+losTimeCnv+". Sleeping for 60 seconds" time.sleep(60.0) diff --git a/update-keps.sh b/update-keps.sh index ee57e95..907b091 100755 --- a/update-keps.sh +++ b/update-keps.sh @@ -1,11 +1,11 @@ #!/bin/bash -# mostly from PREDICT man page by KB2BD -# Suitable as a cron.weekly script -mkdir -p /tmp/keps -cd /tmp/keps -rm -f amateur.txt visual.txt weather.txt -wget -qr www.celestrak.com/NORAD/elements/amateur.txt -O amateur.txt -wget -qr www.celestrak.com/NORAD/elements/visual.txt -O visual.txt -wget -qr www.celestrak.com/NORAD/elements/weather.txt -O weather.txt -/usr/bin/predict -u amateur.txt visual.txt weather.txt +#rm /tmp/weather.txt +#wget -qr www.celestrak.com/NORAD/elements/weather.txt -O /tmp/weather.txt +rm /tmp/noaa.txt +wget -qr https://www.celestrak.com/NORAD/elements/noaa.txt -O /tmp/noaa.txt + +rm /tmp/amateur.txt +wget -qr https://www.celestrak.com/NORAD/elements/amateur.txt -O /tmp/amateur.txt + +/usr/bin/predict -u /tmp/noaa.txt /tmp/amateur.txt