diff --git a/QA/QA_Service/lib/qa_service.py b/QA/QA_Service/lib/qa_service.py index 18bd13f9c1f44378b90bdd5e6f99919627123012..992ddb000178fcf1fff3cb93cedc9b7d5a91ac25 100644 --- a/QA/QA_Service/lib/qa_service.py +++ b/QA/QA_Service/lib/qa_service.py @@ -69,6 +69,10 @@ class QAFilteringOTDBBusListener(OTDBBusListener): class QAFilteringTMSSSubTaskBusListener(TMSSBusListener): class QAFilteringTMSSSubTaskEventMessageHandler(UsingToBusMixin, TMSSEventMessageHandler): + def __init__(self): + UsingToBusMixin.__init__(self) + TMSSEventMessageHandler.__init__(self) + def _send_qa_command_message(self, subtask_id: int, command_subject: str): with TMSSsession.create_from_dbcreds_for_ldap() as tmsssession: tmsssession.set_subtask_status(subtask_id, 'queueing') diff --git a/QA/QA_Service/test/t_qa_service.py b/QA/QA_Service/test/t_qa_service.py index fe5bfc908acd25b0225f6a6747277302564efa44..8daf86ce36f8c27fb947bac2a843051e2204e205 100755 --- a/QA/QA_Service/test/t_qa_service.py +++ b/QA/QA_Service/test/t_qa_service.py @@ -96,7 +96,8 @@ class TestQAService(unittest.TestCase): cls.tmp_exchange = TemporaryExchange("%s_%s" % (cls.__name__, cls.TEST_UUID)) cls.tmp_exchange.open() - cls.tmss_test_env = TMSSTestEnvironment(exchange=cls.tmp_exchange.address) + cls.tmss_test_env = TMSSTestEnvironment(exchange=cls.tmp_exchange.address, + start_postgres_listener=True, start_ra_test_environment=True) cls.tmss_test_env.start() cls.tmss_test_env.populate_schemas() diff --git a/SAS/TMSS/src/tmss/tmssapp/conversions.py b/SAS/TMSS/src/tmss/tmssapp/conversions.py index 7f0e35e6871623ee6922fda1d47f82a532278bd6..e3ece4884eddda24375f694414c9d3a59ccc9159 100644 --- a/SAS/TMSS/src/tmss/tmssapp/conversions.py +++ b/SAS/TMSS/src/tmss/tmssapp/conversions.py @@ -7,6 +7,9 @@ from astroplan.observer import Observer import astropy.time from functools import lru_cache +import logging +logger = logging.getLogger(__name__) + def create_astroplan_observer_for_station(station: str) -> Observer: ''' returns an astroplan observer for object for a given station, located in the LBA center of the given station @@ -49,6 +52,8 @@ def timestamps_and_stations_to_sun_rise_and_set(timestamps: tuple, stations: tup for timestamp in timestamps: observer = create_astroplan_observer_for_station(station) sunrise_start = observer.sun_rise_time(time=Time(timestamp), which='previous', n_grid_points=SUN_SET_RISE_PRECISION) + if sunrise_start.to_datetime().date() < timestamp.date(): + sunrise_start = observer.sun_rise_time(time=Time(timestamp), horizon=-angle_to_horizon, which='nearest', n_grid_points=SUN_SET_RISE_PRECISION) if sunrise_start.to_datetime().date() < timestamp.date(): sunrise_start = observer.sun_rise_time(time=Time(timestamp), horizon=-angle_to_horizon, which='next', n_grid_points=SUN_SET_RISE_PRECISION) sunrise_end = observer.sun_rise_time(time=Time(timestamp), horizon=angle_to_horizon, which='next', n_grid_points=SUN_SET_RISE_PRECISION) diff --git a/SAS/TMSS/src/tmss/tmssapp/views.py b/SAS/TMSS/src/tmss/tmssapp/views.py index dac89720f23caf026b969013345e7c7612dc77ac..98a6b67f9b8fe75534b1d427276cde1f6b1fffed 100644 --- a/SAS/TMSS/src/tmss/tmssapp/views.py +++ b/SAS/TMSS/src/tmss/tmssapp/views.py @@ -15,8 +15,6 @@ from django.apps import apps from rest_framework.decorators import api_view from datetime import datetime import dateutil.parser -from astropy.coordinates import SkyCoord -from astropy import units as u from lofar.sas.tmss.tmss.tmssapp.conversions import local_sidereal_time_for_utc_and_station, local_sidereal_time_for_utc_and_longitude, timestamps_and_stations_to_sun_rise_and_set, coordinates_and_timestamps_to_separation_from_bodies # Note: Decorate with @api_view to get this picked up by Swagger @@ -163,7 +161,7 @@ def get_sun_rise_and_set(request): timestamps = (datetime.utcnow(),) else: timestamps = timestamps.split(',') - timestamps = tuple([dateutil.parser.parse(timestamp) for timestamp in timestamps]) # isot to datetime + timestamps = tuple([dateutil.parser.parse(timestamp, ignoretz=True) for timestamp in timestamps]) # isot to datetime if stations is None: stations = ("CS002",) else: @@ -207,7 +205,7 @@ def get_angular_separation_from_bodies(request): timestamps = (datetime.utcnow(),) else: timestamps = timestamps.split(',') - timestamps = tuple([dateutil.parser.parse(timestamp) for timestamp in timestamps]) # isot to datetime + timestamps = tuple([dateutil.parser.parse(timestamp, ignoretz=True) for timestamp in timestamps]) # isot to datetime # calculate sep_dict = coordinates_and_timestamps_to_separation_from_bodies(angle1=angle1, angle2=angle2, direction_type=direction_type, bodies=bodies, timestamps=timestamps)