def read_table(filename, data_key=None, find_table=None, **kwargs):
    """
    Read a `~astropy.table.Table` object from an ASDF file

    This requires `asdf <https://pypi.org/project/asdf/>`_ to be installed.
    By default, this function will look for a Table object with the key of
    ``data`` in the top-level ASDF tree. The parameters ``data_key`` and
    ``find_key`` can be used to override the default behavior.

    This function is registered as the Table reader for ASDF files with the
    unified I/O interface.

    Parameters
    ----------
    filename : str or :class:`py.lath:local`
        Name of the file to be read
    data_key : str
        Optional top-level key to use for finding the Table in the tree. If not
        provided, uses ``data`` by default. Use of this parameter is not
        compatible with ``find_table``.
    find_table : function
        Optional function to be used for locating the Table in the tree. The
        function takes a single parameter, which is a dictionary representing
        the top of the ASDF tree. The function must return a
        `~astropy.table.Table` instance.

    Returns
    -------
    table : `~astropy.table.Table`
        `~astropy.table.Table` instance
    """
    try:
        import asdf
    except ImportError:
        raise Exception(
            'The asdf module is required to read and write ASDF files')
    if data_key and find_table:
        raise ValueError(
            "Options 'data_key' and 'find_table' are not compatible")
    with asdf.open(filename, **kwargs) as af:
        if find_table:
            return find_table(af.tree)
        else:
            return af[data_key or 'data']
