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

Use astropy time in function template, nicer test

parent 9dbda9d2
import track_doppler
import unittest
from mock import call, patch
import astropy.units as u
from vlsr import doppler_frequency
from astropy.coordinates import SkyCoord
import astropy.units as u
......@@ -40,9 +43,9 @@ class DummyLocalOscillator(object):
@frequency.setter
def frequency(self, freq):
self._frequency = freq
print("Dummy LO set to {}".format(self._frequency))
print("Dummy LO set to 1GHz {:+.3f}".format((self._frequency-1*u.GHz).to(u.kHz)))
track_doppler.track_doppler(lo=DummyLocalOscillator(), dt=DummyTelescope())
track_doppler.track_doppler(lo=DummyLocalOscillator(), dt=DummyTelescope(), doppler_function=doppler_frequency)
if __name__ == '__main__':
unittest.main()
import astropy.units as u
from astropy.coordinates import SkyCoord, EarthLocation
from astropy.time import Time
import numpy as np
import argparse
......@@ -16,10 +18,14 @@ freq_hi = 1420.405751 * u.MHz
def doppler_harm(sky_coordinate, time, tracking_frequency, location):
ra = sky_coordinate.ra.to(u.rad).value
dec = sky_coordinate.dec.to(u.rad).value
t = time.unix
dt_lat = location.lat.to(u.rad).value
dt_lon = location.lon.to(u.rad).value
dt_alt = location.height.to(u.m).value
argstring = "{ra} {dec} 2000 {time} {dt_lat} {dt_lon} {dt_alt}".format(
ra=ra, dec=dec, time=time, dt_lat=dt_lat, dt_lon=dt_lon, dt_alt=dt_alt)
ra=ra, dec=dec, time=t, dt_lat=dt_lat, dt_lon=dt_lon, dt_alt=dt_alt)
doppler_executable = "/home/harm/bin/doppler_mb"
doppler_executable = "/home/harm/bin/doppler_bl"
doppler_cmd = doppler_executable + " " + argstring + " " + str(tracking_frequency.to(u.MHz).value)
freq_doppler = float(subprocess.Popen(doppler_cmd, stdout=subprocess.PIPE, shell=True).stdout.read())
......@@ -55,7 +61,7 @@ def track_doppler(lo=None, dt=None,
while not exit_event.is_set():
sky_coordinate = dt.radec
freq_doppler = doppler_function(sky_coordinate, time.time(), tracking_frequency, dt_loc)
freq_doppler = doppler_function(sky_coordinate, Time.now(), tracking_frequency, dt_loc)
dfreq = 1*u.GHz + tracking_frequency - freq_doppler
lo.frequency = dfreq
exit_event.wait(timeout=0.5)
......@@ -4,7 +4,6 @@ from astropy.coordinates import SkyCoord, EarthLocation
import astropy.units as u
from astropy.units import Quantity
import astropy.constants
from typing import Union
import numpy as np
......
Markdown is supported
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