diff --git a/SAS/TMSS/src/tmss/tmssapp/adapters/sip.py b/SAS/TMSS/src/tmss/tmssapp/adapters/sip.py index d1c5ec15123baef2dedd88ff45586ff3535fb38a..49e555448b91d3587c7f39db9a1c7b8021dc5f90 100644 --- a/SAS/TMSS/src/tmss/tmssapp/adapters/sip.py +++ b/SAS/TMSS/src/tmss/tmssapp/adapters/sip.py @@ -54,6 +54,8 @@ def get_siplib_stations_list(subtask): Retrieve a list of siplib Stations objects which is extracted from the station_list and the antennaset :param subtask: :return: + + Conversion logic see here: https://support.astron.nl/confluence/display/TMSS/Dataproduct+Provenance """ siplib_station_list = [] list_stations = subtask.specifications_doc['stations']['station_list'] 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 256c576f84a5bf38f14de663abce45395a5ae325..2029524ff1cc8ba2dacd6214157d9854a9490aee 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 @@ -6,17 +6,11 @@ "version":"1", "type":"object", "definitions":{ - "station_list":{ - "title":"fixed station list", - "default":[ - "CS001" - ], - "type":"array", - "additionalItems":false, - "additionalProperties":false, - "items":{ - "type":"string", - "enum":[ + "station":{ + "type":"string", + "title":"Station", + "description":"", + "enum":[ "CS001", "CS002", "CS003", @@ -71,9 +65,18 @@ "PL612", "IE613", "LV614" - ], - "title":"Station", - "description":"" + ] + }, + "station_list":{ + "title":"fixed station list", + "default":[ + "CS001" + ], + "type":"array", + "additionalItems":false, + "additionalProperties":false, + "items":{ + "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1#/definitions/station" }, "minItems":1, "uniqueItems":true diff --git a/SAS/TMSS/src/tmss/tmssapp/schemas/dataproduct_feedback_template-feedback-1.json b/SAS/TMSS/src/tmss/tmssapp/schemas/dataproduct_feedback_template-feedback-1.json index 4c851e2e22e891d32cc34baf0d764ed0eff97f79..ec18c35a2e37b575f746f06d40c2de992e6c2fd2 100644 --- a/SAS/TMSS/src/tmss/tmssapp/schemas/dataproduct_feedback_template-feedback-1.json +++ b/SAS/TMSS/src/tmss/tmssapp/schemas/dataproduct_feedback_template-feedback-1.json @@ -77,22 +77,8 @@ "type": "object", "properties": { "set": { - "title": "Antenna set", - "type": "string", - "default": "HBA_DUAL", - "enum": [ - "HBA_DUAL", - "HBA_DUAL_INNER", - "HBA_ONE", - "HBA_ONE_INNER", - "HBA_ZERO", - "HBA_ZERO_INNER", - "LBA_INNER", - "LBA_OUTER", - "LBA_SPARSE_EVEN", - "LBA_SPARSE_ODD", - "LBA_ALL" - ] + "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1/#/definitions/antenna_set", + "default": "HBA_DUAL" }, "fields": { "title": "Fields", @@ -103,62 +89,7 @@ "type": "object", "properties": { "station": { - "title": "Station", - "type": "string", - "enum": [ - "CS001", - "CS002", - "CS003", - "CS004", - "CS005", - "CS006", - "CS007", - "CS011", - "CS013", - "CS017", - "CS021", - "CS024", - "CS026", - "CS028", - "CS030", - "CS031", - "CS032", - "CS101", - "CS103", - "CS201", - "CS301", - "CS302", - "CS401", - "CS501", - "RS106", - "RS205", - "RS208", - "RS210", - "RS305", - "RS306", - "RS307", - "RS310", - "RS406", - "RS407", - "RS409", - "RS503", - "RS508", - "RS509", - "DE601", - "DE602", - "DE603", - "DE604", - "DE605", - "FR606", - "SE607", - "UK608", - "DE609", - "PL610", - "PL611", - "PL612", - "IE613", - "LV614" - ] + "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1/#/definitions/station" }, "field": { "title": "Field", @@ -193,42 +124,7 @@ "properties": { "pointing": { "title": "Pointing", - "type": "object", - "required": [ - "direction_type", - "angle1", - "angle2" - ], - "properties": { - "direction_type": { - "title": "Direction type", - "type": "string", - "default": "J2000", - "enum": [ - "J2000", - "SUN", - "MOON", - "MERCURY", - "VENUS", - "MARS", - "JUPITER", - "SATURN", - "URANUS", - "NEPTUNE", - "PLUTO" - ] - }, - "angle1": { - "title": "Angle 1", - "type": "number", - "default": 0.0 - }, - "angle2": { - "title": "Angle 2", - "type": "number", - "default": 0.0 - } - } + "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/pointing/1/#/definitions/pointing" } }, "required": [ "pointing" ] diff --git a/SAS/TMSS/src/tmss/tmssapp/schemas/dataproduct_feedback_template-feedback-1.txt b/SAS/TMSS/src/tmss/tmssapp/schemas/dataproduct_feedback_template-feedback-1.txt deleted file mode 100644 index 4c851e2e22e891d32cc34baf0d764ed0eff97f79..0000000000000000000000000000000000000000 --- a/SAS/TMSS/src/tmss/tmssapp/schemas/dataproduct_feedback_template-feedback-1.txt +++ /dev/null @@ -1,315 +0,0 @@ -{ - "$id":"http://tmss.lofar.org/api/schemas/dataproductfeedbacktemplate/feedback/1#", - "$schema": "http://json-schema.org/draft-06/schema#", - "title": "feedback", - "type": "object", - "properties": { - "percentage_written": { - "title": "Percentage written", - "type": "integer", - "default": 0 - }, - "frequency": { - "title": "Frequency", - "type": "object", - "properties": { - "subbands": { - "title": "Subbands", - "type": "array", - "default": [], - "items": { - "title": "Subband", - "type": "integer", - "minimum": 0, - "maximum": 511 - } - }, - "central_frequencies": { - "title": "Central frequencies", - "type": "array", - "default": [], - "items": { - "title": "frequency", - "type": "number", - "default": 0.0, - "minimum": 0.0 - } - }, - "channel_width": { - "title": "Channel width", - "type": "number", - "default": 3051.8, - "minimum": 0.0 - }, - "channels_per_subband": { - "title": "Channels per subband", - "type": "integer", - "default": 64, - "minimum": 1 - } - }, - "required": [ "subbands", "central_frequencies", "channel_width", "channels_per_subband" ] - }, - "time": { - "title": "Time", - "type": "object", - "properties": { - "start_time": { - "title": "Start time", - "type": "string", - "default": "" - }, - "duration": { - "title": "Duration", - "type": "number", - "default": 0.0 - }, - "sample_width": { - "title": "Sample width", - "type": "number", - "default": 0.0 - } - }, - "required": [ "start_time", "duration", "sample_width" ] - }, - "antennas": { - "title": "Antennas", - "type": "object", - "properties": { - "set": { - "title": "Antenna set", - "type": "string", - "default": "HBA_DUAL", - "enum": [ - "HBA_DUAL", - "HBA_DUAL_INNER", - "HBA_ONE", - "HBA_ONE_INNER", - "HBA_ZERO", - "HBA_ZERO_INNER", - "LBA_INNER", - "LBA_OUTER", - "LBA_SPARSE_EVEN", - "LBA_SPARSE_ODD", - "LBA_ALL" - ] - }, - "fields": { - "title": "Fields", - "type": "array", - "default": [], - "items": { - "title": "Field", - "type": "object", - "properties": { - "station": { - "title": "Station", - "type": "string", - "enum": [ - "CS001", - "CS002", - "CS003", - "CS004", - "CS005", - "CS006", - "CS007", - "CS011", - "CS013", - "CS017", - "CS021", - "CS024", - "CS026", - "CS028", - "CS030", - "CS031", - "CS032", - "CS101", - "CS103", - "CS201", - "CS301", - "CS302", - "CS401", - "CS501", - "RS106", - "RS205", - "RS208", - "RS210", - "RS305", - "RS306", - "RS307", - "RS310", - "RS406", - "RS407", - "RS409", - "RS503", - "RS508", - "RS509", - "DE601", - "DE602", - "DE603", - "DE604", - "DE605", - "FR606", - "SE607", - "UK608", - "DE609", - "PL610", - "PL611", - "PL612", - "IE613", - "LV614" - ] - }, - "field": { - "title": "Field", - "type": "string", - "default": "HBA", - "enum": [ - "LBA", - "HBA", - "HBA0", - "HBA1" - ] - }, - "type": { - "title": "Type", - "type": "string", - "default": "HBA", - "enum": [ - "LBA", - "HBA" - ] - } - }, - "required": [ "station", "field", "type" ] - } - } - }, - "required": [ "fields" ] - }, - "target": { - "title": "Target", - "type": "object", - "properties": { - "pointing": { - "title": "Pointing", - "type": "object", - "required": [ - "direction_type", - "angle1", - "angle2" - ], - "properties": { - "direction_type": { - "title": "Direction type", - "type": "string", - "default": "J2000", - "enum": [ - "J2000", - "SUN", - "MOON", - "MERCURY", - "VENUS", - "MARS", - "JUPITER", - "SATURN", - "URANUS", - "NEPTUNE", - "PLUTO" - ] - }, - "angle1": { - "title": "Angle 1", - "type": "number", - "default": 0.0 - }, - "angle2": { - "title": "Angle 2", - "type": "number", - "default": 0.0 - } - } - } - }, - "required": [ "pointing" ] - }, - "samples": { - "title": "Samples", - "type": "object", - "properties": { - "polarisations": { - "title": "Polarisations", - "type": "array", - "default": [ - "XX", - "XY", - "YX", - "YY" - ], - "items": { - "title": "Polarisation", - "type": "string", - "default": "I", - "enum": [ - "XX", - "XY", - "YX", - "YY", - "I", - "Q", - "U", - "V", - "Xr", - "Xi", - "Yr", - "Yi" - ] - } - }, - "type": { - "title": "Type", - "type": "string", - "default": "float", - "enum": [ - "float", - "integer" - ] - }, - "complex": { - "title": "Complex values", - "type": "boolean", - "default": true - }, - "bits": { - "title": "Bits per sample", - "type": "integer", - "default": 32, - "enum": [ - 4, - 8, - 16, - 32, - 64 - ] - }, - "writer": { - "title": "Writer", - "type": "string", - "default": "standard", - "enum": [ - "lofarstman", - "standard", - "dysco" - ] - }, - "writer_version": { - "title": "Writer version", - "type": "string", - "default": "UNKNOWN" - } - }, - "required": [ "polarisations", "type", "complex", "bits", "writer" ] - } - }, - "required": [ "percentage_written", "frequency", "time", "antennas", "target", "samples" ] -} diff --git a/SAS/TMSS/test/t_adapter.py b/SAS/TMSS/test/t_adapter.py index c27d8cf419022721a534c6ca737c6126e873d432..379f3a37a4b53165882be3579af3eef08a8b40fe 100755 --- a/SAS/TMSS/test/t_adapter.py +++ b/SAS/TMSS/test/t_adapter.py @@ -44,6 +44,7 @@ from lofar.sas.tmss.tmss.tmssapp.adapters.parset import convert_to_parset from lofar.common.json_utils import get_default_json_object_for_schema from lofar.sas.tmss.tmss.tmssapp.adapters.sip import generate_sip_for_dataproduct from lofar.sas.tmss.tmss.tmssapp.adapters.feedback import generate_dataproduct_feedback_from_subtask_feedback_and_set_finished +from lofar.lta.sip import constants class ParsetAdapterTest(unittest.TestCase): def test_01(self): @@ -63,9 +64,10 @@ class SIPdapterTest(unittest.TestCase): def test_simple_sip_generate_from_dataproduct(self): subtask_template = models.SubtaskTemplate.objects.get(name='observation control') specifications_doc = get_default_json_object_for_schema(subtask_template.schema) + specifications_doc['stations']['filter'] = "HBA_210_250" feedback_template = models.DataproductFeedbackTemplate.objects.get(name='feedback') # feedback_doc = get_default_json_object_for_schema(feedback_template.schema) # todo <- fix the default generator, for some reason it does not produce valid json here... - feedback_doc = {'percentage_written': 100, 'frequency': {'subbands': [156], 'central_frequencies': [33593750.0], 'channel_width': 6103.515625, 'channels_per_subband': 32}, 'time': {'start_time': '2013-02-16T17:00:00.000', 'duration': 5.02732992172, 'sample_width': 2.00278016}, 'antennas': {'set': 'HBA_DUAL', 'fields': [{'type': 'HBA', 'field': 'HBA0', 'station': 'CS001'}, {'type': 'HBA', 'field': 'HBA1', 'station': 'CS001'}]}, 'target': {'pointing': {'angle1': 0, 'angle2': 0, 'angle3': 0, 'direction_type': 'J2000'}}, 'samples': {'polarisations': ['XX', 'XY', 'YX', 'YY'], 'type': 'float', 'bits': 32, 'writer': 'standard', 'writer_version': '2.2.0', 'complex': True}, '$schema': 'http://127.0.0.1:8001/api/schemas/dataproductfeedbacktemplate/feedback/1#'} + feedback_doc = {'percentage_written': 100, 'frequency': {'subbands': [156], 'central_frequencies': [33593750.0], 'channel_width': 6103.515625, 'channels_per_subband': 32}, 'time': {'start_time': '2013-02-16T17:00:00', 'duration': 5.02732992172, 'sample_width': 2.00278016}, 'antennas': {'set': 'HBA_DUAL', 'fields': [{'type': 'HBA', 'field': 'HBA0', 'station': 'CS001'}, {'type': 'HBA', 'field': 'HBA1', 'station': 'CS001'}]}, 'target': {'pointing': {'angle1': 0, 'angle2': 0, 'angle3': 0, 'direction_type': 'J2000'}}, 'samples': {'polarisations': ['XX', 'XY', 'YX', 'YY'], 'type': 'float', 'bits': 32, 'writer': 'standard', 'writer_version': '2.2.0', 'complex': True}, '$schema': 'http://127.0.0.1:8001/api/schemas/dataproductfeedbacktemplate/feedback/1#'} for dp in specifications_doc['stations']['digital_pointings']: dp['subbands'] = list(range(8)) subtask_data = Subtask_test_data(subtask_template=subtask_template, specifications_doc=specifications_doc) @@ -73,10 +75,13 @@ class SIPdapterTest(unittest.TestCase): subtask_output = models.SubtaskOutput.objects.create(**SubtaskOutput_test_data(subtask=subtask)) dataproduct:models.Dataproduct = models.Dataproduct.objects.create(**Dataproduct_test_data(feedback_doc=feedback_doc, producer=subtask_output)) + # make sure we can create a valid SIP sip = generate_sip_for_dataproduct(dataproduct) - # TODO: Although validation succeeded at this step, it would be interesting to check some values of the produced xml... - logger.info(sip.get_prettyxml()) + # double-check that SIP contains values from feedback and specifications docs + self.assertIn(str(feedback_doc['frequency']['channel_width']), sip.get_prettyxml()) + self.assertIn(str(feedback_doc['time']['start_time']), sip.get_prettyxml()) + self.assertIn(constants.FILTERSELECTIONTYPE_210_250_MHZ, sip.get_prettyxml()) # specifications_doc: "HBA_210_250" class FeedbackAdapterTest(unittest.TestCase):