Skip to content
Snippets Groups Projects
Select Git revision
  • ba2ac6ddac64361ecb11f4d724a278e12816409b
  • master default protected
  • add-mwa-itrf-interface
  • rtd-ubuntu24-plucky
  • ast-1644-temp-fix
  • ast-1600-fix-beam-for-meerkat-ska-mid
  • readthedocs-c++17
  • mwa_python_wrapper
  • ast-1384-remove-element-index-argument
  • ast-1509-fix-polarization-orientation-in-gridded-response
  • add-test-for-squared-mueller-matrices
  • 1493-extend-python-bindings
  • ast-1493-implement-response-dishpoint-1
  • ast-1325-prototype-ska-beam-model-interface
  • ast-1416-oskar-ska-sdp-func-1
  • ast-1386-create-default-element
  • ast-1384-fix-sorted-frequencies-check-sphericalharmonicsresponse-1
  • ast-1111-add-vector-bindings
  • ast-973-add-test-for-lobes-coefficients
  • ast-645-add-beam-normalisation-mode-preapplied
  • disable-element-beam-1
  • v0.7.1
  • v0.7.0
  • v0.6.2
  • v0.6.1
  • v0.6.0
  • v0.5.8
  • v0.5.7
  • v0.5.6
  • v0.5.5
  • v0.5.4
  • v0.5.3
  • v0.5.2
  • v0.5.1
  • v0.4.0
  • v0.3.1
  • v0.3.0
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
41 results

Element.cc

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    observation.py 2.07 KiB
    # -*- coding: utf-8 -*-
    #
    # This file is part of the LOFAR2.0 Station Control project.
    #
    # Distributed under the terms of the APACHE license.
    # See LICENSE.txt for more info.
    
    """
    Contains class for pythonic interface with observations
    """
    
    from json import dumps
    import logging
    
    from tango import DeviceProxy
    
    logger = logging.getLogger()
    
    
    class Observation:
        """
        This class provides a pythonic interface to the
        ObservationControl and Observation devices on a station.
        """
    
        def __init__(
            self,
            specification: dict,
            host: str = "databaseds.tangonet:10000",
            station="STAT",
        ):
    
            # create device proxies to station at "host"
            self._observation_control_dev = DeviceProxy(
                f"tango://{host}/{station}/ObservationControl/1"
            )
            self.host = host
            self.station = station
    
            # convert specification dict to json
            self._specification = dumps(specification)
    
            # get the ID
            self._id = int(specification["observation_id"])
    
        def observation_id(self) -> int:
            """
            Returns the observation ID of this observation
            """
            return self._id
    
        def start(self):
            """
            Starts this observation
            """
            self._observation_control_dev.start_observation(self._specification)
    
        def abort(self):
            """
            Aborts this observation
            """
            self._observation_control_dev.stop_observation(self._id)
    
        def observation_proxy(self):
            """
            Returns the DeviceProxy of this observation
            """
            # return a proxy to the correct Observation device on the station (
            # "STAT/Observation/{observation_id}")
            return DeviceProxy(f"tango://{self.host}/{self.station}/Observation/{self._id}")
    
        def is_running(self):
            """
            Returns whether this observation is currently running or not
            """
            # return whether the observation is still running (
            # ObservationControl.is_observation_running command)
            return self._observation_control_dev.is_observation_running(self._id)