# This module defines the LOW CSP schema
# for the OSO-TMC interface
from inspect import cleandoc
from .._common import TMSchema, split_interface_version
[docs]
def update_csp_conf_schema_for_oso_tmc(
# lowcbf: TMSchema,
main_schema: TMSchema,
version: str,
tmc_schema_uri: str = "",
) -> TMSchema:
"""Retrieve Low CBF configure resources schema used by OSO-TMC interface.
This method is invoked by Low TMC to update the configuration schema for
the OSO-TMC interface.
:param lowcbf_schema: Low CBF schema
:param version: Interface Version URI
:param tmc_schema_uri: tmc URI version. Used to differentiate
the OSO-TMC-CSP schema according
to the TMC interface version
:return: TMSchema
"""
cbf_version = split_interface_version(version)
tmc_version = split_interface_version(tmc_schema_uri)
# CSP schema
if tmc_version > (3, 0):
if "subarray" in main_schema:
main_schema.__delitem__("subarray")
if "subarray_id" in main_schema["common"]:
# COMMON
main_schema["common"].__delitem__("subarray_id")
# LOW CBF schema
lowcbf = main_schema["lowcbf"]
if cbf_version > (0, 1):
for stn in lowcbf["stations"]["stn_beams"]:
stn.__delitem__("delay_poly")
if "timing_beams" in lowcbf:
for beam in lowcbf["timing_beams"]["beams"]:
if tmc_version < (4, 1):
beam.__delitem__("field")
if tmc_version >= (4, 0):
beam.__delitem__("jones")
if cbf_version > (0, 1):
beam.__delitem__("delay_poly")
cbf_version_0_1 = split_interface_version(version) == (0, 1)
visibility = "visibilities" if cbf_version_0_1 else "vis"
if visibility in lowcbf:
for stn in lowcbf[visibility]["stn_beams"]:
if tmc_version != (3, 1):
stn.__delitem__("host")
stn.__delitem__("port")
stn.__delitem__("mac")
if tmc_version == (5, 0):
for pst_beam_data in main_schema["pst"]["beams"]:
# Remove the mandatory-ness for OSO-TMC of delay_centre by
# deleting the key
del pst_beam_data["scan"]["delay_centre"]
del pst_beam_data["scan"]["timing_beam_id"]
# Add the optional-ness by adding 'delay_centre' as optional field
pst_beam_data["scan"].add_opt_field(
"delay_centre",
[float],
check_strict=lambda x: len(x) == 3,
description=cleandoc(
"""
The telescope delay centre in International Terrestrial
Reference Frame (ITRF) coordinates.
**Units:** metres
**Keyword:** DELAY_CENTRE
"""
),
)
return lowcbf