Esempio n. 1
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
Esempio n. 2
0
def create_configuration_from_file(antfile: str,
                                   name: str = None,
                                   location: EarthLocation = None,
                                   mount: str = 'altaz',
                                   names: str = "%d",
                                   frame: str = 'local',
                                   diameter=35.0,
                                   meta: dict = None,
                                   rmax=None,
                                   **kwargs) -> Configuration:
    """ Define from a file

    :param names:
    :param antfile: Antenna file name
    :param name: Name of array e.g. 'LOWBD2'
    :param location:
    :param mount: mount type: 'altaz', 'xy'
    :param frame: 'local' | 'global'
    :param diameter: Effective diameter of station or antenna
    :param meta: Any meta info
    :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)
    return fc