track_doppler.py 1.33 KB
Newer Older
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
1
2
import astropy.units as u
import numpy as np
3
import argparse
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
4

5
6
import threading

Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
7
8
9
10
11
12
13
import subprocess

from telescope import telescope
from camrasdevices import Receiver, LocalOscillator

import time

14
freq_hi = 1420.405751
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
15

16
17
def track_doppler(lo=None, dt=None,
                  tracking_frequency=freq_hi,
18
19
                  doppler_executable="/home/harm/bin/doppler_mb",
                  exit_event=None):
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
20
21
22
23
24
    """Sets the Local Oscillator to a frequency to correct for Doppler shift"""
    dt_lat = np.deg2rad(52.812019)
    dt_lon = np.deg2rad(6.396169)
    dt_alt = 25.0

25
26
27
28
    if not lo:
        lo = LocalOscillator();
    if not dt:
        dt = telescope();
29
30
    if not exit_event:
        exit_event = threading.Event()
31

32
33
34
    while not exit_event.is_set():
        ra  = dt.radec.ra.to(u.rad).value
        dec = dt.radec.dec.to(u.rad).value
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
35
36
37
38
        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)

39
        doppler_cmd = doppler_executable + " " + argstring + " " + str(tracking_frequency)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
40
41
42
        freq_doppler = float(subprocess.Popen(doppler_cmd, stdout=subprocess.PIPE, shell=True).stdout.read())
        dfreq = 1000.0 + tracking_frequency - freq_doppler
        lo.frequency = dfreq * 1e6
43
        exit_event.wait(timeout=0.5)