'Normalize the filter kernel.
Parameters
mode : {\'integral\', \'peak\'}
One of the following modes:
* \'integral\' (default)
Kernel is normalized such that its integral = 1.
* \'peak\'
Kernel is normalized such that its peak = 1.'

def normalize(self, mode=u'integral'):

    if (mode == u'integral'):
        normalization = self._array.sum()
    elif (mode == u'peak'):
        normalization = self._array.max()
    else:
        raise ValueError(u"invalid    mode,    must    be    'integral'    or    'peak'")
    if (normalization == 0):
        warnings.warn(u'The    kernel    cannot    be    normalized    because    it    sums    to    zero.', AstropyUserWarning)
    else:
        np.divide(self._array, normalization, self._array)
    self._kernel_sum = self._array.sum()
