diff --git a/.gitattributes b/.gitattributes index 929b6bb4f5a33f37a97181698c5a0626021018f0..fd70048c7ad908b94cd835cee34f0f16eadd84a4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,3 +8,6 @@ *.h5 binary *.jpg binary *.bin binary + +# casacore measures tables +table.* binary diff --git a/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.dat b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.dat new file mode 100644 index 0000000000000000000000000000000000000000..1f7869a8f1af1f6d4089128eeed130c78d5c6ae2 Binary files /dev/null and b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.dat differ diff --git a/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.f0 b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.f0 new file mode 100644 index 0000000000000000000000000000000000000000..5c14b2d3c72812c815005ec6fbd10110c7ceab70 Binary files /dev/null and b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.f0 differ diff --git a/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.f0i b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.f0i new file mode 100644 index 0000000000000000000000000000000000000000..d50b1bdd28ae76847df63f335bcbdd1bd1e7cc9f Binary files /dev/null and b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.f0i differ diff --git a/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.info b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.info new file mode 100644 index 0000000000000000000000000000000000000000..d1fa70b4e608c03fc4f6da5a213c36d568f9fbc4 Binary files /dev/null and b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.info differ diff --git a/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.lock b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.lock new file mode 100644 index 0000000000000000000000000000000000000000..dab1a78a5dec98a99cad64cd140e1308abf761a8 Binary files /dev/null and b/docker-compose/lofar-device-base/WSRT_Measures_stub/ephemerides/DE200/table.lock differ diff --git a/tangostationcontrol/tangostationcontrol/beam/test_delays.py b/tangostationcontrol/tangostationcontrol/beam/test_delays.py deleted file mode 100644 index 1668345163c4f3bff244ede6ff63cf2c2786f9b1..0000000000000000000000000000000000000000 --- a/tangostationcontrol/tangostationcontrol/beam/test_delays.py +++ /dev/null @@ -1,65 +0,0 @@ -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}") diff --git a/tangostationcontrol/tangostationcontrol/test/beam/__init__.py b/tangostationcontrol/tangostationcontrol/test/beam/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tangostationcontrol/tangostationcontrol/test/beam/test_delays.py b/tangostationcontrol/tangostationcontrol/test/beam/test_delays.py new file mode 100644 index 0000000000000000000000000000000000000000..624491c454f6d1b6795295b66eee072f45774928 --- /dev/null +++ b/tangostationcontrol/tangostationcontrol/test/beam/test_delays.py @@ -0,0 +1,103 @@ +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]}") +