σ
ίΘ[c           @` s,  d  d l  m Z m Z m Z m Z d  d l Z d  d l Z d d l m	 Z	 m
 Z
 m Z d d l m Z d d l m Z d d l m Z m Z d	 d
 d d d d d d d d d d d d d g Z d   Z d e	 f d     YZ d e
 f d     YZ d e	 f d     YZ d e
 f d      YZ d! e
 f d"     YZ d# e
 f d$     YZ d% e	 f d&     YZ d' e
 f d(     YZ d) e	 f d*     YZ d+ e
 f d,     YZ d- e
 f d.     YZ d/ e
 f d0     YZ  d1 e	 f d2     YZ! d3 e
 f d4     YZ" d5 e
 f d6     YZ# d7 e f d8     YZ$ d S(9   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   Kernel1Dt   Kernel2Dt   Kernel(   t   KernelSizeErrori   (   t   models(   t   Fittable1DModelt   Fittable2DModelu   Gaussian1DKernelu   Gaussian2DKernelu   CustomKernelu   Box1DKernelu   Box2DKernelu   Tophat2DKernelu   Trapezoid1DKernelu   MexicanHat1DKernelu   MexicanHat2DKernelu   AiryDisk2DKernelu   Moffat2DKernelu   Model1DKernelu   Model2DKernelu   TrapezoidDisk2DKernelu   Ring2DKernelc         C` s5   t  t j |    } | d d k r- | d S| Sd  S(   Ni   i    i   (   t   intt   matht   ceil(   t   valuet   i(    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyt   _round_up_to_odd_integer   s    t   Gaussian1DKernelc           B` s#   e  Z d  Z e Z e Z d   Z RS(   u  
    1D Gaussian filter kernel.

    The Gaussian filter is a filter with great smoothing properties. It is
    isotropic and does not produce artifacts.

    Parameters
    ----------
    stddev : number
        Standard deviation of the Gaussian kernel.
    x_size : odd int, optional
        Size of the kernel array. Default = 8 * stddev
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by linearly interpolating
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin. Very slow.
    factor : number, optional
        Factor of oversampling. Default factor = 10. If the factor
        is too large, evaluation can be very slow.


    See Also
    --------
    Box1DKernel, Trapezoid1DKernel, MexicanHat1DKernel


    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Gaussian1DKernel
        gauss_1D_kernel = Gaussian1DKernel(10)
        plt.plot(gauss_1D_kernel, drawstyle='steps')
        plt.xlabel('x [pixels]')
        plt.ylabel('value')
        plt.show()
    c         K` s|   t  j d t j d t j  | d |  |  _ t d |  |  _ t t	 |   j
 |   t j d |  j j    |  _ d  S(   Ng      π?i   i    i   (   R   t
   Gaussian1Dt   npt   sqrtt   pit   _modelR   t   _default_sizet   superR   t   __init__t   abst   _arrayt   sumt   _truncation(   t   selft   stddevt   kwargs(    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   U   s
    !(   t   __name__t
   __module__t   __doc__t   Truet
   _separablet   Falset   _is_boolR   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR      s   3t   Gaussian2DKernelc           B` s#   e  Z d  Z e Z e Z d   Z RS(   uΑ  
    2D Gaussian filter kernel.

    The Gaussian filter is a filter with great smoothing properties. It is
    isotropic and does not produce artifacts.

    Parameters
    ----------
    stddev : number
        Standard deviation of the Gaussian kernel.
    x_size : odd int, optional
        Size in x direction of the kernel array. Default = 8 * stddev.
    y_size : odd int, optional
        Size in y direction of the kernel array. Default = 8 * stddev.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.


    See Also
    --------
    Box2DKernel, Tophat2DKernel, MexicanHat2DKernel, Ring2DKernel,
    TrapezoidDisk2DKernel, AiryDisk2DKernel, Moffat2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Gaussian2DKernel
        gaussian_2D_kernel = Gaussian2DKernel(10)
        plt.imshow(gaussian_2D_kernel, interpolation='none', origin='lower')
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()

    c         K` s}   t  j d d t j | d d d | |  |  _ t d |  |  _ t t |   j	 |   t j
 d |  j j    |  _ d  S(   Ng      π?i   i    i   (   R   t
   Gaussian2DR   R   R   R   R   R   R(   R   R   R   R   R   (   R   R   R    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR      s
    (   R!   R"   R#   R$   R%   R&   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR(   ]   s   6t   Box1DKernelc           B` s#   e  Z d  Z e Z e Z d   Z RS(   uΊ  
    1D Box filter kernel.

    The Box filter or running mean is a smoothing filter. It is not isotropic
    and can produce artifacts, when applied repeatedly to the same data.

    By default the Box kernel uses the ``linear_interp`` discretization mode,
    which allows non-shifting, even-sized kernels.  This is achieved by
    weighting the edge pixels with 1/2. E.g a Box kernel with an effective
    smoothing of 4 pixel would have the following array: [0.5, 1, 1, 1, 0.5].


    Parameters
    ----------
    width : number
        Width of the filter kernel.
    mode : str, optional
        One of the following discretization modes:
            * 'center'
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp' (default)
                Discretize model by linearly interpolating
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    See Also
    --------
    Gaussian1DKernel, Trapezoid1DKernel, MexicanHat1DKernel


    Examples
    --------
    Kernel response function:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Box1DKernel
        box_1D_kernel = Box1DKernel(9)
        plt.plot(box_1D_kernel, drawstyle='steps')
        plt.xlim(-1, 9)
        plt.xlabel('x [pixels]')
        plt.ylabel('value')
        plt.show()

    c         K` sb   t  j d | d |  |  _ t |  |  _ d | d <t t |   j |   d |  _ |  j	   d  S(   Ng      π?i    u   linear_interpu   mode(
   R   t   Box1DR   R   R   R   R*   R   R   t	   normalize(   R   t   widthR    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   Ϊ   s    
	(   R!   R"   R#   R$   R%   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR*      s   7t   Box2DKernelc           B` s#   e  Z d  Z e Z e Z d   Z RS(   u  
    2D Box filter kernel.

    The Box filter or running mean is a smoothing filter. It is not isotropic
    and can produce artifact, when applied repeatedly to the same data.

    By default the Box kernel uses the ``linear_interp`` discretization mode,
    which allows non-shifting, even-sized kernels.  This is achieved by
    weighting the edge pixels with 1/2.


    Parameters
    ----------
    width : number
        Width of the filter kernel.
    mode : str, optional
        One of the following discretization modes:
            * 'center'
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp' (default)
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.


    See Also
    --------
    Gaussian2DKernel, Tophat2DKernel, MexicanHat2DKernel, Ring2DKernel,
    TrapezoidDisk2DKernel, AiryDisk2DKernel, Moffat2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Box2DKernel
        box_2D_kernel = Box2DKernel(9)
        plt.imshow(box_2D_kernel, interpolation='none', origin='lower',
                   vmin=0.0, vmax=0.015)
        plt.xlim(-1, 9)
        plt.ylim(-1, 9)
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()
    c         K` sl   t  j d | d d d | |  |  _ t |  |  _ d | d <t t |   j |   d |  _ |  j	   d  S(   Ng      π?i   i    u   linear_interpu   mode(
   R   t   Box2DR   R   R   R   R.   R   R   R,   (   R   R-   R    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR      s    &
	(   R!   R"   R#   R$   R%   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR.   γ   s   9t   Tophat2DKernelc           B` s   e  Z d  Z d   Z RS(   uβ  
    2D Tophat filter kernel.

    The Tophat filter is an isotropic smoothing filter. It can produce
    artifacts when applied repeatedly on the same data.

    Parameters
    ----------
    radius : int
        Radius of the filter kernel.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.


    See Also
    --------
    Gaussian2DKernel, Box2DKernel, MexicanHat2DKernel, Ring2DKernel,
    TrapezoidDisk2DKernel, AiryDisk2DKernel, Moffat2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Tophat2DKernel
        tophat_2D_kernel = Tophat2DKernel(40)
        plt.imshow(tophat_2D_kernel, interpolation='none', origin='lower')
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()

    c         K` s`   t  j d t j | d d d |  |  _ t d |  |  _ t t |   j	 |   d |  _
 d  S(   Ng      π?i   i    (   R   t   Disk2DR   R   R   R   R   R   R0   R   R   (   R   t   radiusR    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   \  s    *(   R!   R"   R#   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR0   )  s   2t   Ring2DKernelc           B` s   e  Z d  Z d   Z RS(   u)  
    2D Ring filter kernel.

    The Ring filter kernel is the difference between two Tophat kernels of
    different width. This kernel is useful for, e.g., background estimation.

    Parameters
    ----------
    radius_in : number
        Inner radius of the ring kernel.
    width : number
        Width of the ring kernel.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    See Also
    --------
    Gaussian2DKernel, Box2DKernel, Tophat2DKernel, MexicanHat2DKernel,
    Ring2DKernel, AiryDisk2DKernel, Moffat2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Ring2DKernel
        ring_2D_kernel = Ring2DKernel(9, 8)
        plt.imshow(ring_2D_kernel, interpolation='none', origin='lower')
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()
    c         K` su   | | } t  j d t j | d | d d d | |  |  _ t d |  |  _ t t |   j	 |   d |  _
 d  S(   Ng      π?i   i    (   R   t   Ring2DR   R   R   R   R   R   R3   R   R   (   R   t	   radius_inR-   R    t
   radius_out(    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR     s    
 (   R!   R"   R#   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR3   c  s   2t   Trapezoid1DKernelc           B` s    e  Z d  Z e Z d d  Z RS(   u  
    1D trapezoid kernel.

    Parameters
    ----------
    width : number
        Width of the filter kernel, defined as the width of the constant part,
        before it begins to slope down.
    slope : number
        Slope of the filter kernel's tails
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by linearly interpolating
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    See Also
    --------
    Box1DKernel, Gaussian1DKernel, MexicanHat1DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Trapezoid1DKernel
        trapezoid_1D_kernel = Trapezoid1DKernel(17, slope=0.2)
        plt.plot(trapezoid_1D_kernel, drawstyle='steps')
        plt.xlabel('x [pixels]')
        plt.ylabel('amplitude')
        plt.xlim(-1, 28)
        plt.show()
    g      π?c         K` s_   t  j d d | |  |  _ t | d |  |  _ t t |   j |   d |  _ |  j	   d  S(   Ni   i    g       @(
   R   t   Trapezoid1DR   R   R   R   R7   R   R   R,   (   R   R-   t   slopeR    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   Ρ  s
    	(   R!   R"   R#   R&   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR7     s   /t   TrapezoidDisk2DKernelc           B` s    e  Z d  Z e Z d d  Z RS(   u  
    2D trapezoid kernel.

    Parameters
    ----------
    radius : number
        Width of the filter kernel, defined as the width of the constant part,
        before it begins to slope down.
    slope : number
        Slope of the filter kernel's tails
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    See Also
    --------
    Gaussian2DKernel, Box2DKernel, Tophat2DKernel, MexicanHat2DKernel,
    Ring2DKernel, AiryDisk2DKernel, Moffat2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import TrapezoidDisk2DKernel
        trapezoid_2D_kernel = TrapezoidDisk2DKernel(20, slope=0.2)
        plt.imshow(trapezoid_2D_kernel, interpolation='none', origin='lower')
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()

    g      π?c         K` sf   t  j d d d | |  |  _ t d | d |  |  _ t t |   j |   d |  _ |  j	   d  S(   Ni   i    i   g       @(
   R   t   TrapezoidDisk2DR   R   R   R   R:   R   R   R,   (   R   R2   R9   R    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR     s
    	(   R!   R"   R#   R&   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR:   Ω  s   1t   MexicanHat1DKernelc           B` s   e  Z d  Z e Z d   Z RS(   uΔ  
    1D Mexican hat filter kernel.

    The Mexican Hat, or inverted Gaussian-Laplace filter, is a
    bandpass filter. It smoothes the data and removes slowly varying
    or constant structures (e.g. Background). It is useful for peak or
    multi-scale detection.

    This kernel is derived from a normalized Gaussian function, by
    computing the second derivative. This results in an amplitude
    at the kernels center of 1. / (sqrt(2 * pi) * width ** 3). The
    normalization is the same as for `scipy.ndimage.gaussian_laplace`,
    except for a minus sign.

    Parameters
    ----------
    width : number
        Width of the filter kernel, defined as the standard deviation
        of the Gaussian function from which it is derived.
    x_size : odd int, optional
        Size in x direction of the kernel array. Default = 8 * width.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by linearly interpolating
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.


    See Also
    --------
    Box1DKernel, Gaussian1DKernel, Trapezoid1DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import MexicanHat1DKernel
        mexicanhat_1D_kernel = MexicanHat1DKernel(10)
        plt.plot(mexicanhat_1D_kernel, drawstyle='steps')
        plt.xlabel('x [pixels]')
        plt.ylabel('value')
        plt.show()

    c         K` s   d t  j d t  j  | d } t j | d |  |  _ t d |  |  _ t t	 |   j
 |   t  j |  j j   |  j j  |  _ d  S(   Ng      π?i   i   i    i   (   R   R   R   R   t   MexicanHat1DR   R   R   R   R<   R   R   R   R   t   sizeR   (   R   R-   R    t	   amplitude(    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   S  s
    "(   R!   R"   R#   R$   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR<     s   ;t   MexicanHat2DKernelc           B` s   e  Z d  Z e Z d   Z RS(   u€  
    2D Mexican hat filter kernel.

    The Mexican Hat, or inverted Gaussian-Laplace filter, is a
    bandpass filter. It smoothes the data and removes slowly varying
    or constant structures (e.g. Background). It is useful for peak or
    multi-scale detection.

    This kernel is derived from a normalized Gaussian function, by
    computing the second derivative. This results in an amplitude
    at the kernels center of 1. / (pi * width ** 4). The normalization
    is the same as for `scipy.ndimage.gaussian_laplace`, except
    for a minus sign.

    Parameters
    ----------
    width : number
        Width of the filter kernel, defined as the standard deviation
        of the Gaussian function from which it is derived.
    x_size : odd int, optional
        Size in x direction of the kernel array. Default = 8 * width.
    y_size : odd int, optional
        Size in y direction of the kernel array. Default = 8 * width.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.


    See Also
    --------
    Gaussian2DKernel, Box2DKernel, Tophat2DKernel, Ring2DKernel,
    TrapezoidDisk2DKernel, AiryDisk2DKernel, Moffat2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import MexicanHat2DKernel
        mexicanhat_2D_kernel = MexicanHat2DKernel(10)
        plt.imshow(mexicanhat_2D_kernel, interpolation='none', origin='lower')
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()
    c         K` s   d t  j | d } t j | d d |  |  _ t d |  |  _ t t |   j	 |   t  j
 |  j j   |  j j  |  _ d  S(   Ng      π?i   i    i   (   R   R   R   t   MexicanHat2DR   R   R   R   R@   R   R   R   R   R>   R   (   R   R-   R    R?   (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR     s
    (   R!   R"   R#   R&   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR@   [  s   >t   AiryDisk2DKernelc           B` s   e  Z d  Z e Z d   Z RS(   uΰ  
    2D Airy disk kernel.

    This kernel models the diffraction pattern of a circular aperture. This
    kernel is normalized to a peak value of 1.

    Parameters
    ----------
    radius : float
        The radius of the Airy disk kernel (radius of the first zero).
    x_size : odd int, optional
        Size in x direction of the kernel array. Default = 8 * radius.
    y_size : odd int, optional
        Size in y direction of the kernel array. Default = 8 * radius.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    See Also
    --------
    Gaussian2DKernel, Box2DKernel, Tophat2DKernel, MexicanHat2DKernel,
    Ring2DKernel, TrapezoidDisk2DKernel, AiryDisk2DKernel, Moffat2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import AiryDisk2DKernel
        airydisk_2D_kernel = AiryDisk2DKernel(10)
        plt.imshow(airydisk_2D_kernel, interpolation='none', origin='lower')
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()
    c         K` s[   t  j d d d |  |  _ t d |  |  _ t t |   j |   |  j   d  |  _
 d  S(   Ni   i    i   (   R   t
   AiryDisk2DR   R   R   R   RB   R   R,   t   NoneR   (   R   R2   R    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   Ϋ  s
    
(   R!   R"   R#   R&   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRB   €  s   4t   Moffat2DKernelc           B` s   e  Z d  Z e Z d   Z RS(   u€  
    2D Moffat kernel.

    This kernel is a typical model for a seeing limited PSF.

    Parameters
    ----------
    gamma : float
        Core width of the Moffat model.
    alpha : float
        Power index of the Moffat model.
    x_size : odd int, optional
        Size in x direction of the kernel array. Default = 8 * radius.
    y_size : odd int, optional
        Size in y direction of the kernel array. Default = 8 * radius.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    See Also
    --------
    Gaussian2DKernel, Box2DKernel, Tophat2DKernel, MexicanHat2DKernel,
    Ring2DKernel, TrapezoidDisk2DKernel, AiryDisk2DKernel

    Examples
    --------
    Kernel response:

     .. plot::
        :include-source:

        import matplotlib.pyplot as plt
        from astropy.convolution import Moffat2DKernel
        moffat_2D_kernel = Moffat2DKernel(3, 2)
        plt.imshow(moffat_2D_kernel, interpolation='none', origin='lower')
        plt.xlabel('x [pixels]')
        plt.ylabel('y [pixels]')
        plt.colorbar()
        plt.show()
    c         K` s   t  j | d t j | | d d | |  |  _ d | d d | d d } t d |  |  _ t t |   j	 |   |  j
   d  |  _ d  S(   Ng      π?i    g       @g      ΰ?g      @(   R   t   Moffat2DR   R   R   R   R   R   RE   R   R,   RD   R   (   R   t   gammat   alphaR    t   fwhm(    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR     s    
(   R!   R"   R#   R&   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRE   γ  s   5t   Model1DKernelc           B` s#   e  Z d  Z e Z e Z d   Z RS(   uk  
    Create kernel from 1D model.

    The model has to be centered on x = 0.

    Parameters
    ----------
    model : `~astropy.modeling.Fittable1DModel`
        Kernel response function model
    x_size : odd int, optional
        Size in x direction of the kernel array. Default = 8 * width.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by linearly interpolating
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    Raises
    ------
    TypeError
        If model is not an instance of `~astropy.modeling.Fittable1DModel`

    See also
    --------
    Model2DKernel : Create kernel from `~astropy.modeling.Fittable2DModel`
    CustomKernel : Create kernel from list or array

    Examples
    --------
    Define a Gaussian1D model:

        >>> from astropy.modeling.models import Gaussian1D
        >>> from astropy.convolution.kernels import Model1DKernel
        >>> gauss = Gaussian1D(1, 0, 2)

    And create a custom one dimensional kernel from it:

        >>> gauss_kernel = Model1DKernel(gauss, x_size=9)

    This kernel can now be used like a usual Astropy kernel.
    c         K` sA   t  | t  r | |  _ n t d   t t |   j |   d  S(   Nu   Must be Fittable1DModel(   t
   isinstanceR	   R   t	   TypeErrorR   RJ   R   (   R   t   modelR    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   ]  s    (   R!   R"   R#   R&   R%   R'   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRJ   %  s   4t   Model2DKernelc           B` s#   e  Z d  Z e Z e Z d   Z RS(   uξ  
    Create kernel from 2D model.

    The model has to be centered on x = 0 and y = 0.

    Parameters
    ----------
    model : `~astropy.modeling.Fittable2DModel`
        Kernel response function model
    x_size : odd int, optional
        Size in x direction of the kernel array. Default = 8 * width.
    y_size : odd int, optional
        Size in y direction of the kernel array. Default = 8 * width.
    mode : str, optional
        One of the following discretization modes:
            * 'center' (default)
                Discretize model by taking the value
                at the center of the bin.
            * 'linear_interp'
                Discretize model by performing a bilinear interpolation
                between the values at the corners of the bin.
            * 'oversample'
                Discretize model by taking the average
                on an oversampled grid.
            * 'integrate'
                Discretize model by integrating the
                model over the bin.
    factor : number, optional
        Factor of oversampling. Default factor = 10.

    Raises
    ------
    TypeError
        If model is not an instance of `~astropy.modeling.Fittable2DModel`

    See also
    --------
    Model1DKernel : Create kernel from `~astropy.modeling.Fittable1DModel`
    CustomKernel : Create kernel from list or array

    Examples
    --------
    Define a Gaussian2D model:

        >>> from astropy.modeling.models import Gaussian2D
        >>> from astropy.convolution.kernels import Model2DKernel
        >>> gauss = Gaussian2D(1, 0, 0, 2, 2)

    And create a custom two dimensional kernel from it:

        >>> gauss_kernel = Model2DKernel(gauss, x_size=9)

    This kernel can now be used like a usual astropy kernel.

    c         K` sJ   t  |  _ t | t  r$ | |  _ n t d   t t |   j |   d  S(   Nu   Must be Fittable2DModel(	   R&   R%   RK   R
   R   RL   R   RN   R   (   R   RM   R    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR      s
    	(   R!   R"   R#   R&   R'   R%   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRN   e  s   7t	   PSFKernelc           B` s   e  Z d  Z e Z d   Z RS(   u=   
    Initialize filter kernel from astropy PSF instance.
    c         C` s   t  d   d  S(   Nu   Not yet implemented(   t   NotImplementedError(   R   (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   ―  s    (   R!   R"   R#   R&   R%   R   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRO   ©  s   t   CustomKernelc           B` s8   e  Z d  Z d   Z e d    Z e j d    Z RS(   u'  
    Create filter kernel from list or array.

    Parameters
    ----------
    array : list or array
        Filter kernel array. Size must be odd.

    Raises
    ------
    TypeError
        If array is not a list or array.
    KernelSizeError
        If array size is even.

    See also
    --------
    Model2DKernel, Model1DKernel

    Examples
    --------
    Define one dimensional array:

        >>> from astropy.convolution.kernels import CustomKernel
        >>> import numpy as np
        >>> array = np.array([1, 2, 3, 2, 1])
        >>> kernel = CustomKernel(array)
        >>> kernel.dimension
        1

    Define two dimensional array:

        >>> array = np.array([[1, 1, 1], [1, 2, 1], [1, 1, 1]])
        >>> kernel = CustomKernel(array)
        >>> kernel.dimension
        2
    c         C` s&   | |  _  t t |   j |  j  d  S(   N(   t   arrayR   RQ   R   R   (   R   RR   (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyR   Ω  s    	c         C` s   |  j  S(   u&   
        Filter kernel array.
        (   R   (   R   (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRR   έ  s    c         C` sΰ   t  | t j  r* | j t j  |  _ n9 t  | t  rW t j | d t j |  _ n t d   t	 d   |  j
 D  } | s t d   n  |  j d k } |  j d k } t t j	 t j | |    |  _ d |  _ d S(	   u,   
        Filter kernel array setter
        t   dtypeu   Must be list or array.c         s` s   |  ] } | d  d k Vq d S(   i   i    N(    (   t   .0t	   axes_size(    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pys	   <genexpr>ρ  s    u$   Kernel size must be odd in all axes.g      π?i    g        N(   RK   R   t   ndarrayt   astypet   float64R   t   listRR   RL   t   allt   shapeR   t   boolt
   logical_orR'   R   (   R   RR   t   oddt   onest   zeros(    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRR   δ  s    $(   R!   R"   R#   R   t   propertyRR   t   setter(    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyRQ   ³  s   %	(%   t
   __future__R    R   R   R   R   t   numpyR   t   coreR   R   R   t   utilsR   t   modelingR   t   modeling.coreR	   R
   t   __all__R   R   R(   R*   R.   R0   R3   R7   R:   R<   R@   RB   RE   RJ   RN   RO   RQ   (    (    (    s:   lib/python2.7/site-packages/astropy/convolution/kernels.pyt   <module>   s8   "					?BDF:<:<FI?B@D
