Skip to content
Snippets Groups Projects
Commit 23a3205a authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

Merge branch 'L2SS-984-fix-beamlet-subband-tests' into 'master'

Resolve L2SS-984 "Fix beamlet subband tests"

Closes L2SS-984

See merge request !440
parents 6378b2a5 0256c47d
No related branches found
No related tags found
1 merge request!440Resolve L2SS-984 "Fix beamlet subband tests"
...@@ -11,6 +11,8 @@ from .base import AbstractTestBases ...@@ -11,6 +11,8 @@ from .base import AbstractTestBases
from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy
from tango import DevState
import numpy import numpy
import numpy.testing import numpy.testing
import time import time
...@@ -41,8 +43,6 @@ class TestDeviceBeamlet(AbstractTestBases.TestDeviceBase): ...@@ -41,8 +43,6 @@ class TestDeviceBeamlet(AbstractTestBases.TestDeviceBase):
sdp_proxy = self.setup_sdp() sdp_proxy = self.setup_sdp()
self.proxy.initialise() self.proxy.initialise()
# TODO(Corne): Update test so effects of attribute are asserted L2SS-984
# self.proxy.subband_select_RW = [0] * 488
self.proxy.on() self.proxy.on()
# The subband frequency of HBA subband 0 is 200 MHz, # The subband frequency of HBA subband 0 is 200 MHz,
...@@ -58,14 +58,34 @@ class TestDeviceBeamlet(AbstractTestBases.TestDeviceBase): ...@@ -58,14 +58,34 @@ class TestDeviceBeamlet(AbstractTestBases.TestDeviceBase):
expected_bf_weights = numpy.array([49152] * 192 * 488, dtype=numpy.uint32) expected_bf_weights = numpy.array([49152] * 192 * 488, dtype=numpy.uint32)
numpy.testing.assert_almost_equal(expected_bf_weights, calculated_bf_weights) numpy.testing.assert_almost_equal(expected_bf_weights, calculated_bf_weights)
def test_subband_select_change(self):
# Setup configuration
sdp_proxy = self.setup_sdp()
# Change subband
self.proxy.off()
self.proxy.initialise()
self.assertEqual(DevState.STANDBY, self.proxy.state())
self.proxy.subband_select_RW = [10] * 488
self.proxy.on()
self.assertEqual(DevState.ON, self.proxy.state())
# The subband frequency of HBA subband 10 is 201953125 Hz
# so its period is 4.95 ns ca, half period is 2.4758e-9
delays = numpy.array([[2.4758e-9] * 192] * 488)
calculated_bf_weights_subband_10 = self.proxy.calculate_bf_weights(delays.flatten())
self.assertEqual(-2**14, c_short(49152).value) # check our calculations
expected_bf_weights_10 = numpy.array([49152] * 192 * 488, dtype=numpy.uint32)
numpy.testing.assert_almost_equal(expected_bf_weights_10, calculated_bf_weights_subband_10)
def test_sdp_clock_change(self): def test_sdp_clock_change(self):
# Setup configuration # Setup configuration
sdp_proxy = self.setup_sdp() sdp_proxy = self.setup_sdp()
self.proxy.initialise() self.proxy.initialise()
# TODO(Corne): Update test so effects of attribute are asserted L2SS-984 self.proxy.subband_select_RW = numpy.array(list(range(317)) + [316] + list(range(318,488)), dtype=numpy.uint32)
# self.proxy.subband_select_RW = list(range(488))
self.proxy.on() self.proxy.on()
# any non-zero delay should result in different weights for different clocks # any non-zero delay should result in different weights for different clocks
...@@ -87,3 +107,16 @@ class TestDeviceBeamlet(AbstractTestBases.TestDeviceBase): ...@@ -87,3 +107,16 @@ class TestDeviceBeamlet(AbstractTestBases.TestDeviceBase):
self.assertTrue((calculated_bf_weights_200 != calculated_bf_weights_160).all()) self.assertTrue((calculated_bf_weights_200 != calculated_bf_weights_160).all())
self.assertTrue((calculated_bf_weights_200 == calculated_bf_weights_200_v2).all()) self.assertTrue((calculated_bf_weights_200 == calculated_bf_weights_200_v2).all())
# change subbands
self.proxy.off()
self.proxy.initialise()
self.proxy.subband_select_RW = [317] * 488
self.proxy.on()
calculated_bf_weights_200_v3 = self.proxy.calculate_bf_weights(delays.flatten())
self.assertTrue((calculated_bf_weights_200_v2 != calculated_bf_weights_200_v3).all())
sdp_proxy.clock_RW = 160 * 1000000
time.sleep(1) # wait for beamlet device to process change event
calculated_bf_weights_160_v2 = self.proxy.calculate_bf_weights(delays.flatten())
self.assertTrue((calculated_bf_weights_160 != calculated_bf_weights_160_v2).all())
...@@ -14,6 +14,7 @@ from tangostationcontrol.devices.antennafield import AntennaQuality, AntennaUse ...@@ -14,6 +14,7 @@ from tangostationcontrol.devices.antennafield import AntennaQuality, AntennaUse
from .base import AbstractTestBases from .base import AbstractTestBases
import numpy import numpy
import time
class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase): class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase):
...@@ -34,7 +35,7 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase): ...@@ -34,7 +35,7 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase):
self.addCleanup(TestDeviceProxy.test_device_turn_off, self.recv_iden) self.addCleanup(TestDeviceProxy.test_device_turn_off, self.recv_iden)
self.recv_proxy = self.setup_recv_proxy() self.recv_proxy = self.setup_recv_proxy()
self.beamlet_proxy = self.setup_beamlet_proxy() self.beamlet_proxy = self.initialise_beamlet_proxy()
def setup_recv_proxy(self): def setup_recv_proxy(self):
recv_proxy = TestDeviceProxy(self.recv_iden) recv_proxy = TestDeviceProxy(self.recv_iden)
...@@ -43,6 +44,12 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase): ...@@ -43,6 +44,12 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase):
recv_proxy.set_defaults() recv_proxy.set_defaults()
return recv_proxy return recv_proxy
def initialise_beamlet_proxy(self):
beamlet_proxy = TestDeviceProxy(self.beamlet_iden)
beamlet_proxy.off()
beamlet_proxy.initialise()
return beamlet_proxy
def setup_beamlet_proxy(self): def setup_beamlet_proxy(self):
beamlet_proxy = TestDeviceProxy(self.beamlet_iden) beamlet_proxy = TestDeviceProxy(self.beamlet_iden)
beamlet_proxy.off() beamlet_proxy.off()
...@@ -73,19 +80,22 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase): ...@@ -73,19 +80,22 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase):
antennafield_proxy.boot() antennafield_proxy.boot()
return antennafield_proxy return antennafield_proxy
def test_pointing_to_zenith(self): def test_pointing_to_zenith_clock_change(self):
self.addCleanup(TestDeviceProxy.test_device_turn_off, self.beamlet_iden)
self.addCleanup(TestDeviceProxy.test_device_turn_off, self.sdp_iden) self.addCleanup(TestDeviceProxy.test_device_turn_off, self.sdp_iden)
self.addCleanup( self.addCleanup(
TestDeviceProxy.test_device_turn_off, self.antennafield_iden TestDeviceProxy.test_device_turn_off, self.antennafield_iden
) )
self.setup_antennafield_proxy(self.antenna_qualities_ok, self.antenna_use_ok) self.setup_antennafield_proxy(self.antenna_qualities_ok, self.antenna_use_ok)
self.setup_sdp_proxy() self.sdp_proxy = self.setup_sdp_proxy()
self.beamlet_proxy = self.initialise_beamlet_proxy()
self.beamlet_proxy.on()
# TODO(Corne): Update these and ensure their effects is asserted in tests L2SS-984 # Set first (default) clock configuration
# Setup beamlet configuration self.sdp_proxy.clock_RW = 200 * 1000000
# self.beamlet_proxy.clock_RW = 200 * 1000000 time.sleep(1)
# self.beamlet_proxy.subband_select_RW = list(range(488))
self.proxy.initialise() self.proxy.initialise()
self.proxy.Tracking_enabled_RW = False self.proxy.Tracking_enabled_RW = False
...@@ -95,7 +105,52 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase): ...@@ -95,7 +105,52 @@ class TestDeviceDigitalBeam(AbstractTestBases.TestDeviceBase):
self.proxy.set_pointing(numpy.array([["AZELGEO", "0deg", "90deg"]] * 488).flatten()) self.proxy.set_pointing(numpy.array([["AZELGEO", "0deg", "90deg"]] * 488).flatten())
# beam weights should now be non-zero, we don't actually check their values for correctness # beam weights should now be non-zero, we don't actually check their values for correctness
self.assertNotEqual(0, sum(self.beamlet_proxy.FPGA_bf_weights_xx_yy_RW.flatten())) FPGA_bf_weights_xx_yy_clock200 = self.beamlet_proxy.FPGA_bf_weights_xx_yy_RW.flatten()
self.assertNotEqual(0, sum(FPGA_bf_weights_xx_yy_clock200))
self.beamlet_proxy = self.initialise_beamlet_proxy()
self.beamlet_proxy.on()
# Change clock configuration
self.sdp_proxy.clock_RW = 160 * 1000000
time.sleep(1)
FPGA_bf_weights_xx_yy_clock160 = self.beamlet_proxy.FPGA_bf_weights_xx_yy_RW.flatten()
# Assert some values are different
self.assertNotEqual(sum(FPGA_bf_weights_xx_yy_clock160), sum(FPGA_bf_weights_xx_yy_clock200))
def test_pointing_to_zenith_subband_change(self):
self.addCleanup(TestDeviceProxy.test_device_turn_off, self.beamlet_iden)
self.addCleanup(TestDeviceProxy.test_device_turn_off, self.sdp_iden)
self.addCleanup(
TestDeviceProxy.test_device_turn_off, self.antennafield_iden
)
self.setup_antennafield_proxy(self.antenna_qualities_ok, self.antenna_use_ok)
self.sdp_proxy = self.setup_sdp_proxy()
self.beamlet_proxy = self.initialise_beamlet_proxy()
self.beamlet_proxy.subband_select_RW = numpy.array(list(range(317)) + [316] + list(range(318,488)), dtype=numpy.uint32)
self.beamlet_proxy.on()
self.proxy.initialise()
self.proxy.Tracking_enabled_RW = False
self.proxy.on()
# Point to Zenith
self.proxy.set_pointing(numpy.array([["AZELGEO", "0deg", "90deg"]] * 488).flatten())
# Store values with first subband configuration
FPGA_bf_weights_xx_yy_subband_v1 = self.beamlet_proxy.FPGA_bf_weights_xx_yy_RW.flatten()
# Restart beamlet proxy
self.beamlet_proxy = self.initialise_beamlet_proxy()
self.beamlet_proxy.subband_select_RW = [317] * 488
self.beamlet_proxy.on()
# Store values with second subband configuration
FPGA_bf_weights_xx_yy_subband_v2 = self.beamlet_proxy.FPGA_bf_weights_xx_yy_RW.flatten()
# Assert some values are different
self.assertNotEqual(sum(FPGA_bf_weights_xx_yy_subband_v1), sum(FPGA_bf_weights_xx_yy_subband_v2))
def test_set_pointing_masked_enable(self): def test_set_pointing_masked_enable(self):
"""Verify that only selected inputs are written""" """Verify that only selected inputs are written"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment