Unverified Commit f5c4cd26 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Add hackish go-to script

parent 1cd54fd0
#!/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
def wait_until_there(l, b, tolerance=0.01*u.deg):
diff = 2 * tolerance
while diff > tolerance:
pos = dt.getRaDec(waitForUpdate=True).transform_to(Galactic)
diff = max(abs(l-pos.l), abs(b-pos.b))
newl = None
for offset_b in np.arange(-scansize, scansize+0.0001, 0.5) * u.deg:
sign *= -1
if newl is not None:
wait_until_there(newl, newb, tolerance=0.1*u.deg)
for offset_l in np.arange(-sign*scansize, sign*(scansize+0.0001), sign*1.5) * u.deg:
newl, newb = centersetpoint.galactic.l + offset_l, centersetpoint.galactic.b + offset_b
setpoint = SkyCoord(l=newl, b=newb, frame=Galactic).transform_to(FK5)
print(f"{newl.deg:.1f}, {newb.deg:.1f}")
wait_until_there(newl, newb, tolerance=.8*u.deg)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment