def create_configuration_from_file(antfile: str, location: EarthLocation = None,
                                   mount: str = 'altaz',
                                   names: str = "%d", frame: str = 'local',
                                   diameter=35.0,
                                   rmax=None, name='') -> Configuration:
    """ Define from a file

    :param names: Antenna names
    :param antfile: Antenna file name
    :param location:
    :param mount: mount type: 'altaz', 'xy'
    :param frame: 'local' | 'global'
    :param diameter: Effective diameter of station or antenna
    :return: Configuration
    """
    antxyz = numpy.genfromtxt(antfile, delimiter=",")
    assert antxyz.shape[1] == 3, ("Antenna array has wrong shape %s" % antxyz.shape)
    if frame == 'local':
        latitude = location.geodetic[1].to(u.rad).value
        antxyz = xyz_at_latitude(antxyz, latitude)
    if rmax is not None:
        lantxyz = antxyz - numpy.average(antxyz, axis=0)
        r = numpy.sqrt(lantxyz[:, 0] ** 2 + lantxyz[:, 1] ** 2 + lantxyz[:, 2] ** 2)
        antxyz = antxyz[r < rmax]
        log.debug('create_configuration_from_file: Maximum radius %.1f m includes %d antennas/stations' %
                  (rmax, antxyz.shape[0]))
    
    nants = antxyz.shape[0]
    anames = [names % ant for ant in range(nants)]
    mounts = numpy.repeat(mount, nants)
    fc = Configuration(location=location, names=anames, mount=mounts, xyz=antxyz, frame=frame,
                       diameter=diameter, name=name)
    return fc
def create_configuration_from_MIDfile(antfile: str,
                                      location=None,
                                      mount: str = 'azel',
                                      rmax=None,
                                      name='') -> Configuration:
    """ Define from a file

    :param names: Antenna names
    :param antfile: Antenna file name
    :param mount: mount type: 'azel', 'xy'
    :return: Configuration
    """

    # X Y Z Diam Station
    # 9.36976 35.48262 1052.99987 13.50 M001
    antxyz = numpy.genfromtxt(antfile,
                              skip_header=5,
                              usecols=[0, 1, 2],
                              delimiter=" ")

    antxyz = xyz_at_latitude(antxyz, location.lat.rad)
    antxyz += [
        location.geocentric[0].to(u.m).value,
        location.geocentric[1].to(u.m).value,
        location.geocentric[2].to(u.m).value
    ]

    nants = antxyz.shape[0]
    assert antxyz.shape[
        1] == 3, "Antenna array has wrong shape %s" % antxyz.shape

    anames = numpy.genfromtxt(antfile,
                              dtype='str',
                              skip_header=5,
                              usecols=[4],
                              delimiter=" ")
    mounts = numpy.repeat(mount, nants)
    diameters = numpy.genfromtxt(antfile,
                                 dtype='str',
                                 skip_header=5,
                                 usecols=[3],
                                 delimiter=" ")

    antxyz, diameters, anames, mounts = limit_rmax(antxyz, diameters, anames,
                                                   mounts, rmax)

    fc = Configuration(location=location,
                       names=anames,
                       mount=mounts,
                       xyz=antxyz,
                       diameter=diameters,
                       name=name)

    return fc
Beispiel #3
0
        def transform(x, y, z, lat):
            """

            :param x:
            :param y:
            :param z:
            :param lat:
            :return:
            """
            res = xyz_at_latitude(numpy.array([x, y, z]), numpy.radians(lat))
            assert_allclose(numpy.linalg.norm(res),
                            numpy.linalg.norm([x, y, z]))
            return res
def create_configuration_from_file(antfile: str,
                                   location: EarthLocation = None,
                                   mount: str = 'azel',
                                   names: str = "%d",
                                   diameter=35.0,
                                   rmax=None,
                                   name='') -> Configuration:
    """ Define from a file

    :param names: Antenna names
    :param antfile: Antenna file name
    :param location:
    :param mount: mount type: 'azel', 'xy', 'equatorial'
    :param diameter: Effective diameter of station or antenna
    :return: Configuration
    """
    antxyz = numpy.genfromtxt(antfile, delimiter=",")
    assert antxyz.shape[1] == 3, ("Antenna array has wrong shape %s" %
                                  antxyz.shape)
    latitude = location.geodetic[1].to(u.rad).value
    antxyz = xyz_at_latitude(antxyz, latitude)
    antxyz += [
        location.geocentric[0].to(u.m).value,
        location.geocentric[1].to(u.m).value,
        location.geocentric[2].to(u.m).value
    ]

    nants = antxyz.shape[0]
    diameters = diameter * numpy.ones(nants)
    anames = [names % ant for ant in range(nants)]
    mounts = numpy.repeat(mount, nants)
    antxyz, diameters, anames, mounts = limit_rmax(antxyz, diameters, anames,
                                                   mounts, rmax)

    fc = Configuration(location=location,
                       names=anames,
                       mount=mounts,
                       xyz=antxyz,
                       diameter=diameters,
                       name=name)
    return fc