Telescope Model Public API

ska_telmodel

Interface module for generating CSP configuration.

Handles parsing and validation of inputs and passes them on to the internal configuration functions in config.

ska_telmodel.csp.interface.make_csp_config(csp_interface_version: Union[int, str], sdp_interface_version: Union[int, str], scan_type: str, csp_config_str: Union[str, dict], sdp_receive_addrs_map_str: Union[str, dict]) → str[source]

Generate a CSP scan configuration for a scan using SDP receive addresses.

This should be used right before CSP is configured so that data streams are sent to the right ingest nodes.

Parameters:
  • csp_interface_version – Version of CSP interface (URI)
  • sdp_interface_version – Version of SDP interface (URI)
  • scan_type – Type of scan to configure
  • csp_config_in – General CSP configuration
  • sdp_receive_addrs – Receive addresses map for scan types, generated by SDP
Returns:

A validated JSON string with CSP configuration.

Raise:

ValueError when the input JSON configuration fails validation.

Used for checking CSP configuration strings for conformance

ska_telmodel.csp.schema.get_cbf_config_schema(version: str, strict: bool) → schema.Schema[source]

Central Beam Former configuration schema

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON Schema for the MID.CBF configuration.

ska_telmodel.csp.schema.get_common_config_schema(version: str, strict: bool) → schema.Schema[source]

CSP Subarray common configuration schema.

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON Schema for the CSP subarray common configuration (ADR-18).

ska_telmodel.csp.schema.get_csp_config_schema(version: str, strict: bool) → schema.Schema[source]

Returns a schema to verify a CSP configuration

Parameters:
  • version – Interface version
  • strict – Strict mode - refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!
Returns:

The JSON Schema for the CSP configuration.

Raise:

ValueError exception on mismatch major version or invalid JSON Schema URI

ska_telmodel.csp.schema.get_fsp_config_schema(version: str, strict: bool)[source]

Frequency slice processor configuration schema

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON schema for the MID.CBF FSP configuration.

ska_telmodel.csp.schema.get_pss_beam_config_schema(version: str, strict: bool) → schema.Schema[source]

Pulsar Search Beam specific items

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON Schema for the PSS beam configuration.

ska_telmodel.csp.schema.get_pss_config_schema(version: str, strict: bool) → schema.Schema[source]

Pulsar Search specific items

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON Schema for the PSS configuration.

ska_telmodel.csp.schema.get_pst_config_schema(version: str, strict: bool) → schema.Schema[source]

Pulsar Timing specific items

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON Schema for the PST configuration.

ska_telmodel.csp.schema.get_search_window_config_schema(version: str, strict: bool) → schema.Schema[source]

SearchWindow configuration schema

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON Schema for the MID.CBF SearchWindow configuration.

ska_telmodel.csp.schema.get_subarray_config_schema(version: str, strict: bool) → schema.Schema[source]

CSP Subarray configuration schema

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON Schema for the CSP subarray specific configuraiton.

ska_telmodel.csp.schema.get_vlbi_config_schema(version: str, strict: bool)[source]

VLBI specific items

Parameters:
  • version – Interface Version URI
  • strict – Schema strictness
Returns:

the JSON schema for the MID.CBF VLBI configuration.

ska_telmodel.csp.schema.use_camel_case(version: str) → bool[source]

Checks whether the given CSP schema version uses camel-case attribute names.

param version:Interface Version URI
returns:True or False according to schema version number

Telescope Model Internals

ska_telmodel.schema

ska_telmodel.schema.example_by_uri(version: str, *args) → dict[source]

Generates an example for a particular schema

Parameters:
  • version – Interface URI
  • args – Extra parameters depending on interface (strings)
Returns:

Dictionary

ska_telmodel.schema.schema_by_uri(version: str, strict: int = 1, **kwargs) → schema.Schema[source]

Looks up interface schema based on interface identifier

Parameters:
  • version – Interface URI
  • strict – Strictness level
Returns:

Interface schema

ska_telmodel.schema.validate(version: str, config: dict, strictness: int = 1)[source]

Validate a dictionary against schema

Will automatically determine the schema to check against

Parameters:
  • version – Interface with version
  • config – Dictionary to validate
  • strictness – Strictness level (0: permissive warnings, 1: permissive errors + strict warnings, 2: strict errors). DO NOT USE STRICTNESS 2 IN PRODUCTION!

ska_telmodel.csp.config

ska_telmodel.csp.config.add_receive_addresses(scan_type: str, csp_config: dict, scan_receive_addrs: dict, csp_interface_version: str) → dict[source]

Add SDP receive addresses into CSP configuration

Parameters:
  • scan_trype – Scan type executed
  • csp_config – CSP input configuration
  • sdp_receive_addrs – SDP receive addresses for scan
Returns:

New CSP configuration

ska_telmodel.csp.config.get_fsp_channel_offset(csp_config_in: dict) → int[source]

Determines first channel ID within an FSP

ska_telmodel.csp.config.get_fsp_output_channel_offset(fsp_config: dict, fsp_id: str, fsp_ch_offset: str) → int[source]

Determines the FSP channel offset. Either read from the dictionary or reconstructed.

Parameters:fsp_config – FSP configuration structure

ska_telmodel.channel_map

Tools for working with JSON compressed channel maps.

The SKA is meant to have a large number of channels, which means that any type of per-channel configuration might become very cumbersome to transfer and reason about. To prevent such issues we are using a simple run-length encoding to “compress” the representation. The idea is that if we write:

[ [0,0], [200,1], [400, 3] ]

We essentially mean the dictionary:

{ 0: 0, 1: 0, ..., 199:0, 200:1, ..., 399:1, 400: 3, ...}

Furthermore runs of numbers are supported, by adding an increment:

[ [0,0,1], [200,1] ]

Means:

{ 0: 0, 1: 1, 2:2, ..., 199:100, 200:1, ...}
ska_telmodel.channel_map.channel_map_at(channel_map: List[list], channel: int, make_entry: bool = False) → Any[source]

Query a value from a channel map

Parameters:
  • channel_map – Queried map
  • channel – Channel ID to query
  • make_entry – Return an channel map entry (including increment) instead of just the value
Returns:

Value from map

ska_telmodel.channel_map.shift_channel_map(channel_map: List[list], channel_shift: int) → List[list][source]

Shift a channel map by some channel distance

Parameters:
  • channel_map – Channel map to use
  • channel_shift – Shift to apply
ska_telmodel.channel_map.split_channel_map(channel_map: List[list], first_channel: int, channel_group_steps: int, rebase_groups: int = None, minimum_groups: int = 0) → List[List[list]][source]

Split a channel map using a constant channel step length

Parameters:
  • channel_map – Channel map to split. Each entry is expected to have the start channel in the first field, and mapped data in the remaining entries
  • first_channel – First channel to appear in the map
  • channel_group_steps – Chunks to split the channel map into
  • rebase_groups – Start every group at given channel index (None: left as-is)
  • minimum_groups – Minimum number of groups to return
Returns:

List of channel maps

ska_telmodel.channel_map.split_channel_map_at(channel_map: List[list], channel_groups: List[int], rebase_groups: int = None) → List[List[list]][source]

Split a channel map at certain points

Parameters:
  • channel_map – Channel map to split. Each entry is expected to have the start channel in the first field, and mapped data in the remaining entries
  • channel_groups – Boundaries between channel groups. The n-th returned channel map will cover channels channel_groups[n]..channel_groups[n+1]-1. Needs to have at least two entries.
  • rebase_groups – Start every group at given channel index (None: left as-is)
Returns:

List of channel maps