Commit 6d63eb89 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Fix setRaDec

parent d7e05bd6
......@@ -10,6 +10,8 @@ import os.path
config = ConfigParser()
config.readfp(open(os.path.join(os.path.dirname(__file__), 'telescope.ini')))
class telescope():
def __init__(self, setmode=None, consoleHost=None):
......@@ -32,6 +34,13 @@ class telescope():
# Initialize offset socket for all modes where output is desired
if self.setmode is not None:
self.offsetsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def getRaDec(self):
Get the J200 coordinates of the telescope as an astropy SkyCoord
......@@ -58,29 +67,29 @@ class telescope():
(ra, dec) = setpoint.to_string('hmsdms').split()
cmd = bytes(ra + "\t" + dec[1:] + "\n", 'UTF-8')
cmd = '{:s}\t{:s}\n'.format(ra, dec).decode('UTF-8')'J2000 setpoint sent to DT: {}'.format(cmd))
def setAzEl(self, setpoint):
Set the AzEl setpoint of the telescope.
Only works if the setmode is 'AZEL'
setpoint can be an astropy AltAz or a tuple (az,el) in radians
setpoint should be a tuple of radians or of astropy Quantity
if self.setmode != 'AZEL':
raise Exception("Cannot set Az/El i mode is not AZEL")
raise Exception("Cannot set Az/El if mode is not AZEL")
if isinstance(setpoint, AltAz):
az =
el = setpoint.alt.radian
(az, el) = setpoint
if isinstance(az, u.Quantity):
az =
if isinstance(el, u.Quantity):
el =
md = bytes(az + '\t' + el + '\n', 'UTF-8')'AzEl setpoint sent to DT: {}'.format(cmd))
cmd = '{:f}\t{:f}\n'.format(az, el).decode('UTF-8')'AzEl sent to DT: {}'.format(cmd))
def setOffset(self, offset):
......@@ -88,13 +97,15 @@ class telescope():
offset should be a tuple of radians or of astropy Quantity
if self.setmode is None:
raise Exception("Cannot set offset if mode is None")
(off_az, off_el) = offset
if isinstance(off_az, u.Quantity):
off_az =
if isinstance(off_az, u.Quantity):
if isinstance(off_el, u.Quantity):
off_el =
md = bytes(off_az + '\t' + off_el + '\n', 'UTF-8')
cmd = '{:f}\t{:f}\n'.format(off_az, off_el).decode('UTF-8')'Offset sent to DT: {}'.format(cmd))
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