Commit 9dbda9d2 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Refactor track_doppler and vlsr to work together

parent 5b5477fe
......@@ -13,11 +13,7 @@ import time
freq_hi = 1420.405751 * u.MHz
def doppler_harm(sky_coordinate, time, tracking_frequency):
dt_lat = np.deg2rad(52.812019)
dt_lon = np.deg2rad(6.396169)
dt_alt = 25.0
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
argstring = "{ra} {dec} 2000 {time} {dt_lat} {dt_lon} {dt_alt}".format(
......@@ -30,10 +26,6 @@ def doppler_harm(sky_coordinate, time, tracking_frequency):
return freq_doppler * u.MHz
def doppler_vlsr(sky_coordinate, time, tracking_frequency):
# TODO: finish this function (wrap doppler_frequency from vlsr
return 42
def track_doppler(lo=None, dt=None,
tracking_frequency=freq_hi,
doppler_function=doppler_harm,
......@@ -41,12 +33,12 @@ def track_doppler(lo=None, dt=None,
"""Sets the Local Oscillator to a frequency to correct for Doppler shift
Args:
lo (LocalOscillator): the local oscillator of which the frequency will be set.
Defaults to None, in this case one will be created
dt (Telescope): a Telescope instance to read the current pointing from.
Defaults to None, in this case one will be created
doppler_function (function): a function that computes the doppler frequency.
This function gets a SkyCoord and a time (float), and should return a frequency Quantity
lo (LocalOscillator): the local oscillator of which the frequency will be set.
Defaults to None, in this case one will be created
dt (Telescope): a Telescope instance to read the current pointing from.
Defaults to None, in this case one will be created
doppler_function (function): a function that computes the doppler frequency.
This function gets a SkyCoord and a time (float), and should return a frequency Quantity
"""
if not lo:
......@@ -55,10 +47,15 @@ def track_doppler(lo=None, dt=None,
dt = telescope();
if not exit_event:
exit_event = threading.Event()
dt_lat = 52.812019 * u.deg
dt_lon = 6.396169 * u.deg
dt_alt = 25.0 * u.m
dt_loc = EarthLocation.from_geodetic(lat = dt_lat, lon = dt_lon, height = dt_alt)
while not exit_event.is_set():
sky_coordinate = dt.radec
freq_doppler = doppler_function(sky_coordinate, time.time(), tracking_frequency)
freq_doppler = doppler_function(sky_coordinate, time.time(), tracking_frequency, dt_loc)
dfreq = 1*u.GHz + tracking_frequency - freq_doppler
lo.frequency = dfreq
exit_event.wait(timeout=0.5)
......@@ -33,16 +33,15 @@ def vlsr(t,loc,psrc,verbose=False):
return vsun_proj-vsrc
def doppler_frequency(t: Time, loc: EarthLocation, psrc: SkyCoord,
rest_frequency: Union[Quantity, float], verbose=False):
def doppler_frequency(psrc, t, rest_frequency, loc, verbose=False):
"""
Compute the Doppler corrected frequency, taking into account the line of sight radial velocity.
Args:
psrc: sky location for correction
loc: observer location
t: time for correction
frequency: observed frequency in LSR
psrc (SkyCoord): sky location for correction
t (float): time for correction
rest_frequency (Union[Quantity, float]): observed frequency in LSR
loc (EarthLocation): observer location
Returns:
Quantity: Observable frequency
......
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