Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Will return the new slots created, which can either
be one, two or three slots depending on if there is
space remaining before or after the inserted slot.
Parameters
----------
early_time : `~astropy.time.Time`
The start time of the new slot to insert.
later_time : `~astropy.time.Time`
The end time of the new slot to insert.
"""
# check if the new slot would overwrite occupied/other slots
if self.occupied:
raise ValueError('slot is already occupied')
new_slot = Slot(early_time, later_time)
new_slot.middle = True
early_slot = Slot(self.start, early_time)
late_slot = Slot(later_time, self.end)
if early_time > self.start and later_time < self.end:
return [early_slot, new_slot, late_slot]
elif early_time > self.start:
return [early_slot, new_slot]
elif later_time < self.end:
return [new_slot, late_slot]
else:
return [new_slot]
Parameters
----------
early_time : `~astropy.time.Time`
The start time of the new slot to insert.
later_time : `~astropy.time.Time`
The end time of the new slot to insert.
"""
# check if the new slot would overwrite occupied/other slots
if self.occupied:
raise ValueError('slot is already occupied')
new_slot = Slot(early_time, later_time)
new_slot.middle = True
early_slot = Slot(self.start, early_time)
late_slot = Slot(later_time, self.end)
if early_time > self.start and later_time < self.end:
return [early_slot, new_slot, late_slot]
elif early_time > self.start:
return [early_slot, new_slot]
elif later_time < self.end:
return [new_slot, late_slot]
else:
return [new_slot]
space remaining before or after the inserted slot.
Parameters
----------
early_time : `~astropy.time.Time`
The start time of the new slot to insert.
later_time : `~astropy.time.Time`
The end time of the new slot to insert.
"""
# check if the new slot would overwrite occupied/other slots
if self.occupied:
raise ValueError('slot is already occupied')
new_slot = Slot(early_time, later_time)
new_slot.middle = True
early_slot = Slot(self.start, early_time)
late_slot = Slot(later_time, self.end)
if early_time > self.start and later_time < self.end:
return [early_slot, new_slot, late_slot]
elif early_time > self.start:
return [early_slot, new_slot]
elif later_time < self.end:
return [new_slot, late_slot]
else:
return [new_slot]
def __init__(self, start_time, end_time, constraints=None):
"""
Parameters
-----------
start_time : `~astropy.time.Time`
The starting time of the schedule; the start of your
observing window.
end_time : `~astropy.time.Time`
The ending time of the schedule; the end of your
observing window
constraints : sequence of `~astroplan.constraints.Constraint` s
these are constraints that apply to the entire schedule
"""
self.start_time = start_time
self.end_time = end_time
self.slots = [Slot(start_time, end_time)]
self.observer = None