Skip to content
Snippets Groups Projects
Commit 01b7df67 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-2823: minor fix, take modulo HALF_SIDEREAL_DAY_LENGTH into account

parent a4b4d600
No related branches found
No related tags found
No related merge requests found
...@@ -1179,17 +1179,21 @@ class SchedulingUnitCommonPropertiesMixin: ...@@ -1179,17 +1179,21 @@ class SchedulingUnitCommonPropertiesMixin:
transit_window_width_seconds = abs(self.scheduling_constraints_doc['sky']['transit_offset']['to'] - self.scheduling_constraints_doc['sky']['transit_offset']['from']) transit_window_width_seconds = abs(self.scheduling_constraints_doc['sky']['transit_offset']['to'] - self.scheduling_constraints_doc['sky']['transit_offset']['from'])
# ToDo: move get_transit_offset_pointings (and similar) methods to Task/SchedulingUnit # ToDo: move get_transit_offset_pointings (and similar) methods to Task/SchedulingUnit
from lofar.sas.tmss.services.scheduling.constraints import get_transit_offset_pointings from lofar.sas.tmss.services.scheduling.constraints import get_transit_offset_pointings
SIDEREAL_DAY_LENGTH = 23*3600 + 56*60 + 4
HALF_SIDEREAL_DAY_LENGTH = SIDEREAL_DAY_LENGTH//2
for task in self.observation_tasks: for task in self.observation_tasks:
if task.is_target_observation: if task.is_target_observation:
pointings = get_transit_offset_pointings(task) pointings = get_transit_offset_pointings(task)
transits = [p.transit_lst for p in pointings if p.direction_type=="J2000"] transits = [p.transit_lst for p in pointings if p.direction_type=="J2000"]
if transits: if transits:
earliest_transit = min(transits) # express transit time's into seconds_since_midnight_in_a_local_sideral_day
latest_transit = max(transits) transits_seconds = [int((datetime.datetime.combine(datetime.date.today(), transit)-datetime.datetime.combine(datetime.date.today(), datetime.time(0,0,0))).total_seconds()) for transit in transits]
delta_transit = datetime.datetime.combine(datetime.date.today(), latest_transit) - datetime.datetime.combine(datetime.date.today(), earliest_transit) # check all delta's (in seconds) between all pairs of transits, raise if too large
delta_transit_seconds = delta_transit.total_seconds() for i, transit_a in enumerate(transits_seconds[:-1]):
if delta_transit_seconds > transit_window_width_seconds: for transit_b in transits_seconds[i+1:]:
raise RuleValidationException("time between latest and earliest transit for targets in task id=%s name='%s' su_id=%s is larger than the transit_offset window itself: delta_transit=%dsec > transit_window_width=%ssec" % (task.id, task.name, self.id, delta_transit_seconds, transit_window_width_seconds)) delta_transit_seconds = abs(transit_a-transit_b)%HALF_SIDEREAL_DAY_LENGTH
if delta_transit_seconds > transit_window_width_seconds:
raise RuleValidationException("time between latest and earliest transit for targets in task id=%s name='%s' su_id=%s is larger than the transit_offset window itself: delta_transit=%dsec > transit_window_width=%ssec" % (task.id, task.name, self.id, delta_transit_seconds, transit_window_width_seconds))
class SchedulingUnitDraft(TemplateSchemaMixin, ProjectPropertyMixin, SchedulingUnitCommonPropertiesMixin, RefreshFromDbInvalidatesCachedPropertiesMixin, NamedCommon): class SchedulingUnitDraft(TemplateSchemaMixin, ProjectPropertyMixin, SchedulingUnitCommonPropertiesMixin, RefreshFromDbInvalidatesCachedPropertiesMixin, NamedCommon):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment