def extract_array(indices_center, halfsizes, inputarray2D):
    """
    extract a 2D slice array from inputarray2D

    aa= array([[ 0,  1,  2,  3,  4,  5,  6],
       [ 7,  8,  9, 10, 11, 12, 13],
       [14, 15, 16, 17, 18, 19, 20],
       [21, 22, 23, 24, 25, 26, 27],
       [28, 29, 30, 31, 32, 33, 34],
       [35, 36, 37, 38, 39, 40, 41],
       [42, 43, 44, 45, 46, 47, 48],
       [49, 50, 51, 52, 53, 54, 55]])

    extract_array((3,4),(2,1),aa)

    array([[10, 11, 12],
       [17, 18, 19],
       [24, 25, 26],
       [31, 32, 33],
       [38, 39, 40]])
    """
    slowindex_center, fastindex_center = indices_center
    slowindex_halfsize, fastindex_halfsize = halfsizes
    nslow, nfast = inputarray2D.shape
    imax = min(slowindex_center + slowindex_halfsize, nslow - 1)[0]
    imin = max(slowindex_center - slowindex_halfsize, 0)[0]
    jmax = min(fastindex_center + fastindex_halfsize, nfast - 1)[0]
    jmin = max(fastindex_center - fastindex_halfsize, 0)[0]
    print('imin:imax + 1, jmin:jmax + 1', imin, imax + 1, jmin, jmax + 1)
    return inputarray2D[imin:imax + 1, jmin:jmax + 1]
