diff --git a/README.md b/README.md index 90f3cd6dd48a267513966f005ce474084238a124..c6d9616b973d3f34fc5d8adf793d48a6d21331a4 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ tox -e debug tests.requests.test_prometheus ## Releasenotes +- 0.6. - Correctly transpose XST blocks in `XSTCollector`. - 0.5. - Swapped [x][y] for [y][x] dimensionality in `get_attribute_history` - 0.4. - Added collectors including `XSTCollector`, `BSTCollector` and `SSTCollecotr` import under `from lofar_station_client.statistics import xxx` diff --git a/VERSION b/VERSION index 2eb3c4fe4eebcdea3da0790cc0ba74cb286ec4f4..5a2a5806df6e909afe3609b5706cb1012913ca0e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5 +0.6 diff --git a/lofar_station_client/statistics/collector.py b/lofar_station_client/statistics/collector.py index 4a03cefefdb5998f41ee9c942efd2d107812b879..b89d2a86b3a43dc2d1b84c2fef839dc83a739baa 100644 --- a/lofar_station_client/statistics/collector.py +++ b/lofar_station_client/statistics/collector.py @@ -404,13 +404,13 @@ class XSTCollector(StatisticsCollector): .view(numpy.complex64) ) + # reshape into [a][b] + block = block.reshape(self.BLOCK_LENGTH, self.BLOCK_LENGTH) + if xst_conjugated[subband_index][block_index]: # block is conjugated and transposed. process. block = block.conjugate().transpose() - # reshape into [a][b] - block = block.reshape(self.BLOCK_LENGTH, self.BLOCK_LENGTH) - # compute destination in matrix first_baseline = baseline_from_index(block_index) first_baseline = ( diff --git a/tests/statistics/test_collector.py b/tests/statistics/test_collector.py index 24d7cfb418aa8a8a7500266b0c10f4191953177d..8ca45f9cc8583387318dc950a5df319f63640717 100644 --- a/tests/statistics/test_collector.py +++ b/tests/statistics/test_collector.py @@ -135,17 +135,19 @@ class TestXSTCollector(base.TestCase): f"but was written to the XST matrix.", ) - def test_conjugated_packet(self): - """Test packet payload conjugation with a baseline (a,b) where a<b""" + def test_conjugated_transposed_packet(self): + """Test packet payload conjugation & transposewith a baseline (a,b) where a<b""" collector = XSTCollector() - # a valid packet as obtained from SDP, with 64-bit BE 1+1j as payload, at - # baseline (0,12) VV VV + # a valid packet as obtained from SDP. + # the first 72 samples are 1+1j, the second 72 samples are 2+2j (64-bit BE). + # at baseline (0,12) VV VV packet = ( b"X\x05\x00\x00\x00\x00\x00\x00\x10\x08\x00\x02\xfa\xef\x00f\x00\x0c\x0c" b"\x08\x01 \x14\x00\x00\x01!\xd9&z\x1b\xb3" - + 288 * b"\x00\x00\x00\x00\x00\x00\x00\x01" + + 144 * b"\x00\x00\x00\x00\x00\x00\x00\x01" + + 144 * b"\x00\x00\x00\x00\x00\x00\x00\x02" ) # parse it ourselves to extract info nicely @@ -165,6 +167,11 @@ class TestXSTCollector(base.TestCase): # zero xst_values = collector.xst_values()[0] + # number of complex values that should end up in the XST matrix + correct_nr_values = 144 + # number of values we've counted so far + actual_nr_values = 0 + for baseline_a in range(collector.MAX_INPUTS): for baseline_b in range(collector.MAX_INPUTS): if baseline_b > baseline_a: @@ -184,12 +191,25 @@ class TestXSTCollector(base.TestCase): ) if baseline_a_was_in_packet and baseline_b_was_in_packet: - self.assertEqual( - 1 - 1j, - xst_values[baseline_a][baseline_b], - msg=f"element [{baseline_a}][{baseline_b}] did not end up " - f"conjugated in XST matrix.", - ) + # through conjugation, the imaginary part is made negative + # through transposition, the second dimension (b) now is the divider + # between the two distinct values + if baseline_b - fields.first_baseline[0] < 6: + self.assertEqual( + 1 - 1j, + xst_values[baseline_a][baseline_b], + msg=f"element [{baseline_a}][{baseline_b}] did not end up " + f"conjugated & transposed in XST matrix.", + ) + else: + self.assertEqual( + 2 - 2j, + xst_values[baseline_a][baseline_b], + msg=f"element [{baseline_a}][{baseline_b}] did not end up " + f"conjugated & transposed in XST matrix.", + ) + + actual_nr_values += 1 else: self.assertEqual( 0 + 0j, @@ -198,6 +218,8 @@ class TestXSTCollector(base.TestCase): f"but was written to the XST matrix.", ) + self.assertEqual(correct_nr_values, actual_nr_values, "Mismatch between number of values in the packet and in the resulting matrix") + def test_multiple_subbands(self): collector = XSTCollector()