diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index 2b2f973245ff8ec50e66dd0cc730fe75c4efdc7a..db045de8f48b8357fac6dc34e5814e681b90a66a 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -1052,6 +1052,19 @@ class SchedulingUnitCommonPropertiesMixin: '''get all observation tasks in this scheduling unit''' return self.tasks.filter(specifications_template__type__value=TaskType.Choices.OBSERVATION.value).all() + @cached_property + def target_pointings(self) -> ['Pointing']: + '''get all pointings of all target observations''' + from lofar.sas.tmss.services.scheduling.constraints import get_target_sap_pointings + target_observations = [t for t in self.observation_tasks.all() if t.is_target_observation] + target_pointings = sum([get_target_sap_pointings(t) for t in target_observations], []) + return target_pointings + + @cached_property + def target_pointings_astropy(self) -> str: + '''get all pointings of all target observations in astropy notation''' + return ', '.join(p.as_SkyCoord().to_string('hmsdms') if p.direction_type=='J2000' else p.target for p in self.target_pointings if p is not None) + @cached_property def specified_duration(self) -> datetime.timedelta: '''return the specified overall duration of all tasks of this scheduling unit