import warnings


def skymodel_to_array(sky):
    """
    Make a recarray of source components from a SkyModel object.

    Deprecated. Use `SkyModel.to_recarray` instead.

    Parameters
    ----------
    sky : :class:`pyradiosky.SkyModel`
        SkyModel object to convert to a recarray.

    Returns
    -------
    catalog_table : recarray
        recarray equivalent to SkyModel data.

    Notes
    -----
    This stores all SkyModel data in a contiguous array
    that can be more easily handled with numpy.
    This is used by pyuvsim for sharing catalog data via MPI.
    """
    warnings.warn(
        "This function is deprecated, use `SkyModel.to_recarray` instead. "
        "This function will be removed in version 0.2.0.",
        category=DeprecationWarning,
    )

    return sky.to_recarray()