import predict
import json
import sys
import datetime
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
pass_elevation = default_min_elevation
if ( len ( sys . argv ) > 1 ) :
pass_elevation = int ( sys . argv [ 1 ] )
if ( pass_elevation == ' ' ) :
pass_elevation = default_min_elevation
predictions = default_predictions
if ( len ( sys . argv ) > 2 ) :
predictions = int ( sys . argv [ 2 ] )
if ( predictions == ' ' ) :
predictions = default_predictions
if ( len ( sys . argv ) > 3 ) :
suppress_low_passes = True
def convert_time ( unixtime ) :
return datetime . datetime . fromtimestamp (
int ( unixtime )
) . strftime ( ' % H: % M % Y- % m- %d ' )
def convert_time_short ( unixtime ) :
return datetime . datetime . fromtimestamp (
int ( unixtime )
) . strftime ( ' % M ' )
def get_sat ( sat ) :
return sat + ' \n ' + tle_data [ sat ]
qth = ( 49.5 , 123.5 , 50 ) # lat (N), long (W), alt (meters)
data = { }
for sat , freq in frequencies . iteritems ( ) :
name = predict . observe ( get_sat ( sat ) , qth ) [ ' name ' ] . strip ( )
t = predict . transits ( get_sat ( sat ) , qth )
count = 0
while ( count < predictions ) :
p = t . next ( )
p_nw = t_nw . next ( )
p_se = t_se . next ( )
while ( p . peak ( ) [ ' elevation ' ] < default_min_elevation ) :
p = t . next ( )
p_nw = t_nw . next ( )
p_se = t_se . next ( )
if ( not suppress_low_passes ) :
print name , " pass too low, recalculating "
data [ name ] = { }
data [ name ] [ ' frequency ' ] = freq
data [ name ] [ ' start_unix ' ] = p . start
data [ name ] [ ' start ' ] = convert_time ( data [ name ] [ ' start_unix ' ] )
data [ name ] [ ' duration_seconds ' ] = int ( p . duration ( ) )
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 '
count = count + 1
import json
with open ( ' satpredict.txt ' , ' w ' ) as fp :
json . dump ( data , fp , indent = 4 )