def unpad_array(a, nps):
    """
    Unpads an array using the outputs from pad_array.

    This function takes a padded array and removes the padding from both.
    Effectively, this is a complement to gridder.cut for when you already
    know the number of elements to remove.

    .. note:: Unlike :func:`~fatiando.gridder.pad_array`, this returns a slice
        of the input array.  Therefore, any changes to the padded array will be
        reflected in the unpadded array.

    Parameters:

    * a : array
        Array to be un-padded.  Can be of arbitrary dimension.
    * nps : list
        List of tuples giving the min and max indices for the cutoff.
        Identical to nps returned by pad_array

    Returns:

    * b : array
        Array of same dimension as a, with padding removed

    Examples:

        >>> z = numpy.array([3, 4, 4, 5, 6])
        >>> zpad, nps = pad_array(z)
        >>> zpad
        array([ 4.4,  3.2,  3. ,  4. ,  4. ,  5. ,  6. ,  4.4])
        >>> zunpad = unpad_array(zpad, nps)
        >>> zunpad
        array([ 3.,  4.,  4.,  5.,  6.])

    """
    o = []
    for ii in range(0, a.ndim):
        o.append(slice(nps[ii][0], a.shape[ii] - nps[ii][1]))
    b = a[o]
    return b
