Skip to content
Snippets Groups Projects
Commit 97bcd435 authored by Taya Snijder's avatar Taya Snijder
Browse files

Merge branch 'L2SS-554_delay-pointing-unit-tests' into 'master'

Resolve L2SS-554 "Delay pointing unit tests"

Closes L2SS-554

See merge request !229
parents 526c4092 cbc7b3e3
No related branches found
No related tags found
1 merge request!229Resolve L2SS-554 "Delay pointing unit tests"
...@@ -8,3 +8,6 @@ ...@@ -8,3 +8,6 @@
*.h5 binary *.h5 binary
*.jpg binary *.jpg binary
*.bin binary *.bin binary
# casacore measures tables
table.* binary
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
from delays import *
if __name__ == '__main__':
# # create a frame tied to the reference position
reference_itrf = [3826577.066, 461022.948, 5064892.786] # CS002LBA, in ITRF2005 epoch 2012.5
d = delay_calculator(reference_itrf)
# # set the timestamp to solve for
timestamp = datetime.datetime(2021,1,1,0,0,5)
d.set_measure_time(timestamp)
# compute the delays for an antennas w.r.t. the reference position
antenna_itrf = [[3826923.546, 460915.441, 5064643.489]] # CS001LBA, in ITRF2005 epoch 2012.5
# # obtain the direction vector for a specific pointing
direction = "J2000","0deg","0deg"
# calculate the delays based on the set reference position, the set time and now the set direction and antenna positions.
delays = d.convert(direction, antenna_itrf)
# print the delays
# pprint.pprint(delays)
#test changing the time
print(f"Changing timestamp test\nBase parametres: Direction: {direction}, position: {antenna_itrf}")
for i in range(10):
# # set the timestamp to solve for
timestamp = datetime.datetime(2021,1,1,0,i,5)
d.set_measure_time(timestamp)
delays = d.convert(direction, antenna_itrf)
# print the delays
print(f"Timestamp: {timestamp}: {delays}")
# reset time
timestamp = datetime.datetime(2021, 1, 1, 0, 0, 5)
d.set_measure_time(timestamp)
#test changing the antenna position
print(f"Changing Antenna position test.\nBase parametres: Time: {timestamp} Direction: {direction}")
for i in range(10):
antenna_itrf = [[3826577.066 + i, 461022.948, 5064892.786]] # CS002LBA, in ITRF2005 epoch 2012.5
delays = d.convert(direction, antenna_itrf)
# print the delays
print(f"Antenna position: {antenna_itrf}: {delays}")
# test changing the direction
antenna_itrf = [[3826923.546, 460915.441, 5064643.489]] # CS001LBA, in ITRF2005 epoch 2012.5
print(f"Changing direction test.\nBase parametres: Time: {timestamp} , position: {antenna_itrf}")
for i in range(10):
direction = "J2000", f"{i}deg", "0deg"
delays = d.convert(direction, antenna_itrf)
# print the delays
print(f"Direction: {direction}: {delays}")
import datetime
from tangostationcontrol.beam.delays import *
from tangostationcontrol.test import base
class TestDelays(base.TestCase):
def test_init(self):
"""
Fail condition is simply the object creation failing
"""
reference_itrf = [3826577.066, 461022.948, 5064892.786] # CS002LBA, in ITRF2005 epoch 2012.5
d = delay_calculator(reference_itrf)
self.assertIsNotNone(d)
def test_sun(self):
# # create a frame tied to the reference position
reference_itrf = [3826577.066, 461022.948, 5064892.786]
d = delay_calculator(reference_itrf)
for i in range(24):
# set the time to the day of the winter solstice 2021 (21 december 16:58) as this is the time with the least change in sunlight
timestamp = datetime.datetime(2021, 12, 21, i, 58, 0)
d.set_measure_time(timestamp)
# point to the sun
direction = "SUN", "0deg", "0deg"
# calculate the delays based on the set reference position, the set time and now the set direction and antenna positions.
pointing = d.measure.direction(*direction)
direction = d.get_direction_vector(pointing)
"""
direction[2] is the z-coordinate of ITRF, which points to the north pole.
This direction is constant when pointing to the sun, as the earth rotates around its axis,
but changes slowly due to the earths rotation around the sun.
The summer and winter solstices are when these values are at their peaks and the changes are the smallest.
This test takes the value at the winter solstice and checks whether the measured values are near enough to that.
"""
# Measured manually at the winter solstice. Using datetime.datetime(2021, 12, 21, 16, 58, 0)
z_at_solstice = -0.3977784695213487
z_direction = direction[2]
self.assertAlmostEqual(z_at_solstice, z_direction, 4)
def test_identical_location(self):
# # create a frame tied to the reference position
reference_itrf = [3826577.066, 461022.948, 5064892.786] # CS002LBA, in ITRF2005 epoch 2012.5
d = delay_calculator(reference_itrf)
# set the antenna position identical to the reference position
antenna_itrf = [[reference_itrf[0], reference_itrf[1], reference_itrf[2]]] # CS001LBA, in ITRF2005 epoch 2012.5
# # set the timestamp to solve for
timestamp = datetime.datetime(2000, 1, 1, 0, 0, 0)
d.set_measure_time(timestamp)
# compute the delays for an antennas w.r.t. the reference position
# # obtain the direction vector for a specific pointing
direction = "J2000", "0deg", "0deg"
# calculate the delays based on the set reference position, the set time and now the set direction and antenna positions.
delays = d.convert(direction, antenna_itrf)
self.assertListEqual(delays, [0.0], msg=f"delays = {delays}")
def test_light_second_delay(self):
"""
This test measures the delay between 2 positions 1 light second apart.
"""
# # create a frame tied to the reference position
reference_itrf = [3826577.066, 461022.948, 5064892.786] # CS002LBA, in ITRF2005 epoch 2012.5
d = delay_calculator(reference_itrf)
# set the antenna position identical to the reference position
speed_of_light = 299792458.0
antenna_itrf = [[reference_itrf[0], reference_itrf[1] - speed_of_light, reference_itrf[2]]] # CS001LBA, in ITRF2005 epoch 2012.5
# # set the timestamp to solve for
timestamp = datetime.datetime(2000, 1, 1, 0, 0, 0)
d.set_measure_time(timestamp)
# compute the delays for an antennas w.r.t. the reference position
# # obtain the direction vector for a specific pointing
direction = "J2000", "0deg", "0deg"
# calculate the delays based on the set reference position, the set time and now the set direction and antenna positions.
delays = d.convert(direction, antenna_itrf)
self.assertTrue(0.98 <= delays[0] <= 1.02, f"delays[0] = {delays[0]}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment