Commit f45c2cc7 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Use event to interrupt sleeping

parent 89662c2d
#!/usr/bin/env python3
import track_doppler
import unittest
from mock import call, patch
from astropy.coordinates import SkyCoord
import astropy.units as u
class DopplerTrackingTest(unittest.TestCase):
def setUp(self):
telescope_patch = patch('telescope.telescope')
self.telescope_mock = telescope_mock.start()
local_oscillator_patch = patch('camrasdevices.LocalOscillator')
self.local_oscillator_mock = local_oscillator_patch.start()
def test_something(self):
class DummyTelescope():
def __init__(self):
fake_pointing = SkyCoord(ra=0.*u.deg, dec=31.*u.deg)
self.radec = fake_pointing
def getJ2000(self):
for i in range(3):
fake_pointing = SkyCoord(ra=0.*u.deg, dec=31.*u.deg)
yield {'radec': fake_pointing,}
yield {'radec': self.radec}
class DummyLocalOscillator():
class DummyLocalOscillator(object):
def __init__(self):
self._frequency = 0
......@@ -27,4 +42,7 @@ class DummyLocalOscillator():
self._frequency = freq
print("Dummy LO set to {}".format(self._frequency))
track_hi.track_frequency(lo=DummyLocalOscillator(), dt=DummyTelescope())
track_doppler.track_doppler(lo=DummyLocalOscillator(), dt=DummyTelescope())
if __name__ == '__main__':
......@@ -2,6 +2,8 @@ import astropy.units as u
import numpy as np
import argparse
import threading
import subprocess
from telescope import telescope
......@@ -13,7 +15,8 @@ freq_hi = 1420.405751
def track_doppler(lo=None, dt=None,
"""Sets the Local Oscillator to a frequency to correct for Doppler shift"""
dt_lat = np.deg2rad(52.812019)
dt_lon = np.deg2rad(6.396169)
......@@ -23,10 +26,12 @@ def track_doppler(lo=None, dt=None,
lo = LocalOscillator();
if not dt:
dt = telescope();
if not exit_event:
exit_event = threading.Event()
for pointing in dt.getJ2000():
ra = pointing['radec']
dec = pointing['radec']
while not exit_event.is_set():
ra =
dec =
t = time.time()
argstring = "{ra} {dec} 2000 {time} {dt_lat} {dt_lon} {dt_alt}".format(
ra=ra, dec=dec, time=t, dt_lat=dt_lat, dt_lon=dt_lon, dt_alt=dt_alt)
......@@ -35,3 +40,4 @@ def track_doppler(lo=None, dt=None,
freq_doppler = float(subprocess.Popen(doppler_cmd, stdout=subprocess.PIPE, shell=True)
dfreq = 1000.0 + tracking_frequency - freq_doppler
lo.frequency = dfreq * 1e6
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