satnogs-auto-scheduler/test_predictor.py

82 lines
3.5 KiB
Python
Executable File

#!/usr/bin/env python3
from tqdm import tqdm
from datetime import datetime
from cache import CacheManager
from utils import satellites_from_transmitters, \
print_scheduledpass_summary
from auto_scheduler.pass_predictor import create_observer, \
find_passes
tmin = datetime(2019,11,5,12,7,10)
tmax = datetime(2019,11,5,13,7,10)
min_culmination = 5
min_pass_duration = 2
ground_station = {'altitude': 280,
'antenna': [ { 'antenna_type': 'yagi',
'band': 'UHF',
'frequency': 430000000,
'frequency_max': 470000000},
{ 'antenna_type': 'yagi',
'band': 'VHF',
'frequency': 135000000,
'frequency_max': 146000000}],
'client_version': '0.9',
'created': '2015-07-22T14:24:10Z',
'description': 'Yaesu G-5500 with M2 cross yagi antennas and S-band '
'parabolic dish',
'id': 2,
'last_seen': '2019-11-05T12:02:10Z',
'lat': 39.236,
'lng': -86.305,
'location': '',
'min_horizon': 5,
'name': 'KB9JHU',
'observations': 20701,
'qthlocator': 'EM69uf',
'status': 'Online',
'target_utilization': 100}
passes_0 = {'mytime': '2019/11/5 12:07:10', 'name': 'SPOOQY-1', 'id': '44332', 'tle1': '1 44332U 98067QH 19306.08869167 .00007980 00000-0 12906-3 0 9995\n', 'tle2': '2 44332 51.6412 35.2671 0005344 234.5067 125.5425 15.53818829 21405\n', 'tr': datetime(2019, 11, 5, 12, 22, 27, 60922), 'azr': '319', 'tt': datetime(2019, 11, 5, 12, 26, 26, 616777), 'altt': '30', 'ts': datetime(2019, 11, 5, 12, 30, 24, 387405), 'azs': '100', 'valid': False, 'uuid': '4rK9bvm9bm7BLypA69EnEh', 'success_rate': 0.79, 'good_count': 1754, 'data_count': 2195, 'mode': 'GMSK9k6', 'scheduled': False}
if __name__ == '__main__':
cache = CacheManager(ground_station['id'],
ground_station['antenna'],
cache_dir='./tests/cache',
cache_age=24, # hours
max_norad_cat_id=90000)
assert(str(cache.last_update()) == '2019-11-02 19:35:18')
tles = list(cache.read_tles())
transmitters = list(cache.read_transmitters())
assert(len(tles) == 240)
assert(len(transmitters) == 545)
# Extract interesting satellites from receivable transmitters
satellites = satellites_from_transmitters(transmitters, tles)
# Find all passes for station 2, given the transmitters and tles
observer = create_observer(ground_station['lat'],
ground_station['lng'],
ground_station['altitude'],
min_riseset=ground_station['min_horizon'])
# Loop over satellites
passes = []
for satellite in tqdm(satellites):
passes.extend(find_passes(satellite,
observer,
tmin,
tmax,
min_culmination,
min_pass_duration))
# print_scheduledpass_summary(passes, ground_station['id'])
assert(len(passes) == 119)
assert(passes[0] == passes_0)