diff --git a/SAS/TMSS/src/tmss/tmssapp/schemas/UC1-scheduling-unit-observation-strategy.json b/SAS/TMSS/src/tmss/tmssapp/schemas/UC1-scheduling-unit-observation-strategy.json index 183f8933332dd016194b939315b4bc25a9c3d183..9e917e322eea7f4f7495828ef9a4d5581dffc2ef 100644 --- a/SAS/TMSS/src/tmss/tmssapp/schemas/UC1-scheduling-unit-observation-strategy.json +++ b/SAS/TMSS/src/tmss/tmssapp/schemas/UC1-scheduling-unit-observation-strategy.json @@ -62,7 +62,20 @@ }, "antenna_set": "HBA_DUAL_INNER", "filter": "HBA_110_190", - "stations":["CS001"], + "stations": [ + { + "group": "DUTCH", + "max_missing": 4 + }, + { + "group": "INTERNATIONAL", + "max_missing": 2 + }, + { + "group": "INTERNATIONAL_REQUIRED", + "max_missing": 1 + } + ], "tile_beam": { "direction_type": "J2000", "angle1": 0.42, diff --git a/SAS/TMSS/src/tmss/tmssapp/schemas/common_schema_template-stations-1.json b/SAS/TMSS/src/tmss/tmssapp/schemas/common_schema_template-stations-1.json index b2da0323b13d085e1932349a6fadd2a9b82f768d..9d9fc6adf1920e58b46682f7bc32624bdd4a9fa9 100644 --- a/SAS/TMSS/src/tmss/tmssapp/schemas/common_schema_template-stations-1.json +++ b/SAS/TMSS/src/tmss/tmssapp/schemas/common_schema_template-stations-1.json @@ -89,12 +89,11 @@ "station_constraint":{ "type":"object", "default":{}, - "additionalProperties":false, "oneOf": [ { "title":"Custom list", "properties":{ - "stations":{ + "list":{ "title":"Stations", "description": "Custom station selection", "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1#/definitions/station_list", @@ -105,7 +104,7 @@ "default":0 } }, - "required":[ "stations", "max_missing" ] + "required":[ "list", "max_missing" ] }, { "title": "All", "properties":{ @@ -205,7 +204,7 @@ "minItems":1, "default": [ { "group": "ALL", - "stations": [], + "list": [], "max_missing": 0 } ] }, diff --git a/SAS/TMSS/src/tmss/tmssapp/schemas/task_template-target_observation-1.json b/SAS/TMSS/src/tmss/tmssapp/schemas/task_template-target_observation-1.json index f6e92bc010d32d7e20cc879dfe7576fd18dfdb71..27ffc2d55403fa70f926ff1a6613139ec61be5af 100644 --- a/SAS/TMSS/src/tmss/tmssapp/schemas/task_template-target_observation-1.json +++ b/SAS/TMSS/src/tmss/tmssapp/schemas/task_template-target_observation-1.json @@ -8,7 +8,7 @@ "properties": { "stations": { "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1#/definitions/stations", - "default": ["CS001"] + "default": [ {} ] }, "antenna_set": { "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1/#/definitions/antenna_set", diff --git a/SAS/TMSS/src/tmss/tmssapp/subtasks.py b/SAS/TMSS/src/tmss/tmssapp/subtasks.py index 87189cc5cb1307e30073ba8d47309b583719d6f0..1a7c995a452e6d40e0f6f8aa4bd62cb1fc28cd44 100644 --- a/SAS/TMSS/src/tmss/tmssapp/subtasks.py +++ b/SAS/TMSS/src/tmss/tmssapp/subtasks.py @@ -129,16 +129,25 @@ def create_observation_subtask_specifications_from_observation_task_blueprint(ta subtask_spec['stations']["filter"] = task_spec["filter"] if "stations" in task_spec: - if "group" in task_spec["stations"]: - try: - # retrieve stations in group from RADB virtual instrument - station_group_name = task_spec["stations"]["group"] - subtask_spec['stations']['station_list'] = get_stations_in_group(station_group_name) - except Exception as e: - raise SubtaskCreationException("Could not determine stations in group '%s' for task_blueprint id=%s. Error: %s" % ( - station_group_name, task_blueprint.id, e)) - else: - subtask_spec['stations']['station_list'] = task_spec["stations"] + subtask_station_list = [] + # task_spec["stations"] is a list + for station_item in task_spec["stations"]: + if "group" in station_item: + station_group_name = station_item["group"] + try: + # retrieve stations in group from RADB virtual instrument + subtask_station_list.extend(get_stations_in_group(station_group_name)) + except Exception as e: + raise SubtaskCreationException("Could not determine stations in group '%s' for task_blueprint id=%s. Error: %s" % ( + station_group_name, task_blueprint.id, e)) + elif "list" in station_item: + subtask_station_list.extend(station_item["list"]) + else: + logger.info("NO 'group' or 'list' in task spec, so nothing to be added to station list") + subtask_spec['stations']['station_list'] = sorted(list(set(subtask_station_list))) + else: + logger.info("NO stations defined at all") + # TODO: Do something with max_missing if 'calibrator' not in task_blueprint.specifications_template.name.lower(): # copy/convert the analoge/digital_pointings only for non-calibrator observations (the calibrator has its own pointing) @@ -173,6 +182,16 @@ def create_observation_subtask_specifications_from_observation_task_blueprint(ta def get_stations_in_group(station_group_name: str) -> []: '''Get a list of station names in the given station_group. A lookup is performed in the RADB, in the virtual instrument table''' + + # TODO Make names RA and TMSS spec equal: 'NL' or 'DUTCH'? + if station_group_name == "DUTCH": + station_group_name = "NL" + + #International required is by defintion DE601 or DE605, take 601 for now + # TODO check with RA the availability of both stations + if station_group_name == "INTERNATIONAL_REQUIRED": + return ["DE601"] + with RADBRPC.create() as radbrpc: resource_group_memberships = radbrpc.getResourceGroupMemberships()['groups'] station_resource_group = next(rg for rg in resource_group_memberships.values() @@ -184,6 +203,10 @@ def get_stations_in_group(station_group_name: str) -> []: if 'RS408' in station_names: station_names.remove('RS408') + # HACK remove TEST1 from station list otherwise validate will fail + if 'TEST1' in station_names: + station_names.remove('TEST1') + return sorted(list(station_names))