diff --git a/tangostationcontrol/docs/source/devices/tilebeam.rst b/tangostationcontrol/docs/source/devices/tilebeam.rst index e0c4ce810434da3347b0ec9804937c9d69d9ec66..1df29562f605039cad0f77ad284b1f0d3b562f0b 100644 --- a/tangostationcontrol/docs/source/devices/tilebeam.rst +++ b/tangostationcontrol/docs/source/devices/tilebeam.rst @@ -8,19 +8,19 @@ Beam Tracking Beam tracking automatically recomputes and reapplies pointings periodically, and immediately when new pointings are configured. It exposes the following interface: -:HBAT_tracking_enabled_R: Whether beam tracking is running. +:Tracking_enabled_R: Whether beam tracking is running. :type: ``bool`` -:HBAT_pointing_direction_RW: The direction in which the beam should be tracked for each antenna. The beam tracker will steer the beam periodically, and explicitly whenever the pointings change. +:Pointing_direction_RW: The direction in which the beam should be tracked for each antenna. The beam tracker will steer the beam periodically, and explicitly whenever the pointings change. :type: ``str[N_ant][3]`` -:HBAT_pointing_direction_R: The last applied pointing of each antenna. +:Pointing_direction_R: The last applied pointing of each antenna. :type: ``str[N_ant][3]`` -:HBAT_pointing_timestamp_R: The timestamp for which the last set pointing for each antenna was applied and set (in seconds since 1970). +:Pointing_timestamp_R: The timestamp for which the last set pointing for each antenna was applied and set (in seconds since 1970). :type: ``float[N_ant][3]`` @@ -29,11 +29,11 @@ Beam Steering The beam steering is responsible for pointing the beams at a target, by converting pointings to ``recv.HBAT_bf_delay_steps``. The beam steering is typically controlled by the beam tracker. To point the antennas in any direction manually, you should disable beam tracking first: -:HBAT_tracking_enabled_RW: Enable or disable beam tracking (default: ``True``). +:Tracking_enabled_RW: Enable or disable beam tracking (default: ``True``). :type: ``bool`` -:HBAT_set_pointing(pointings): Point the beams towards the specified ``pointings[N_ant][3]`` for all antennas (for which ``recv.ANT_mask_RW`` is set). +:set_pointing(pointings): Point the beams towards the specified ``pointings[N_ant][3]`` for all antennas (for which ``recv.ANT_mask_RW`` is set). :returns: ``None`` diff --git a/tangostationcontrol/tangostationcontrol/devices/tilebeam.py b/tangostationcontrol/tangostationcontrol/devices/tilebeam.py index 7adee9e269bf24d340175d1704448ded674c3684..25373f689e280bb2c81a1d6cbb5527a611f02092 100644 --- a/tangostationcontrol/tangostationcontrol/devices/tilebeam.py +++ b/tangostationcontrol/tangostationcontrol/devices/tilebeam.py @@ -37,14 +37,14 @@ class TileBeam(beam_device): # Device Properties # ----------------- - HBAT_beam_tracking_interval = device_property( + Beam_tracking_interval = device_property( dtype='DevFloat', - doc='HBAT beam weights updating interval time [seconds]', + doc='Beam weights updating interval time [seconds]', mandatory=False, default_value = 10.0 ) - HBAT_beam_tracking_preparation_period = device_property( + Beam_tracking_preparation_period = device_property( dtype='DevFloat', doc='Preparation time [seconds] needed before starting update operation', mandatory=False, @@ -55,27 +55,27 @@ class TileBeam(beam_device): # Attributes # ---------- - HBAT_pointing_direction_R = attribute(access=AttrWriteType.READ, + Pointing_direction_R = attribute(access=AttrWriteType.READ, dtype=((numpy.str,),), max_dim_x=3, max_dim_y=96, - fget=lambda self: self._hbat_pointing_direction_r) + fget=lambda self: self._pointing_direction_r) - HBAT_pointing_direction_RW = attribute(access=AttrWriteType.READ_WRITE, + Pointing_direction_RW = attribute(access=AttrWriteType.READ_WRITE, dtype=((numpy.str,),), max_dim_x=3, max_dim_y=96, - fget=lambda self: self._hbat_pointing_direction_rw) + fget=lambda self: self._pointing_direction_rw) - HBAT_pointing_timestamp_R = attribute(access=AttrWriteType.READ, + Pointing_timestamp_R = attribute(access=AttrWriteType.READ, dtype=(numpy.double,), max_dim_x=96, - fget=lambda self: self._hbat_pointing_timestamp_r) + fget=lambda self: self._pointing_timestamp_r) - HBAT_tracking_enabled_R = attribute(access=AttrWriteType.READ, - doc="Whether the HBAT tile beam is updated periodically", + Tracking_enabled_R = attribute(access=AttrWriteType.READ, + doc="Whether the tile beam is updated periodically", dtype=numpy.bool, - fget=lambda self: self.HBAT_beam_tracker.is_alive()) + fget=lambda self: self.Beam_tracker.is_alive()) - HBAT_tracking_enabled_RW = attribute(access=AttrWriteType.READ_WRITE, - doc="Whether the HBAT tile beam should be updated periodically", + Tracking_enabled_RW = attribute(access=AttrWriteType.READ_WRITE, + doc="Whether the tile beam should be updated periodically", dtype=numpy.bool, - fget=lambda self: self._hbat_tracking_enabled_rw) + fget=lambda self: self._tracking_enabled_rw) # -------- # overloaded functions @@ -85,19 +85,19 @@ class TileBeam(beam_device): super().init_device() # thread to perform beam tracking - self.HBAT_beam_tracker = None + self.Beam_tracker = None @log_exceptions() def configure_for_initialise(self): super().configure_for_initialise() # Initialise pointing array data and attribute - self._hbat_pointing_timestamp_r = numpy.zeros(96, dtype=numpy.double) - self._hbat_pointing_direction_r = numpy.zeros((96,3), dtype="<U32") - self._hbat_pointing_direction_rw = numpy.array([["AZELGEO","0deg","90deg"]] * 96, dtype="<U32") + self._pointing_timestamp_r = numpy.zeros(96, dtype=numpy.double) + self._pointing_direction_r = numpy.zeros((96,3), dtype="<U32") + self._pointing_direction_rw = numpy.array([["AZELGEO","0deg","90deg"]] * 96, dtype="<U32") # Initialise tracking control - self._hbat_tracking_enabled_rw = True + self._tracking_enabled_rw = True # Set a reference of RECV device that is correlated to this BEAM device util = Util.instance() @@ -116,22 +116,22 @@ class TileBeam(beam_device): # absolute positions of each antenna element self.HBAT_antenna_positions = [HBAT_reference_itrf[tile] + HBAT_antenna_itrf_offsets[tile] for tile in range(96)] - # Create a thread object to update HBAT beam weights - self.HBAT_beam_tracker = BeamTracker(self) + # Create a thread object to update beam weights + self.Beam_tracker = BeamTracker(self) @log_exceptions() def configure_for_on(self): super().configure_for_on() # Start beam tracking thread - if self._hbat_tracking_enabled_rw: - self.HBAT_beam_tracker.start() + if self._tracking_enabled_rw: + self.Beam_tracker.start() @log_exceptions() def configure_for_off(self): - if self.HBAT_beam_tracker: + if self.Beam_tracker: # Stop thread object - self.HBAT_beam_tracker.stop() + self.Beam_tracker.stop() super().configure_for_off() @@ -139,28 +139,28 @@ class TileBeam(beam_device): # internal functions # -------- - def write_HBAT_pointing_direction_RW(self, value): - """ Setter method for attribute HBAT_pointing_direction_RW """ + def write_Pointing_direction_RW(self, value): + """ Setter method for attribute Pointing_direction_RW """ # verify whether values are valid for tile in range(96): if not self.HBAT_delay_calculators[tile].is_valid_direction(value[tile]): raise ValueError(f"Invalid direction: {value[tile]}") - self._hbat_pointing_direction_rw = value + self._pointing_direction_rw = value # force update across tiles if pointing changes - self.HBAT_beam_tracker.force_update() + self.Beam_tracker.force_update() logger.info("Pointing direction update requested") - def write_HBAT_tracking_enabled_RW(self, value): - self._hbat_tracking_enabled_rw = value + def write_Tracking_enabled_RW(self, value): + self._tracking_enabled_rw = value if value: - self.HBAT_beam_tracker.start() + self.Beam_tracker.start() else: - self.HBAT_beam_tracker.stop() + self.Beam_tracker.stop() - def _HBAT_delays(self, pointing_direction: numpy.array, timestamp: datetime.datetime = None): + def _delays(self, pointing_direction: numpy.array, timestamp: datetime.datetime = None): """ Calculate the delays (in seconds) based on the pointing list and the timestamp """ @@ -182,7 +182,7 @@ class TileBeam(beam_device): return delays - def _HBAT_set_pointing(self, pointing_direction: numpy.array, timestamp: datetime.datetime = None): + def _set_pointing(self, pointing_direction: numpy.array, timestamp: datetime.datetime = None): """ Uploads beam weights based on a given pointing direction 2D array (96 tiles x 3 parameters) """ @@ -193,7 +193,7 @@ class TileBeam(beam_device): timestamp = datetime.datetime.now() # Retrieve delays from casacore - delays = self._HBAT_delays(pointing_direction, timestamp) + delays = self._delays(pointing_direction, timestamp) # Convert delays into beam weights delays = delays.flatten() @@ -208,8 +208,8 @@ class TileBeam(beam_device): mask = self.recv_proxy.ANT_mask_RW.flatten() for rcu in range(96): if mask[rcu]: - self._hbat_pointing_direction_r[rcu] = pointing_direction[rcu] - self._hbat_pointing_timestamp_r[rcu] = timestamp.timestamp() + self._pointing_direction_r[rcu] = pointing_direction[rcu] + self._pointing_timestamp_r[rcu] = timestamp.timestamp() logger.info("Pointing direction updated") # -------- @@ -220,7 +220,7 @@ class TileBeam(beam_device): @DebugIt() @log_exceptions() @only_in_states(beam_device.DEFAULT_COMMAND_STATES) - def HBAT_delays(self, pointing_direction: numpy.array, timestamp: datetime.datetime = None): + def delays(self, pointing_direction: numpy.array, timestamp: datetime.datetime = None): """ Calculate the delays (in seconds) based on the pointing list and the timestamp TBD: antenna and reference positions will be retrieved from RECV and not stored as BEAM device properties @@ -233,7 +233,7 @@ class TileBeam(beam_device): pointing_direction = numpy.array(pointing_direction).reshape(96,3) - delays = self._HBAT_delays(pointing_direction, timestamp) + delays = self._delays(pointing_direction, timestamp) return delays.flatten() @@ -241,7 +241,7 @@ class TileBeam(beam_device): @DebugIt() @log_exceptions() @only_in_states(beam_device.DEFAULT_COMMAND_STATES) - def HBAT_set_pointing(self, pointing_direction: list, timestamp: datetime.datetime = None): + def set_pointing(self, pointing_direction: list, timestamp: datetime.datetime = None): """ Uploads beam weights based on a given pointing direction 2D array (96 tiles x 3 parameters) """ @@ -254,12 +254,12 @@ class TileBeam(beam_device): # Reshape the flatten input array pointing_direction = numpy.array(pointing_direction).reshape(96,3) - self._HBAT_set_pointing(pointing_direction, timestamp) + self._set_pointing(pointing_direction, timestamp) @command(dtype_in = DevString) @DebugIt() @only_in_states(beam_device.DEFAULT_COMMAND_STATES) - def HBAT_set_pointing_for_specific_time(self, parameters: DevString = None): + def set_pointing_for_specific_time(self, parameters: DevString = None): """ Uploads beam weights based on a given pointing direction 2D array (96 tiles x 3 parameters) for the given timestamp @@ -277,7 +277,7 @@ class TileBeam(beam_device): # Reshape the flatten pointing array pointing_direction = numpy.array(pointing_direction).reshape(96,3) - self._HBAT_set_pointing(pointing_direction, timestamp) + self._set_pointing(pointing_direction, timestamp) # ---------- @@ -313,7 +313,7 @@ class BeamTracker(): return self.done = False - self.thread = Thread(target=self._update_HBAT_pointing_direction, name=f"BeamTracker of {self.device.get_name()}") + self.thread = Thread(target=self._update_pointing_direction, name=f"BeamTracker of {self.device.get_name()}") self.thread.start() logger.info("BeamTracking thread started") @@ -359,13 +359,13 @@ class BeamTracker(): now = datetime.datetime.now().timestamp() # Computes the left seconds before the next update - next_update_in = self.device.HBAT_beam_tracking_interval - (now % self.device.HBAT_beam_tracking_interval) + next_update_in = self.device.Beam_tracking_interval - (now % self.device.Beam_tracking_interval) # Computes the needed sleep time before the next update - sleep_time = next_update_in - self.device.HBAT_beam_tracking_preparation_period + sleep_time = next_update_in - self.device.Beam_tracking_preparation_period # If sleep time is negative, add the tracking interval for the next update if sleep_time < 0: - return sleep_time + self.device.HBAT_beam_tracking_interval + return sleep_time + self.device.Beam_tracking_interval else: return sleep_time @@ -375,14 +375,14 @@ class BeamTracker(): @log_exceptions() @fault_on_error() - def _update_HBAT_pointing_direction(self): + def _update_pointing_direction(self): """ Updates the beam weights using a fixed interval of time """ # Check if flag beamtracking is true with self.update_lock: while not self.done: self.stale_pointing = False - self.device._HBAT_set_pointing(self.device._hbat_pointing_direction_rw, datetime.datetime.now()) + self.device._set_pointing(self.device._pointing_direction_rw, datetime.datetime.now()) # sleep until the next update, or when interrupted (this releases the lock, allowing for notification) # note that we need wait_for as conditions can be triggered multiple times in succession diff --git a/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_tilebeam.py b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_tilebeam.py index c6935e256caa035611d508922fd8dcde2937ac4a..decd1678b5332bd0c45c70ae3527c1c289cd6f6b 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_tilebeam.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/default/devices/test_device_tilebeam.py @@ -39,16 +39,16 @@ class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase): recv_proxy.set_defaults() return recv_proxy - def test_HBAT_delays_dims(self): - """Verify HBAT delays are retrieved with correct dimensions""" + def test_delays_dims(self): + """Verify delays are retrieved with correct dimensions""" self.setup_recv_proxy() # setup BEAM self.proxy.warm_boot() - # verify HBAT_delays method returns the correct dimensions - HBAT_delays = self.proxy.HBAT_delays(self.pointing_direction) - self.assertEqual(1536, len(HBAT_delays)) # 96*16 + # verify delays method returns the correct dimensions + delays = self.proxy.delays(self.pointing_direction) + self.assertEqual(1536, len(delays)) # 96*16 def test_set_pointing(self): """Verify if set pointing procedure is correctly executed""" @@ -56,32 +56,32 @@ class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase): # setup BEAM self.proxy.warm_boot() - self.proxy.HBAT_tracking_enabled_RW = False + self.proxy.Tracking_enabled_RW = False # Verify attribute is present (all zeros if never used before) - HBAT_delays_r1 = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) - self.assertIsNotNone(HBAT_delays_r1) + delays_r1 = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) + self.assertIsNotNone(delays_r1) time.sleep(3) # Verify writing operation does not lead to errors - self.proxy.HBAT_set_pointing(self.pointing_direction) # write values to RECV - HBAT_delays_r2 = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) + self.proxy.set_pointing(self.pointing_direction) # write values to RECV + delays_r2 = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) - self.assertIsNotNone(HBAT_delays_r2) + self.assertIsNotNone(delays_r2) # Verify delays changed (to be discussed) - #self.assertFalse((HBAT_delays_r1==HBAT_delays_r2).all()) + #self.assertFalse((delays_r1==delays_r2).all()) def test_pointing_to_zenith(self): # setup RECV as well recv_proxy = self.setup_recv_proxy() self.proxy.warm_boot() - self.proxy.HBAT_tracking_enabled_RW = False + self.proxy.Tracking_enabled_RW = False # Point to Zenith - self.proxy.HBAT_set_pointing(numpy.array([["AZELGEO","0deg","90deg"]] * 96).flatten()) + self.proxy.set_pointing(numpy.array([["AZELGEO","0deg","90deg"]] * 96).flatten()) calculated_HBAT_delay_steps = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) @@ -94,10 +94,10 @@ class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase): recv_proxy = self.setup_recv_proxy() self.proxy.warm_boot() - self.proxy.HBAT_tracking_enabled_RW = False + self.proxy.Tracking_enabled_RW = False # point at north on the horizon - self.proxy.HBAT_set_pointing(["AZELGEO","0deg","0deg"] * 96) + self.proxy.set_pointing(["AZELGEO","0deg","0deg"] * 96) # obtain delays of the X polarisation of all the elements of the first tile north_beam_delay_steps = recv_proxy.HBAT_BF_delay_steps_RW[0].reshape(2,4,4)[0] @@ -107,7 +107,7 @@ class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase): for angle in (90,180,270): # point at angle degrees (90=E, 180=S, 270=W) - self.proxy.HBAT_set_pointing(["AZELGEO",f"{angle}deg","0deg"] * 96) + self.proxy.set_pointing(["AZELGEO",f"{angle}deg","0deg"] * 96) # obtain delays of the X polarisation of all the elements of the first tile angled_beam_delay_steps = recv_proxy.HBAT_BF_delay_steps_RW[0].reshape(2,4,4)[0] @@ -121,7 +121,7 @@ class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase): recv_proxy = self.setup_recv_proxy() self.proxy.warm_boot() - self.proxy.HBAT_tracking_enabled_RW = False + self.proxy.Tracking_enabled_RW = False # Point to LOFAR 1 ref pointing (0.929342, 0.952579, J2000) pointings = numpy.array([["J2000", "0.929342rad", "0.952579rad"]] * 96).flatten() @@ -134,7 +134,7 @@ class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase): } json_string = json.dumps(parameters, cls=NumpyEncoder) - self.proxy.HBAT_set_pointing_for_specific_time(json_string) + self.proxy.set_pointing_for_specific_time(json_string) calculated_HBAT_delay_steps = numpy.array(recv_proxy.read_attribute('HBAT_BF_delay_steps_RW').value) @@ -154,12 +154,12 @@ class TestDeviceTileBeam(AbstractTestBases.TestDeviceBase): self.proxy.warm_boot() # check if we're really tracking - self.assertTrue(self.proxy.HBAT_tracking_enabled_R) + self.assertTrue(self.proxy.Tracking_enabled_R) # point somewhere new_pointings = [("J2000",f"{tile}deg","0deg") for tile in range(96)] - self.proxy.HBAT_pointing_direction_RW = new_pointings + self.proxy.Pointing_direction_RW = new_pointings # check pointing - self.assertListEqual(new_pointings, list(self.proxy.HBAT_pointing_direction_R)) + self.assertListEqual(new_pointings, list(self.proxy.Pointing_direction_R)) diff --git a/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/test_recv_cluster.py b/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/test_recv_cluster.py index 898ca83892593852472387b9a489a4a51cc0204c..5235cfcaa783bda13b49dd90b144b3197c7fad29 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/test_recv_cluster.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/recv_cluster/test_recv_cluster.py @@ -59,7 +59,7 @@ class TestRecvCluster(base.IntegrationTestCase): for _i in range(25): start_time = time.monotonic_ns() for proxy in beam_proxies: - proxy.HBAT_set_pointing(self.pointing_direction) + proxy.set_pointing(self.pointing_direction) stop_time = time.monotonic_ns() results.append(stop_time - start_time) diff --git a/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py b/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py index 905c5a3b12f43a85562c32f1e509fe5e3a1e7baf..5677b32c70f175ff74fff293e58bb1c535689a2c 100644 --- a/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py +++ b/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py @@ -33,11 +33,11 @@ class TestBeamDevice(base.TestCase): with DeviceTestContext(tilebeam.TileBeam, process=True, timeout=10) as proxy: proxy.initialise() self.assertEqual(96, len(proxy.read_attribute( - "HBAT_pointing_direction_R").value)) + "Pointing_direction_R").value)) def test_get_pointing_timestamps(self): """Verify can read timestamps attribute and length matches without err""" with DeviceTestContext(tilebeam.TileBeam, process=True, timeout=10) as proxy: proxy.initialise() self.assertEqual(96, len(proxy.read_attribute( - "HBAT_pointing_timestamp_R").value)) + "Pointing_timestamp_R").value))