go_to.py 2 KB
Newer Older
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python

from astropy.coordinates import SkyCoord, Galactic, FK5
import astropy.units as u
import numpy as np
from telescope import Telescope
import sys
from argparse import ArgumentParser
import time

dt = Telescope(consoleHost='localhost', setmode='J2000')
print("Connected to telescope")


if __name__ == "__main__":
    parser = ArgumentParser(description="Point the telescope somewhere")
    parser.add_argument("-n", "--name", help="Named source", type=str)
    parser.add_argument("-l", help="Galactic longitude (deg)", type=float)
    parser.add_argument("-b", help="Galactic latitude (deg)", type=float)
    parser.add_argument("--ra", help="Right ascension (deg)", type=float)
    parser.add_argument("--dec", help="Declination (deg)", type=float)
    parser.add_argument("--scan", help="Scan?", action="store_true")
    parser.add_argument("--scansize", help="Scan size (deg)", type=float, default=5.0)

    args = parser.parse_args()

    if args.name is not None:
        setpoint = SkyCoord.from_name(args.name)
    elif (args.l is not None) and (args.b is not None):
        setpoint = SkyCoord(l=args.l*u.deg, b=args.b*u.deg, frame=Galactic).transform_to(FK5)
    elif (args.ra is not None) and (args.dec is not None):
        setpoint = dt.setRaDec(SkyCoord(ra=args.ra, dec=args.dec))

    if args.scan:
        scansize = args.scansize
        centersetpoint = setpoint
        sign = -1
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
38
39
        dt.setRaDec(setpoint)
        dt.setOffset((0,0))
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
40
        dt.waitUntilThere()
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
41
        time.sleep(1)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
42
        
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
43
        for offset_el in np.arange(-scansize, scansize+0.0001, 0.5) * u.deg:
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
44
45
46
            sign *= -1
            dt.waitUntilThere(tolerance=0.1*u.deg)
            time.sleep(2)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
47
48
49
            for offset_az in np.arange(-sign*scansize, sign*(scansize+0.0001), sign*1.5) * u.deg:
                dt.setOffset((offset_az, offset_el))
                print(f"{offset_az:.1f}, {offset_el:.1f}")
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
50
                time.sleep(1)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
51
                dt.waitUntilThere(tolerance=1*u.deg)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
52
53
    else:
        dt.setRaDec(setpoint)