Skip to content
Snippets Groups Projects
Commit 6608dfd0 authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

TMSS-300: process review comments

parent bee806b6
No related branches found
No related tags found
1 merge request!233Resolve TMSS-300
...@@ -54,6 +54,8 @@ def get_siplib_stations_list(subtask): ...@@ -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 Retrieve a list of siplib Stations objects which is extracted from the station_list and the antennaset
:param subtask: :param subtask:
:return: :return:
Conversion logic see here: https://support.astron.nl/confluence/display/TMSS/Dataproduct+Provenance
""" """
siplib_station_list = [] siplib_station_list = []
list_stations = subtask.specifications_doc['stations']['station_list'] list_stations = subtask.specifications_doc['stations']['station_list']
......
...@@ -6,17 +6,11 @@ ...@@ -6,17 +6,11 @@
"version":"1", "version":"1",
"type":"object", "type":"object",
"definitions":{ "definitions":{
"station_list":{ "station":{
"title":"fixed station list", "type":"string",
"default":[ "title":"Station",
"CS001" "description":"",
], "enum":[
"type":"array",
"additionalItems":false,
"additionalProperties":false,
"items":{
"type":"string",
"enum":[
"CS001", "CS001",
"CS002", "CS002",
"CS003", "CS003",
...@@ -71,9 +65,18 @@ ...@@ -71,9 +65,18 @@
"PL612", "PL612",
"IE613", "IE613",
"LV614" "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, "minItems":1,
"uniqueItems":true "uniqueItems":true
......
...@@ -77,22 +77,8 @@ ...@@ -77,22 +77,8 @@
"type": "object", "type": "object",
"properties": { "properties": {
"set": { "set": {
"title": "Antenna set", "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1/#/definitions/antenna_set",
"type": "string", "default": "HBA_DUAL"
"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": { "fields": {
"title": "Fields", "title": "Fields",
...@@ -103,62 +89,7 @@ ...@@ -103,62 +89,7 @@
"type": "object", "type": "object",
"properties": { "properties": {
"station": { "station": {
"title": "Station", "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/stations/1/#/definitions/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": { "field": {
"title": "Field", "title": "Field",
...@@ -193,42 +124,7 @@ ...@@ -193,42 +124,7 @@
"properties": { "properties": {
"pointing": { "pointing": {
"title": "Pointing", "title": "Pointing",
"type": "object", "$ref": "http://tmss.lofar.org/api/schemas/commonschematemplate/pointing/1/#/definitions/pointing"
"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" ] "required": [ "pointing" ]
......
{
"$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" ]
}
...@@ -44,6 +44,7 @@ from lofar.sas.tmss.tmss.tmssapp.adapters.parset import convert_to_parset ...@@ -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.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.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.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): class ParsetAdapterTest(unittest.TestCase):
def test_01(self): def test_01(self):
...@@ -63,9 +64,10 @@ class SIPdapterTest(unittest.TestCase): ...@@ -63,9 +64,10 @@ class SIPdapterTest(unittest.TestCase):
def test_simple_sip_generate_from_dataproduct(self): def test_simple_sip_generate_from_dataproduct(self):
subtask_template = models.SubtaskTemplate.objects.get(name='observation control') subtask_template = models.SubtaskTemplate.objects.get(name='observation control')
specifications_doc = get_default_json_object_for_schema(subtask_template.schema) 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_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 = 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']: for dp in specifications_doc['stations']['digital_pointings']:
dp['subbands'] = list(range(8)) dp['subbands'] = list(range(8))
subtask_data = Subtask_test_data(subtask_template=subtask_template, specifications_doc=specifications_doc) subtask_data = Subtask_test_data(subtask_template=subtask_template, specifications_doc=specifications_doc)
...@@ -73,10 +75,13 @@ class SIPdapterTest(unittest.TestCase): ...@@ -73,10 +75,13 @@ class SIPdapterTest(unittest.TestCase):
subtask_output = models.SubtaskOutput.objects.create(**SubtaskOutput_test_data(subtask=subtask)) 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)) 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) 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): class FeedbackAdapterTest(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment