-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassPredictor.py
More file actions
45 lines (34 loc) · 1.47 KB
/
PassPredictor.py
File metadata and controls
45 lines (34 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from datetime import datetime
# local imports
from Satellite import SatellitePredictor
class PassPredictor:
'''
predicts future passes for multiple satellites
'''
def __init__(self, start_date=datetime.now(), end_date=None, satellites=None, min_elevation=0, max_elevation=90, min_sun_elevation=-90, max_sun_elevation=90):
self.start_date = start_date
self.end_date = end_date
self.satellites = satellites
self.min_elevation = min_elevation
self.max_elevation = max_elevation
self.min_sun_elevation = min_sun_elevation
self.max_sun_elevation = max_sun_elevation
self.value = None
# create a predictor for each satellite
self.predictors = [SatellitePredictor(satellite, self.start_date, self.end_date, self.min_elevation, self.max_elevation, self.min_sun_elevation, self.max_sun_elevation) for satellite in self.satellites]
def __iter__(self):
return self
def __next__(self):
next_predictor = None
# find the earliest pass
for predictor in self.predictors:
if predictor.value == None:
next(predictor)
if next_predictor == None:
next_predictor = predictor
elif predictor.value.aos < next_predictor.value.aos:
next_predictor = predictor
next_pass = next_predictor.value
next(next_predictor)
self.value = next_pass
return next_pass