track_hi.py 1.79 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

def track_frequency(lo=LocalOscillator(), dt=telescope(),
15
                    tracking_frequency=freq_hi,
16
                    doppler_executable="/home/harm/bin/doppler_mb"):
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
17
18
19
20
21
22
23
24
25
26
27
28
    """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

    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)

29
        doppler_cmd = doppler_executable + " " + argstring + " " + str(tracking_frequency)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
30
31
32
33
        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

34
35
36
37
38
39
40
41
def main():
    parser = argparse.ArgumentParser(description = "Adjust the frequency of the local oscillator to track the HI frequency at the pointing of the telescope")
    parser.add_argument("-d", "--doppler-executable", "Executable for computing the Doppler correction", default="/home/harm/bin/doppler_mb")
    parser.add_argument("-f", "--frequency", "Frequency to track, default is HI frequency at {} MHz".format(freq_hi), default=freq_hi, type=float)

    args = parser.parse_arguments()

    track_frequency(tracking_frequency=args.frequency, doppler_executable=args.doppler_executable)
Tammo Jan Dijkema's avatar
Tammo Jan Dijkema committed
42
    track_frequency()
43
44
45

if __name__ == '__main__':
    main()