From 93c18f66bd66c1540397f47ac416de2a3de03372 Mon Sep 17 00:00:00 2001 From: Dr Paul Brewer Date: Fri, 26 Sep 2014 00:45:13 -0400 Subject: [PATCH] initial commit assumptions: rtl-sdr dongle, stationary antenna goal: record wav files for later processing prerequistes: working rtl-sdr, predict (text based, not gpredict), sox LICENSE - General Public License version 2.0, or any later version dotpredict-predict.tle copy to .predict/predict.tle to get coverage of NOAA-18 and NOAA-19 that is missing in predict's default config noaacapture.py This is the main python script. It will calculate the time of the next pass for recording. It expects to call rtl_fm to do the recording and sox to convert the file to .wav pypredict.py This is a short python module for extracting the AOS/LOS times of the next pass for a specified satellite. It calls predict -p and extracts the times from the first and last lines. update-keps.sh This is a short shell script to update the keps, which are orbital parameters needed by the predict program. It is mostly copied from the PREDICT man page. PREDICT was written by John Magliacane, KD2BD and released under the GPL license. --- LICENSE | 0 dotpredict-predict.tle | 69 ++++++++++++++++++++++++++++++++++++++++++ noaacapture.py | 55 +++++++++++++++++++++++++++++++++ pypredict.py | 25 +++++++++++++++ update-keps.sh | 9 ++++++ 5 files changed, 158 insertions(+) mode change 100644 => 100755 LICENSE create mode 100755 dotpredict-predict.tle create mode 100755 noaacapture.py create mode 100755 pypredict.py create mode 100755 update-keps.sh diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/dotpredict-predict.tle b/dotpredict-predict.tle new file mode 100755 index 0000000..7ffb10f --- /dev/null +++ b/dotpredict-predict.tle @@ -0,0 +1,69 @@ +OSCAR-7 +1 07530U 74089B 14266.78662275 -.00000039 00000-0 26515-4 0 789 +2 07530 101.4846 245.4111 0012383 101.9633 17.9051 12.53607373823877 +OSCAR-27 +1 22825U 93061C 06134.49181646 .00000017 00000-0 22806-4 0 3995 +2 22825 98.2811 117.9786 0008650 8.4587 351.6746 14.29172110658548 +OSCAR-29 +1 24278U 96046B 14267.08639596 .00000004 00000-0 37933-4 0 4835 +2 24278 98.5154 267.2966 0350993 41.1959 359.0942 13.53029655894049 +OSCAR-50 +1 27607U 02058C 14267.28624087 .00000725 00000-0 12818-3 0 5212 +2 27607 64.5556 290.2200 0059851 344.1140 15.8082 14.73920955632083 +NOAA-14 +1 23455U 94089A 06134.32605279 -.00000033 00000-0 66498-5 0 1174 +2 23455 99.0397 192.2321 0010010 143.3377 216.8479 14.13657419586285 +NOAA-15 +1 25338U 98030A 14268.44083274 .00000145 00000-0 80179-4 0 3605 +2 25338 98.7602 262.1402 0010166 211.3654 314.1197 14.25472120851129 +NOAA-17 +1 27453U 02032A 06134.29847588 .00000281 00000-0 14156-3 0 9006 +2 27453 98.6221 207.1671 0012016 169.5829 190.5591 14.23777448201959 +HUBBLE +1 20580U 90037B 14266.96955307 .00002315 00000-0 14413-3 0 1200 +2 20580 28.4694 107.6130 0002766 267.7109 220.4993 15.05779391139628 +ISS +1 25544U 98067A 14268.54034133 .00013485 00000-0 23853-3 0 1553 +2 25544 51.6470 322.1845 0002071 123.6697 21.6675 15.50629733906894 +NOAA-18 +1 28654U 05018A 14268.45683922 .00000233 00000-0 15252-3 0 2673 +2 28654 99.1598 250.0225 0013921 347.1180 177.0069 14.12065086481718 +NOAA-19 +1 33591U 09005A 14268.50183324 .00000229 00000-0 15033-3 0 4030 +2 33591 98.9539 213.2790 0013799 192.4389 301.7203 14.11766654290148 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 + +1 00000U 00 0.00000000 .00000000 00000-0 00000-0 0 03 +2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02 diff --git a/noaacapture.py b/noaacapture.py new file mode 100755 index 0000000..ea258a1 --- /dev/null +++ b/noaacapture.py @@ -0,0 +1,55 @@ +import time +import pypredict +import subprocess + +satellites = ['NOAA-18','NOAA-19','NOAA-15'] +freqs = [137912500, 137100000, 137620000] + +def runForDuration(cmdline, duration): + try: + child = subprocess.Popen(cmdline) + time.sleep(duration) + child.terminate() + except OSError as e: + print "OS Error during command: "+" ".join(cmdline) + print "OS Error: "+e.strerror + +def recordFM(freq, fname, duration): + cmdline = ['rtl_fm','-f',str(freq),'-s','44100','-g','40',fname+'.raw'] + runForDuration(cmdline, duration) + +def transcode(fname): + cmdline = ['sox','-t','raw','-r','44100','-es','-b','16','-c','1','-V1',fname+'.raw',fname+'.wav','rate','11025'] + subprocess.call(cmdline) + +def recordWAV(freq,fname,duration): + recordFM48k(freq,fname,duration) + transcode(fname) + +def spectrum(fname,duration): + cmdline = ['rtl_power','-f','137000000:138000000:1000','-i','1m','-g','40',fname+'.csv'] + runForDuration(cmdline,duration) + +def findNextPass(): + predictions = [pypredict.aoslos(s) for s in satellites] + aoses = [p[0] for p in predictions] + nextIndex = aoses.index(min(aoses)) + return (satellites[nextIndex],\ + freqs[nextIndex],\ + predictions[nextIndex]) + +while True: + (satName, freq, (aosTime, losTime)) = findNextPass() + now = time.time() + towait = aosTime-now + if towait>0: + print "waiting "+str(towait)+" seconds 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) + # spectrum(fname,losTime-aosTime) + print "finished pass "+fname+" at "+str(time.time()) + time.sleep(60.0) + diff --git a/pypredict.py b/pypredict.py new file mode 100755 index 0000000..12b6652 --- /dev/null +++ b/pypredict.py @@ -0,0 +1,25 @@ +import subprocess +import sys + +class missingSatellitePredictionError(Exception): + def __init__(self): + self.description = "predict could not find aos, los of next pass" + + def __str__(self): + return self.description + +def aoslos(satname): + lines = subprocess.check_output(['predict','-p',satname]).split("\n") + try: + aosTime=int(lines[0].split(" ")[0]) + losTime=int(lines[-2].split(" ")[0]) + if losTime>aosTime: + return (aosTime,losTime) + except Exception: + pass + raise missingSatellitePredictionError() + + + + + diff --git a/update-keps.sh b/update-keps.sh new file mode 100755 index 0000000..01199f4 --- /dev/null +++ b/update-keps.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# mostly from PREDICT man page by KB2BD +cd ./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 +