Internals

ska_telmodel.schema

ska_telmodel.schema._validate_schema_using_document_url(obj: dict, version: str) None[source]

Validate a configuration object efficiently using cached validators.

Implements an efficient caching mechanism for external schema documents.

  • Automatically caches schemas fetched from external URLs.

  • Used LRU (Least Recently Used) cache strategy.

  • Added Configurable cache size to manage memory usage.

Parameters:
  • obj – Object to validate

  • version – Schema version string

Returns:

None

Raises:

ValueError – On schema validation failure.

ska_telmodel._common

ska_telmodel._common.MID_MKT = Regex('^MKT0([0-5][0-9]|6[0-3])$')

MID Meerkat, 000-063.

ska_telmodel._common.MID_SKA = Regex('^SKA((?!000)0[0-9][0-9]|1[0-2][0-9]|13[0-3])$')

MID SKA, 001-133.

class ska_telmodel._common.TMSchema(schema: Any | None = None, error=None, ignore_extra_keys: bool = False, name: str | None = None, description: str | None = None, as_reference: bool = False, version: str | None = None, strict: bool = False)[source]

Wrapper on top of schema.Schema for incremental schema build-up.

find_field_recursive(name: str) TMSchema | None[source]

Recursively finds a field of the given name in the schema

If the key exists multiple times, an arbitrary item will get returned. Note that to be returned by this function, the field must be in a TMSchema - if the schema is specified as a dictionary, it won’t be found.

Parameters:

name – Name of the field to look for

Returns:

A schema containing the given key

is_field_optional(name: str) bool | None[source]

Checks whether the field with the given name is optional.

Returns None if the field does not exist

Parameters:

name – Name of the field

Returns:

bool

stringify_keys_recursive() TMSchema[source]

Returns a schema where all keys are strings.

For schema it is valid to have a type as key in the schema (e.g. str), which stands for an arbitrary key. However, this will not work when generating documentation, so it needs to be replaced by a string in those cases.

Returns:

Schema with keys renamed as appropriate

ska_telmodel._common.get_unique_id_schema(strict: bool, type_re: str = '[a-z0-9]+') Schema[source]

Return schema for unique identifier.

Parameters:

type_re – Restricts ID type(s) to accept.

ska_telmodel._common.interface_uri(prefix: str, *versions: int) str[source]

Make an URI from the given prefix and versions

Parameters:
  • prefix – Schema URI prefix. Must end in ‘/’

  • versions – Components of the version

ska_telmodel._common.mk_if(cond: bool) Callable[[Any], Any][source]

Generate schema combinator to conditionally activate a part.

ska_telmodel._common.split_interface_version(version: str) Tuple[int, int][source]

Extracts version number from interface URI

Parameters:

version – Version string

Returns:

(major version, minor version) tuple

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: 199, 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 = 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 = 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

ska_telmodel.data

class ska_telmodel.data.backend.CARBackend(uri: str, *args, **kwargs)[source]

Represents data in (a mirror of) the SKA central artefact repository. Permissible URI formats:

car:[project name]?[branch]#[directory]
car://[gitlab server]/[project name]?[branch]#[directory]

So for instance:

car:ska-telmodel?master
car://gitlab.com/ska-telescope/ska-telmodel?master#tmdata

The source of truth might still be Gitlab, yet this backend will only work with artefacts that have been uploaded to the CAR. The short form URI will be expanded into the long form automatically.

classmethod backend_name() str[source]

Returns the name of the backend.

Will be used for the scheme in URIs to identify the backend type of a telescope model data source.

get_uri(pinned: bool) str[source]

Returns URI for this telescope model data backend

Parameters:

pinned – Attempt to return an URI that will continue to refer to this specific version of telescope model data

Returns:

URI identifying data source

class ska_telmodel.data.backend.FilesystemBackend(uri: str, update: bool = False)[source]

Retrieves data from a locally accessible file system. URI format:

file://[absolute path]

Note that changes to the file system are outside of our control. Consistency must be ensured externally.

classmethod backend_name() str[source]

Returns the name of the backend.

Will be used for the scheme in URIs to identify the backend type of a telescope model data source.

copy(key: str, dest: str)[source]

Write key contents to a file.

Raises KeyError if the key does not exist

Parameters:
  • key – Key to query

  • dest – Path of destination file

exists(key: str) bool[source]

Check whether a given key exists.

Parameters:

key – Key to query

Returns:

True if key exists

get(key: str) bytes[source]

Get the data stored with the given key

Parameters:

key – Key to query

Returns:

Bytes stored at key

get_uri(pinned: bool) str[source]

Returns URI for this telescope model data backend

Parameters:

pinned – Attempt to return an URI that will continue to refer to this specific version of telescope model data

Returns:

URI identifying data source

list_keys(key_prefix: str = '') Iterable[str][source]

List children keys

Yields all keys with prefix “{key_prefix}/” in ascending order

Parameters:

key_prefix – Path to query

meta(key: str) dict[str, Any][source]

Retrieve meta data regarding the given key.

Parameters:

key – Key to query

Returns:

Dictionary with the size, and is_large values

open(key: str, binary: bool = True) IO[bytes][source]

Access data at given key as a file-like object

Raises KeyError if the key does not exist

Parameters:

key – Key to query

class ska_telmodel.data.backend.GitlabBackend(uri: str, update: bool = False, gl: gitlab.Gitlab = None, try_nexus: bool = True, nexus_url: str = None, env=None)[source]

Represents data in a GitLab repository. URI format:

gitlab://[gitlab server]/[project name]?[branch]#[directory]

So for instance:

gitlab://gitlab.com/ska-telescope/ska-telmodel?master#tmdata

Would refer to data contained in the ska-telmodel repository itself.

Repositories accessed in this way should make sure to activate the tmdata standard continuous integration stages (see https://gitlab.com/ska-telescope/templates-repository ) to ensure that telescope model data is cached in the SKAO central artefact repository. Once that has been done, this library will never actually query GitLab directly.

Furthermore, this backend will cache all loaded data locally, including resolved Gitlab references (like master in the example above). This especially means that once instantiated, the version of data will be “pinned” even between different instances (and processes). Use the update parameter to ska_telmodel.data.TMData or GitlabBackend respectively to refresh the local cache.

classmethod backend_name() str[source]

Returns the name of the backend.

Will be used for the scheme in URIs to identify the backend type of a telescope model data source.

copy(key: str, dest: str)[source]

Write key contents to a file.

Raises KeyError if the key does not exist

Parameters:
  • key – Key to query

  • dest – Path of destination file

exists(key: str) bytes[source]

Check whether a given key exists.

Parameters:

key – Key to query

Returns:

True if key exists

get(key: str) bytes[source]

Get the data stored with the given key

Parameters:

key – Key to query

Returns:

Data stored at key, or None if it doesn’t exist

get_uri(pinned: bool) str[source]

Returns URI for this telescope model data backend

Parameters:

pinned – Attempt to return an URI that will continue to refer to this specific version of telescope model data

Returns:

URI identifying data source

list_keys(key_prefix: str = '') Iterable[str][source]

List children keys

Yields all keys with prefix “{key_prefix}/” in ascending order. Exception is if the path is empty, in which case all available keys are listed.

Parameters:

key_prefix – Path to query

meta(key: str) dict[str, Any][source]

Retrieve meta data regarding the given key.

Parameters:

key – Key to query

Returns:

Dictionary with the size, and is_large values

open(key: str) IO[bytes][source]

Access data at given key as a file-like object

Raises KeyError if the key does not exist

Parameters:

key – Key to query

property project_name: str

Get the current project name.

class ska_telmodel.data.backend.MemoryBackend(uri: str, update: bool = False)[source]

Represents in-memory data. URIs should look as follows:

mem://?[key1]=[value1]&[key2]=[value2]

This will directly set the given telescope model data keys to the given values. Useful for testing, and overriding single values in telescope model data.

classmethod backend_name() str[source]

Returns the name of the backend.

Will be used for the scheme in URIs to identify the backend type of a telescope model data source.

get(key: str) bytes[source]

Get the data stored with the given key

Parameters:

key – Key to query

Returns:

Bytes stored at key

get_uri(pinned: bool) str[source]

Returns URI for this telescope model data backend

Parameters:

pinned – Attempt to return an URI that will continue to refer to this specific version of telescope model data

Returns:

URI identifying data source

list_keys(key_prefix: str = '') Iterable[str][source]

List children keys

Yields all keys with prefix “{key_prefix}/” in ascending order

Parameters:

key_prefix – Path to query

meta(key: str) dict[str, Any][source]

Retrieve meta data regarding the given key.

Parameters:

key – Key to query

Returns:

Dictionary with the size, and is_large values

class ska_telmodel.data.backend.TMDataBackend(uri: str, update: bool = False)[source]

Base class for telescope model data backends

Sub-classes should override backend_name(), then utilise telmodel_backend() to register the telescope model data backend. A minimal implementation should furthermore provide list_keys() and get().

abstract classmethod backend_name() str[source]

Returns the name of the backend.

Will be used for the scheme in URIs to identify the backend type of a telescope model data source.

copy(key: str, dest: str)[source]

Write key contents to a file.

Raises KeyError if the key does not exist

Parameters:
  • key – Key to query

  • dest – Path of destination file

exists(key: str) bool[source]

Check whether a given key exists.

Parameters:

key – Key to query

Returns:

True if key exists

abstract get(key: str) bytes[source]

Get the data stored with the given key

Parameters:

key – Key to query

Returns:

Data stored at key, or None if it doesn’t exist

get_uri(pinned: bool) str[source]

Returns URI for this telescope model data backend

Parameters:

pinned – Attempt to return an URI that will continue to refer to this specific version of telescope model data

Returns:

URI identifying data source

abstract list_keys(key_prefix: str = '') Iterable[str][source]

List children keys

Yields all keys with prefix “{key_prefix}/” in ascending order. Exception is if the path is empty, in which case all available keys are listed.

Parameters:

key_prefix – Path to query

meta(key: str) dict[str, Any][source]

Retrieve meta data regarding the given key.

Parameters:

key – Key to query

Returns:

Dictionary with the size, and is_large values

open(key: str) IO[bytes][source]

Access data at given key as a file-like object

Raises KeyError if the key does not exist

Parameters:

key – Key to query

classmethod valid_key(key: str) bool[source]

Check whether this is a valid key we could store data for

For this to be valid, it needs to: * Have every path segment start with a letter * Have no dot in directory names, and a dot in file name

Returns:

Validity of key

classmethod valid_prefix(key: str) bool[source]

Check whether argument could be a valid prefix to a key

For this to be valid, it needs to: * Have every path segment start with a letter * Have no dot in directory names, and a dot in file name

Returns:

Validity of key

This module concerns itself with adding new data to a current repository.

class ska_telmodel.data.new_data_backend.GitBackend(repo: str = 'ska-telescope/ska-telmodel-data', git_host: str = 'gitlab.com')[source]

This backend uses git as it’s data source, it assumes that the authentication is handled on the host side.

The repo should be one of (in order of preference):

If checkout_location is provided that will be used instead of a temp directory. By default we use ~/.ska-telmodel and place each checkout in there.

add_data(path: Path, key: str | None = None) None[source]

Copy new file into repo, and run validate on each file.

If path is a directory, the directory structure will also be taken into account when creating the key.

Parameters:
  • path – This can be either a directory of files, or a single file.

  • key – If path is a directory, then key is used as the prefix, if path is a file then this is used as the key.

checkout_branch(name)[source]

Checkout named branch.

commit_transaction() None[source]

Push changes to branch, if there are no local uncommitted changes.

local_location() Path[source]

The location of this backend on disk.

start_transaction(name_of_update: str, create_new_branch: bool = True) None[source]

Create a new clone (if needed), pull the main branch, and create a new branch.

Parameters:

name_of_update – This will become the branch name.

status() dict[str, list[str]][source]

Get current status of all new files.

Returns:

the names of the files in different states.

validate(file: Path) bool[source]

Validates the given file. The file can be anywhere.

Parameters:

file – The path to the file.

Returns:

Whether the file is validated or not.

class ska_telmodel.data.new_data_backend.NewDataBackend[source]

Base class for the data uploading backends.

This class is meant just as a guide to how to use the backends.

abstract add_data(path: Path, key: str | None = None) None[source]

Add a new data file or directory to the transaction.

Parameters:
  • path – This can be either a directory of files, or a single file.

  • key – If path is a directory, then key is used as the prefix, if path is a file then this is used as the key.

abstract commit_transaction() None[source]

Save the current transaction and mark it as completed.

abstract local_location() Path[source]

The location of this backend on disk.

abstract start_transaction(name_of_update: str) None[source]

Start a new session.

Parameters:

name_of_update – A short description of the update.

abstract status() dict[str, list[str]][source]

Get the state of the current session

abstract validate(file: Path) bool[source]

Validate the given file.

ska_telmodel.csp

ska_telmodel.csp.config.add_lowcbf_visibility_receive_addresses(csp_config: dict, scan_receive_addrs: dict, sdp_interface_version) dict[source]

Add SDP visibility receive addresses into low-cbf configuration

Parameters:
  • csp_config – CSP input configuration

  • scan_receive_addrs – SDP receive addresses for scan

  • sdp_interface_version – SDP interface version

Returns:

New CSP configuration

ska_telmodel.csp.config.add_midcbf_visibility_receive_addresses(csp_config: dict, scan_receive_addrs: dict, csp_interface_version: str, sdp_interface_version: str) dict[source]

Add SDP visibility receive addresses into mid-cbf configuration

Parameters:
  • csp_config – CSP input configuration

  • scan_receive_addrs – SDP receive addresses for scan

  • csp_interface_version – CSP interface version to assume

  • sdp_interface_version – SDP interface version to assume

Returns:

New CSP configuration

ska_telmodel.csp.config.add_pss_receive_addresses(csp_config: dict, scan_receive_addrs: dict, csp_interface_version: str, sdp_interface_version: str) dict[source]

Add SDP visibility receive addresses into pulsar search configuration

Parameters:
  • csp_config – CSP input configuration

  • scan_receive_addrs – SDP receive addresses for scan

  • csp_interface_version – CSP interface version to assume

  • sdp_interface_version – SDP interface version to assume

Returns:

New CSP configuration

ska_telmodel.csp.config.add_pst_receive_addresses(csp_config: dict, scan_receive_addrs: dict, csp_interface_version: str, sdp_interface_version: str) dict[source]

Add SDP visibility receive addresses into pulsar timing 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.add_receive_addresses(scan_type: str, csp_config: dict, scan_receive_addrs: dict, csp_interface_version: str, sdp_interface_version: str, telescope_branch: str = 'mid') dict[source]

Add SDP visibility receive addresses into CSP configuration

Parameters:
  • csp_config – CSP input configuration

  • scan_receive_addrs – SDP receive addresses for scan

  • csp_interface_version – CSP interface version to assume

  • sdp_interface_version – SDP interface version to assume

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

  • fsp_id – Position of FSP in configuration

  • fsp_ch_offset – Name of FSP channel offset field

ska_telmodel.csp.examples.expand_output_port(input_mapping: list[list[int]], max_channels: int = 14880) list[list[int]][source]

Expand output_port mapping to give concrete ports for each stream of 20 channels. Port value is set from initial port and incremented by the port_increment value if given, or 1 if the increment is not present.

param input_mapping: output_port mapping to convert from

ska_telmodel.csp.examples.get_csp_assignresources_example(version: str) dict[source]

Generate example of CSP assignresources argument

Parameters:

version – Version URI of configuration format

ska_telmodel.csp.examples.get_csp_config_example(version: str, scan: str | None = None) dict[source]

Generate examples for CSP configuration strings

Parameters:
  • version – Version URI of configuration format

  • scan – Includes SDP receive addresses for a scan? None means that this is “template” configuration as passed to TMC. Valid parameters: cal_a, science_a

ska_telmodel.csp.examples.get_csp_delaymodel_example(version: str) dict[source]

Generate example of CSP delay model argument

Parameters:

version – Version URI of configuration format

ska_telmodel.csp.examples.get_csp_endscan_example(version: str) dict[source]

Generate example of CSP endscan argument

Parameters:

version – Version URI of configuration format

ska_telmodel.csp.examples.get_csp_low_delaymodel_example(version: str) dict[source]

Generate example of CSP low delay model argument

Parameters:

version – Version URI of configuration format

ska_telmodel.csp.examples.get_csp_releaseresources_example(version: str, example: str | None = None) dict[source]

Generate example of CSP releaseresources argument

Parameters:

version – Version URI of configuration format

ska_telmodel.csp.examples.get_csp_scan_example(version: str) dict[source]

Generate example of CSP scan argument

Parameters:

version – Version URI of configuration format

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: str, sdp_interface_version: str, scan_type: str, csp_config_str: str | dict, sdp_receive_addrs_map_str: str | dict, telescope_branch: str = 'mid') str[source]

Generate 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_str – General CSP configuration

  • sdp_receive_addrs_map_str – Receive addresses map for scan types, generated by SDP

  • telescope_branch – flag to identify if the function is called by “mid” or “low” telescope

Returns:

A validated JSON string with CSP configuration.

Raise:

ValueError when the input JSON configuration fails validation.

ska_telmodel.csp.interface.make_low_csp_config(csp_interface_version: str, sdp_interface_version: str, scan_type: str, csp_config_str: str | dict, sdp_receive_addrs_map_str: str | dict) dict[source]

Generate 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_str – General CSP configuration

  • sdp_receive_addrs_map_str – Receive addresses map for scan types, generated by SDP

Returns:

new CSP configuration. dict format.

Raise:

ValueError when the input JSON configuration fails validation.

Raise:

ValueError when the input interface version fails validation.

Raise:

ValueError when the input telescope_branch fails validation.

Raise:

ValueError when the input scan_type not in sdp_receive_addrs

ska_telmodel.csp.interface.make_mid_csp_config(csp_interface_version: str, sdp_interface_version: str, scan_type: str, csp_config_str: str | dict, sdp_receive_addrs_map_str: str | dict) dict[source]

Generate 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_str – General CSP configuration

  • sdp_receive_addrs_map_str – Receive addresses map for scan types, generated by SDP

Returns:

new CSP configuration. dict format.

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, tmc_schema_uri: str = '') Schema[source]

Correlator and Beamformer configuration schema

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

  • tmc_schema_uri – tmc URI version. Used to differentiate the OSO-TMC-CSP schema according to the TMC interface version

Returns:

the JSON Schema for the Mid.CBF configuration.

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

Correlator and Beamformer configuration schema received under TMC-OSO

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

  • tmc_schema_uri – tmc URI version. Used to differentiate the OSO-TMC-CSP schema according to the TMC interface version

Returns:

the JSON Schema for the MID.CBF configuration.

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

CSP Subarray common configuration schema. This section is valid for Mid CSP because it includes some parameters that are Mid.CBF specific. The set of parameters that are common to Mid and Low CSP, are retrieved by the _get_common_config_schema method defined in the common_schema python module.

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_common_config_schema_oso_tmc(version: str, strict: bool, tmc_schema_uri: str = '') Schema[source]

CSP Subarray common configuration schema OSO-TMC This section is valid for Mid CSP because it includes some parameters that are Mid CBF specific. The set of parameters that are common to Mid and Low CSP, are retrieved by the _get_common_config_schema method defined in the common_schema python module.

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

  • tmc_schema_uri – tmc URI version. Used to differentiate the OSO-TMC-CSP schema according to the TMC interface version

Returns:

the JSON Schema for the OSO-TMC, CSP subarray common configuration (ADR-99).

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

Correlation Processing Region configuration schema

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

  • tmc_schema_uri – tmc URI version. Used to differentiate the OSO-TMC-CSP schema according to the TMC interface version

Returns:

the JSON Schema for the Correlation Processing Region specific configuration.

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

CSP Correlation configuration schema

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

  • tmc_schema_uri – tmc URI version. Used to differentiate the OSO-TMC-CSP schema according to the TMC interface version

Returns:

the JSON Schema for the CSP subarray specific configuraiton.

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

Returns the schema to verify the CSP assignresources command.

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

ska_telmodel.csp.schema.get_csp_config_schema(version: str, strict: bool, tmc_schema_uri: str = '') 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!

  • tmc_schema_uri – TMC Interface version When received, conditions are added to get OSO-TMC-CSP schema else, TMC-CSP schema will be generated.

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_csp_delay_details_schema(version: str, strict: bool) Schema[source]

Returns the schema with the CSP delay details

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

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

Returns the schema to verify the CSP delaymodel command.

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

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

Returns the schema to verify the CSP endscan command.

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

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

Returns the schema to verify the CSP low delaymodel command.

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

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

Returns the schema with the CSP delay details

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

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

Returns the schema to verify the CSP releaseresources command.

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

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

Returns the schema to verify the CSP scan command.

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on 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_low_csp_station_beam_details_schema(version: str, strict: bool) Schema[source]

Returns the schema with the Low CSP delay details

Parameters:
  • version – Interface version URI

  • strict – Strict mode. If true, refuse even harmless schema violations (like extra keys). DO NOT USE FOR INPUT VALIDATION!

Returns:

The JSON Schema for the command.

Raise:

ValueError exception on invalid JSON Schema URI.

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

CSP Pulsar Search Timing Beam-Former 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_pst_bf_processing_region_config_schema(version: str, strict: bool) Schema[source]

PST Beam-Former Processing Region configuration schema

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

Returns:

the JSON Schema for the PST Beam-Former Processing Region specific configuration.

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

Timing beam configuration schema

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

  • tmc_schema_uri – tmc URI version. Used to differentiate the OSO-TMC-CSP schema according to the TMC interface version

Returns:

the JSON Schema for the Timing beam specific configuration.

ska_telmodel.csp.schema.get_search_window_config_schema(version: str, strict: bool) 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[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.validators.validate_integration_factor(integration_factor: int) bool[source]

Checks if the integration_factor is valid.

Parameters:

integration_factor – Integration time for correlation products

Returns:

True if integration_factor is valid

ska_telmodel.csp.version.check_csp_interface_version(version: str, allowed_prefixes: str | List[str] = ['https://schema.skao.int/ska-csp-assignresources/', 'https://schema.skao.int/ska-csp-configure/', 'https://schema.skao.int/ska-csp-configurescan/', 'https://schema.skao.int/ska-csp-scan/', 'https://schema.skao.int/ska-csp-endscan/', 'https://schema.skao.int/ska-csp-releaseresources/', 'https://schema.skao.int/ska-csp-delaymodel/', 'https://schema.skao.int/ska-mid-csp-delaymodel/', 'https://schema.skao.int/ska-low-csp-delaymodel/']) str[source]

Check CSP interface version.

Checks that the interface URI has one of the allowed prefixes. If it does, the version number is returned. If not, a ValueError exception is raised.

Parameters:
  • version – CSP interface URI

  • allowed_prefixes – allowed URI prefix(es)

Returns:

version number

ska_telmodel.csp.version.csp_config_versions(min_ver=None, max_ver=None)[source]

Returns a list of CSP configuration interface version URIs

Parameters:
  • min_ver – Tuple of minimum version to return

  • max_ver – Tuple of maximum version to return

ska_telmodel.csp.version.normalize_csp_config_version(csp_interface_version: int | str, csp_config: dict | None = None)[source]

Provides a standard interface version for configure

Parameters:
  • csp_interface_version – External guess at the interface version

  • csp_config – Example configuration to derive version from

Returns:

Canonical URI of interface version

ska_telmodel.pst

ska_telmodel.pst.examples.get_pst_config_example(version: str, scan_type: str | None = None) dict[source]

Generate examples for PST configuration strings

This will delegate to the appropriate telescope example (i.e. Mid or Low) depending on the prefix of the scan_type parameter. If the scan_type is prefixed with mid_ then a SKAMid PST scan config example is returned else a SKALow PST scan config example is returned.

Valid values of scan_type are:
  • pst_scan_vr

  • pst_scan_pt

  • pst_scan_ft

  • pst_scan_ds

  • low_pst_scan_vr

  • low_pst_scan_pt

  • low_pst_scan_ft

  • low_pst_scan_ds

  • mid_pst_scan_vr

  • mid_pst_scan_pt

  • mid_pst_scan_ft

  • mid_pst_scan_ds

Parameters:
  • version – Version URI of configuration format

  • scan – Includes SDP receive addresses for a scan? None means that this is “template” configuration as passed to TMC.

Examples specifically for SKALow

ska_telmodel.pst.low_examples.get_low_pst_config_example(version: str, scan_type: str | None = None) dict[source]

Generate examples for SKALow PST configuration strings

Parameters:
  • version – Version URI of configuration format

  • scan – Includes SDP receive addresses for a scan? None means that this is “template” configuration as passed to TMC. Valid parameters: pst_scan_vr, pst_scan_pt, pst_scan_ft, and pst_scan_ds

Examples specifically for SKAMid

ska_telmodel.pst.mid_examples.get_mid_pst_config_example(version: str, scan_type: str | None = None) dict[source]

Generate examples for SKAMid PST configuration strings

Parameters:
  • version – Version URI of configuration format

  • scan – Includes SDP receive addresses for a scan? None means that this is “template” configuration as passed to TMC. Valid parameters: pst_scan_vr, pst_scan_pt, pst_scan_ft, and pst_scan_ds

Used for checking CSP configuration strings for conformance

ska_telmodel.pst.schema.get_pst_beam_config_schema(version: str, strict: bool) TMSchema[source]

Pulsar Timing specific beam configuration

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

Returns:

the JSON Schema for the PST beam configuration.

ska_telmodel.pst.schema.get_pst_config_schema(version: str, strict: bool) TMSchema[source]

Return the PST configure schema.

This PST schema could be used to validate the JSON script received during configuration.This schema includes the common section with the mandatory fields.

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

Returns:

the JSON Schema for the PST configuration.

ska_telmodel.pst.schema.get_pst_scan_config_schema(version: str, strict: bool, beamid_required=True) TMSchema[source]

Pulsar Timing specific scan configuration

Parameters:
  • version – Interface Version URI

  • strict – Schema strictness

Returns:

the JSON Schema for the PST scan configuration.

ska_telmodel.pst.version.check_interface_version(version: str, allowed_prefixes: str | List[str] = ['https://schema.skao.int/ska-pst-configure/']) str[source]

Check PST interface version.

Checks that the interface URI has one of the allowed prefixes. If it does, the version number is returned. If not, a ValueError exception is raised.

Parameters:
  • version – PST interface URI

  • allowed_prefixes – allowed URI prefix(es)

Returns:

version number

ska_telmodel.sdp

Common elements of SDP schemas.

ska_telmodel.sdp.common.get_beam_function_pattern(strict: bool)[source]

Get pattern for SDP beam functions

As used for SDP configuration - i.e. basically a kind of data that the SKA SDP needs to receive.

Returns:

A string pattern suitable for use in schemas

ska_telmodel.sdp.common.get_receptor_schema(strict: bool) Schema[source]

Return schema for receptors.

Parameters:

strict – check names if set

Returns:

schema

SDP schema examples.

SDP schema definitions.

SDP schema prefixes and versions.

ska_telmodel.sdp.version.sdp_interface_versions(prefix: str, min_ver=None, max_ver=None)[source]

Returns a list of SDP interface version URIs

Parameters:
  • prefix – Interface URI prefix

  • min_ver – Tuple of minimum version to return

  • max_ver – Tuple of maximum version to return