ska_pst.testutils.common

Module that includes common code for SKA PST Python code.

class ska_pst.testutils.common.QualityAttributeMapping(*, udp_gen_arg: str, invalid_packets_attribute_name: str, invalid_packet_rate_attribute_name: str, percentage_valid_attribute_name: str)[source]

A data class used to map signal quality attributes to UDP Gen and TANGO attributes.

invalid_packet_rate_attribute_name: str

The TANGO attribute name that reports on instantaneous packet rate with invalid flag set.

invalid_packets_attribute_name: str

The TANGO attribute name that reports the overall number of packets with invalid flag set.

percentage_valid_attribute_name: str

The TANGO attribute name that reports on percentage of packets that are valid.

udp_gen_arg: str

The argument use in UDP gen to simulate invalid packet.

ska_pst.testutils.common.convert_value_to_quantity(value: str) Union[str, astropy.units.Quantity, Tuple[astropy.units.Quantity, astropy.units.Quantity]][source]

Convert a value string to a quantity.

This tries to use the astropy.units package to see if it can convert it to a quantity. If the value starts with a number then it is expected to be a quantity (value with optional unit). If it isn’t a number the string value is returned.

This is method should be extended to handled the edge cases that may arise in the future.

ska_pst.testutils.common.csp_scan_type(mode: ska_control_model.PstProcessingMode, facility: TelescopeFacilityEnum, version: str = ska_schemas.pst.version.PST_CONFIG_VER4_0) str[source]

Get CSP Scan example string.

This is to be used when calling the ska_schemas.pst.examples.get_pst_config_example() method to retrieve the correct example CSP-PST JSON data.

Parameters
  • mode (PstProcessingMode) – the PST processing mode to get the CSP scan type for.

  • facility (TelescopeFacilityEnum) – the telescope facility, for SKAMid the value is prefixed with ‘mid’.

  • version (str, optional) – the interface version to use, defaults to PST_CONFIG_VER4_0. This is used to ensure compatibility of detected filterbank processing mode in legacy versions as the string is pst_scan_ds

Returns

the CSP Scan example string

Return type

str

ska_pst.testutils.common.pst_processing_mode_from_str(value: str) ska_control_model.PstProcessingMode[source]

Get processing mode from a string.

PST BDD tests may use ‘voltage recorder’ or ‘pulsar timing’. This will capitalise the string and replace spaces with underscores before converting to an enum value.