def find_above(target, valid_data):
    """ Finds the nearest valid cell above the target.

    Parameters
    ----------
    target: tuple
        Indices of target cell
    valid_data: np.array(logical)

    Returns
    -------
    above_idx: tuple
        Indices of valid cell immediately above target
    """

    # Initialize cell counter
    above_idx = target[0] - 1

    # Find nearest valid cell above target
    while above_idx >= 0 and not valid_data[above_idx, target[1]]:
        above_idx = above_idx - 1
    if above_idx >= 0:
        above_idx = (above_idx, target[1])
    else:
        above_idx = None

    return above_idx