def same_array_size(array1, array2):
    """Crop the input arrays such that they are the same size in both
    dimensions

    Parameters
    ----------
    array1 : numpy.ndarray
        2D array

    array2 : numpy.ndarray
        2D array

    Returns
    -------
    array1 : numpy.ndarray
        Potentially cropped 2D array

    array2 : numpy.ndarray
        Potentially cropped 2D array

    """
    shape1 = array1.shape
    shape2 = array2.shape
    miny = min([shape1[0], shape2[0]])
    minx = min([shape1[1], shape2[1]])

    # Crop y dimension
    if shape1[0] == miny:
        smaller = array1
        larger = array2
        smaller_shape = shape1
        larger_shape = shape2
    else:
        smaller = array2
        larger = array1
        smaller_shape = shape2
        larger_shape = shape1

    diff = abs(larger_shape[0] - miny)
    low_delta = diff // 2
    if diff % 2 == 1:
        high_delta = low_delta + 1
    else:
        high_delta = low_delta
    larger = larger[low_delta: larger_shape[0]-high_delta, :]

    if shape1[0] == miny:
        array1 = smaller
        array2 = larger
    else:
        array1 = larger
        array2 = smaller
    shape1 = array1.shape
    shape2 = array2.shape

    # Crop x dimension
    if shape1[1] == minx:
        smaller = array1
        larger = array2
        smaller_shape = shape1
        larger_shape = shape2
    else:
        smaller = array2
        larger = array1
        smaller_shape = shape2
        larger_shape = shape1

    diff = abs(larger_shape[1] - minx)
    low_delta = diff // 2
    if diff % 2 == 1:
        high_delta = low_delta + 1
    else:
        high_delta = low_delta
    larger = larger[:, low_delta: larger_shape[1]-high_delta]

    if shape1[1] == minx:
        array1 = smaller
        array2 = larger
    else:
        array1 = larger
        array2 = smaller
    shape1 = array1.shape
    shape2 = array2.shape

    return array1, array2