    Return the x,y,z coordinates of the focal point.

    The focal point corresponds to the location of
    the near-field object of interest in the ENU
    frame centered on the median position of the
    antennas.

    Parameters
    ----------
    uvd : UVData object
        UVData object
    focus : float
        Focal distance of the array (km)
    ra : float
        Right ascension of the focal point ie phase center (deg; shape (Ntimes,))
    dec : float
        Declination of the focal point ie phase center (deg; shape (Ntimes,))

    Returns
    -------
    x, y, z: ndarray, ndarray, ndarray
        ENU-frame coordinates of the focal point (meters) (shape (Ntimes,))


    Calculate near-field phase/delay along the Nblts axis.

    Parameters
    ----------
    uvd : UVData object
        UVData object
    focus_x, focus_y, focus_z : ndarray, ndarray, ndarray
        ENU-frame coordinates of focal point (Each of shape (Ntimes,))

    Returns
    -------
    new_w : ndarray
        The calculated near-field delay (or w-term) for each visibility along
        the Nblts axis


    Calculate lat/lon/alt from ECEF x,y,z.

    Parameters
    ----------
    xyz : ndarray of float
        numpy array, shape (Npts, 3), with ECEF x,y,z coordinates.
    frame : str
        Coordinate frame of xyz.
        Valid options are ITRS (default) or MCMF.
    ellipsoid : str
        Ellipsoid to use for lunar coordinates. Must be one of "SPHERE",
        "GSFC", "GRAIL23", "CE-1-LAM-GEO" (see lunarsky package for details). Default
        is "SPHERE". Only used if frame is MCMF.
    check_acceptability : bool
        Flag to check XYZ coordinates are reasonable.

    Returns
    -------
    latitude :  ndarray or float
        latitude, numpy array (if Npts > 1) or value (if Npts = 1) in radians
    longitude :  ndarray or float
        longitude, numpy array (if Npts > 1) or value (if Npts = 1) in radians
    altitude :  ndarray or float
        altitude, numpy array (if Npts > 1) or value (if Npts = 1) in meters


    Calculate ECEF x,y,z from lat/lon/alt values.

    Parameters
    ----------
    latitude :  ndarray or float
        latitude, numpy array (if Npts > 1) or value (if Npts = 1) in radians
    longitude :  ndarray or float
        longitude, numpy array (if Npts > 1) or value (if Npts = 1) in radians
    altitude :  ndarray or float
        altitude, numpy array (if Npts > 1) or value (if Npts = 1) in meters
    frame : str
        Coordinate frame of xyz.
        Valid options are ITRS (default) or MCMF.
    ellipsoid : str
        Ellipsoid to use for lunar coordinates. Must be one of "SPHERE",
        "GSFC", "GRAIL23", "CE-1-LAM-GEO" (see lunarsky package for details). Default
        is "SPHERE". Only used if frame is MCMF.

    Returns
    -------
    xyz : ndarray of float
        numpy array, shape (Npts, 3), with ECEF x,y,z coordinates.


    Get rotated ECEF positions such that the x-axis goes through the longitude.

    Miriad and uvfits expect antenna positions in this frame
    (with longitude of the array center/telescope location)

    Parameters
    ----------
    xyz : ndarray of float
        numpy array, shape (Npts, 3), with ECEF x,y,z coordinates.
    longitude : float
        longitude in radians to rotate coordinates to
        (usually the array center/telescope location).

    Returns
    -------
    ndarray of float
        Rotated ECEF coordinates, shape (Npts, 3).


    Calculate ECEF from a rotated ECEF (Inverse of rotECEF_from_ECEF).

    Parameters
    ----------
    xyz : ndarray of float
        numpy array, shape (Npts, 3), with rotated ECEF x,y,z coordinates.
    longitude : float
        longitude in radians giving the x direction of the rotated coordinates
        (usually the array center/telescope location).

    Returns
    -------
    ndarray of float
        ECEF coordinates, shape (Npts, 3).


    Calculate local ENU (east, north, up) coordinates from ECEF coordinates.

    Parameters
    ----------
    xyz : ndarray of float
        numpy array, shape (Npts, 3), with ECEF x,y,z coordinates.
    center_loc : EarthLocation or MoonLocation object
        An EarthLocation or MoonLocation object giving the center of the ENU
        coordinates. Either `center_loc` or all of `latitude`, `longitude`,
        `altitude` must be passed.
    latitude : float
        Latitude of center of ENU coordinates in radians.
        Not used if `center_loc` is passed.
    longitude : float
        Longitude of center of ENU coordinates in radians.
        Not used if `center_loc` is passed.
    altitude : float
        Altitude of center of ENU coordinates in radians.
        Not used if `center_loc` is passed.
    frame : str
        Coordinate frame of xyz and center of ENU coordinates. Valid options are
        ITRS (default) or MCMF. Not used if `center_loc` is passed.
    ellipsoid : str
        Ellipsoid to use for lunar coordinates. Must be one of "SPHERE",
        "GSFC", "GRAIL23", "CE-1-LAM-GEO" (see lunarsky package for details). Default
        is "SPHERE". Only used if frame is MCMF. Not used if `center_loc` is passed.

    Returns
    -------
    ndarray of float
        numpy array, shape (Npts, 3), with local ENU coordinates


    Calculate ECEF coordinates from local ENU (east, north, up) coordinates.

    Parameters
    ----------
    enu : ndarray of float
        numpy array, shape (Npts, 3), with local ENU coordinates.
    center_loc : EarthLocation or MoonLocation object
        An EarthLocation or MoonLocation object giving the center of the ENU
        coordinates. Either `center_loc` or all of `latitude`, `longitude`,
        `altitude` must be passed.
    latitude : float
        Latitude of center of ENU coordinates in radians.
        Not used if `center_loc` is passed.
    longitude : float
        Longitude of center of ENU coordinates in radians.
        Not used if `center_loc` is passed.
    altitude : float
        Altitude of center of ENU coordinates in radians.
        Not used if `center_loc` is passed.
    frame : str
        Coordinate frame of xyz and center of ENU coordinates. Valid options are
        ITRS (default) or MCMF. Not used if `center_loc` is passed.
    ellipsoid : str
        Ellipsoid to use for lunar coordinates. Must be one of "SPHERE",
        "GSFC", "GRAIL23", "CE-1-LAM-GEO" (see lunarsky package for details). Default
        is "SPHERE". Only used if frame is MCMF. Not used if `center_loc` is passed.

    Returns
    -------
    xyz : ndarray of float
        numpy array, shape (Npts, 3), with ECEF x,y,z coordinates.


    Convert from healpix lat/lon to UVBeam za/az convention.

    Note that this is different (unfortunately) from the conversion between
    the UVBeam Zenith Angle, Azimuth coordinate system and the astropy Alt/Az
    coordinate system. The astropy Azimuth runs the opposite direction and
    has a different starting angle than UVBeam's Azimuth because they are both
    right handed coordinate systems but Altitude moves the opposite direction
    than Zenith Angle does.

    The conversion used in this code sets the Healpix latitude to 90-zenith angle
    but it does not change the origin or direction for the azimuthal angle. This
    convention was set early in the development of UVBeam and we preserve it to
    preserve backwards compatibility.

    Parameters
    ----------
    hpx_lat: float or array of float
        Healpix latiudinal coordinate in radians.
    hpx_lon: float or array of float
        Healpix longitudinal coordinate in radians.

    Returns
    -------
    zenith_angle: float or array of float
        In radians
    azimuth: float or array of float
        In radians in uvbeam convention: North of East(East=0, North=pi/2)


    Convert from UVBeam az/za convention to healpix lat/lon.

    Note that this is different (unfortunately) from the conversion between
    the UVBeam Zenith Angle, Azimuth coordinate system and the astropy Alt/Az
    coordinate system. The astropy Azimuth runs the opposite direction and
    has a different starting angle than UVBeam's Azimuth because they are both
    right handed coordinate systems but Altitude moves the opposite direction
    than Zenith Angle does.

    The conversion used in this code sets the Healpix latitude to 90-zenith angle
    but it does not change the origin or direction for the azimuthal angle. This
    convention was set early in the development of UVBeam and we preserve it to
    preserve backwards compatibility.

    Parameters
    ----------
    zenith_angle: float, array_like of float
        Zenith angle in radians
    azimuth: float, array_like of float
        Azimuth in radians in uvbeam convention: North of East(East=0, North=pi/2)

    Returns
    -------
    hpx_lat: float or array of float
        Healpix latiudinal coordinate in radians.
    hpx_lon: float or array of float
        Healpix longitudinal coordinate in radians.


    Check that antenna positions are consistent with ground-based values.

    Check that the antenna position, telescope location, or combination of both produces
    locations that are consistent with surface-based positions. If supplying both
    antenna position and telescope location, the check will be run against the sum total
    of both. For the Earth, the permitted range of values is betwen 6350 and 6390 km,
    whereas for theMoon the range is 1717.1 to 1757.1 km.

    telescope_loc : array-like of float or EarthLocation or MoonLocation
        Telescope location, specified as a 3-element tuple (specifying geo/selenocentric
        position in meters) or as an astropy EarthLocation (or lunarsky MoonLocation).
    telescope_frame : str, optional
        Reference frame for latitude/longitude/altitude. Options are itrs (default) or
        mcmf. Only used if telescope_loc is not an EarthLocation or MoonLocation.
    antenna_positions : ndarray of float
        List of antenna positions relative to array center in ECEF coordinates,
        required if not providing `uvw_array`. Shape is (Nants, 3). If no telescope_loc
        is specified, these values will be assumed to be relative to geocenter.
    raise_error : bool
        If True, an error is raised if telescope_loc and/or telescope_loc do not conform
        to expectations for a surface-based telescope. Default is True.
    raise_warning : bool
        If True, a warning is raised if telescope_loc and/or telescope_loc do not
        conform to expectations for a surface-based telescope. Default is True, only
        used if `raise_error` is set to False.

    Returns
    -------
    valid : bool
        If True, the antenna_positions and/or telescope_loc conform to expectations for
        a surface-based telescope. Otherwise returns false.


    Check the catalog to see if an existing entry matches provided data.

    This is a helper function for verifying if an entry already exists within
    the catalog, contained within the supplied phase center catalog.

    Parameters
    ----------
    phase_center_catalog : dict
        Dictionary containing the entries to check.
    cat_name : str
        Name of the phase center, which should match a the value of "cat_name"
        inside an entry of `phase_center_catalog`.
    cat_type : str
        Type of phase center of the entry. Must be one of:
            "sidereal" (fixed RA/Dec),
            "ephem" (RA/Dec that moves with time),
            "driftscan" (fixed az/el position),
            "unprojected" (no w-projection, equivalent to the old
            `phase_type` == "drift").
    cat_lon : float or ndarray
        Value of the longitudinal coordinate (e.g., RA, Az, l) in radians of the
        phase center. No default unless `cat_type="unprojected"`, in which case the
        default is zero. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    cat_lat : float or ndarray
        Value of the latitudinal coordinate (e.g., Dec, El, b) in radians of the
        phase center. No default unless `cat_type="unprojected"`, in which case the
        default is pi/2. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    cat_frame : str
        Coordinate frame that cat_lon and cat_lat are given in. Only used for
        sidereal and ephem phase centers. Can be any of the several supported frames
        in astropy (a limited list: fk4, fk5, icrs, gcrs, cirs, galactic).
    cat_epoch : str or float
        Epoch of the coordinates, only used when cat_frame = fk4 or fk5. Given
        in units of fractional years, either as a float or as a string with the
        epoch abbreviation (e.g, Julian epoch 2000.0 would be J2000.0).
    cat_times : ndarray of floats
        Only used when `cat_type="ephem"`. Describes the time for which the values
        of `cat_lon` and `cat_lat` are caclulated, in units of JD. Shape is (Npts,).
    cat_pm_ra : float
        Proper motion in RA, in units of mas/year. Only used for sidereal phase
        centers.
    cat_pm_dec : float
        Proper motion in Dec, in units of mas/year. Only used for sidereal phase
        centers.
    cat_dist : float or ndarray of float
        Distance of the source, in units of pc. Only used for sidereal and ephem
        phase centers. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    cat_vrad : float or ndarray of float
        Radial velocity of the source, in units of km/s. Only used for sidereal and
        ephem phase centers. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    ignore_name : bool
        Nominally, this method will only look at entries where `cat_name`
        matches the name of an entry in the catalog. However, by setting this to
        True, the method will search all entries in the catalog and see if any
        match all of the provided data (excluding `cat_name`).
    target_cat_id : int
        Optional argument to specify a particular cat_id to check against.
    phase_dict : dict
        Instead of providing individual parameters, one may provide a dict which
        matches that format used within `phase_center_catalog` for checking for
        existing entries. If used, all other parameters (save for `ignore_name`
        and `cat_name`) are disregarded.

    Returns
    -------
    cat_id : int or None
        The unique ID number for the phase center added to the internal catalog.
        This value is used in the `phase_center_id_array` attribute to denote which
        source a given baseline-time corresponds to. If no catalog entry matches,
        then None is returned.
    cat_diffs : int
        The number of differences between the information provided and the catalog
        entry contained within `phase_center_catalog`. If everything matches, then
        `cat_diffs=0`.


    Look up catalog IDs which match a given name.

    Parameters
    ----------
    phase_center_catalog : dict
        Catalog to look for matching names in.
    cat_name : str or list of str
        Name to match against entries in phase_center_catalog.

    Returns
    -------
    cat_id_list : list
        List of all catalog IDs which match the given name.


    Print out the details of the phase centers.

    Prints out an ASCII table that contains the details of the supploed phase center
    catalog, which typically acts as the internal source catalog for various UV objects.

    Parameters
    ----------
    phase_center_catalog : dict
        Dict containing the list of phase centers (and corresponding data) to be
        printed out.
    catalog_identifier : str or int or list of str or int
        Optional parameter which, if provided, will cause the method to only return
        information on the phase center(s) with the matching name(s) or catalog ID
        number(s). Default is to print out information on all catalog entries.
    hms_format : bool
        Optional parameter, which if selected, can be used to force coordinates to
        be printed out in Hours-Min-Sec (if set to True) or Deg-Min-Sec (if set to
        False) format. Default is to print out in HMS if all the objects have
        coordinate frames of icrs, gcrs, fk5, fk4, and top; otherwise, DMS format
        is used.
    return_str: bool
        If set to True, the method returns an ASCII string which contains all the
        table infrmation. Default is False.
    print_table : bool
        If set to True, prints the table to the terminal window. Default is True.

    Returns
    -------
    table_str : bool
        If return_str=True, an ASCII string containing the entire table text

    Raises
    ------
    ValueError
        If `cat_name` matches no keys in `phase_center_catalog`.


    Update a phase center with a new catalog ID number.

    Parameters
    ----------
    phase_center_catalog : dict
        Catalog to be updated. Note that the supplied catalog will be modified in situ.
    cat_id : int
        Optional argument. If supplied, then the method will check to see that the
        supplied ID is not in either the supplied catalog or in the reserved IDs.
        provided value as the new catalog ID, provided that an existing catalog
        If not supplied, then the method will automatically assign a value, defaulting
        to the value in `cat_id` if supplied (and assuming that ID value has no
        conflicts with the reserved IDs).
    old_id : int
        Optional argument, current catalog ID of the phase center, which corresponds to
        a key in `phase_center_catalog`.
    reserved_ids : array-like in int
        Optional argument. An array-like of ints that denotes which ID numbers
        are already reserved. Useful for when combining two separate catalogs.

    Returns
    -------
    new_id : int
        New phase center ID.

    Raises
    ------
    ValueError
        If there's no entry that matches `cat_id`, or of the value `new_id`
        is already taken.


    Add an entry to a object/source catalog or find a matching one.

    This is a helper function for identifying and adding a phase center to a catalog,
    typically contained within the attribute `phase_center_catalog`. If a matching
    phase center is found, the catalog ID associated with that phase center is returned.

    Parameters
    ----------
    cat_name : str
        Name of the phase center to be added.
    cat_type : str
        Type of phase center to be added. Must be one of:
            "sidereal" (fixed RA/Dec),
            "ephem" (RA/Dec that moves with time),
            "driftscan" (fixed az/el position),
            "unprojected" (no w-projection, equivalent to the old
            `phase_type` == "drift").
            "near-field" (equivalent to sidereal with the addition
            of near-field corrections)
    cat_lon : float or ndarray
        Value of the longitudinal coordinate (e.g., RA, Az, l) in radians of the
        phase center. No default unless `cat_type="unprojected"`, in which case the
        default is zero. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    cat_lat : float or ndarray
        Value of the latitudinal coordinate (e.g., Dec, El, b) in radians of the
        phase center. No default unless `cat_type="unprojected"`, in which case the
        default is pi/2. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    cat_frame : str
        Coordinate frame that cat_lon and cat_lat are given in. Only used
        for sidereal and ephem targets. Can be any of the several supported frames
        in astropy (a limited list: fk4, fk5, icrs, gcrs, cirs, galactic).
    cat_epoch : str or float
        Epoch of the coordinates, only used when cat_frame = fk4 or fk5. Given
        in units of fractional years, either as a float or as a string with the
        epoch abbreviation (e.g, Julian epoch 2000.0 would be J2000.0).
    cat_times : ndarray of floats
        Only used when `cat_type="ephem"`. Describes the time for which the values
        of `cat_lon` and `cat_lat` are caclulated, in units of JD. Shape is (Npts,).
    cat_pm_ra : float
        Proper motion in RA, in units of mas/year. Only used for sidereal phase
        centers.
    cat_pm_dec : float
        Proper motion in Dec, in units of mas/year. Only used for sidereal phase
        centers.
    cat_dist : float or ndarray of float
        Distance of the source, in units of pc. Only used for sidereal and ephem
        phase centers. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    cat_vrad : float or ndarray of float
        Radial velocity of the source, in units of km/s. Only used for sidereal and
        ephem phase centers. Expected to be a float for sidereal and driftscan phase
        centers, and an ndarray of floats of shape (Npts,) for ephem phase centers.
    info_source : str
        Optional string describing the source of the information provided. Used
        primarily in UVData to denote when an ephemeris has been supplied by the
        JPL-Horizons system, user-supplied, or read in by one of the various file
        interpreters. Default is 'user'.
    force_update : bool
        Normally, `_add_phase_center` will throw an error if there already exists a
        phase_center with the given cat_id. However, if one sets
        `force_update=True`, the method will overwrite the existing entry in
        `phase_center_catalog` with the parameters supplied. Note that doing this
        will _not_ update other attributes of the `UVData` object. Default is False.
    cat_id : int
        An integer signifying the ID number for the phase center, used in the
        `phase_center_id_array` attribute. If a matching phase center entry exists
        already, that phase center ID will be returned, which may be different than
        the value specified to this parameter. The default is for the method to
        assign this value automatically.

    Returns
    -------
    phase_center_entry : dict
        Catalog containing the phase centers.
    cat_id : int
        The unique ID number for the phase center that either matches the specified
        parameters or was added to the internal catalog. If a matching entry was
        found, this may not be the value passed to the `cat_id` parameter. This
        value is used in the `phase_center_id_array` attribute to denote which
        source a given baseline-time corresponds to.

    Raises
    ------
    ValueError
        If attempting to add a non-unique source name or if adding a sidereal
        source without coordinates.


    Get the antenna numbers corresponding to a given baseline number.

    Parameters
    ----------
    baseline : int or array_like of ints
        baseline number
    Nants_telescope : int
        number of antennas
    use_miriad_convention : bool
        Option to use the MIRIAD convention where BASELINE id is
        `bl = 256 * ant1 + ant2` if `ant2 < 256`, otherwise
        `bl = 2048 * ant1 + ant2 + 2**16`.
        Note antennas should be 1-indexed (start at 1, not 0)

    Returns
    -------
    int or array_like of int
        first antenna number(s)
    int or array_like of int
        second antenna number(s)


    Get the baseline number corresponding to two given antenna numbers.

    Parameters
    ----------
    ant1 : int or array_like of int
        first antenna number
    ant2 : int or array_like of int
        second antenna number
    Nants_telescope : int
        number of antennas
    attempt256 : bool
        Option to try to use the older 256 standard used in
        many uvfits files. If there are antenna numbers >= 256, the 2048
        standard will be used unless there are antenna numbers >= 2048
        or Nants_telescope > 2048. In that case, the 2147483648 standard
        will be used. Default is False.
    use_miriad_convention : bool
        Option to use the MIRIAD convention where BASELINE id is
        `bl = 256 * ant1 + ant2` if `ant2 < 256`, otherwise
        `bl = 2048 * ant1 + ant2 + 2**16`.
        Note antennas should be 1-indexed (start at 1, not 0)

    Returns
    -------
    int or array of int
        baseline number corresponding to the two antenna numbers.


    Get antpair and polarization from parsing an aipy-style ant string.

    Used to support the select function. Generates two lists of antenna pair
    tuples and polarization indices based on parsing of the string ant_str.
    If no valid polarizations (pseudo-Stokes params, or combinations of [lr]
    or [xy]) or antenna numbers are found in ant_str, ant_pairs_nums and
    polarizations are returned as None.

    Parameters
    ----------
    uv : UVBase Object
        A UVBased object that supports the following functions and parameters:
        - get_ants
        - get_antpairs
        - get_pols
        These are used to construct the baseline ant_pair_nums
        and polarizations returned.
    ant_str : str
        String containing antenna information to parse. Can be 'all',
        'auto', 'cross', or combinations of antenna numbers and polarization
        indicators 'l' and 'r' or 'x' and 'y'.  Minus signs can also be used
        in front of an antenna number or baseline to exclude it from being
        output in ant_pairs_nums. If ant_str has a minus sign as the first
        character, 'all,' will be appended to the beginning of the string.
        See the tutorial for examples of valid strings and their behavior.
    print_toggle : bool
        Boolean for printing parsed baselines for a visual user check.
    x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is
        labelled as the x polarization ("east" or "north") to allow for
        converting from E/N strings. If input uv object has an `x_orientation`
        parameter and the input to this function is `None`, the value from the
        object will be used. Any input given to this function will override the
        value on the uv object. See corresponding parameter on UVData
        for more details.

    Returns
    -------
    ant_pairs_nums : list of tuples of int or None
        List of tuples containing the parsed pairs of antenna numbers, or
        None if ant_str is 'all' or a pseudo-Stokes polarizations.
    polarizations : list of int or None
        List of desired polarizations or None if ant_str does not contain a
        polarization specification.


    Decompose a list of ant-tuples or baseline numbers into ant-pairs and polarizations.

    This is a helper function that takes the `bls` parameter from the select function
    of several different classes (which can accept multiple different input types) and
    generates a consistent output, namely antenna pairs and a list of polarizations to
    select upon.

    Parameters
    ----------
    bls : list of tuple or int
        List containing the baselines being selected, either based on baseline number
        (in which case, the list should contain only ints), antenna-pairs (the list
        should contain 2-tuples), or antenna-polarization pairs (the list should contain
        3-tules, with the third element being a string denoting the polarization).
    polarizations : str or array-like of str
        List of polarizations that are being selected. If provided and bls contains
        3-tuples, an error is thrown.
    baseline_array : array-like of int
        Array of baseline numbers for the object.
    ant_1_array : array-like of int
        Array of first antenna numbers for the object.
    ant_2_array : array-like of int
        Array of second antenna numbers for the object.
    nants_telescope : int
        Number of antennas within a given telescope. Used to translate between baseline
        number and antenna pairs.
    invert : bool
        Option to specify whether a select operation is trying to perform an inverse
        selection (matching everything but what is listed). If set to True and bls
        contains 3-tuples, an error is thrown.
    strict : bool or None
        Normally, select will warn when an element of the selection criteria does not
        match any element for the parameter, as long as the selection criteria results
        in *at least one* element being selected. However, if set to True, an error is
        thrown if any selection criteria does not match what is given for the object
        parameters element. If set to None, then neither errors nor warnings are raised,
        unless no records are selected. Default is False.

    Returns
    -------
    bls : list of tuples
        List containing all matching antenna-pairs (in the form of 2-tuples).
    polarizations : list of str
        List specifying which polarizations are being selected.


    Check if the spectral windows are contiguous for multi-spw datasets.

    This checks the flex_spw_id_array to make sure that all channels for each
    spectral window are together in one block, versus being interspersed (e.g.,
    channel #1 and #3 is in spw #1, channels #2 and #4 are in spw #2). In theory,
    UVH5 and UVData objects can handle this, but MIRIAD, MIR, UVFITS, and MS file
    formats cannot, so we just consider it forbidden.

    Parameters
    ----------
    spw_array : array of integers
        Array of spectral window numbers, shape (Nspws,).
    flex_spw_id_array : array of integers
        Array of spectral window numbers per frequency channel, shape (Nfreqs,).
    strict : bool
        If set to True, then the function will raise an error if checks are failed.
        If set to False, then a warning is raised instead. If set to None, then
        no errors or warnings are raised.


    Check if frequencies are evenly spaced and separated by their channel width.

    This is a requirement for writing uvfits & miriad files.

    Parameters
    ----------
    freq_array : array of float or UVParameter
        Array of frequencies, shape (Nfreqs,).
    freq_tols : tuple of float
        freq_array tolerances (from uvobj._freq_array.tols).
    channel_width : array of float or UVParameter
        Channel widths, either a scalar or an array of shape (Nfreqs,).
    channel_width_tols : tuple of float
        channel_width tolerances (from uvobj._channel_width.tols).
    spw_array : array of integers or None
        Array of spectral window numbers, shape (Nspws,).
    flex_spw_id_array : array of integers or None
        Array of spectral window numbers per frequency channel, shape (Nfreqs,).
    strict : bool
        If set to True, then the function will raise an error if checks are failed.
        If set to False, then a warning is raised instead. If set to None, then
        no errors or warnings are raised.
    ignore_chanwidth_error : bool
        If set to True, when no errors or warnings are raised if the channel spacing
        does not match the channel width. Default is False. Note: this does not affect
        what is returned by the function (e.g., chanwidth_error is correctly returned
        regardless of what is set here).

    Returns
    -------
    spacing_error : bool
        Flag that channel spacings or channel widths are not equal.
    chanwidth_error : bool
        Flag that channel spacing does not match channel width.


    Figure out the frequency sorting order for object based frequency sorting.

    Parameters
    ----------
    Nfreqs :  int
        Number of frequencies, taken directly from the object parameter.
    freq_array :  array_like of float
        Frequency array, taken directly from the object parameter.
    Nfreqs :  int
        Number of spectral windows, taken directly from the object parameter.
    spw_array :  array_like of int
        Spectral window array, taken directly from the object parameter.
    flex_spw_id_array : array_like of int
        Array of SPW IDs for each channel, taken directly from the object parameter.
    spw_order : str or array_like of int
        A string describing the desired order of spectral windows along the
        frequency axis. Allowed strings include `number` (sort on spectral window
        number) and `freq` (sort on median frequency). A '-' can be prepended
        to signify descending order instead of the default ascending order,
        e.g., if you have SPW #1 and 2, and wanted them ordered as [2, 1],
        you would specify `-number`. Alternatively, one can supply an index array
        of length Nspws that specifies how to shuffle the spws (this is not the desired
        final spw order).  Default is to apply no sorting of spectral windows.
    channel_order : str or array_like of int
        A string describing the desired order of frequency channels within a
        spectral window. Allowed strings include `freq`, which will sort channels
        within a spectral window by frequency. A '-' can be optionally prepended
        to signify descending order instead of the default ascending order.
        Alternatively, one can supply an index array of length Nfreqs that
        specifies the new order. Default is to apply no sorting of channels
        within a single spectral window. Note that proving an array_like of ints
        will cause the values given to `spw_order` and `select_spw` to be ignored.
    select_spw : int or array_like of int
        An int or array_like of ints which specifies which spectral windows to
        apply sorting. Note that setting this argument will cause the value
        given to `spw_order` to be ignored.

    Returns
    -------
    index_array : ndarray of int
        Array giving the desired order of the channels to be used for sorting along the
        frequency axis

    Raises
    ------
    UserWarning
        Raised if providing arguments to select_spw and channel_order (the latter
        overrides the former).
    ValueError
        Raised if select_spw contains values not in spw_array, or if channel_order
        is not the same length as freq_array.


    Get time indices in a select.

    Parameters
    ----------
    frequencies : array_like of float
        The frequencies to keep in the object, each value passed here should
        exist in the freq_array.
    freq_chans : array_like of float
        The frequency channel numbers to keep in the object.
    obj_freq_array : array_like of float
        Frequency array on object.
    freq_tols : tuple of float
        Length 2 tuple giving (rtol, atol) to use for freq matching.
    obj_channel_width : array_like of float or None
        Channel width array on object, used for checking for FITs issues.
    channel_width_tols : tuple of float or None
        Length 2 tuple giving (rtol, atol) to use for channel_width vs freq
        separation checking. Can be None if obj_channel_width is None.
    obj_spw_id_array : array_like of int
        flex_spw_id_array on object.
    warn_spacing : bool
        Whether or not to warn about frequency/polarization spacing. Default is False.
    invert : bool
        Normally indices matching given criteria are what are included in the
        subsequent list. However, if set to True, these indices are excluded
        instead. Default is False.
    strict : bool or None
        Normally, select will warn when an element of the selection criteria does not
        match any element for the parameter, as long as the selection criteria results
        in *at least one* element being selected. However, if set to True, an error is
        thrown if any selection criteria does not match what is given for the object
        parameters element. If set to None, then neither errors nor warnings are raised,
        unless no records are selected. Default is False.

    Returns
    -------
    freq_inds : np.ndarray of int
        Indices of frequencies to keep on the object.
    selections : list of str
        list of selections done.


Check if two histories are the same.


    Find extra history to add to have minimal repeats.

    Parameters
    ----------
    history1 : str
        First history.
    history2 : str
        Second history

    Returns
    -------
    str
        Extra history to add to first history.


    Check that LSTs are consistent with the time_array and telescope location.

    This just calls `get_lst_for_time`, compares that result to the `lst_array`
    and warns if they are not within the tolerances specified by `lst_tols`.

    Parameters
    ----------
    jd_array : ndarray of float
        JD times to get lsts for.
    lst_array : ndarray of float
        LSTs to check to see if they match the jd_array at the location.
    latitude : float
        Latitude of location to check the lst for in degrees.
    longitude : float
        Longitude of location to check the lst for in degrees.
    altitude : float
        Altitude of location to check the lst for in meters.
    lst_tops : tuple of float
        A length 2 tuple giving the (relative, absolute) tolerances to check the
        LST agreement to. These are passed directly to numpy.allclose.
    frame : str
        Reference frame for latitude/longitude/altitude.
        Options are itrs (default) or mcmf.
    ellipsoid : str
        Ellipsoid to use for lunar coordinates. Must be one of "SPHERE", "GSFC",
        "GRAIL23", "CE-1-LAM-GEO" (see lunarsky package for details). Default
        is "SPHERE". Only used if frame is mcmf.
    telescope_loc : tuple or EarthLocation or MoonLocation
        Alternative way of specifying telescope lat/lon/alt, either as a 3-element tuple
        or as an astropy EarthLocation (or lunarsky MoonLocation). Cannot supply both
        `telescope_loc` and `latitute`, `longitude`, or `altitude`.

    Returns
    -------
    None

    Warns
    -----
    If the `lst_array` does not match the calculated LSTs to the lst_tols.


    Get time indices in a select.

    Parameters
    ----------
    times : array_like of float
        The times to keep in the object, each value passed here should exist in the
        time_array. Can be None, cannot be set with `time_range`, `lsts` or `lst_array`.
    time_range : array_like of float
        The time range in Julian Date to keep in the object, must be length 2. Some of
        the times in the object should fall between the first and last elements. Can be
        None, cannot be set with `times`, `lsts` or `lst_array`.
    lsts : array_like of float
        The local sidereal times (LSTs) to keep in the object, each value passed here
        should exist in the lst_array. Can be None, cannot be set with `times`,
        `time_range`, or `lst_range`.
    lst_range : array_like of float
        The local sidereal time (LST) range in radians to keep in the
        object, must be of length 2. Some of the LSTs in the object should
        fall between the first and last elements. If the second value is
        smaller than the first, the LSTs are treated as having phase-wrapped
        around LST = 2*pi = 0, and the LSTs kept on the object will run from
        the larger value, through 0, and end at the smaller value. Can be None, cannot
        be set with `times`, `time_range`, or `lsts`.
    obj_time_array : array_like of float
        Time array on object. Can be None if `object_time_range` is set.
    obj_time_range : array_like of float
        Time range on object. Can be None if `object_time_array` is set.
    obj_lst_array : array_like of float
        LST array on object. Can be None if `object_lst_range` is set.
    obj_lst_range : array_like of float
        LST range on object. Can be None if `object_lst_array` is set.
    time_tols : tuple of float
        Length 2 tuple giving (rtol, atol) to use for time matching.
    lst_tols : tuple of float
        Length 2 tuple giving (rtol, atol) to use for lst matching.
    time_inds : array_like of int, optional
        The time indices to keep in the object. This is not commonly used.
    invert : bool
        Normally indices matching given criteria are what are included in the
        subsequent list. However, if set to True, these indices are excluded
        instead. Default is False.
    strict : bool or None
        Normally, select will warn when an element of the selection criteria does not
        match any element for the parameter, as long as the selection criteria results
        in *at least one* element being selected. However, if set to True, an error is
        thrown if any selection criteria does not match what is given for the object
        parameters element. If set to None, then neither errors nor warnings are raised,
        unless no records are selected. Default is False.
    warn_spacing
        Whether or not to warn about time spacing. Only used if no ranges from the
        object are supplied. Default is False.

    Returns
    -------
    time_inds : list of int
        Indices of times to keep on the object.
    selections : list of str
        list of selections done.


    Check if times are evenly spaced.

    This is a requirement for calfits files.

    Parameters
    ----------
    times_array : array-like of float or UVParameter
        Array of times, shape (Ntimes,).
    time_range : array-like of float or UVParameter
        Array of time ranges, shape (Ntime_ranges). Optional.
    time_tols : tuple of float
        time_array tolerances (from uvobj._time_array.tols).  Optional.
    integration_time : array-like of float or UVParameter
        Array of integration times, shape (Ntimes,).  Optional.
    channel_width_tols : tuple of float
        integration_time tolerances (from uvobj._integration_time.tols). Optional.
    strict : bool
        If set to True, then the function will raise an error if checks are failed.
        If set to False, then a warning is raised instead. If set to None, then
        no errors or warnings are raised. Default is True.


Return iterable version of input.


Combine the filename attribute from multiple UVBase objects.

    The 4 cases are:
    1. `filename1` has been set, `filename2` has not
    2. `filename1` has not been set, `filename2` has
    3. `filename1` and `filename2` both have been set
    4. `filename1` and `filename2` both have not been set
    In case (1), we do not want to update the attribute, because it is
    already set correctly. In case (2), we want to replace `filename1`
    with the value from `filename2. In case (3), we want to take the union of
    the sets of the filenames. In case (4), we want the filename attribute
    to still be `None`.

    Parameters
    ----------
    filename1 : list of str or None
        The list of filenames for the first UVBase object. If it is not set, it
        should be `None`.
    filename2 : list of str or None
        The list of filenames for the second UVData object. If it is not set, it
        should be `None`.

    Returns
    -------
    combined_filenames : list of str or None
        The combined list, with potentially duplicate entries removed.


    Convert list of indices to a list of slices.

    Parameters
    ----------
    indices : list
        A 1D list of integers for array indexing (boolean ndarrays are also supported).
    max_nslice_frac : float
        A float from 0 -- 1. If the number of slices
        needed to represent input 'indices' divided by len(indices)
        exceeds this fraction, then we determine that we cannot
        easily represent 'indices' with a list of slices.
    max_nslice : int
        Optional argument, defines the maximum number of slices for determining if
        `indices` can be easily represented with a list of slices. If set, then
        the argument supplied to `max_nslice_frac` is ignored.
    return_index_on_fail : bool
        If set to True and the list of input indexes cannot easily be represented by
        a list of slices (as defined by `max_nslice` or `max_nslice_frac`), then return
        the input list of index values instead of a list of suboptimal slices.

    Returns
    -------
    slice_list : list
        Nominally the list of slice objects used to represent indices. However, if
        `return_index_on_fail=True` and input indexes cannot easily be represented,
        return a 1-element list containing the input for `indices`.
    check : bool
        If True, indices is easily represented by slices
        (`max_nslice_frac` or `max_nslice` conditions met), otherwise False.

    Notes
    -----
    Example:
        if: indices = [1, 2, 3, 4, 10, 11, 12, 13, 14]
        then: slices = [slice(1, 5, 1), slice(11, 15, 1)]


    Convert an iterable of integers into a slice object if possible.

    Parameters
    ----------
    ind : list
        A 1D list of integers for array indexing.
    allow_empty : bool
        If set to False (default) and ind is a zero-length list, None is returned. If
        set to True, then a "zero-length slice" (e.g., `slice(0,0)`) is returned
        instead.

    Returns
    -------
    index_obj : slice or list
        If the list of indices can be represented by a slice, a slice is returned,
        otherwise the list of indices is returned.


    Build a flag index array based on a multi-dimensional index array.

    Parameters
    ----------
    dims_dict : dict
        Dict whose keys are the axes being selected on, and the values are list of
        index positions along that axis.
    dims : tuple
        Shape of the array being accessed.


    Detect if a value is between a specified range(s).

    Parameters
    ----------
    val : float or ndarray
        Value to evaluate, either float/singleton, otherwise of shape (Nranges,).
    val_range : np.array
        Array of ranges, shape (Nranges, 2).
    wrap : bool
        Apply wrapping. Default is False.
    wrap_amount : float
        Top end of the range for the wrap (bottom is 0). Default is 2 * pi.

    Returns
    -------
    bool
        True if any range overlaps


    Detect if any val_range in an array overlap.

    Parameters
    ----------
    val_range : np.array of float
        Array of ranges, shape (Nranges, 2).
    range_type : str
        Type of range (for good error messages)

    Returns
    -------
    bool
        True if any range overlaps.


    Determine the union of unique elements from two lists.

    Convenience function for handling various actions with indices.

    Parameters
    ----------
    obj1 : list or tuple or set or 1D ndarray
        First list from which to determine unique entries.
    obj2 : list or tuple or set or 1D ndarray
        Second list from which to determine unique entries, which is joined with the
        first list. If None, the method will simply return the sorted list of unique
        elements in obj1.

    Returns
    -------
    sorted_unique : list
        List containing the union of unique entries between obj1 and obj2.


    Determine the intersection of unique elements from two lists.

    Convenience function for handling various actions with indices.

    Parameters
    ----------
    obj1 : list or tuple or set or 1D ndarray
        First list from which to determine unique entries.
    obj2 : list or tuple or set or 1D ndarray
        Second list from which to determine unique entries, which is intersected with
        the first list. If None, the method will simply return the sorted list of unique
        elements in obj1.

    Returns
    -------
    sorted_unique : list
        List containing the intersection of unique entries between obj1 and obj2.


    Determine the difference of unique elements from two lists.

    Convenience function for handling various actions with indices.

    Parameters
    ----------
    obj1 : list or tuple or set or 1D ndarray
        First list from which to determine unique entries.
    obj2 : list or tuple or set or 1D ndarray
        Second list from which to determine unique entries, which is differenced with
        the first list. If None, the method will simply return the sorted list of unique
        elements in obj1.

    Returns
    -------
    sorted_unique : list
        List containing the difference in unique entries between obj1 and obj2.


    Determine whether to raise a warning or an error.

    Parameters
    ----------
    err_msg : str
        Message to pass along with the warning/error.
    strict : bool | None
        If True, raise an error. If False, raise a warning. If None, no message is
        raised at all (warning is silenced).
    err_type : Exception
        Type of error to raise if `strict=True`. Default is ValueError.
    warn_type : Warning
        Type of warning to raise if `strict=False`. Default is UserWarning.


    Determine if indices are outside of the expected range.

    Parameters
    ----------
    inds : array-like of int
        Indices to check.
    nrecs : int
        Number of records in the underlying array.
    name : str
        Name of underlying array, default is "inds".
    invert : bool
        If False, inds are treated as the positions in the array that should be
        preserved, but if True, those positions are discarded instead. Default is False.
    strict : bool
        If True, raise an error. If False, raise a warning.

    Returns
    -------
    inds : ndarray of int
        Array of well-conditioned, sorted index values (whose value will be within the
        range of [0, nrecs - 1]).


    Combine masked array with an existing index list.

    Parameters
    ----------
    mask : array-like of bool
        Array that marks whether or not entries meet matching criteria.
    inds : array-like of int or None
        Existing list of index positions that meet matching criteria. Can be None,
        in which case only mask is evaluated.
    invert : bool
        If False, then indices where mask == True are returned. But if set to True,
        indices where mask == False are returned instead. Default is False.
    use_and : bool
        If True, then what is returned is the intersection of value derived from both
        mask and inds. If False, then the union of mask and inds is returned instead.
        Default is True.

    Returns
    -------
    new_inds : ndarray of int
        Index positions which meet the selection criterion recorded in mask and inds.


    Obtain indices to convert (Nants,) to (Nblts,).

    Parameters
    ----------
    uvd : UVData object

    Returns
    -------
    ind1, ind2 : ndarray, ndarray
        index pairs to compose (Nblts,) shaped arrays for each
        baseline from an (Nants,) shaped array


    Obtain indices to convert (Ntimes,) to (Nblts,).

    Parameters
    ----------
    uvd : UVData object
        UVData object

    Returns
    -------
    inds : ndarray
        Indices that, when applied to an array of shape (Ntimes,),
        correctly convert it to shape (Nblts,)


    Get antenna indices in a select.

    Parameters
    ----------
    antenna_names : array_like of str
        List of antennas to be selected based on name.
    antenna_nums : array_like of int
        List of antennas to be selected based on number.
    tel_ant_names : array_like of str
        List that contains the full set of antenna names for the telescope, which is
        matched to the list provided in `tel_ant_nums`. Used to map antenna name to
        number.
    tel_ant_nums : array_like of int
        List that contains the full set of antenna numbers for the telescope, which is
        matched to the list provided in `tel_ant_names`. Used to map antenna name to
        number.
    obj_ant_array : array_like of int
        The antenna numbers present in the object.
    invert : bool, optional
        Normally indices matching given criteria are what are included in the
        subsequent list. However, if set to True, these indices are excluded
        instead. Default is False.
    strict : bool or None
        Normally, select will warn when an element of the selection criteria does not
        match any element for the parameter, as long as the selection criteria results
        in *at least one* element being selected. However, if set to True, an error is
        thrown if any selection criteria does not match what is given for the object
        parameters element. If set to None, then neither errors nor warnings are raised,
        unless no records are selected. Default is False.

    Returns
    -------
    ant_inds : list of int
        Indices of antennas to keep on the object.
    selections : list of str
        list of selections done.


Identify neighbors of each vec in vecs, to distance tol.


    Find clusters of vectors (e.g. redundant baselines, times).

    Parameters
    ----------
    location_ids : array_like of int
        ID labels for locations.
    location_vectors : array_like of float
        location vectors, can be multidimensional
    tol : float
        tolerance for clusters
    strict : bool
        Require that all adjacency lists be isolated maximal cliques.
        This ensures that vectors do not fall into multiple clusters.
        Default: False

    Returns
    -------
    list of list of location_ids


    Find redundant groups using a gridding algorithm developed by the HERA team.

    This is essentially a gridding approach, but it only keeps track of the grid
    points that have baselines assigned to them. It iterates through the
    baselines and assigns each baseline to a an existing group if it is within
    a grid spacing or makes a new group if there is no group. The location of
    the group is the baseline vector of the first baseline assigned to it, rounded
    to the grid spacing, so the resulting assigned grid point can depend on the
    order in which baseline vectors are passed to it. It is possible for a baseline
    to be assigned to a group that is up to but strictly less than 4 times the
    grid spacing from its true location, so we use a grid a factor of 4 smaller
    than the passed tolerance (`tol`). This method is quite robust for regular
    arrays if the tolerance is properly specified, but may not behave predictably
    for highly non-redundant arrays.

    Parameters
    ----------
    baselines : array_like of int
        Baseline numbers, shape (Nbls,)
    baseline_vecs : array_like of float
        Baseline vectors in meters, shape (Nbls, 3).
    tol : float
        Absolute tolerance of redundancy, in meters.

    Returns
    -------
    baseline_groups : list of lists of int
        list of lists of redundant baseline numbers
    baseline_ind_conj : list of int
        List of baselines that are redundant when reversed. Only returned if
        include_conjugates is True


    Return map from "x" and "y" pols to "e" and "n" based on x_orientation.

    Parameters
    ----------
    x_orientation : str
        String giving the x_orientation, one of "east" or "north".

    Returns
    -------
    dict
        Dictionary mapping "x" and "y" pols to "e" and "n" based on x_orientation.


    Convert polarization str to number according to AIPS Memo 117.

    Prefer 'pI', 'pQ', 'pU' and 'pV' to make it clear that these are pseudo-Stokes,
    not true Stokes, but also supports 'I', 'Q', 'U', 'V'.

    Parameters
    ----------
    pol : str
        polarization string
    x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is
        labelled as the x polarization ("east" or "north") to allow for
        converting from E/N strings. See corresonding parameter on UVData
        for more details.

    Returns
    -------
    int
        Number corresponding to string

    Raises
    ------
    ValueError
        If the pol string cannot be converted to a polarization number.

    Warns
    -----
    UserWarning
        If the x_orientation not recognized.


    Convert polarization number to str according to AIPS Memo 117.

    Uses 'pI', 'pQ', 'pU' and 'pV' to make it clear that these are pseudo-Stokes,
    not true Stokes

    Parameters
    ----------
    num : int
        polarization number
    x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is
        labelled as the x polarization ("east" or "north") to convert to
        E/N strings. See corresonding parameter on UVData for more details.

    Returns
    -------
    str
        String corresponding to polarization number

    Raises
    ------
    ValueError
        If the polarization number cannot be converted to a polarization string.

    Warns
    -----
    UserWarning
        If the x_orientation not recognized.


    Convert jones polarization str to number according to calfits memo.

    Parameters
    ----------
    jstr : str or array_like of str
        antenna (jones) polarization string(s) to convert.
    x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is
        labelled as the x polarization ("east" or "north") to allow for
        converting from E/N strings. See corresonding parameter on UVData
        for more details.

    Returns
    -------
    int or list of int
        antenna (jones) polarization number(s) corresponding to the input string(s)

    Raises
    ------
    ValueError
        If the jones string cannot be converted to a polarization number.

    Warns
    -----
    UserWarning
        If the x_orientation not recognized.


    Convert jones polarization number to str according to calfits memo.

    Parameters
    ----------
    num : int or array_like of int
        antenna (jones) polarization number(s) to convert to strings
    x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is
        labelled as the x polarization ("east" or "north") to convert to
        E/N strings. See corresonding parameter on UVData for more details.

    Returns
    -------
    str or list of str
        antenna (jones) polarization string(s) corresponding to number

    Raises
    ------
    ValueError
        If the jones polarization number cannot be converted to a jones
        polarization string.

    Warns
    -----
    UserWarning
        If the x_orientation not recognized.


    Parse a polarization string and return pyuvdata standard polarization string.

    See utils.POL_STR2NUM_DICT for options.

    Parameters
    ----------
    polstr : str
        polarization string
    x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is
        labelled as the x polarization ("east" or "north") to allow for
        converting from E/N strings. See corresonding parameter on UVData
        for more details.

    Returns
    -------
    str
        AIPS Memo 117 standard string

    Raises
    ------
    ValueError
        If the pol string cannot be converted to a polarization number.

    Warns
    -----
    UserWarning
        If the x_orientation not recognized.


    Parse a Jones polarization string and return pyuvdata standard jones string.

    See utils.JONES_STR2NUM_DICT for options.

    Parameters
    ----------
    jpolstr : str
        Jones polarization string

    Returns
    -------
    str
        calfits memo standard string

    Raises
    ------
    ValueError
        If the jones string cannot be converted to a polarization number.

    Warns
    -----
    UserWarning
        If the x_orientation not recognized.


    Return the polarization for the conjugate baseline.

    For example, (1, 2, 'xy') = conj(2, 1, 'yx').
    The returned polarization is determined by assuming the antenna pair is
    reversed in the data, and finding the correct polarization correlation
    which will yield the requested baseline when conjugated. Note this means
    changing the polarization for linear cross-pols, but keeping auto-pol
    (e.g. xx) and Stokes the same.

    Parameters
    ----------
    pol : str or int
        Polarization string or integer.

    Returns
    -------
    cpol : str or int
        Polarization as if antennas are swapped (type matches input)


    Reorder multiple pols, swapping pols that are conjugates of one another.

    For example ('xx', 'xy', 'yx', 'yy') -> ('xx', 'yx', 'xy', 'yy')
    This is useful for the _key2inds function in the case where an antenna
    pair is specified but the conjugate pair exists in the data. The conjugated
    data should be returned in the order of the polarization axis, so after
    conjugating the data, the pols need to be reordered.
    For example, if a file contains antpair (0, 1) and pols 'xy' and 'yx', but
    the user requests antpair (1, 0), they should get:
    [(1x, 0y), (1y, 0x)] = [conj(0y, 1x), conj(0x, 1y)]

    Parameters
    ----------
    pols : array_like of str or int
        Polarization array (strings or ints).

    Returns
    -------
    conj_order : ndarray of int
        Indices to reorder polarization array.


    Determine order of input polarization numbers.

    Determines the order by which to sort a given list of polarizations, according to
    the ordering scheme. Two orders are currently supported: "AIPS" and "CASA". The
    main difference between the two is the grouping of same-handed polarizations for
    AIPS (whereas CASA orders the polarizations such that same-handed pols are on the
    ends of the array).

    Parameters
    ----------
    pols : array_like of str or int
        Polarization array (strings or ints).
    order : str
        Polarization ordering scheme, either "CASA" or "AIPS".

    Returns
    -------
    index_array : ndarray of int
        Indices to reorder polarization array.


    Get the polarizations given a feed array.

    Parameters
    ----------
    feed_array : ndarray of str
        Array of feed orientations. Options are: n/e or x/y or r/l.
    include_cross_pols : bool
        Option to include the cross polarizations (e.g. xy and yx or en and ne).
        Defaults to True if more than one feed, set to False for only one feed.
    x_orientation : str, optional
        Orientation of the x-axis. Options are 'east', 'north', 'e', 'n', 'ew', 'ns'.
    return_feed_pol_order : bool
        Option to return a list of tuples giving the ordering of the feeds for
        each pol. Default False.

    Returns
    -------
    polarization_array : ndarray of int
        Polarization integer array.
    feed_pol_order : list of tuples of int, optional
        List of feed index tuples for each pol.


    Get polarization indices in a select.

    Parameters
    ----------
    polarizations : array_like of str or int
        The polarizations to keep in the object, each value passed here should exist in
        obj_pol_array (unless `invert=True`).
    obj_pol_array : array_like of int
        The polarizations present in the object.
    obj_x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is labelled as the x
        polarization ("east" or "north") to allow for converting from E/N strings.
    flex_pol : bool
        Demark whether or not the object is a flex-pol object, which by construct has
        no polarization axis to select on (it's folded onto the spw-axis instead).
        Default is False.
    invert : bool
        Normally indices matching given criteria are what are included in the
        subsequent list. However, if set to True, these indices are excluded
        instead. Default is False.
    strict : bool or None
        Normally, select will warn when an element of the selection criteria does not
        match any element for the parameter, as long as the selection criteria results
        in *at least one* element being selected. However, if set to True, an error is
        thrown if any selection criteria does not match what is given for the object
        parameters element. If set to None, then neither errors nor warnings are raised,
        unless no records are selected. Default is False.
    is_jones : bool
        Normally this function handles polarizations, but if set to True, Jones terms
        can be input instead. Default is False, it is recommended rather than using this
        setting directly one should use the function _select_jones_helper instead.
    warn_spacing : bool
        Whether or not to warn about polarization spacing. Default is False.

    Returns
    -------
    pol_inds : list of int
        Indices of polarization to keep on the object.
    selections : list of str
        list of selections done.


    Get Jones indices in a select.

    Parameters
    ----------
    jones : array_like of str or int
        The Jones terms to keep in the object, each value passed here should exist in
        obj_jones_array (unless `invert=True`).
    obj_jones_array : array_like of int
        The Jones terms present in the object.
    obj_x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is labelled as the x
        polarization ("east" or "north") to allow for converting from E/N strings.
    flex_jones : bool
        Demark whether or not the object is a flex-Jones object, which by construct has
        no Jones axis to select on (it's folded onto the spw-axis instead). Default is
        False.
    invert : bool
        Normally indices matching given criteria are what are included in the
        subsequent list. However, if set to True, these indices are excluded
        instead. Default is False.
    strict : bool or None
        Normally, select will warn when an element of the selection criteria does not
        match any element for the parameter, as long as the selection criteria results
        in *at least one* element being selected. However, if set to True, an error is
        thrown if any selection criteria does not match what is given for the object
        parameters element. If set to None, then neither errors nor warnings are raised,
        unless no records are selected. Default is False.
    warn_spacing : bool
        Whether or not to warn about Jones spacing. Default is False.

    Returns
    -------
    jones_inds : list of int
        Indices of Jones terms to keep on the object.
    selections : list of str
        list of selections done.


    Get Jones indices in a select.

    Parameters
    ----------
    feeds : array_like of str
        The feeds to keep in the object, each value passed here should exist in
        obj_feed_array (unless `invert=True`).
    obj_feed_array : array_like of str
        The Jones terms present in the object.
    obj_x_orientation : str, optional
        Orientation of the physical dipole corresponding to what is labelled as the x
        polarization ("east" or "north") to allow for converting from E/N strings.
    invert : bool
        Normally indices matching given criteria are what are included in the
        subsequent list. However, if set to True, these indices are excluded
        instead. Default is False.
    strict : bool or None
        Normally, select will warn when an element of the selection criteria does not
        match any element for the parameter, as long as the selection criteria results
        in *at least one* element being selected. However, if set to True, an error is
        thrown if any selection criteria does not match what is given for the object
        parameters element. If set to None, then neither errors nor warnings are raised,
        unless no records are selected. Default is False.

    Returns
    -------
    feed_inds : list of int
        Indices of feeds to keep on the object.
    selections : list of str
        list of selections done.


    Check if polarizations are evenly spaced.

    This is a requirement for writing uvfits and beamfits files.

    Parameters
    ----------
    polarization_array : array-like of int or UVParameter
        Array of polarization codes, shape (Npols,).
    strict : bool
        If set to True, then the function will raise an error if checks are failed.
        If set to False, then a warning is raised instead. If set to None, then
        no errors or warnings are raised.
    allow_resort : bool
        If set to False, polarizations are checked in their present order. If set to
        True, values are sorted prior to evaluating (useful for cases where the
        polarization index can be reindexed). Default is False.


    Check if Jones polarization terms are equally spaced.

    This is a requirement for writing calfits files.

    Parameters
    ----------
    jones_array : array-like of int or UVParameter
        Array of Jones codes, shape (Njones,).
    strict : bool
        If set to True, then the function will raise an error if checks are failed.
        If set to False, then a warning is raised instead. If set to None, then
        no errors or warnings are raised.
    allow_resort : bool
        If set to False, jones terms are checked in their present order. If set to
        True, values are sorted prior to evaluating (useful for cases where the
        jones index can be reindexed). Default is False.


    Collapse by averaging data.

    This is similar to np.average, except it handles infs (by giving them
    zero weight) and zero weight axes (by forcing result to be inf with zero
    output weight).

    Parameters
    ----------
    arr : array
        Input array to process.
    weights: ndarray, optional
        weights for average. If none, will default to equal weight for all
        non-infinite data.
    axis : int or tuple, optional
        Axis or axes to collapse (passed to np.sum). Default is all.
    return_weights : bool
        Whether to return sum of weights.
    return_weights_square: bool
        Whether to return the sum of the square of the weights. Default is False.


    Collapse by averaging absolute value of data.

    Parameters
    ----------
    arr : array
        Input array to process.
    weights: ndarray, optional
        weights for average. If none, will default to equal weight for all
        non-infinite data.
    axis : int or tuple, optional
        Axis or axes to collapse (passed to np.sum). Default is all.
    return_weights : bool
        Whether to return sum of weights.
    return_weights_square: bool
        whether to return the sum of the squares of the weights. Default is False.


    Collapse by averaging in quadrature.

    Parameters
    ----------
    arr : array
        Input array to process.
    weights: ndarray, optional
        weights for average. If none, will default to equal weight for all
        non-infinite data.
    axis : int or tuple, optional
        Axis or axes to collapse (passed to np.sum). Default is all.
    return_weights : bool
        Whether to return sum of weights.
    return_weights_square: bool
        whether to return the sum of the squares of the weights. Default is False.


    Collapse using OR operation.

    Parameters
    ----------
    arr : array
        Input array to process.
    weights: ndarray, optional
        NOT USED, but kept for symmetry with other collapsing functions.
    axis : int or tuple, optional
        Axis or axes to collapse (take OR over). Default is all.
    return_weights : bool
        Whether to return dummy weights array.
        NOTE: the dummy weights will simply be an array of ones
    return_weights_square: bool
        NOT USED, but kept for symmetry with other collapsing functions.


    Collapse using AND operation.

    Parameters
    ----------
    arr : array
        Input array to process.
    weights: ndarray, optional
        NOT USED, but kept for symmetry with other collapsing functions.
    axis : int or tuple, optional
        Axis or axes to collapse (take AND over). Default is all.
    return_weights : bool
        Whether to return dummy weights array.
        NOTE: the dummy weights will simply be an array of ones
    return_weights_square: bool
        NOT USED, but kept for symmetry with other collapsing functions.


    Parent function to collapse an array with a given algorithm.

    Parameters
    ----------
    arr : array
        Input array to process.
    alg : str
        Algorithm to use. Must be defined in this function with
        corresponding subfunction above.
    weights: ndarray, optional
        weights for collapse operation (e.g. weighted mean).
        NOTE: Some subfunctions do not use the weights. See corresponding
        doc strings.
    axis : int or tuple, optional
        Axis or axes to collapse. Default is all.
    return_weights : bool
        Whether to return sum of weights.
    return_weights_square: bool
        Whether to return the sum of the squares of the weights. Default is False.


    Check that a specified custom datatype conforms to UVH5 standards.

    According to the UVH5 spec, the data type for the data array must be a
    compound datatype with an "r" field and an "i" field. Additionally, both
    datatypes must be the same (e.g., "<i4", "<r8", etc.).

    Parameters
    ----------
    dtype : numpy dtype
        A numpy dtype object with an "r" field and an "i" field.

    Returns
    -------
    None

    Raises
    ------
    ValueError
        This is raised if dtype is not a numpy dtype, if the dtype does not have
        an "r" field and an "i" field, or if the "r" field and "i" fields have
        different types.


    Get length of a slice s into array of len axlen.

    Parameters
    ----------
    s : slice object
        Slice object to index with
    axlen : int
        Length of axis s slices into

    Returns
    -------
    int
        Length of slice object


    Given a tuple of indices, determine the indexed array shape.

    Parameters
    ----------
    dset : numpy array or h5py dataset
        A numpy array or a reference to an HDF5 dataset on disk. Requires the
        `dset.shape` attribute exists and returns a tuple.
    indices : tuple
        A tuple with the indices to extract along each dimension of dset.
        Each element should contain a list of indices, a slice element,
        or a list of slice elements that will be concatenated after slicing.
        For data arrays with 4 dimensions, the second dimension (the old spw axis)
        should not be included because it can only be length one.

    Returns
    -------
    tuple
        a tuple with the shape of the indexed array
    tuple
        a tuple with indices used (will be different than input if dset has
        4 dimensions and indices has 3 dimensions)


    Index a UVH5 data, flags or nsamples h5py dataset to get data or overwrite data.

    If no `input_array` is passed, this function extracts the data at the indices
    and returns it. If `input_array` is passed, this function replaced the data at the
    indices with the input array.

    Parameters
    ----------
    dset : h5py dataset
        A reference to an HDF5 dataset on disk.
    indices : tuple
        A tuple with the indices to extract along each dimension of dset.
        Each element should contain a list of indices, a slice element,
        or a list of slice elements that will be concatenated after slicing.
        Indices must be provided such that all dimensions can be indexed
        simultaneously. This should have a length equal to the length of the dset,
        with an exception to support the old array shape for uvdata arrays (in that
        case the dset is length 4 but the second dimension is shallow, so only three
        indices need to be passed).
    input_array : ndarray, optional
        Array to be copied into the dset at the indices. If not provided, the data in
        the dset is indexed and returned.

    Returns
    -------
    ndarray or None
        The indexed dset if the `input_array` parameter is not used.

    Notes
    -----
    This makes and fills an empty array with dset indices.
    For trivial indexing, (e.g. a trivial slice), constructing
    a new array and filling it is suboptimal over direct
    indexing, e.g. dset[indices].
    This function specializes in repeated slices over the same axis,
    e.g. if indices is [[slice(0, 5), slice(10, 15), ...], ..., ]


    Read the given data set of a specified type to floating point complex data.

    Parameters
    ----------
    dset : h5py dataset
        A reference to an HDF5 dataset on disk.
    indices : tuple
        The indices to extract. Should be either lists of indices or numpy
        slice objects.
    dtype_out : str or numpy dtype
        The datatype of the output array. One of (complex, np.complex64,
        np.complex128). Default is np.complex64 (single-precision real and
        imaginary floats).

    Returns
    -------
    output_array : ndarray
        The array referenced in the dataset cast to complex values.

    Raises
    ------
    ValueError
        This is raised if dtype_out is not an acceptable value.


    Write floating point complex data as a specified type.

    Parameters
    ----------
    data : ndarray
        The data array to write out. Should be a complex-valued array that
        supports the .real and .imag attributes for accessing real and imaginary
        components.
    dset : h5py dataset
        A reference to an HDF5 dataset on disk.
    indices : tuple
        A 3-tuple representing indices to write data to. Should be either lists
        of indices or numpy slice objects. For data arrays with 4 dimensions, the second
        dimension (the old spw axis) should not be included because it can only be
        length one.

    Returns
    -------
    None


    Get the HDF5 compression and compression options to use.

    Parameters
    ----------
    compression : str
        HDF5 compression specification or "bitshuffle".

    Returns
    -------
    compression_use : str
        HDF5 compression specification
    compression_opts : tuple
        HDF5 compression options


Close the file.


Open the file.


Get the header group.


The telescope location in latitude, longitude, and altitude, in degrees.


The antenna positions in ENU coordinates, in meters.


The telescope frame.


The reference ellipsoid to use for lunar coordinates.


The telescope location object.


The telescope location in ECEF coordinates, in meters.


The antenna names in the file.


The x_orientation in the file.


The extra_keywords from the file.


Dictionary of phase centers.


A Telescope object created from the data.


    Interpret a UVData pair of frame + epoch into a CASA frame name.

    Parameters
    ----------
    frame_name : str
        Name of the frame. Typically matched to the UVData attribute
        `phase_center_frame`.
    epoch_val : float
        Epoch value for the given frame, in Julian years unless `frame_name="FK4"`,
        in which case the value is in Besselian years. Typically matched to the
        UVData attribute `phase_center_epoch`.
    raise_error : bool
        Whether to raise an error if the name has no match. Default is True, if set
        to false will raise a warning instead.

    Returns
    -------
    ref_name : str
        Name of the CASA-based spatial coordinate reference frame.

    Raises
    ------
    ValueError
        If the provided coordinate frame and/or epoch value has no matching
        counterpart to those supported in CASA.


    Read time scale from TIME column in an MS table.

    Parameters
    ----------
    ms_table : table
        Handle for the MeasurementSet table that contains a "TIME" column.
    raise_error : bool
        Whether to raise an error if the name has no match. Default is True, if set
        to false will raise a warning instead.

    Returns
    -------
    time_scale_name : str
        Name of the time scale.

    Raises
    ------
    ValueError
        If the CASA time scale frame does not match the known supported list of
        time scales for astropy.


    Interpret a CASA frame into an astropy-friendly frame and epoch.

    Parameters
    ----------
    ref_name : str
        Name of the CASA-based spatial coordinate reference frame.
    raise_error : bool
        Whether to raise an error if the name has no match. Default is True, if set
        to false will raise a warning instead.

    Returns
    -------
    frame_name : str
        Name of the frame. Typically matched to the UVData attribute
        `phase_center_frame`.
    epoch_val : float
        Epoch value for the given frame, in Julian years unless `frame_name="FK4"`,
        in which case the value is in Besselian years. Typically matched to the
        UVData attribute `phase_center_epoch`.

    Raises
    ------
    ValueError
        If the CASA coordinate frame does not match the known supported list of
        frames for CASA.
    NotImplementedError
        If using a CASA coordinate frame that does not yet have a corresponding
        astropy frame that is supported by pyuvdata.


    Read Measurement Set ANTENNA table.

    Parameters
    ----------
    filepath : str
        path to MS (without ANTENNA suffix)
    check_frame : bool
        If set to True and the "telescope_frame" keyword is found within the Measurement
        Set, check that the frame is one supported by pyuvdata (and if not, an error is
        raised). Currently supported frames include ITRS/ITRF and MCMF.

    Returns
    -------
    ant_dict : dict
        A dictionary with keys that map to columns of the MS, including "antenna_names"
        (list of type string, shape (Nants_telescope,)), "station_names" (list of type
        string, shape (Nants_telescope,)), "antenna_numbers" (ndarray of type int,
        shape (Nants_telescope,)), "antenna_diameters" (ndarray of type float, shape
        (Nants_telescope,)), "telescope_frame" (str), "telescope_ellipsoid" (str),
        and "antenna_positions" (ndarray of type float, shape (Nants_telescope, 3)).

    Raises
    ------
    ValueError
        If `check_frame=True` and "telescope_frame" does not match to a supported type.
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the antenna information into a CASA table.

    Parameters
    ----------
    filepath : str
        Path to MS (without ANTENNA suffix).
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have a telescope
        parameter with parameters that match by name to the other keywords
        required here (with the exception of telescope_frame and telescope_ellipsoid,
        which are derived from the telescope.location UVParameter).
    antenna_numbers : ndarray
        Required if uvobj not provided, antenna numbers for all antennas of the
        telescope, dtype int and shape (Nants_telescope,).
    antenna_names : list
        Required if uvobj not provided, antenna names for all antennas of the telescope.
        List should be length Nants_telescope, and contain elements of type str.
    antenna_positions : ndarray
        Required if uvobj not provided, ITRF/MCMF 3D position (in meters) of antennas
        relative to the array center, of dtype float with shape (Nants_telescope, 3).
    antenna_diameters : ndarray
        Required if uvobj not provided, diameter (in meters) of each antenna, dtype
        float with shape (Nants_telescope,).
    telescope_location : ndarray
        Required if uvobj not provided, ITRF/MCMF 3D location of the array center (in
        meters), dtype float with shape (3,).
    telescope_frame : str
        Required if uvobj not provided, name of the frame in which the telescope
        positions are provided (typically "MCMF", "ITRS", or "ITRF").
    telescope_ellipsoid : str
        Required if uvobj not provided and telescope frame is "MCMF", ellipsoid to use
        for lunar coordinates. Must be one of "SPHERE", "GSFC", "GRAIL23",
        "CE-1-LAM-GEO" (see lunarsky package for details).

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


Read Measurement Set DATA_DESCRIPTION table.

    Parameters
    ----------
    filepath : str
        path to MS (without DATA_DESCRIPTION suffix)

    Returns
    -------
    data_desc_dict : dict
        A dictionary with keys that map to columns of the MS, used to index against
        other tables. These include "SPECTRAL_WINDOW_ID", which match to given rows
        from the SPECTRAL_WINDOW table, "POLARIZATION_ID", which match to given rows
        in the POLARIZATION table, and "FLAG_ROW", which denotes of the ID in question
        has been flagged.

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the data description information into a CASA table.

    Parameters
    ----------
    filepath : str
        Path to MS (without DATA_DESCRIPTION suffix).
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have parameters
        that match by name to the other keywords required here.
    nspws : int
        Required if uvobj is not supplied, the total number of spectral windows to be
        recorded.
    flex_spw_polarization_array : list of int
        Optional argument, required if trying to record a flex-pol data set, which
        denotes the polarization per spectral window, with length equal to nspws.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


    Read Measurement Set FIELD table.

    Parameters
    ----------
    filepath : str
        path to MS (without FIELD suffix)
    return_phase_center_catalog : bool
        Nominally this function will return a dict containing the columns of the table,
        but if set to True, instead a catalog will be supplied in the style of the
        UVData/UVCal `phase_center_catalog` parameters (further description of this
        parameter can be found in the class documentation).

    Returns
    -------
    field_dict : dict
        A dictionary with keys that map to columns of the MS, including "name" (field
        names, list of len Nfield with elements of type str), "ra" (RA in radians,
        ndarray of floats with shape (Nfield,)), "dec" (Dec in radians, ndarray of
        floats with shape (Nfield,)), "source_id" (row number in MS file, ndarray of
        ints with shape (Nfield,)), and "alt_id" (matching source ID number, ndarray of
        ints with shape (Nfield,)). Only given if return_phase_center_catalog=False.
    phase_center_catalog : dict
        A catalog stylized like the UVData/UVCal `phase_center_catalog` parameters, with
        keys matching to the "alt_id"/source ID entries. Useful for plugging directly
        into the `phase_center_catalog` attribute of a UVBase object. Only supplied if
        return_phase_center_catalog=True.
    field_map : dict
        A dict between row number (keys) and the source ID (values), which can be used
        to map the phase center ID array from the main MS table. Only supplied if
        return_phase_center_catalog=True.

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the field information into a CASA table.

    Parameters
    ----------
    filepath : str
        path to MS (without FIELD suffix)
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have parameters
        that match by name to the other keywords required here (with the exception of
        time_val, which is calculated from the time_array UVParameter).
    phase_center_catalog : dict
        A catalog stylized like the UVData/UVCal `phase_center_catalog` parameters (see
        documentation of those classes for more details on expected structure). Required
        if uvobj is not supplied.
    time_val : float
        Required if uvobj is not supplied, representative JD date for the catalog to
        be recorded into the MS file.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


    Read a CASA history table into a string for the uvdata history parameter.

    Also stores messages column as a list for consistency with other uvdata types

    Parameters
    ----------
    filepath : str
        Path to CASA table with history information.
    pyuvdata_version_str : str
        String containing the version of pyuvdata used to read in the MS file, which is
        appended to the history if not previously encoded into the history table.
    check_origin : bool
        If set to True, check whether the MS in question was created by pyuvdata, as
        determined by the history table. Default is False.
    raise_err : bool
        Normally an error is raised if a HISTORY table cannot be found. However, if
        set to False, the history string containing just the pyuvdata version will
        be returned instead.

    Returns
    -------
    str
        string encoding complete casa history table converted with a new
        line denoting rows and a ';' denoting column breaks.
    pyuvdata_written :  bool
        boolean indicating whether or not this MS was written by pyuvdata. Only returned
        of `check_origin=True`.

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Parse the history into an MS history table.

    If the history string contains output from `_ms_hist_to_string`, parse that back
    into the MS history table.

    Parameters
    ----------
    filepath : str
        path to MS (without HISTORY suffix)
    history : str
        Required if uvobj is not given, a string containing the history to be written.
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the history string.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


    Read Measurement Set OBSERVATION table.

    Parameters
    ----------
    filepath : str
        path to MS (without OBSERVATION suffix)

    Returns
    -------
    obs_dict : dict
        A dictionary containing observation information, including "telescope_name"
        (str with the name of the telescope), "observer" (str of observer name), and
        if present, "telescope_location" (ndarray of floats and shape (3,) describing
        the ITRF/MCMF 3D location in meters of the array center).

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the observation information into a CASA table.

    Parameters
    ----------
    filepath : str
        path to MS (without OBSERVATION suffix)
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have parameters
        that match by name to the other keywords required here (with the exception of
        telescope_frame, which is pulled from the telescope_location UVParameter).
    telescope_name :str
        Required if uvobj not provided, name of the telescope.
    telescope_location : ndarray
        Required if uvobj not provided, 3D location (in ITRF/MCMF coordinates in meters)
        of the array center.
    observer : str
        Required if uvobj not provided, name of the observer.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


    Read Measurement Set SPECTRAL_WINDOW table.

    Parameters
    ----------
    filepath : str
        path to MS (without SPECTRAL_WINDOW suffix)

    Returns
    -------
    spw_dict : dict
        Dictionary containing spectral window information, including "chan_freq"
        (ndarray of float and shape (Nspws,), center frequencies of the channels),
        "chan_width" (ndarray of float and shape (Nspws,), channel bandwidths),
        "num_chan" (ndarray of int and shape (Nspws,), number of channels per window),
        and "row_idx" (list of length Nspws with int elements, containing the table row
        number for each window).

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the spectral information into a CASA table.

    Parameters
    ----------
    filepath : str
        path to MS (without SPECTRAL_WINDOW suffix)
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have parameters
        that match by name to the other keywords required here (with the exception of
        id_array, which is pulled from spw_array or flex_spw_id_array depending on the
        context).
    freq_array : ndarray
        Required if uvobj not provided, frequency centers for each channel. Expected
        shape is (Nfreqs,), type float.
    channel_width : ndarray or float
        Required if uvobj not provided, frequency centers for each channel. Expected
        to be of shape (Nfreqs,), type float.
    spw_array : ndarray
        Required if uvobj not provided, ID numbers for spectral windows.
    id_array : ndarray
        Map of how each entry in `freq_array` matches to the spectral windows in
        `spw_array`. Required if uvobj not provided.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


    Read Measurement Set FEED table.

    Note that this method is not yet implemented, and is a placeholder for future
    development.

    Parameters
    ----------
    filepath : str
        path to MS (without FEED suffix)

    Returns
    -------
    feed_dict : dict
        Dictionary containing feed information.

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the feed information into a CASA table.

    Parameters
    ----------
    filepath : str
        path to MS (without FEED suffix)
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have parameters
        that match by name to the other keywords required here.
    nfeeds : int
        Required if uvobj not provided, number of feeds in the telescope for the object.
    feed_array : ndarray of str
        Required if uvobj not provided, describes the polarization of each receiver,
        should be one of "X", "Y", "L", or "R". Shape (nants, nfeeds).
    feed_angle : ndarray of float
        Required if uvobj not provided, orientation of the receiver with respect to the
        great circle at fixed azimuth, shape (nants, nfeeds).
    antenna_numbers : array-like of int
        Required if uvobj not provided, antenna numbers for all antennas of the
        telescope, dtype int and shape (nants,).
    time_val : float
        Required if uvobj is not supplied, representative JD date for the catalog to
        be recorded into the MS file.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


    Read Measurement Set SOURCE table.

    Parameters
    ----------
    filepath : str
        path to MS (without SOURCE suffix)

    Returns
    -------
    source_dict : dict
        A dictionary with keys matched to the source ID, and up to six values which
        map to specific keys in entries of the `phase_center_catalog` parameter
        found in UVData/UVCal objects. They are "cat_lon" (longitudinal position in
        radians), "cat_lat" (latitudinal position in radians), "cat_times"
        (JD dates of ephemeris entries), "cat_type" (type of catalog entry), "cat_pm_ra"
        (proper motion in RA), and "cat_pm_dec" (proper motion in Dec). These entries
        can be used to update keys in `phase_center_catalog` as derived from the FIELD
        table, which only has space to record a single RA/Dec coordinate plus reference
        frame information.

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the source information into a CASA table.

    Parameters
    ----------
    filepath : str
        path to MS (without SOURCE suffix)
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have parameters
        that match by name to the other keywords required here (with the exception of
        time_default, which is derived from the time_array UVParameter).
    time_default : float
        Default time (in MJD seconds) to use for the catalog entries.
    phase_center_catalog : dict
        A catalog stylized like the UVData/UVCal `phase_center_catalog` parameters (see
        documentation of those classes for more details on expected structure). Required
        if uvobj is not supplied.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.


    Read Measurement Set POINTING table.

    Note that this method is not yet implemented, and is a placeholder for future
    development.

    Parameters
    ----------
    filepath : str
        path to MS (without POINTING suffix)

    Returns
    -------
    pointing_dict : dict
        Dictionary containing pointing information.

    Raises
    ------
    FileNotFoundError
        If no MS file is found with the provided name.


    Write out the pointing information into a CASA table.

    Parameters
    ----------
    filepath : str
        path to MS (without POINTING suffix)
    uvobj : UVBase (with matching parameters)
        Optional parameter, can be used to automatically fill the other required
        keywords for this function. Note that the UVBase object must have parameters
        that match by name to the other keywords required here (with the exception of
        max_ant, which is derived from from the antenna_numbers UVParameter).
    max_ant : int
        Required if uvobj not provided, the highest-number antenna for the telescope.
    integration_time : ndarray
        Required if uvobj not provided, integration time per entry. Ndarray of float,
        should match in shape to `time_array`.
    time_array : ndarray
        Required if uvobj not provided, JD date of each entry. Ndarray of float, should
        match in shape to `integration_time`.

    Raises
    ------
    FileNotFoundError
        If no main MS table is found when looking at filepath.