def unique_id(ID, IDList):
    """
    Assigns a unique ID to each spectral target.
    A spectral target may appear in multiple files so
    unique_id assigns IDs by appending _<New number> to
    the spectral target ID.

    Parameters
    ----------
    ID : String
        Spectral target ID.
    IDList : Dictionary
        Keys are original IDs and the values are the
        numbers that were last used for ID generation.

    returns
    -------
    ID : String
        Unique ID.
    IDList : Dictionary
        Updated IDList.
    """
    keys = IDList.keys()
    if ID not in keys:
        IDList[ID] = 0
        return ID, IDList

    IDList[ID] += 1
    ID = ID+"_%s" % (IDList[ID])

    return ID, IDList