Commit 641100cc authored by Marco Buttu's avatar Marco Buttu
Browse files

Changed the startUpdating() interface in order to manage the galactic corrections

parent 39a237a5
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -103,13 +103,17 @@ module Receivers {
         * @param sector the antenna sector (NORTH or SOUTH)
         * @param sector the antenna sector (NORTH or SOUTH)
         * @param azimuth the azimuth (radians) at the beginning of the scan
         * @param azimuth the azimuth (radians) at the beginning of the scan
         * @param elevation the elevation (radians) at the beginning of the scan
         * @param elevation the elevation (radians) at the beginning of the scan
         * @param ra the RA (radians) at the beginning of the scan
         * @param dec the DEC (radians) at the beginning of the scan
         * @throw ComponentErrors::ComponentErrorsEx
         * @throw ComponentErrors::ComponentErrorsEx
         */
         */
        void startUpdating(
        void startUpdating(
            in Management::TScanAxis axis, 
            in Management::TScanAxis axis, 
            in Antenna::TAzimuthSection sector,
            in Antenna::TAzimuthSection sector,
            in double azimuth,
            in double azimuth,
            in double elevation
            in double elevation,
            in double ra,
            in double dec
        ) raises (ComponentErrors::ComponentErrorsEx);
        ) raises (ComponentErrors::ComponentErrorsEx);




+2 −2
Original line number Original line Diff line number Diff line
@@ -348,10 +348,10 @@ class DewarPositionerImpl(POA, cc, services, lcycle):
    def getScanInfo(self):
    def getScanInfo(self):
        return ScanInfo(**self.positioner.getScanInfo())
        return ScanInfo(**self.positioner.getScanInfo())


    def startUpdating(self, axis, sector, az, el):
    def startUpdating(self, axis, sector, az, el, ra, dec):
        logger.logNotice('starting the derotator position updating')
        logger.logNotice('starting the derotator position updating')
        try:
        try:
            self.positioner.startUpdating(axis, sector, az, el)
            self.positioner.startUpdating(axis, sector, az, el, ra, dec)
        except PositionerError, ex:
        except PositionerError, ex:
            logger.logError(ex.message)
            logger.logError(ex.message)
            exc = ComponentErrorsImpl.OperationErrorExImpl()
            exc = ComponentErrorsImpl.OperationErrorExImpl()
+15 −3
Original line number Original line Diff line number Diff line
@@ -10,10 +10,22 @@ class PosGenerator(object):


    def __init__(self, zdtimeout=5):
    def __init__(self, zdtimeout=5):
        self.zdtimeout = zdtimeout # Timeout in case of zero division error
        self.zdtimeout = zdtimeout # Timeout in case of zero division error
        self.mapping = {
                'parallactic': {
                    'getAngleFunction': PosGenerator.getParallacticAngle, 
                    'coordinateFrame': 'horizontal'
                },
                'galacticParallactic': {
                    'getAngleFunction': PosGenerator.getGalacticParallacticAngle, 
                    'coordinateFrame': 'equatorial'
                },
        }
      
      
    def goto(self, iStaticPos):
    def goto(self, iStaticPos):
        yield iStaticPos
        yield iStaticPos


    # TODO: refactoring required, in order to put all the parallactic and
    # galacticParallactic common code in one place
    def parallactic(self, source, siteInfo):
    def parallactic(self, source, siteInfo):
        """Return the parallactic angle"""
        """Return the parallactic angle"""
        try:
        try:
@@ -52,7 +64,7 @@ class PosGenerator(object):
                logger.logNotice('%s: %s' %(raeson, ex.message))
                logger.logNotice('%s: %s' %(raeson, ex.message))
                raise PosGeneratorError(raeson)
                raise PosGeneratorError(raeson)


    def galactic_parallactic(self, source, siteInfo):
    def galacticParallactic(self, source, siteInfo):
        """Return the galactic parallactic angle"""
        """Return the galactic parallactic angle"""
        try:
        try:
            latitude = siteInfo['latitude']
            latitude = siteInfo['latitude']
@@ -70,7 +82,7 @@ class PosGenerator(object):
                coordinates = source.getApparentCoordinates(t) # Values in radians
                coordinates = source.getApparentCoordinates(t) # Values in radians
                az, el, ra, dec = coordinates[:4] 
                az, el, ra, dec = coordinates[:4] 
                p = PosGenerator.getParallacticAngle(latitude, az, el)
                p = PosGenerator.getParallacticAngle(latitude, az, el)
                pg = PosGenerator.getGalacticParallacticAngle(ra, dec)
                pg = PosGenerator.getGalacticParallacticAngle(latitude, ra, dec)
                yield p + pg
                yield p + pg
                last_zerodiv_time = datetime.datetime.now()
                last_zerodiv_time = datetime.datetime.now()
            except ZeroDivisionError:
            except ZeroDivisionError:
@@ -98,7 +110,7 @@ class PosGenerator(object):
        return degrees(p)
        return degrees(p)


    @staticmethod
    @staticmethod
    def getGalacticParallacticAngle(ra, dec):
    def getGalacticParallacticAngle(latitude, ra, dec):
        """Arguments in radians"""
        """Arguments in radians"""
        # North celestial pole coordinates in equatorial celestial frame (j200)
        # North celestial pole coordinates in equatorial celestial frame (j200)
        # ncp = ('12 51 26.28', '27 07 41.7') 
        # ncp = ('12 51 26.28', '27 07 41.7') 
+12 −6
Original line number Original line Diff line number Diff line
@@ -141,7 +141,7 @@ class Positioner(object):
                    %(self.control.target, self.device.getMinLimit(), self.device.getMaxLimit()))
                    %(self.control.target, self.device.getMinLimit(), self.device.getMaxLimit()))




    def startUpdating(self, axis, sector, az, el):
    def startUpdating(self, axis, sector, az, el, ra, dec):
        sectors = ('ANT_NORTH', 'ANT_SOUTH')
        sectors = ('ANT_NORTH', 'ANT_SOUTH')
        try:
        try:
            Positioner.generalLock.acquire()
            Positioner.generalLock.acquire()
@@ -182,12 +182,18 @@ class Positioner(object):
                        self._start(self.posgen.goto, position)
                        self._start(self.posgen.goto, position)
                    else:
                    else:
                        posgen = getattr(self.posgen, functionName) 
                        posgen = getattr(self.posgen, functionName) 
                        angle_mapping = self.posgen.mapping[functionName]
                        getAngleFunction = self.posgen.mapping[functionName]['getAngleFunction']
                        coordinateFrame = self.posgen.mapping[functionName]['coordinateFrame']
                        lat = self.siteInfo['latitude']
                        try:
                        try:
                            iParallacticPos = PosGenerator.getParallacticAngle(
                            if coordinateFrame == 'horizontal':
                                self.siteInfo['latitude'], 
                                iParallacticPos = getAngleFunction(lat, az, el)
                                az, 
                            elif coordinateFrame == 'equatorial':
                                el
                                iParallacticPos = getAngleFunction(lat, ra, dec)
                            )
                            else:
                                raise PositionerError('coordinate frame %s unknown' %coordinateFrame)

                        except ZeroDivisionError:
                        except ZeroDivisionError:
                            raise NotAllowedError('zero division error computing p(%.2f, %.2f)' %(az, el))
                            raise NotAllowedError('zero division error computing p(%.2f, %.2f)' %(az, el))


+4 −6
Original line number Original line Diff line number Diff line
@@ -12,16 +12,14 @@ from DewarPositioner.cdbconf import CDBConf


class GetPositionFromHistoryTest(unittest2.TestCase):
class GetPositionFromHistoryTest(unittest2.TestCase):


    @classmethod
    def setUp(self):
    def setUpClass(self):
        client = PySimpleClient()
        client = PySimpleClient()
        self.positioner = client.getComponent('RECEIVERS/DewarPositioner')
        self.positioner = client.getComponent('RECEIVERS/DewarPositioner')
        self.positioner.setup('KKG')
        self.positioner.setup('KKG')
        self.cmdPos = 0.8
        self.cmdPos = 0.8
        time.sleep(0.2)
        time.sleep(0.2)


    @classmethod
    def tearDown(self):
    def tearDownClass(self):
        self.positioner.park()
        self.positioner.park()
        time.sleep(0.2)
        time.sleep(0.2)


@@ -56,7 +54,7 @@ class GetPositionFromHistoryTest(unittest2.TestCase):
        """Verify the position at a time greater then the latest one"""
        """Verify the position at a time greater then the latest one"""
        # Change the position (it was 0 after the park())
        # Change the position (it was 0 after the park())
        self.positioner.setPosition(self.cmdPos)
        self.positioner.setPosition(self.cmdPos)
        time.sleep(1)
        time.sleep(2)
        # Verify the position we get at 60 seconds in the future
        # Verify the position we get at 60 seconds in the future
        t = getTimeStamp().value + 60*10**7
        t = getTimeStamp().value + 60*10**7
        p = self.positioner.getPositionFromHistory(t)
        p = self.positioner.getPositionFromHistory(t)
@@ -66,7 +64,7 @@ class GetPositionFromHistoryTest(unittest2.TestCase):
        """Verify the position at time 0"""
        """Verify the position at time 0"""
        # Change the position (it was 0 after the park())
        # Change the position (it was 0 after the park())
        self.positioner.setPosition(self.cmdPos)
        self.positioner.setPosition(self.cmdPos)
        time.sleep(1)
        time.sleep(2)
        # Verify the position we get at 60 seconds in the future
        # Verify the position we get at 60 seconds in the future
        p = self.positioner.getPositionFromHistory(0)
        p = self.positioner.getPositionFromHistory(0)
        self.assertAlmostEqual(p, self.cmdPos, places=1)
        self.assertAlmostEqual(p, self.cmdPos, places=1)
Loading