Browse Source

adding comments

master
va7eex 7 years ago
committed by GitHub
parent
commit
3a5fafa237
  1. 18
      satpredict.py

18
satpredict.py

@ -3,14 +3,15 @@ import json
import sys
import datetime
#Frequencies that satellites transmit on.
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
default_predictions = 1 #how many predictions do we want to predict in advance
default_min_elevation = 30 #how low the angle of the satellitie pass is allowed to be if we want to record a pass
suppress_low_passes = False #Less console spam if you enable this.
#You can change the default elevation with the first parameter
pass_elevation = default_min_elevation
if( len(sys.argv) > 1 ):
pass_elevation = int(sys.argv[1])
@ -18,6 +19,7 @@ if( len(sys.argv) > 1 ):
if( pass_elevation == '' ):
pass_elevation = default_min_elevation
#you can change the number of predictions per satellite with the second parameter
predictions = default_predictions
if( len(sys.argv) > 2):
predictions = int(sys.argv[2])
@ -25,14 +27,17 @@ if( len(sys.argv) > 2):
if( predictions == '' ):
predictions = default_predictions
#anything in the third parameter will turn off console spam
if( len(sys.argv) > 3 ):
suppress_low_passes = True
#format a unix timestamp in a time appropriate for the 'at' command
def convert_time( unixtime ):
return datetime.datetime.fromtimestamp(
int(unixtime)
).strftime('%H:%M %Y-%m-%d')
#format the unix timestamp for minutes, used to determine length of recording
def convert_time_short( unixtime ):
return datetime.datetime.fromtimestamp(
int(unixtime)
@ -41,6 +46,7 @@ def convert_time_short( unixtime ):
def get_sat( sat ):
return sat + '\n' + tle_data[sat]
#Where on the earth you are. Change this to your location
qth = (49.5, 123.5, 50) # lat (N), long (W), alt (meters)
data = {}
@ -56,6 +62,7 @@ for sat, freq in frequencies.iteritems():
p_nw = t_nw.next()
p_se = t_se.next()
#peak check. PEAK CHECK!
while (p.peak()['elevation'] < default_min_elevation):
p = t.next()
p_nw = t_nw.next()
@ -63,6 +70,7 @@ for sat, freq in frequencies.iteritems():
if( not suppress_low_passes ):
print name, "pass too low, recalculating"
#this is the data we want to pass on to the rest of the program
data[name] = {}
data[name]['frequency'] = freq
data[name]['start_unix'] = p.start
@ -71,7 +79,7 @@ for sat, freq in frequencies.iteritems():
data[name]['duration_minutes'] = convert_time_short(data[name]['duration_seconds'])
data[name]['elevation'] = p.peak()['elevation']
print name, 'next pass at:', data[name]['start'], 'at', data[name]['elevation'], 'degrees.', data[name]['direction'] + '-bound'
print name, 'next pass at:', data[name]['start'], 'at', data[name]['elevation'], 'degrees.'
count = count + 1
import json

Loading…
Cancel
Save