Beispiel #1
0
 def GST(self):
     """
     Mean Greenwhich Sidereal Time
     """
     lst = self.LST()
     gst = (lst - self["longitude"].toH()) % Coord.fromH(24)
     return gst
Beispiel #2
0
    def _valueAt(self, fn, *coords):
        """
        Accepts a function callback and variable coords.

        If len(coords) == 1 convert (from tuple or Position) to decimal degress.
        If len(coords) == 2, convert (from number or Coord) to decimal degress
        """

        assert len(coords) >= 1
        assert self._wcs is not None

        if len(coords) == 2:
            c1 = Coord.fromH(coords[0]).D
            c2 = Coord.fromD(coords[1]).D
        else:
            if isinstance(coords[0], Position):
                c1, c2 = coords[0].dd()
            else:  # assumes as tuple
                c1, c2 = coords[0]

        value = fn(N.array([[c1, c2]]), 1)

        if len(value) >= 1:
            return tuple(value[0])
        else:
            raise WCSNotFoundException("Couldn't convert coordinates.")
Beispiel #3
0
    def getRa(self):  # converted to Astelco

        ret = self._tpl.getobject('POSITION.EQUATORIAL.RA_J2000')
        if ret:
			self._ra = Coord.fromH(ret)
        self.log.debug('Ra: %9.5f'%float(ret))
        return self._ra
 def GST(self):
     """
     Mean Greenwhich Sidereal Time
     """
     lst = self.LST()
     gst = (lst - self["longitude"].toH()) % Coord.fromH(24)
     return gst
Beispiel #5
0
    def _valueAt(self, fn, *coords):
        """
        Accepts a function callback and variable coords.

        If len(coords) == 1 convert (from tuple or Position) to decimal degress.
        If len(coords) == 2, convert (from number or Coord) to decimal degress
        """

        assert len(coords) >= 1
        assert self._wcs is not None

        if len(coords) == 2:
            c1 = Coord.fromH(coords[0]).D
            c2 = Coord.fromD(coords[1]).D
        else:
            if isinstance(coords[0], Position):
                c1, c2 = coords[0].dd()
            else:  # assumes as tuple
                c1, c2 = coords[0]

        value = fn(N.array([[c1, c2]]), 1)

        if len(value) >= 1:
            return tuple(value[0])
        else:
            raise WCSNotFoundException("Couldn't convert coordinates.")
Beispiel #6
0
    def fromRaDec(ra, dec, epoch=Epoch.J2000):

        try:
            if type(ra) is str:
                ra = Coord.fromHMS(ra)
            elif isinstance(ra, Coord):
                ra = ra.toHMS()
            else:
                try:
                    ra = Coord.fromH(float(ra))
                    ra = ra.toHMS()
                except ValueError:
                    raise ValueError(
                        "Invalid RA coordinate type %s. Expected numbers, strings or Coords."
                        % str(type(ra)))

            Position._checkRange(float(ra), 0, 360)

        except ValueError as e:
            raise ValueError("Invalid RA coordinate %s" % str(ra))
        except PositionOutsideLimitsError:
            raise ValueError(
                "Invalid RA range %s. Must be between 0-24 hours or 0-360 deg."
                % str(ra))

        try:
            if type(dec) is str:
                dec = Coord.fromDMS(dec)
            elif isinstance(dec, Coord):
                dec = dec.toDMS()
            else:
                try:
                    dec = Coord.fromD(float(dec))
                    dec = dec.toDMS()
                except ValueError:
                    raise ValueError(
                        "Invalid DEC coordinate type %s. Expected numbers, strings or Coords."
                        % str(type(dec)))

            Position._checkRange(float(dec), -90, 360)

        except ValueError as e:
            raise ValueError("Invalid DEC coordinate %s" % str(dec))
        except PositionOutsideLimitsError:
            raise ValueError(
                "Invalid DEC range %s. Must be between 0-360 deg or -90 - +90 deg."
                % str(dec))

        return Position((ra, dec), system=System.CELESTIAL, epoch=epoch)
Beispiel #7
0
    def test_park(self):

        # FIXME: make a real test.
        raise SkipTest()

        def printPosition():
            print self.tel.getPositionRaDec(), self.tel.getPositionAltAz()
            sys.stdout.flush()

        print

        ra = self.tel.getRa()
        dec = self.tel.getDec()

        print "current position:", self.tel.getPositionRaDec()
        print "moving to:", (ra - "01 00 00"), (dec - "01 00 00")

        self.tel.slewToRaDec(
            Position.fromRaDec(ra - Coord.fromH(1), dec - Coord.fromD(1)))

        for i in range(10):
            printPosition()
            time.sleep(0.5)

        print "parking..."
        sys.stdout.flush()
        self.tel.park()

        t0 = time.time()
        wait = 30

        for i in range(10):
            printPosition()
            time.sleep(0.5)

        while time.time() < t0 + wait:
            print "\rwaiting ... ",
            sys.stdout.flush()
            time.sleep(1)

        print "unparking..."
        sys.stdout.flush()

        self.tel.unpark()

        for i in range(10):
            printPosition()
            time.sleep(0.5)
Beispiel #8
0
    def test_park (self):
        
        # FIXME: make a real test.
        raise SkipTest()

        def printPosition():
            print self.tel.getPositionRaDec(), self.tel.getPositionAltAz()
            sys.stdout.flush()
            
        print

        ra  = self.tel.getRa()
        dec = self.tel.getDec()

        print "current position:", self.tel.getPositionRaDec()
        print "moving to:", (ra-"01 00 00"), (dec-"01 00 00")

        self.tel.slewToRaDec(Position.fromRaDec(ra-Coord.fromH(1), dec-Coord.fromD(1)))

        for i in range(10):
            printPosition()
            time.sleep(0.5)

        print "parking..."
        sys.stdout.flush()
        self.tel.park()

        t0 = time.time()
        wait = 30

        for i in range(10):
            printPosition()
            time.sleep(0.5)
       
        while time.time() < t0+wait:
            print "\rwaiting ... ",
            sys.stdout.flush()
            time.sleep(1)

        print "unparking..."
        sys.stdout.flush()

        self.tel.unpark()

        for i in range(10):
            printPosition()
            time.sleep(0.5)
Beispiel #9
0
    def test_slew_abort(self):

        site = self.manager.getProxy("/Site/0")

        # go to know position
        self.tel.slewToRaDec(Position.fromRaDec(site.LST(), site["latitude"]))
        last = self.tel.getPositionRaDec()

        # clear event checkings
        FiredEvents = {}

        # drift it
        dest = Position.fromRaDec(last.ra + Coord.fromH(1),
                                  last.dec + Coord.fromD(10))
        real_dest = None

        @callback(self.manager)
        def slewBeginClbk(target):
            global real_dest
            real_dest = target

        @callback(self.manager)
        def slewCompleteClbk(position, status):
            assert last.ra < position.ra < real_dest.ra
            assert last.dec < position.dec < real_dest.dec

        self.tel.slewBegin += slewBeginClbk
        self.tel.slewComplete += slewCompleteClbk

        # async slew
        def slew():
            tel = self.manager.getProxy(self.TELESCOPE)
            tel.slewToRaDec(dest)

        pool = ThreadPool()
        pool.queueTask(slew)

        # wait thread to be scheduled
        time.sleep(2)

        # abort and test
        self.tel.abortSlew()

        pool.joinAll()

        # event checkings
        self.assertEvents(TelescopeStatus.ABORTED)
Beispiel #10
0
    def test_slew_abort (self):

        site = self.manager.getProxy("/Site/0")

        # go to know position
        self.tel.slewToRaDec(Position.fromRaDec(site.LST(), site["latitude"]))
        last = self.tel.getPositionRaDec()

        # clear event checkings
        FiredEvents = {}

        # drift it
        dest = Position.fromRaDec(last.ra+Coord.fromH(1), last.dec+Coord.fromD(10))
        real_dest = None

        @callback(self.manager)
        def slewBeginClbk(target):
            global real_dest
            real_dest = target

        @callback(self.manager)
        def slewCompleteClbk(position, status):
            assert last.ra  < position.ra  < real_dest.ra
            assert last.dec < position.dec < real_dest.dec

        self.tel.slewBegin += slewBeginClbk
        self.tel.slewComplete += slewCompleteClbk

        # async slew
        def slew():
            tel = self.manager.getProxy(self.TELESCOPE)
            tel.slewToRaDec(dest)

        pool = ThreadPool()
        pool.queueTask(slew)

        # wait thread to be scheduled
        time.sleep(2)

        # abort and test
        self.tel.abortSlew()

        pool.joinAll()

        # event checkings
        self.assertEvents(TelescopeStatus.ABORTED)
    def fromRaDec (ra, dec, epoch=Epoch.J2000):

        try:
            if type(ra) == StringType:
                ra = Coord.fromHMS(ra)
            elif isinstance(ra, Coord):
                ra = ra.toHMS()
            else:
                try:
                    ra = Coord.fromH(float(ra))
                    ra = ra.toHMS()
                except ValueError:
                    raise ValueError("Invalid RA coordinate type %s. Expected numbers, strings or Coords." % str(type(ra)))

            Position._checkRange(float(ra), 0, 360)

        except ValueError, e:
            raise ValueError("Invalid RA coordinate %s" % str(ra))
Beispiel #12
0
    def test_sync (self):

        # get current position, drift the scope, and sync on the first
        # position (like done when aligning the telescope).

        real = self.tel.getPositionRaDec()

        @callback(self.manager)
        def syncCompleteClbk(position):
            assert position.ra == real.ra
            assert position.dec == real.dec

        self.tel.syncComplete += syncCompleteClbk

        # drift to "real" object coordinate
        drift = Position.fromRaDec(real.ra+Coord.fromH(1), real.dec+Coord.fromD(1))
        self.tel.slewToRaDec(drift)

        self.tel.syncRaDec(real)

        time.sleep(2)
Beispiel #13
0
    def test_sync (self):

        # get current position, drift the scope, and sync on the first
        # position (like done when aligning the telescope).

        real = self.tel.getPositionRaDec()

        @callback(self.manager)
        def syncCompleteClbk(position):
            assert position.ra == real.ra
            assert position.dec == real.dec

        self.tel.syncComplete += syncCompleteClbk

        # drift to "real" object coordinate
        drift = Position.fromRaDec(real.ra+Coord.fromH(1), real.dec+Coord.fromD(1))
        self.tel.slewToRaDec(drift)

        self.tel.syncRaDec(real)

        time.sleep(2)
 def getPositionRaDec(self):
     self._telescope.GetRaDec()
     return Position.fromRaDec(Coord.fromH(self._telescope.dRa),
                               Coord.fromD(self._telescope.dDec),
                               epoch=Epoch.NOW).toEpoch(Epoch.J2000)
Beispiel #15
0
    def getTargetRa(self):  # converted to Astelco
        ret = self._tpl.getobject('OBJECT.EQUATORIAL.RA')

        return Coord.fromH(ret)
Beispiel #16
0
 def getPositionRaDec(self):
     self._telescope.GetRaDec()
     return Position.fromRaDec(Coord.fromH(self._telescope.dRa), Coord.fromD(self._telescope.dDec))
Beispiel #17
0
 def getRa(self):
     self._telescope.GetRaDec()
     return Coord.fromH(self._telescope.dRa)
Beispiel #18
0
 def getLocalSiderealTime(self):  # converted to Astelco
     ret = self._tpl.getobject('POSITION.LOCAL.SIDEREAL')
     c = Coord.fromH(ret)
     return dt.datetime.time(c.HMS[1:-1])
 def getPositionRaDec(self):
     self._telescope.GetRaDec()
     return Position.fromRaDec(Coord.fromH(self._telescope.dRa), Coord.fromD(self._telescope.dDec),
                               epoch=Epoch.NOW).toEpoch(Epoch.J2000)
 def getRa(self):
     self._telescope.GetRaDec()
     return Coord.fromH(self._telescope.dRa)
 def getCurrentTrackingRate(self):
     raTrack = Coord.fromH(self._telescope.dRaTrackingRate)
     decTrack = Coord.fromR(self._telescope.dDecTrackingRate)
     return (raTrack.toHMS(), decTrack.toDMS())
Beispiel #22
0
 def getPositionRaDec(self):
     self._telescope.GetRaDec()
     return Position.fromRaDec(Coord.fromH(self._telescope.dRa),
                               Coord.fromD(self._telescope.dDec))
 def getRa(self):
     return Coord.fromH(self._ascom.RightAscension)