def find_closest(arr, val):
    """Return the closest value to val and its index in a 1D array.

    If the closest value occurs more than once in the array, the index
    of the first occurrence is returned.

    Usage: closest_val, ind = find_closest(arr, val)

    """
    diff = abs(arr-val)
    ind = int(diff.argmin())
    closest_val = float(arr[ind])
    return closest_val, ind