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