From 802cb646b792afc75254b4f890f63a55c06492aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rn=20K=C3=BCnsem=C3=B6ller?=
 <jkuensem@physik.uni-bielefeld.de>
Date: Wed, 28 Apr 2021 22:48:22 +0200
Subject: [PATCH] TMSS-195: fix naming

---
 .../constraints/template_constraints_v1.py    | 16 +++++++--------
 .../scheduling/test/t_dynamic_scheduling.py   | 20 +++++++++----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py b/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py
index ce7eabfebb7..1acff898750 100644
--- a/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py
+++ b/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py
@@ -295,7 +295,7 @@ def can_run_anywhere_within_timewindow_with_sky_constraints(scheduling_unit: mod
                                 else:
                                     logger.info('min_target_elevation=%s constraint is not met at timestamp=%s' % (min_elevation.rad, timestamps[i]))
                                 return False
-                if 'lst_offset' in constraints['sky'] and task['specifications_template'] == 'target observation':
+                if 'transit_offset' in constraints['sky'] and task['specifications_template'] == 'target observation':
                     # Check constraint on tile beam for HBA only:
                     if task['specifications_doc']['antenna_set'].startswith('HBA'):
                         # since the constraint only applies to the middle of the obs, consider its duration
@@ -310,8 +310,8 @@ def can_run_anywhere_within_timewindow_with_sky_constraints(scheduling_unit: mod
                         for station, times in transit_times.items():
                             for i in range(len(timestamps)):
                                 offset = (timestamps[i] - times[i]).total_seconds()
-                                offset_from = constraints['sky']['lst_offset']['from']
-                                offset_to = constraints['sky']['lst_offset']['to']
+                                offset_from = constraints['sky']['transit_offset']['from']
+                                offset_to = constraints['sky']['transit_offset']['to']
                                 # because the constraint allows specifying a window that reaches past 12h from transit,
                                 # the transit that it refers to may not be the nearest transit to the observation time.
                                 # Hence we also check if the constraint is met with 24h shift (which is approximately
@@ -319,11 +319,11 @@ def can_run_anywhere_within_timewindow_with_sky_constraints(scheduling_unit: mod
                                 if not ((offset_from < offset < offset_to) or
                                         (offset_from+86400 < offset < offset_to+86400) or
                                         (offset_from-86400 < offset < offset_to-86400)):
-                                    logger.info('lst_offset constraint from=%s to=%s is not met by offset=%s at timestamp=%s' % (offset_from, offset_to, offset, timestamps[i]))
+                                    logger.info('transit_offset constraint from=%s to=%s is not met by offset=%s at timestamp=%s' % (offset_from, offset_to, offset, timestamps[i]))
                                     return False
 
             if 'SAPs' in task['specifications_doc']:
-                if 'lst_offset' in constraints['sky'] and task['specifications_template'] == 'target observation':
+                if 'transit_offset' in constraints['sky'] and task['specifications_template'] == 'target observation':
                     # Check constraint on SAPs for LBA only:
                     if task['specifications_doc']['antenna_set'].startswith('LBA'):
                         # since the constraint only applies to the middle of the obs, consider its duration
@@ -357,8 +357,8 @@ def can_run_anywhere_within_timewindow_with_sky_constraints(scheduling_unit: mod
                         for station, times in transit_times.items():
                             for i in range(len(timestamps)):
                                 offset = (timestamps[i] - times[i]).total_seconds()
-                                offset_from = constraints['sky']['lst_offset']['from']
-                                offset_to = constraints['sky']['lst_offset']['to']
+                                offset_from = constraints['sky']['transit_offset']['from']
+                                offset_to = constraints['sky']['transit_offset']['to']
                                 # because the constraint allows specifying a window that reaches past 12h from transit,
                                 # the transit that it refers to may not be the nearest transit to the observation time.
                                 # Hence we also check if the constraint is met with 24h shift (which is approximately
@@ -366,7 +366,7 @@ def can_run_anywhere_within_timewindow_with_sky_constraints(scheduling_unit: mod
                                 if not ((offset_from < offset < offset_to) or
                                         (offset_from+86400 < offset < offset_to+86400) or
                                         (offset_from-86400 < offset < offset_to-86400)):
-                                    logger.info('lst_offset constraint from=%s to=%s is not met by offset=%s at timestamp=%s' % (offset_from, offset_to, offset, timestamps[i]))
+                                    logger.info('transit_offset constraint from=%s to=%s is not met by offset=%s at timestamp=%s' % (offset_from, offset_to, offset, timestamps[i]))
                                     return False
 
 
diff --git a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
index 8963ff58db5..ea829deadc9 100755
--- a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
+++ b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
@@ -854,20 +854,20 @@ class TestSkyConstraints(unittest.TestCase):
         returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration))
         self.assertFalse(returned_value)
 
-    # lst_offset
+    # transit_offset
 
-    def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_lst_offset_constraint_returns_true_when_met(self):
+    def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_transit_offset_constraint_returns_true_when_met(self):
         # case 1: transits at 14h, obs middle is at 13h, so we have an offset of -3600 seconds
 
         # big window
-        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'lst_offset': {'from': -43200, 'to': 43200}}  # todo: use blueprint contraints after TMSS-697 was merged
+        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'transit_offset': {'from': -43200, 'to': 43200}}  # todo: use blueprint contraints after TMSS-697 was merged
         self.scheduling_unit_blueprint.save()
         timestamp = datetime(2020, 1, 1, 12, 0, 0)
         returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration))
         self.assertTrue(returned_value)
 
         # narrow window
-        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'lst_offset': {'from': -3601, 'to': -3599}}  # todo: use blueprint contraints after TMSS-697 was merged
+        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'transit_offset': {'from': -3601, 'to': -3599}}  # todo: use blueprint contraints after TMSS-697 was merged
         self.scheduling_unit_blueprint.save()
         timestamp = datetime(2020, 1, 1, 12, 0, 0)
         returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration))
@@ -877,37 +877,37 @@ class TestSkyConstraints(unittest.TestCase):
 
         # window spans past 12h, so reference transit is not nearest transit to obs time
         self.target_transit_mock.return_value = self.target_transit_data_previous
-        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'lst_offset': {'from': -43300, 'to': -43100}}  # todo: use blueprint contraints after TMSS-697 was merged
+        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'transit_offset': {'from': -43300, 'to': -43100}}  # todo: use blueprint contraints after TMSS-697 was merged
         self.scheduling_unit_blueprint.save()
         timestamp = datetime(2020, 1, 1, 1, 0, 0)
         returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration))
         self.assertTrue(returned_value)
         self.target_transit_mock.return_value = self.target_transit_data
 
-    def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_lst_offset_constraint_returns_false_when_not_met(self):
+    def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_transit_offset_constraint_returns_false_when_not_met(self):
         # transits at 14h, obs middle is at 13h, so we have an offset of -3600 seconds
 
         # window after
-        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'lst_offset': {'from': -3599, 'to': 43200}}  # todo: use blueprint contraints after TMSS-697 was merged
+        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'transit_offset': {'from': -3599, 'to': 43200}}  # todo: use blueprint contraints after TMSS-697 was merged
         self.scheduling_unit_blueprint.save()
         timestamp = datetime(2020, 1, 1, 12, 0, 0)
         returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration))
         self.assertFalse(returned_value)
 
         # window before
-        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'lst_offset': {'from': -43200, 'to': -3601}}  # todo: use blueprint contraints after TMSS-697 was merged
+        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'transit_offset': {'from': -43200, 'to': -3601}}  # todo: use blueprint contraints after TMSS-697 was merged
         self.scheduling_unit_blueprint.save()
         timestamp = datetime(2020, 1, 1, 12, 0, 0)
         returned_value = tc1.can_run_anywhere_within_timewindow_with_sky_constraints(self.scheduling_unit_blueprint, timestamp, timestamp + timedelta(seconds=self.obs_duration))
         self.assertFalse(returned_value)
 
 
-    def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_lst_offset_constraint_averages_SAPs_for_LBA(self):
+    def test_can_run_anywhere_within_timewindow_with_sky_constraints_with_transit_offset_constraint_averages_SAPs_for_LBA(self):
         # sap1 transits at 14h, sap2 transits at 16h, so average transit is at 15h
         # obs middle is 13h, so we have an offset of -7200 seconds
 
         self.target_transit_mock.side_effect = self.target_transit_data_saps
-        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'lst_offset': {'from': -7201, 'to': -7199}}  # todo: use blueprint contraints after TMSS-697 was merged
+        self.scheduling_unit_blueprint.draft.scheduling_constraints_doc['sky'] = {'transit_offset': {'from': -7201, 'to': -7199}}  # todo: use blueprint contraints after TMSS-697 was merged
         self.scheduling_unit_blueprint.requirements_doc['tasks']['Observation']['specifications_doc']['antenna_set'] = 'LBA_INNER'
         self.scheduling_unit_blueprint.requirements_doc['tasks']['Observation']['specifications_doc']['SAPs'] = \
             [{'name': 'CygA', 'target': 'CygA', 'subbands': [0, 1], 'digital_pointing': {'angle1': 5.233660650313663, 'angle2': 0.7109404782526458, 'direction_type': 'J2000'}},
-- 
GitLab