def apply_integer_offsets(image2d, offx, offy):
    """Apply global (integer) offsets to image.

    Parameters
    ----------
    image2d : numpy array
        Input image
    offx : int
        Offset in the X direction (must be integer).
    offy : int
        Offset in the Y direction (must be integer).

    Returns
    -------
    image2d_shifted : numpy array
        Shifted image

    """

    # protections
    if type(offx) != int or type(offy) != int:
        raise ValueError('Invalid non-integer offsets')

    # image dimensions
    naxis2, naxis1 = image2d.shape

    # initialize output image
    image2d_shifted = np.zeros((naxis2, naxis1))

    # handle negative and positive shifts accordingly
    non = lambda s: s if s < 0 else None
    mom = lambda s: max(0,s)

    # shift image
    image2d_shifted[mom(offy):non(offy), mom(offx):non(offx)] = \
        image2d[mom(-offy):non(-offy), mom(-offx):non(-offx)]

    # return shifted image
    return image2d_shifted
Apply global (integer) offsets to image.

    Parameters
    ----------
    image2d : numpy array
        Input image
    offx : int
        Offset in the X direction (must be integer).
    offy : int
        Offset in the Y direction (must be integer).

    Returns
    -------
    image2d_shifted : numpy array
        Shifted image