Added wait time between observations. Fixes #3
parent
920cf205de
commit
3219edd35e
|
@ -77,7 +77,10 @@ if __name__ == "__main__":
|
|||
parser.add_argument("-s", "--station", help="Ground station ID", type=int)
|
||||
parser.add_argument("-t", "--starttime", help="Start time (YYYY-MM-DD HH:MM:SS) [default: now]",
|
||||
default=datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S"))
|
||||
parser.add_argument("-d", "--duration", help="Duration to schedule [hours]", type=int, default=1)
|
||||
parser.add_argument("-d", "--duration", help="Duration to schedule [hours; default 1.0]", type=float, default=1)
|
||||
parser.add_argument("-w", "--wait",
|
||||
help="Wait time between consecutive observations (for setup and slewing) [seconds; default: 0.0]",
|
||||
type=float, default=0)
|
||||
parser.add_argument("-u", "--username", help="SatNOGS username")
|
||||
parser.add_argument("-p", "--password", help="SatNOGS password")
|
||||
parser.add_argument("-n", "--dryrun", help="Dry run (do not schedule passes)", action="store_true")
|
||||
|
@ -95,6 +98,9 @@ if __name__ == "__main__":
|
|||
# Settings
|
||||
ground_station_id = args.station
|
||||
length_hours = args.duration
|
||||
wait_time_seconds = args.wait
|
||||
if wait_time_seconds < 0:
|
||||
wait_time_seconds = 0.0
|
||||
cache_dir = "/tmp/cache"
|
||||
username = args.username
|
||||
password = args.password
|
||||
|
@ -207,11 +213,9 @@ if __name__ == "__main__":
|
|||
priorities = {}
|
||||
|
||||
# List of scheduled passes
|
||||
scheduledpasses = get_scheduled_passes_from_network(
|
||||
ground_station_id, tmin, tmax)
|
||||
logging.info(
|
||||
"Found %d scheduled passes between %s and %s on ground station %d" %
|
||||
(len(scheduledpasses), tmin, tmax, ground_station_id))
|
||||
scheduledpasses = get_scheduled_passes_from_network(ground_station_id, tmin, tmax)
|
||||
logging.info("Found %d scheduled passes between %s and %s on ground station %d" %
|
||||
(len(scheduledpasses), tmin, tmax, ground_station_id))
|
||||
|
||||
# Get passes of priority objects
|
||||
prioritypasses = []
|
||||
|
@ -235,25 +239,19 @@ if __name__ == "__main__":
|
|||
normalpasses.append(satpass)
|
||||
|
||||
# Priority scheduler
|
||||
prioritypasses = sorted(
|
||||
prioritypasses,
|
||||
key=lambda satpass: -
|
||||
satpass['priority'])
|
||||
scheduledpasses = ordered_scheduler(prioritypasses, scheduledpasses)
|
||||
prioritypasses = sorted(prioritypasses, key=lambda satpass: -satpass['priority'])
|
||||
scheduledpasses = ordered_scheduler(prioritypasses, scheduledpasses, wait_time_seconds)
|
||||
for satpass in passes:
|
||||
logging.debug(satpass)
|
||||
|
||||
# Random scheduler
|
||||
normalpasses = sorted(
|
||||
normalpasses,
|
||||
key=lambda satpass: -
|
||||
satpass['priority'])
|
||||
scheduledpasses = ordered_scheduler(normalpasses, scheduledpasses)
|
||||
# Normal scheduler
|
||||
normalpasses = sorted(normalpasses, key=lambda satpass: -satpass['priority'])
|
||||
scheduledpasses = ordered_scheduler(normalpasses, scheduledpasses, wait_time_seconds)
|
||||
|
||||
# Compute scheduling efficiency
|
||||
dt, dttot, eff = efficiency(scheduledpasses)
|
||||
logging.info(
|
||||
"%d passes scheduled out of %d, %.0f s out of %.0f s at %.3f%% efficiency" %
|
||||
(len(scheduledpasses), len(passes), dt, dttot, 100 * eff))
|
||||
logging.info("%d passes scheduled out of %d, %.0f s out of %.0f s at %.3f%% efficiency" %
|
||||
(len(scheduledpasses), len(passes), dt, dttot, 100 * eff))
|
||||
|
||||
# Find unique objects
|
||||
satids = sorted(set([satpass['id'] for satpass in passes]))
|
||||
|
|
24
utils.py
24
utils.py
|
@ -98,22 +98,28 @@ def get_scheduled_passes_from_network(ground_station, tmin, tmax):
|
|||
return scheduledpasses
|
||||
|
||||
|
||||
def overlap(satpass, scheduledpasses):
|
||||
def overlap(satpass, scheduledpasses, wait_time_seconds):
|
||||
"""Check if this pass overlaps with already scheduled passes"""
|
||||
# No overlap
|
||||
overlap = False
|
||||
|
||||
# Add wait time
|
||||
tr = satpass['tr']
|
||||
ts = satpass['ts'] + timedelta(seconds=wait_time_seconds)
|
||||
|
||||
# Loop over scheduled passes
|
||||
for scheduledpass in scheduledpasses:
|
||||
# Test pass falls within scheduled pass
|
||||
if satpass['tr'] >= scheduledpass['tr'] and satpass['ts'] < scheduledpass['ts']:
|
||||
if tr >= scheduledpass['tr'] and ts < scheduledpass['ts']:
|
||||
overlap = True
|
||||
# Scheduled pass falls within test pass
|
||||
elif scheduledpass['tr'] >= satpass['tr'] and scheduledpass['ts'] < satpass['ts']:
|
||||
elif scheduledpass['tr'] >= tr and scheduledpass['ts'] < ts:
|
||||
overlap = True
|
||||
# Pass start falls within pass
|
||||
elif satpass['tr'] >= scheduledpass['tr'] and satpass['tr'] < scheduledpass['ts']:
|
||||
elif tr >= scheduledpass['tr'] and tr < scheduledpass['ts']:
|
||||
overlap = True
|
||||
# Pass end falls within end
|
||||
elif satpass['ts'] >= scheduledpass['tr'] and satpass['ts'] < scheduledpass['ts']:
|
||||
elif ts >= scheduledpass['tr'] and ts < scheduledpass['ts']:
|
||||
overlap = True
|
||||
if overlap:
|
||||
break
|
||||
|
@ -121,23 +127,23 @@ def overlap(satpass, scheduledpasses):
|
|||
return overlap
|
||||
|
||||
|
||||
def ordered_scheduler(passes, scheduledpasses):
|
||||
def ordered_scheduler(passes, scheduledpasses, wait_time_seconds):
|
||||
"""Loop through a list of ordered passes and schedule each next one that fits"""
|
||||
# Loop over passes
|
||||
for satpass in passes:
|
||||
# Schedule if there is no overlap with already scheduled passes
|
||||
if not overlap(satpass, scheduledpasses):
|
||||
if not overlap(satpass, scheduledpasses, wait_time_seconds):
|
||||
scheduledpasses.append(satpass)
|
||||
|
||||
return scheduledpasses
|
||||
|
||||
|
||||
def random_scheduler(passes, scheduledpasses):
|
||||
def random_scheduler(passes, scheduledpasses, wait_time_seconds):
|
||||
"""Schedule passes based on random ordering"""
|
||||
# Shuffle passes
|
||||
random.shuffle(passes)
|
||||
|
||||
return ordered_scheduler(passes, scheduledpasses)
|
||||
return ordered_scheduler(passes, scheduledpasses, wait_time_seconds)
|
||||
|
||||
|
||||
def efficiency(passes):
|
||||
|
|
Loading…
Reference in New Issue