How to use the pyuvdata.utils.XYZ_from_LatLonAlt function in pyuvdata

To help you get started, we’ve selected a few pyuvdata examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RadioAstronomySoftwareGroup / pyuvsim / pyuvsim / simsetup.py View on Github external
"you must provide telescope_location"
            )
        if 'telescope_name' not in tele_params:
            raise KeyError(
                "If telescope_config_name not provided in `telescope` obsparam section, "
                "you must provide telescope_name"
            )
        telescope_location_latlonalt = tele_params['telescope_location']
        if isinstance(telescope_location_latlonalt, (str, np.str)):
            telescope_location_latlonalt = ast.literal_eval(telescope_location_latlonalt)
        world = tele_params.pop('world', None)

    telescope_location = list(telescope_location_latlonalt)
    telescope_location[0] *= np.pi / 180.
    telescope_location[1] *= np.pi / 180.  # Convert to radians
    tele_params['telescope_location'] = uvutils.XYZ_from_LatLonAlt(*telescope_location)
    telescope_name = tele_params['telescope_name']

    # get array layout
    if 'array_layout' not in tele_params:
        raise KeyError('array_layout must be provided.')
    array_layout = tele_params.pop('array_layout')
    if isinstance(array_layout, str):
        # Interpet as file path to layout csv file.
        layout_csv = array_layout
        # if array layout is a str, parse it as .csv filepath
        if isinstance(layout_csv, (str, np.str)):
            if not os.path.exists(layout_csv):
                layout_csv = os.path.join(config_path, layout_csv)
                if not os.path.exists(layout_csv):
                    raise ValueError(
                        'layout_csv file {} from yaml does not exist'.format(layout_csv))
github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / uvdata / fhd.py View on Github external
if layout_file is not None:
            layout_dict = readsav(layout_file, python_dict=True)
            layout = layout_dict["layout"]

            layout_fields = [name.lower() for name in layout.dtype.names]
            # Try to get the telescope location from the layout file &
            # compare it to the position from the obs structure.
            arr_center = layout["array_center"][0]
            layout_fields.remove("array_center")

            xyz_telescope_frame = layout["coordinate_frame"][0].decode("utf8").lower()
            layout_fields.remove("coordinate_frame")

            if xyz_telescope_frame == "itrf":
                # compare to lat/lon/alt
                location_latlonalt = uvutils.XYZ_from_LatLonAlt(
                    latitude, longitude, altitude
                )
                latlonalt_arr_center = uvutils.LatLonAlt_from_XYZ(
                    arr_center, check_acceptability=run_check_acceptability
                )

                # check both lat/lon/alt and xyz because of subtle differences
                # in tolerances
                if self._xyz_close(
                    location_latlonalt, arr_center
                ) or self._latlonalt_close(
                    (latitude, longitude, altitude), latlonalt_arr_center
                ):
                    self.telescope_location = arr_center
                else:
                    # values do not agree with each other to within the tolerances.
github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / parameter.py View on Github external
def set_lat_lon_alt(self, lat_lon_alt):
        """
        Set value from (latitude, longitude, altitude) tuple in radians.

        Parameters
        ----------
        lat_lon_alt : 3-tuple of float
            Tuple with the latitude (radians), longitude (radians)
            and altitude (meters) to use to set the value attribute.
        """
        if lat_lon_alt is None:
            self.value = None
        else:
            self.value = utils.XYZ_from_LatLonAlt(
                lat_lon_alt[0], lat_lon_alt[1], lat_lon_alt[2]
            )
github RadioAstronomySoftwareGroup / pyuvdata / scripts / import_snap.py View on Github external
enu_datum=['WGS84']
for connection in antenna_configuration:
    #print('connection')
    #print(connection.antenna_number)
    #antnum=connection['antenna_number']
    antnum = connection.antenna_number
    #antname=connection['station_name']
    antname = connection.station_name
    #ant_lla=(np.radians(connection['latitude']),
    #         np.radians(connection['longitude']),
    #        connection['elevation'])
    ant_lla=(np.radians(connection.lat),
             np.radians(connection.lon),
            connection.elevation)
    ant_xyz=utils.XYZ_from_LatLonAlt(ant_lla[0],ant_lla[1],ant_lla[2])
    ant_enu=(connection.easting,
             connection.northing,
             connection.elevation)
    all_antnums.append(antnum)
    all_antnames.append(antname)
    all_antennas_lla[antnum]=np.array(ant_lla)
    all_antennas_enu[antnum]=np.array(ant_enu)
    all_antennas_xyz.append(np.array(ant_xyz))
    if connection.antenna_number in config['ANTENNA_NUMBERS']:
        data_antnums.append(antnum)
        data_antnames.append(antname)
        data_antennas_lla.append(ant_lla)
        data_antennas_enu.append(ant_enu)
        data_antennas_xyz.append(ant_xyz)
#Convert antenna ENU into ITRF
#Create baseline_array
github RadioAstronomySoftwareGroup / pyuvdata / pyuvdata / parameter.py View on Github external
def set_lat_lon_alt_degrees(self, lat_lon_alt_degree):
        """
        Set value from (latitude, longitude, altitude) tuple in degrees.

        Parameters
        ----------
        lat_lon_alt : 3-tuple of float
            Tuple with the latitude (degrees), longitude (degrees)
            and altitude (meters) to use to set the value attribute.

        """
        if lat_lon_alt_degree is None:
            self.value = None
        else:
            latitude, longitude, altitude = lat_lon_alt_degree
            self.value = utils.XYZ_from_LatLonAlt(
                latitude * np.pi / 180.0, longitude * np.pi / 180.0, altitude
            )