def wave_title(index, sourceNumbers, sourcePoints, flag, plotParams):
    """
    Creates a plot title for data arrays and test function arrays
    
    Parameters:
    index: a number indicating which source in 'interval' parameter produced the data
    interval: an integer array of source numbers
    sourcePoints: location of the sources, if known (equals 'None' otherwise)
    flag: a string parameter (either 'data' or 'impulse')
    plotParams: a dictionary of plot parameters for styling
    """
    xu = plotParams['xu']
    yu = plotParams['yu']
    if flag == 'data':
        data_title = plotParams['data_title']
        if sourcePoints is None:
            title = '%s [Record %s/%s]' % (data_title, sourceNumbers[index],
                len(sourceNumbers))
        elif sourcePoints.shape[1] == 2:
            if xu != '' and yu != '':
                title = '%s [Source %s @ (%0.2f %s, %0.2f %s)]' % (data_title,
                    sourceNumbers[index], sourcePoints[index, 0], xu,
                    sourcePoints[index, 1], yu)
            else:
                title = '%s [Source %s @ (%0.2f, %0.2f)]' % (data_title,
                    sourceNumbers[index], sourcePoints[index, 0],
                    sourcePoints[index, 1])
        elif sourcePoints.shape[1] == 3:
            zu = plotParams['zu']
            if xu != '' and yu != '' and zu != '':
                title = '%s [Source %s @ (%0.2f %s, %0.2f %s, %0.2f %s)]' % (
                    data_title, sourceNumbers[index], sourcePoints[index, 0
                    ], xu, sourcePoints[index, 1], yu, sourcePoints[index, 
                    2], zu)
            else:
                title = '%s [Source %s @ (%0.2f, %0.2f, %0.2f)]' % (data_title,
                    sourceNumbers[index], sourcePoints[index, 0],
                    sourcePoints[index, 1], sourcePoints[index, 2])
    else:
        impulse_title = plotParams['impulse_title']
        if sourcePoints.shape[1] == 2:
            if xu != '' and yu != '':
                title = '%s [$\\bf{z}$ @ (%0.2f %s, %0.2f %s)]' % (
                    impulse_title, sourcePoints[index, 0], xu, sourcePoints
                    [index, 1], yu)
            elif xu == '' and yu == '':
                title = '%s [$\\bf{z}$ @ (%0.2f, %0.2f)]' % (impulse_title,
                    sourcePoints[index, 0], sourcePoints[index, 1])
        elif sourcePoints.shape[1] == 3:
            zu = plotParams['zu']
            if xu != '' and yu != '' and zu != '':
                title = '%s [$\\bf{z}$ @ (%0.2f %s, %0.2f %s, %0.2f %s)]' % (
                    impulse_title, sourcePoints[index, 0], xu, sourcePoints
                    [index, 1], yu, sourcePoints[index, 2], zu)
            elif xu == '' and yu == '' and zu == '':
                title = '%s [$\\bf{z}$ @ (%0.2f, %0.2f, %0.2f)]' % (
                    impulse_title, sourcePoints[index, 0], sourcePoints[
                    index, 1], sourcePoints[index, 2])
    return title
