# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
import numpy as np
from ._sampling import _downsample, _upsample

__all__ = ['downsample', 'upsample']


def downsample(array, block_size):
    """
    Downsample an image by block summing image pixels.  This process
    conserves image flux.  If the dimensions of ``image`` are not a
    whole-multiple of ``block_size``, the extra rows/columns will not be
    included in the output downsampled image.

    Parameters
    ----------
    image : array_like, float
        The 2D array of the image.

    block_size : int
        Downsampling integer factor along each axis.

    Returns
    -------
    output : array_like
        The 2D array of the resampled image.

    Examples
    --------
    >>> import numpy as np
    >>> from photutils import utils
    >>> img = np.arange(16.).reshape((4, 4))
    >>> utils.downsample(img, 2)
    array([[ 10.,  18.],
           [ 42.,  50.]])
    """

    return _downsample(array, block_size)


def upsample(array, block_size):
    """
    Upsample an image by block replicating image pixels.  To conserve
    image flux, the block-replicated image is then divided by
    ``block_size**2``.

    Parameters
    ----------
    image : array_like, float
        The 2D array of the image.

    block_size : int
        Upsampling integer factor along each axis.

    Returns
    -------
    output : array_like
        The 2D array of the resampled image.

    Examples
    --------
    >>> import numpy as np
    >>> from photutils import utils
    >>> img = np.array([[0., 1.], [2., 3.]])
    >>> utils.upsample(img, 2)
    array([[ 0.  ,  0.  ,  0.25,  0.25],
           [ 0.  ,  0.  ,  0.25,  0.25],
           [ 0.5 ,  0.5 ,  0.75,  0.75],
           [ 0.5 ,  0.5 ,  0.75,  0.75]])
    """

    return _upsample(array, block_size)

@@ -567,24 +567,318 @@
 led image.%0A%0A
+    This function is similar to the %60scikit-image%60_ %60block_reduce%60_%0A    function, which is more flexible, but slower than %60downsample%60.%0A%0A    .. _scikit-image: http://scikit-image.org/%0A    .. _block_reduce: http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.block_reduce%0A%0A
     Paramete
@@ -1122,32 +1122,72 @@
 sampled image.%0A%0A
+    See Also%0A    --------%0A    upsample%0A%0A
     Examples%0A   
@@ -1897,24 +1897,66 @@
 led image.%0A%0A
+    See Also%0A    --------%0A    downsample%0A%0A
     Examples

Add link to block_reduce