diff --git a/SAS/TMSS/backend/services/scheduling/lib/constraints.py b/SAS/TMSS/backend/services/scheduling/lib/constraints.py index bcbb7c55dce869ff3c26bad25581d607611855f8..75efca90d9ff89d77386a359c4c988d2920c6a1a 100644 --- a/SAS/TMSS/backend/services/scheduling/lib/constraints.py +++ b/SAS/TMSS/backend/services/scheduling/lib/constraints.py @@ -904,15 +904,15 @@ def evaluate_sky_min_elevation_constraint(scheduling_unit: models.SchedulingUnit # evaluate at start/stop/center of observation # take along the relative start_time of this task compared to the scheduling unit's start_time + # currently we only check at bounds and center, we probably want to add some more samples in between later on task_proposed_start_time = proposed_start_time + task.relative_start_time - task_proposed_end_time = task_proposed_start_time + task.specified_duration task_proposed_center_time = task_proposed_start_time + task.specified_duration / 2 + task_proposed_end_time = task_proposed_start_time + task.specified_duration + gridded_timestamps = set([gridder.grid_time(t) for t in (task_proposed_start_time, task_proposed_center_time, task_proposed_end_time)]) - # currently we only check at bounds and center, we probably want to add some more samples in between later on - for timestamp in (task_proposed_start_time, task_proposed_center_time, task_proposed_end_time): + for gridded_timestamp in gridded_timestamps: for station in stations: for pointing, min_elevation in pointings_and_min_elevations: - gridded_timestamp = gridder.grid_time(timestamp) station_target_rise_and_set_times = coordinates_timestamps_and_stations_to_target_rise_and_set(pointing=pointing, timestamps=(gridded_timestamp,), stations=(station,), @@ -940,8 +940,8 @@ def evaluate_sky_min_elevation_constraint(scheduling_unit: models.SchedulingUnit # check if constraint is met... if rise_and_set_time['always_below_horizon'] or \ - (rise_and_set_time['rise'] is not None and timestamp < gridder.minus_margin(rise_and_set_time['rise'])) or \ - (rise_and_set_time['set'] is not None and timestamp > gridder.plus_margin(rise_and_set_time['set'])): + (rise_and_set_time['rise'] is not None and gridded_timestamp < gridder.minus_margin(rise_and_set_time['rise'])) or \ + (rise_and_set_time['set'] is not None and gridded_timestamp > gridder.plus_margin(rise_and_set_time['set'])): elevation = compute_elevation(pointing, gridded_timestamp, station) if elevation < min_elevation.rad: # constraint not met. update result, and do early exit.