From 3e91cdc5b28f1c751186ecb48d15667cee1f9e3b Mon Sep 17 00:00:00 2001
From: thijs snijder <snijder@astron.nl>
Date: Fri, 21 Oct 2022 11:26:07 +0200
Subject: [PATCH] small changes and removed unused imports

---
 .../tangostationcontrol/clients/statistics/client.py         | 1 -
 tangostationcontrol/tangostationcontrol/common/constants.py  | 5 +++--
 tangostationcontrol/tangostationcontrol/devices/boot.py      | 1 -
 tangostationcontrol/tangostationcontrol/devices/sdp/xst.py   | 2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/clients/statistics/client.py b/tangostationcontrol/tangostationcontrol/clients/statistics/client.py
index a774e2a56..8a99992ac 100644
--- a/tangostationcontrol/tangostationcontrol/clients/statistics/client.py
+++ b/tangostationcontrol/tangostationcontrol/clients/statistics/client.py
@@ -15,7 +15,6 @@ from tangostationcontrol.clients.comms_client import AsyncCommClient
 from tangostationcontrol.clients.tcp_replicator import TCPReplicator
 from tangostationcontrol.clients.udp_receiver import UDPReceiver
 from tangostationcontrol.clients.statistics.consumer import StatisticsConsumer
-from tangostationcontrol.common.constants import constants
 
 logger = logging.getLogger()
 
diff --git a/tangostationcontrol/tangostationcontrol/common/constants.py b/tangostationcontrol/tangostationcontrol/common/constants.py
index 001bb089d..2fcd3c314 100644
--- a/tangostationcontrol/tangostationcontrol/common/constants.py
+++ b/tangostationcontrol/tangostationcontrol/common/constants.py
@@ -1,3 +1,4 @@
+from tangostationcontrol.common.baselines import nr_baselines
 
 class constants:
 
@@ -53,7 +54,6 @@ class constants:
     CLK_200_MHZ = 200_000_000
     CLK_160_MHZ = 160_000_000
 
-
     # Maximum number of subbands for which we collect XSTs simultaneously
     MAX_PARALLEL_SUBBANDS = 8
     # Expected block for XST's
@@ -62,7 +62,8 @@ class constants:
     VALUES_PER_COMPLEX = 2
     # Max blocks for the BST statistics
     BST_MAX_BLOCKS = 2
-
+    # Expected number of blocks: enough to cover all baselines without the conjugates (that is, the top-left triangle of the matrix).
+    MAX_BLOCKS = nr_baselines(MAX_INPUTS // BLOCK_LENGTH)
 
     # UNB2 constants
     # number of uniboards in a subrack
diff --git a/tangostationcontrol/tangostationcontrol/devices/boot.py b/tangostationcontrol/tangostationcontrol/devices/boot.py
index 2f44875c6..6e40c0446 100644
--- a/tangostationcontrol/tangostationcontrol/devices/boot.py
+++ b/tangostationcontrol/tangostationcontrol/devices/boot.py
@@ -27,7 +27,6 @@ from tangostationcontrol.devices.device_decorators import only_in_states
 from tangostationcontrol.common.entrypoint import entry
 from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
 from tangostationcontrol.common.states import OPERATIONAL_STATES
-from tangostationcontrol.common.constants import constants
 from tangostationcontrol.devices.lofar_device import lofar_device
 
 import logging
diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py b/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py
index 42ead3ecf..89d172228 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/xst.py
@@ -153,7 +153,7 @@ class XST(Statistics):
     # number of packets with invalid payloads
     nof_payload_errors_R    = attribute_wrapper(comms_id=StatisticsClient, comms_annotation={"type": "statistics", "parameter": "nof_payload_errors"}, dims=(constants.N_pn,), datatype=numpy.uint64)
     # latest XSTs
-    xst_blocks_R            = attribute_wrapper(comms_id=StatisticsClient, comms_annotation={"type": "statistics", "parameter": "xst_blocks", "reshape": True}, dims=(constants.MAX_PARALLEL_SUBBANDS, XSTCollector.MAX_BLOCKS, constants.BLOCK_LENGTH, constants.BLOCK_LENGTH, constants.VALUES_PER_COMPLEX), datatype=numpy.int64)
+    xst_blocks_R            = attribute_wrapper(comms_id=StatisticsClient, comms_annotation={"type": "statistics", "parameter": "xst_blocks", "reshape": True}, dims=(constants.MAX_PARALLEL_SUBBANDS, constants.MAX_BLOCKS, constants.BLOCK_LENGTH, constants.BLOCK_LENGTH, constants.VALUES_PER_COMPLEX), datatype=numpy.int64)
     # whether the values in the block are conjugated and transposed
     xst_conjugated_R        = attribute_wrapper(comms_id=StatisticsClient, comms_annotation={"type": "statistics", "parameter": "xst_conjugated", "reshape": True}, dims=(constants.MAX_PARALLEL_SUBBANDS, XSTCollector.MAX_BLOCKS), datatype=bool)
     # reported timestamp for each subband in the latest XSTs
-- 
GitLab