Source code for tkp.telescope.lofar.antennaarrays

"""
This module contains numbers of phsysicial properties of the LOFAR array.

For performance reasons these distances are precomputed. One can recompute
them using :func:`parse_antennafile()`, :func:`shortest_distances()` and a
``AntennaArrays.conf`` file from
``LOFAR/MAC/Deployment/data/StaticMetaData/AntennaArrays`` in the lofar system
software source tree.
"""
import math


core_dipole_distances = {
    "LBA":
        [2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 3.60, 3.34, 3.26, 3.49,
         3.19, 3.19, 3.51, 3.42, 3.18, 3.59, 3.66, 4.32, 3.23, 3.23, 3.38,
         3.49, 3.19, 3.89, 3.40, 3.51, 3.49, 4.12, 3.82, 3.13, 3.13, 2.99,
         2.99, 3.32, 3.38, 3.36, 3.36, 4.75, 2.79, 2.79, 3.40, 4.15, 3.98,
         3.98, 4.49, 27.04, 27.48, 3.07, 3.07, 6.27, 4.14, 4.39, 5.36, 5.03,
         7.17, 4.92, 5.01, 4.59, 8.19, 6.20, 6.27, 6.27, 6.00, 4.14, 4.39,
         7.84, 8.14, 7.38, 7.17, 9.36, 5.80, 9.83, 7.08, 7.34, 7.40, 6.00,
         10.25, 9.37, 8.83, 8.64, 5.27, 7.66, 8.23, 8.23, 6.72, 5.80, 6.28,
         11.06, 7.40, 10.80, 10.81, 8.64, 5.27, 7.66, 9.06],
    "LBA_OUTER":
        [3.07, 3.07, 6.27, 4.14, 4.39, 5.36, 5.03, 7.17, 4.92, 5.01, 4.59,
         8.19, 6.20, 6.27, 6.27, 6.00, 4.14, 4.39, 7.84, 8.14, 7.38, 7.17,
         9.36, 5.80, 9.83, 7.08, 7.34, 7.40, 6.00, 10.25, 9.37, 8.83, 8.64,
         5.27, 7.66, 8.23, 8.23, 6.72, 5.80, 6.28, 11.06, 7.40, 10.80, 10.81,
         8.64, 5.27, 7.66, 9.06],
    "LBA_INNER":
        [2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 3.60, 3.34, 3.26, 3.49,
         3.19, 3.19, 3.51, 3.42, 3.18, 3.59, 3.66, 4.32, 3.23, 3.23, 3.38,
         3.49, 3.19, 3.89, 3.40, 3.51, 3.49, 4.12, 3.82, 3.13, 3.13, 2.99,
         2.99, 3.32, 3.38, 3.36, 3.36, 4.75, 2.79, 2.79, 3.40, 4.15, 3.98,
         3.98, 4.49, 27.04, 27.48],
    "LBA_SPARSE0":
        [2.55, 3.07, 2.55, 4.14, 2.55, 5.36, 2.55, 7.17, 3.34, 5.01, 3.49,
         8.19, 3.19, 6.27, 3.42, 6.00, 3.59, 4.39, 4.32, 8.14, 3.23, 7.17,
         3.49, 5.80, 3.89, 7.08, 3.51, 7.40, 4.12, 10.25, 3.13, 8.83, 2.99,
         5.27, 3.32, 8.23, 3.36, 6.72, 4.75, 6.28, 2.79, 7.40, 4.15, 10.81,
         3.98, 5.27, 27.04, 9.06],
    "LBA_SPARSE1":
        [3.07, 2.55, 6.27, 2.55, 4.39, 2.55, 5.03, 3.60, 4.92, 3.26, 4.59,
         3.19, 6.20, 3.51, 6.27, 3.18, 4.14, 3.66, 7.84, 3.23, 7.38, 3.38,
         9.36, 3.19, 9.83, 3.40, 7.34, 3.49, 6.00, 3.82, 9.37, 3.13, 8.64,
         2.99, 7.66, 3.38, 8.23, 3.36, 5.80, 2.79, 11.06, 3.40, 10.80, 3.98,
         8.64, 4.49, 7.66, 27.48],
    "LBA_X":
        [2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 3.60, 3.34, 3.26, 3.49,
         3.19, 3.19, 3.51, 3.42, 3.18, 3.59, 3.66, 4.32, 3.23, 3.23, 3.38,
         3.49, 3.19, 3.89, 3.40, 3.51, 3.49, 4.12, 3.82, 3.13, 3.13, 2.99,
         2.99, 3.32, 3.38, 3.36, 3.36, 4.75, 2.79, 2.79, 3.40, 4.15, 3.98,
         3.98, 4.49, 27.04, 27.48],
    "LBA_Y":
        [3.07, 3.07, 6.27, 4.14, 4.39, 5.36, 5.03, 7.17, 4.92, 5.01, 4.59,
         8.19, 6.20, 6.27, 6.27, 6.00, 4.14, 4.39, 7.84, 8.14, 7.38, 7.17,
         9.36, 5.80, 9.83, 7.08, 7.34, 7.40, 6.00, 10.25, 9.37, 8.83, 8.64,
         5.27, 7.66, 8.23, 8.23, 6.72, 5.80, 6.28, 11.06, 7.40, 10.80, 10.81,
         8.64, 5.27, 7.66, 9.06],
    "HBA":
        [34.16, 35.79, 28.15, 29.20, 31.09, 33.66, 22.88, 23.04, 24.32, 26.55,
         29.52, 33.04, 17.75, 17.96, 19.57, 22.29, 25.76, 29.72, 12.93, 15.09,
         18.48, 22.54, 11.20, 15.46, 17.67, 15.05, 24.24, 21.95, 19.90, 19.06,
         29.92, 29.04, 26.55, 24.88, 24.21, 23.76, 34.99, 33.46, 31.31, 29.91,
         29.36, 27.67, 38.06, 36.19, 34.98, 34.51, 41.13, 40.07],
    "HBA0":
        [0.79, 1.36, 1.75, 0.90, 1.51, 2.13, 3.34, 1.95, 1.56, 1.15, 2.34,
         2.38, 0.65, 2.50, 1.15, 1.56, 2.38, 0.49, 2.49, 1.12, 2.55, 1.35,
         1.25, 0.96, 81.42, 79.54, 87.69, 86.26, 84.36, 82.74, 94.11, 92.66,
         91.02, 89.22, 87.37, 83.62, 99.02, 97.65, 95.81, 94.11, 90.90, 87.29,
         102.50, 100.64, 98.18, 94.57, 105.46, 101.85],
    "HBA1":
        [98.51, 100.28, 92.04, 93.65, 95.51, 97.60, 85.70, 87.12, 88.82, 90.78,
         92.98, 95.41, 80.72, 82.23, 84.02, 86.09, 88.41, 90.96, 77.37, 79.28,
         81.46, 83.91, 74.58, 76.90, 0.79, 1.36, 1.75, 0.90, 1.51, 2.13, 3.34,
         1.95, 1.56, 1.15, 2.34, 2.38, 0.65, 2.50, 1.15, 1.56, 2.38, 0.49,
         2.49, 1.12, 2.55, 1.34, 1.25, 0.96],
    "HBA_0":
        [0.79, 1.36, 1.75, 0.90, 1.51, 2.13, 3.34, 1.95, 1.56, 1.15, 2.34,
         2.38, 0.65, 2.50, 1.15, 1.56, 2.38, 0.49, 2.49, 1.12, 2.55, 1.35,
         1.25, 0.96, 81.42, 79.54, 87.69, 86.26, 84.36, 82.74, 94.11, 92.66,
         91.02, 89.22, 87.37, 83.62, 99.02, 97.65, 95.81, 94.11, 90.90, 87.29,
         102.50, 100.64, 98.18, 94.57, 105.46, 101.85],
    "HBA_1":
        [98.51, 100.28, 92.04, 93.65, 95.51, 97.60, 85.70, 87.12, 88.82, 90.78,
         92.98, 95.41, 80.72, 82.23, 84.02, 86.09, 88.41, 90.96, 77.37, 79.28,
         81.46, 83.91, 74.58, 76.90, 0.79, 1.36, 1.75, 0.90, 1.51, 2.13, 3.34,
         1.95, 1.56, 1.15, 2.34, 2.38, 0.65, 2.50, 1.15, 1.56, 2.38, 0.49,
         2.49, 1.12, 2.55, 1.34, 1.25, 0.96],
}

intl_dipole_distances = {
    "LBA":
        [3.55, 3.41, 3.87, 3.41, 5.61, 4.52, 4.96, 4.96, 3.81, 4.03, 4.03,
         4.15, 3.41, 3.42, 3.42, 3.42, 3.54, 3.46, 3.87, 4.68, 5.30, 5.54,
         5.17, 5.77, 3.62, 3.94, 4.07, 4.07, 3.92, 3.92, 5.65, 6.00, 3.91,
         3.49, 6.50, 6.50, 3.52, 3.48, 3.71, 3.71, 4.74, 4.31, 7.99, 7.03,
         3.56, 3.70, 3.50, 4.15, 4.34, 4.10, 4.98, 3.49, 3.25, 6.69, 3.61,
         3.41, 6.92, 3.85, 3.94, 6.85, 4.07, 3.85, 4.31, 3.41, 3.54, 3.48,
         3.42, 4.22, 3.35, 3.35, 3.47, 4.74, 3.70, 4.36, 3.54, 3.61, 3.54,
         4.15, 3.81, 5.98, 4.77, 4.34, 3.87, 3.63, 5.17, 3.52, 7.21, 3.42,
         3.41, 7.75, 3.48, 3.25, 4.95, 3.47, 3.50, 3.42],
    "LBA_OUTER":
        [3.55, 3.41, 3.87, 3.41, 5.61, 4.52, 4.96, 4.96, 3.81, 4.03, 4.03,
         4.15, 3.41, 3.42, 3.42, 3.42, 3.54, 3.46, 3.87, 4.68, 5.30, 5.54,
         5.17, 5.77, 3.62, 3.94, 4.07, 4.07, 3.92, 3.92, 5.65, 6.00, 3.91,
         3.49, 6.50, 6.50, 3.52, 3.48, 3.71, 3.71, 4.74, 4.31, 7.99, 7.03,
         3.56, 3.70, 3.50, 4.15, 4.34, 4.10, 4.98, 3.49, 3.25, 6.69, 3.61,
         3.41, 6.92, 3.85, 3.94, 6.85, 4.07, 3.85, 4.31, 3.41, 3.54, 3.48,
         3.42, 4.22, 3.35, 3.35, 3.47, 4.74, 3.70, 4.36, 3.54, 3.61, 3.54,
         4.15, 3.81, 5.98, 4.77, 4.34, 3.87, 3.63, 5.17, 3.52, 7.21, 3.42,
         3.41, 7.75, 3.48, 3.25, 4.95, 3.47, 3.50, 3.42, ],
    "LBA_INNER":
        [3.55, 3.41, 3.87, 3.41, 5.61, 4.52, 4.96, 4.96, 3.81, 4.03, 4.03,
         4.15, 3.41, 3.42, 3.42, 3.42, 3.54, 3.46, 3.87, 4.68, 5.30, 5.54,
         5.17, 5.77, 3.62, 3.94, 4.07, 4.07, 3.92, 3.92, 5.65, 6.00, 3.91,
         3.49, 6.50, 6.50, 3.52, 3.48,
         3.71, 3.71, 4.74, 4.31, 7.99, 7.03, 3.56, 3.70, 3.50, 4.15, 4.34,
         4.10, 4.98, 3.49, 3.25, 6.69, 3.61, 3.41, 6.92, 3.85, 3.94, 6.85,
         4.07, 3.85, 4.31, 3.41, 3.54, 3.48, 3.42, 4.22, 3.35, 3.35, 3.47,
         4.74, 3.70, 4.36, 3.54, 3.61,
         3.54, 4.15, 3.81, 5.98, 4.77, 4.34, 3.87, 3.63, 5.17, 3.52, 7.21,
         3.42, 3.41, 7.75, 3.48, 3.25, 4.95, 3.47, 3.50, 3.42],
}

remote_dipole_distances = {
    "LBA_OUTER":
        [3.07, 3.07, 6.27, 4.14, 4.39, 5.36, 5.03, 7.18, 4.92, 5.01, 4.59,
         8.19, 6.19, 6.27, 6.27, 6.00, 4.14, 4.39, 7.84, 8.14, 7.38, 7.18,
         9.36, 5.80, 9.83, 7.08, 7.34, 7.40, 6.00, 10.25, 9.37, 8.83, 8.64,
         5.28, 7.66, 8.23, 8.23, 6.72, 5.80, 6.28, 11.06, 7.40, 10.80, 10.81,
         8.64, 5.28, 7.66, 9.06, ],
    "LBA_SPARSE1":
        [3.07, 2.55, 6.27, 2.55, 4.39, 2.55, 5.03, 3.51, 4.92, 3.18, 4.59,
         3.19, 6.19, 3.43, 6.27, 3.18, 4.14, 3.66, 7.84, 3.23, 7.38, 3.38,
         9.36, 3.19, 9.83, 3.39, 7.34, 3.49, 6.00, 3.82, 9.37, 3.12, 8.64,
         2.99, 7.66, 3.38, 8.23, 3.36, 5.80, 2.79, 11.06, 3.39, 10.80, 3.99,
         8.64, 4.49, 7.66, 19.60, ],
    "LBA_SPARSE0":
        [2.55, 3.07, 2.55, 4.14, 2.55, 5.36, 2.55, 7.18, 3.51, 5.01, 3.48,
         8.19, 3.25, 6.27, 3.48, 6.00, 3.58, 4.39, 4.32, 8.14, 3.23, 7.18,
         3.50, 5.80, 3.89, 7.08, 3.51, 7.40, 4.12, 10.25, 3.12, 8.83, 2.99,
         5.28, 3.32, 8.23, 3.36, 6.72, 4.75, 6.28, 2.79, 7.40, 4.15, 10.81,
         3.99, 5.28, 21.02, 9.06, ],
    "LBA_Y":
        [3.07, 3.07, 6.27, 4.14, 4.39, 5.36, 5.03, 7.18, 4.92, 5.01, 4.59,
         8.19, 6.19, 6.27, 6.27, 6.00, 4.14, 4.39, 7.84, 8.14, 7.38, 7.18,
         9.36, 5.80, 9.83, 7.08, 7.34, 7.40, 6.00, 10.25, 9.37, 8.83, 8.64,
         5.28, 7.66, 8.23, 8.23, 6.72, 5.80, 6.28, 11.06, 7.40, 10.80, 10.81,
         8.64, 5.28, 7.66, 9.06, ],
    "LBA_X":
        [2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 3.51, 3.51, 3.18, 3.48,
         3.19, 3.25, 3.43, 3.48, 3.18, 3.58, 3.66, 4.32, 3.23, 3.23, 3.38,
         3.50, 3.19, 3.89, 3.39, 3.51, 3.49, 4.12, 3.82, 3.12, 3.12, 2.99,
         2.99, 3.32, 3.38, 3.36, 3.36, 4.75, 2.79, 2.79, 3.39, 4.15, 3.99,
         3.99, 4.49, 21.02, 19.60, ],
    "LBA":
        [2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 3.51, 3.51, 3.18, 3.48,
         3.19, 3.25, 3.43, 3.48, 3.18, 3.58, 3.66, 4.32, 3.23, 3.23, 3.38,
         3.50, 3.19, 3.89, 3.39, 3.51, 3.49, 4.12, 3.82, 3.12, 3.12, 2.99,
         2.99, 3.32, 3.38, 3.36, 3.36, 4.75, 2.79, 2.79, 3.39, 4.15, 3.99,
         3.99, 4.49, 21.02, 19.60, 3.07, 3.07, 6.27, 4.14, 4.39, 5.36, 5.03,
         7.18, 4.92, 5.01, 4.59, 8.19, 6.19, 6.27, 6.27, 6.00, 4.14, 4.39,
         7.84, 8.14, 7.38, 7.18, 9.36, 5.80, 9.83, 7.08, 7.34, 7.40, 6.00,
         10.25, 9.37, 8.83, 8.64, 5.28, 7.66, 8.23, 8.23, 6.72, 5.80, 6.28,
         11.06, 7.40, 10.80, 10.81, 8.64, 5.28, 7.66, 9.06, ],
    "LBA_INNER":
        [2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 2.55, 3.51, 3.51, 3.18, 3.48,
         3.19, 3.25, 3.43, 3.48, 3.18, 3.58, 3.66, 4.32, 3.23, 3.23, 3.38,
         3.50, 3.19, 3.89, 3.39, 3.51, 3.49, 4.12, 3.82, 3.12, 3.12, 2.99,
         2.99, 3.32, 3.38, 3.36, 3.36, 4.75, 2.79, 2.79, 3.39, 4.15, 3.99,
         3.99, 4.49, 21.02, 19.60, ],
}


[docs]def parse_antennafile(positions_file): """ Parses an antenna file from the LOFAR system software repository. :param positions_file: a antenna file :returns: a dictionary with array as key and positions as values """ file_handler = open(positions_file, 'r') parsed = {} state = 0 array = None position = None # where is the station relative to the centre of the earth antennanum = 0 positions = [] antennacount = 0 for line in file_handler: line = line.strip() if not line or line.startswith('#'): continue if state == 0: # array type array = line state = 1 elif state == 1: # array position position = [float(x) for x in line.split()[2:5]] state = 2 elif state == 2: # array properties meta data antennanum = int(line.split()[0]) antennacount = antennanum state = 3 elif state == 3: if antennacount > 0: positions.append([float(x) for x in line.split()]) antennacount -= 1 else: assert (line == "]") state = 0 parsed[array] = positions positions = [] return parsed
[docs]def shortest_distances(coordinates, full_array): """ returns a list of distances for each antenna relative to its closest neighbour. :param coordinates: a list of 3 value tuples that represent x,y and z coordinates of a subset of the array :param full_array: a list of x,y,z coordinates of a full array :returns: a list of floats of distances """ distances = [] for a in coordinates: shortest_distance = None for b in full_array: distance = pow((a[0] - b[0]), 2) + pow((a[1] - b[1]), 2) + \ pow((a[2] - b[2]), 2) if distance > 0.1 and ( distance < shortest_distance or not shortest_distance): shortest_distance = distance distances.append(shortest_distance) return [math.sqrt(x) for x in distances]
[docs]def pretty_print(file_): """ Pretty prints a parsed antenna file. Use this function to generate copy paste code to be used in the top of this file. :param file_: a file location """ parsed = parse_antennafile(file_) print "{" for key, value in [x for x in parsed.items() if x[0].startswith("LBA")]: print '"%s": \n\t[' % key, ds = shortest_distances(value, parsed["LBA"]) for d in ds: print "%.2f," % d, print "]," print "}"