track_doppler.py 1.2 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
7
8
9
10
11

import subprocess

from telescope import telescope
from camrasdevices import Receiver, LocalOscillator

import time

12
freq_hi = 1420.405751
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
13

14
15
16
def track_doppler(lo=None, dt=None,
                  tracking_frequency=freq_hi,
                  doppler_executable="/home/harm/bin/doppler_mb"):
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
17
18
19
20
21
    """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

22
23
24
25
26
    if not lo:
        lo = LocalOscillator();
    if not dt:
        dt = telescope();

Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
27
28
29
30
31
32
33
    for pointing in dt.getJ2000():
        ra  = pointing['radec'].ra.to(u.rad).value
        dec = pointing['radec'].dec.to(u.rad).value
        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)

34
        doppler_cmd = doppler_executable + " " + argstring + " " + str(tracking_frequency)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
35
36
37
        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