def vector_name_iterator(data):
    """
    Produces an iterator that yields 2-tuples of vectors given a dict of fields

    vectors are identified by identifying fields with common prefixes that all
    end with '_x', '_y', or '_z'.

    The first element of the yielded tuple holds the common prefix of the 
    fields related to the vector, while the second element holds a list of 
    field names corresponding to the various components (orderred as x,y,z).
    Missing components are replaced by a None
    """

    ax_map = {'x' : 0, 'y' : 1, 'z' : 2}
    candidates = {}
    # identify candidate vectors
    for elem in data.keys():
        temp = elem.split('_')
        if len(temp) != 2 or (temp[1] not in ['x','y','z']):
            continue
        prefix, dim = temp
        if prefix not in candidates:
            candidates[prefix] = [None, None, None]
        candidates[prefix][ax_map[dim]] = elem
    return candidates.items()