def check_comp(available_comps, comp):
    """Check if a component is in available components and return a
    helpful error message

    Parameters
    ----------
    available_comps : list
        List of available components.  For example:
        ``['R', 'THETA', 'Z', 'RTHETA', 'THETAZ', 'RZ']``
        Case should be all caps

    comp : str
        Component to check.  Any case.

    Returns
    -------
    idx : int
        Index in ``available_comps``.

    """
    if comp is None:
        raise ValueError('Missing "comp" parameter.  Please select'
                         ' from the following:\n%s' % available_comps)
    comp = comp.upper()
    if comp not in available_comps:
        raise ValueError('Invalid "comp" parameter %s.  Please select' % comp +
                         ' from the following:\n%s' % available_comps)
    return available_comps.index(comp)