def shift(img, interval_length=1.0):
    """ shift a range of data from [0, interval_length] to
    [-interval_length/2, interval_length/2]
    """

    midpoint = interval_length / 2

    shifted = img.copy()
    shifted[shifted > midpoint] -= interval_length
    shifted[shifted < -midpoint] += interval_length

    return shifted