
[c           @` s  d  Z  d d l m Z m Z m Z m Z d d l m Z d d l Z	 d d l
 m Z m Z m Z m Z d d l m Z m Z d d l m Z d	 d
 l m Z d	 d l m Z d	 d l m Z d	 d l m Z m Z d	 d l m Z d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& d' d( d) g Z d	 e	 j  Z! e	 j" e	 j# e	 j$  j%  Z& d* e f d+     YZ' d, e' f d-     YZ( e d. d/ d0 d1 e' f d2     Y Z) d3 e f d4     YZ* d5 e f d6     YZ+ d7 e f d8     YZ, d9 e f d:     YZ- d; e f d<     YZ. d= e f d>     YZ/ d? e f d@     YZ0 dA e f dB     YZ1 dC e f dD     YZ2 dE e f dF     YZ3 dG e f dH     YZ4 dI e f dJ     YZ5 dK e f dL     YZ6 dM e f dN     YZ7 dO e f dP     YZ8 dQ e f dR     YZ9 dS e f dT     YZ: dU e f dV     YZ; dW e f dX     YZ< dY e f dZ     YZ= d[ e f d\     YZ> d] e f d^     YZ? d_ e f d`     YZ@ da e f db     YZA dc e f dd     YZB de e f df     YZC dg e f dh     YZD d S(i   u   Mathematical models.i    (   t   absolute_importt   unicode_literalst   divisiont   print_function(   t   OrderedDictNi   (   t   Fittable1DModelt   Fittable2DModelt   Modelt   ModelDefinitionError(   t	   Parametert   InputParameterError(   t   ellipse_extenti   (   t   map(   t   gaussian_sigma_to_fwhm(   t   units(   t   Quantityt
   UnitsError(   t
   deprecatedu
   AiryDisk2Du   Moffat1Du   Moffat2Du   Box1Du   Box2Du   Const1Du   Const2Du	   Ellipse2Du   Disk2Du   BaseGaussian1Du
   Gaussian1Du   GaussianAbsorption1Du
   Gaussian2Du   Linear1Du	   Lorentz1Du   MexicanHat1Du   MexicanHat2Du   RedshiftScaleFactoru   Scaleu   Sersic1Du   Sersic2Du   Shiftu   Sine1Du   Trapezoid1Du   TrapezoidDisk2Du   Ring2Du   Voigt1Dt   BaseGaussian1Dc           B` sb   e  Z d  Z e d d  Z e d d  Z e d d d e d f  Z d d  Z	 e
 d    Z RS(	   u   Base class for 1D Gaussian models. Do not use this directly.

    See Also
    --------
    Gaussian1D, GaussianAbsorption1D
    t   defaulti   i    t   boundsg      @c         C` s(   |  j  } | |  j } | | | | f S(   u  
        Tuple defining the default ``bounding_box`` limits,
        ``(x_low, x_high)``

        Parameters
        ----------
        factor : float
            The multiple of `stddev` used to define the limits.
            The default is 5.5, corresponding to a relative error < 1e-7.

        Examples
        --------
        >>> from astropy.modeling.models import Gaussian1D
        >>> model = Gaussian1D(mean=0, stddev=2)
        >>> model.bounding_box
        (-11.0, 11.0)

        This range can be set directly (see: `Model.bounding_box
        <astropy.modeling.Model.bounding_box>`) or by using a different factor,
        like:

        >>> model.bounding_box = model.bounding_box(factor=2)
        >>> model.bounding_box
        (-4.0, 4.0)
        (   t   meant   stddev(   t   selft   factort   x0t   dx(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   bounding_box/   s    	c         C` s   |  j  t S(   u$   Gaussian full width at half maximum.(   R   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   fwhmO   s    N(   t   __name__t
   __module__t   __doc__R	   t	   amplitudeR   t   FLOAT_EPSILONt   NoneR   R   t   propertyR   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR       s    t
   Gaussian1Dc           B` sD   e  Z d  Z e d    Z e d    Z e d    Z d   Z RS(   u  
    One dimensional Gaussian model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the Gaussian.
    mean : float
        Mean of the Gaussian.
    stddev : float
        Standard deviation of the Gaussian.

    Notes
    -----

    Model formula:

        .. math:: f(x) = A e^{- \frac{\left(x - x_{0}\right)^{2}}{2 \sigma^{2}}}

    Examples
    --------
    >>> from astropy.modeling import models
    >>> def tie_center(model):
    ...         mean = 50 * model.stddev
    ...         return mean
    >>> tied_parameters = {'mean': tie_center}

    Specify that 'mean' is a tied parameter in one of two ways:

    >>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3,
    ...                             tied=tied_parameters)

    or

    >>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3)
    >>> g1.mean.tied
    False
    >>> g1.mean.tied = tie_center
    >>> g1.mean.tied
    <function tie_center at 0x...>

    Fixed parameters:

    >>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3,
    ...                        fixed={'stddev': True})
    >>> g1.stddev.fixed
    True

    or

    >>> g1 = models.Gaussian1D(amplitude=10, mean=5, stddev=.3)
    >>> g1.stddev.fixed
    False
    >>> g1.stddev.fixed = True
    >>> g1.stddev.fixed
    True

    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import Gaussian1D

        plt.figure()
        s1 = Gaussian1D()
        r = np.arange(-5, 5, .01)

        for factor in range(1, 4):
            s1.amplitude = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -1, 4])
        plt.show()

    See Also
    --------
    Gaussian2D, Box1D, Moffat1D, Lorentz1D
    c         C` s%   | t  j d |  | d | d  S(   u,   
        Gaussian1D model function.
        g      i   (   t   npt   exp(   t   xR    R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   evaluate   s    c         C` sh   t  j d | d |  | d  } | | |  | | d } | | |  | d | d } | | | g S(   u8   
        Gaussian1D model function derivatives.
        g      i   i   (   R%   R&   (   R'   R    R   R   t   d_amplitudet   d_meant   d_stddev(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt	   fit_deriv   s    #c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   t   unitR"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   input_units   s    c         C` s1   t  d | d f d | d f d | d f g  S(   Nu   meanu   xu   stddevu	   amplitudeu   y(   R   (   R   t   inputs_unitt   outputs_unit(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   _parameter_units_for_data_units   s    (	   R   R   R   t   staticmethodR(   R,   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR$   U   s
   Pu   2.0t   alternativeu&   Gaussian1D and subtract it off Const1Dt   GaussianAbsorption1Dc           B` s5   e  Z d  Z d   Z e d    Z e d    Z RS(   ua  
    One dimensional Gaussian absorption line model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the gaussian absorption.
    mean : float
        Mean of the gaussian.
    stddev : float
        Standard deviation of the gaussian.

    Notes
    -----

    Model formula:

        .. math:: f(x) = 1 - A e^{- \frac{\left(x - x_{0}\right)^{2}}{2 \sigma^{2}}}

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt
        import warnings
        from astropy.modeling.models import GaussianAbsorption1D
        from astropy.utils.exceptions import AstropyDeprecationWarning

        plt.figure()
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', AstropyDeprecationWarning)
            s1 = GaussianAbsorption1D()
        r = np.arange(-5, 5, .01)
        for factor in range(1, 4):
            s1.amplitude = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -3, 2])
        plt.show()

    See Also
    --------
    Gaussian1D
    c         O` s   t  t |   j | |   d  S(   N(   t   superR4   t   __init__(   R   t   argst   kwargs(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR6      s    c         C` s   d t  j |  | | |  S(   u6   
        GaussianAbsorption1D model function.
        g      ?(   R$   R(   (   R'   R    R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(      s    c         C` s4   d d l  } t t | j t j |  | | |    S(   uB   
        GaussianAbsorption1D model function derivatives.
        i    N(   t   operatort   listR   t   negR$   R,   (   R'   R    R   R   R9   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,     s    (   R   R   R   R6   R2   R(   R,   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR4      s   /	t
   Gaussian2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z	 e j
 e j
 e j
 d d d d d  Z e d    Z e d    Z d d	  Z e d
    Z e d    Z e d    Z d   Z RS(   ul  
    Two dimensional Gaussian model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the Gaussian.
    x_mean : float
        Mean of the Gaussian in x.
    y_mean : float
        Mean of the Gaussian in y.
    x_stddev : float or None
        Standard deviation of the Gaussian in x before rotating by theta. Must
        be None if a covariance matrix (``cov_matrix``) is provided. If no
        ``cov_matrix`` is given, ``None`` means the default value (1).
    y_stddev : float or None
        Standard deviation of the Gaussian in y before rotating by theta. Must
        be None if a covariance matrix (``cov_matrix``) is provided. If no
        ``cov_matrix`` is given, ``None`` means the default value (1).
    theta : float, optional
        Rotation angle in radians. The rotation angle increases
        counterclockwise.  Must be None if a covariance matrix (``cov_matrix``)
        is provided. If no ``cov_matrix`` is given, ``None`` means the default
        value (0).
    cov_matrix : ndarray, optional
        A 2x2 covariance matrix. If specified, overrides the ``x_stddev``,
        ``y_stddev``, and ``theta`` defaults.

    Notes
    -----
    Model formula:

        .. math::

            f(x, y) = A e^{-a\left(x - x_{0}\right)^{2}  -b\left(x - x_{0}\right)
            \left(y - y_{0}\right)  -c\left(y - y_{0}\right)^{2}}

    Using the following definitions:

        .. math::
            a = \left(\frac{\cos^{2}{\left (\theta \right )}}{2 \sigma_{x}^{2}} +
            \frac{\sin^{2}{\left (\theta \right )}}{2 \sigma_{y}^{2}}\right)

            b = \left(\frac{\sin{\left (2 \theta \right )}}{2 \sigma_{x}^{2}} -
            \frac{\sin{\left (2 \theta \right )}}{2 \sigma_{y}^{2}}\right)

            c = \left(\frac{\sin^{2}{\left (\theta \right )}}{2 \sigma_{x}^{2}} +
            \frac{\cos^{2}{\left (\theta \right )}}{2 \sigma_{y}^{2}}\right)

    If using a ``cov_matrix``, the model is of the form:
        .. math::
            f(x, y) = A e^{-0.5 \left(\vec{x} - \vec{x}_{0}\right)^{T} \Sigma^{-1} \left(\vec{x} - \vec{x}_{0}\right)}

    where :math:`\vec{x} = [x, y]`, :math:`\vec{x}_{0} = [x_{0}, y_{0}]`,
    and :math:`\Sigma` is the covariance matrix:

        .. math::
            \Sigma = \left(\begin{array}{ccc}
            \sigma_x^2               & \rho \sigma_x \sigma_y \\
            \rho \sigma_x \sigma_y   & \sigma_y^2
            \end{array}\right)

    :math:`\rho` is the correlation between ``x`` and ``y``, which should
    be between -1 and +1.  Positive correlation corresponds to a
    ``theta`` in the range 0 to 90 degrees.  Negative correlation
    corresponds to a ``theta`` in the range of 0 to -90 degrees.

    See [1]_ for more details about the 2D Gaussian function.

    See Also
    --------
    Gaussian1D, Box2D, Moffat2D

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Gaussian_function
    R   i   i    g        c         K` s  | d  k ri | d  k r* |  j j j } n  | d  k rH |  j j j } n  | d  k r&|  j j j } q&n | d  k	 s | d  k	 s | d  k	 r t d   n t j |  } | j	 d k r t
 d   n  t j j |  \ }	 }
 t j |	  \ } } |
 d  d   d f } t j | d | d  } | j d i   | d j d t d  f  | d j d t d  f  t t |   j d	 | d
 | d | d | d | d | |  d  S(   Nu3   Cannot specify both cov_matrix and x/y_stddev/thetai   u   Covariance matrix must be 2x2i    i   u   boundsu   x_stddevu   y_stddevR    t   x_meant   y_meant   x_stddevt   y_stddevt   theta(   i   i   (   R"   t	   __class__R?   R   R@   RA   R
   R%   t   arrayt   shapet
   ValueErrort   linalgt   eigt   sqrtt   arctan2t
   setdefaultR!   R5   R<   R6   (   R   R    R=   R>   R?   R@   RA   t
   cov_matrixR8   t   eig_valst   eig_vecst   y_vec(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR6   c  s,    $c         C` s   |  j  t S(   u)   Gaussian full width at half maximum in X.(   R?   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   x_fwhm  s    c         C` s   |  j  t S(   u)   Gaussian full width at half maximum in Y.(   R@   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   y_fwhm  s    g      @c         C` sp   | |  j  } | |  j } |  j j } t | | |  \ } } |  j | |  j | f |  j | |  j | f f S(   u  
        Tuple defining the default ``bounding_box`` limits in each dimension,
        ``((y_low, y_high), (x_low, x_high))``

        The default offset from the mean is 5.5-sigma, corresponding
        to a relative error < 1e-7. The limits are adjusted for rotation.

        Parameters
        ----------
        factor : float, optional
            The multiple of `x_stddev` and `y_stddev` used to define the limits.
            The default is 5.5.

        Examples
        --------
        >>> from astropy.modeling.models import Gaussian2D
        >>> model = Gaussian2D(x_mean=0, y_mean=0, x_stddev=1, y_stddev=2)
        >>> model.bounding_box
        ((-11.0, 11.0), (-5.5, 5.5))

        This range can be set directly (see: `Model.bounding_box
        <astropy.modeling.Model.bounding_box>`) or by using a different factor
        like:

        >>> model.bounding_box = model.bounding_box(factor=2)
        >>> model.bounding_box
        ((-4.0, 4.0), (-2.0, 2.0))
        (   R?   R@   RA   t   valueR   R>   R=   (   R   R   t   at   bRA   R   t   dy(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    c         C` s   t  j |  d } t  j |  d }	 t  j d |  }
 | d } | d } |  | } | | } d | | |	 | } d |
 | |
 | } d |	 | | | } | t  j | | d | | | | | d  S(   u!   Two dimensional Gaussian functioni   g       @g      ?(   R%   t   cost   sinR&   (   R'   t   yR    R=   R>   R?   R@   RA   t   cost2t   sint2t   sin2tt   xstd2t   ystd2t   xdifft   ydiffRR   RS   t   c(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    



 c   )      C` sY  t  j |  } t  j |  }	 t  j |  d }
 t  j |  d } t  j d |  } t  j d |  } | d } | d } | d } | d } |  | } | | } | d } | d } d |
 | | | } d | | | | } d | | |
 | } | t  j | | | | | | |  } |	 | d | d | } |
 | } | | } | | | | } | | } | | } | }  | | }! |
 | }" | | }# | d | | | | }$ | | | d | | }% | | | | | | |! | }& | | | | | | |" | }' | | | | | | |  | }( |# |$ |% |& |' |( g S(   uG   Two dimensional Gaussian function derivative with respect to parametersi   g       @i   g      ?g      ?(   R%   RU   RV   R&   ()   R'   RW   R    R=   R>   R?   R@   RA   t   costt   sintRX   RY   t   cos2tRZ   R[   R\   t   xstd3t   ystd3R]   R^   t   xdiff2t   ydiff2RR   RS   R_   t   gt	   da_dthetat   da_dx_stddevt   da_dy_stddevt	   db_dthetat   db_dx_stddevt   db_dy_stddevt	   dc_dthetat   dc_dx_stddevt   dc_dy_stddevt   dg_dAt
   dg_dx_meant
   dg_dy_meant   dg_dx_stddevt   dg_dy_stddevt	   dg_dtheta(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,     sT    









c         C` sJ   |  j  j d  k r( |  j j d  k r( d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R=   R-   R"   R>   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    $c      	   C` sz   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d f d t j f d	 | d
 f g  S(   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_meanu   y_meanu   x_stddevu   y_stddevu   thetau	   amplitudeu   z(   R   R   t   ut   rad(   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    N(   R   R   R   R	   R    R=   R>   R?   R@   RA   R   R"   R6   R#   RO   RP   R   R2   R(   R,   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR<     s"   M(&/t   Shiftc           B` s   e  Z d  Z d	 Z d
 Z e d d  Z e Z e Z	 e Z
 e d    Z e d    Z e d    Z e d    Z e d    Z RS(   uv   
    Shift a coordinate.

    Parameters
    ----------
    offset : float
        Offset to add to a coordinate.
    u   xR   i    c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   t   offsetR-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   '  s    c         C` s   |  j    } | j d 9_ | S(   u,   One dimensional inverse Shift model functioni(   t   copyRz   (   R   t   inv(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   inverse.  s    c         C` sZ   t  | t j  r' | j } | j } n  t  |  t j  rN |  j }  |  | | S|  | Sd S(   u$   One dimensional Shift model functionN(   t
   isinstanceRw   R   R-   RQ   (   R'   Rz   t   return_unit(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   5  s    		c         C` s   |  S(   u=   Evaluate the implicit term (x) of one dimensional Shift model(    (   R'   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   sum_of_implicit_termsA  s    c         G` s   t  j |   } | g S(   u@   One dimensional Shift model derivative with respect to parameter(   R%   t	   ones_like(   R'   t   paramst   d_offset(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,   F  s    (   u   x(   u   x(   R   R   R   t   inputst   outputsR	   Rz   t   Truet   lineart   input_units_strictt   input_units_allow_dimensionlessR#   R.   R}   R2   R(   R   R,   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyRy     s   t   Scalec           B` s}   e  Z d  Z d Z d	 Z e d d  Z e Z e Z	 e Z
 e Z e d    Z e d    Z e d    Z e d    Z RS(
   u   
    Multiply a model by a factor.

    Parameters
    ----------
    factor : float
        Factor by which to scale a coordinate.
    u   xR   i   c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   c  s    c         C` s    |  j    } d |  j | _ | S(   u,   One dimensional inverse Scale model functioni   (   R{   R   (   R   R|   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR}   j  s    c         C` sT   t  | t j  r' | j } | j } n  t  |  t j  rH |  j | | S| |  Sd S(   u$   One dimensional Scale model functionN(   R~   Rw   R   R-   RQ   (   R'   R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   q  s    	c         G` s   |  } | g S(   u@   One dimensional Scale model derivative with respect to parameter(    (   R'   R   t   d_factor(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,   |  s    (   u   x(   u   x(   R   R   R   R   R   R	   R   R   R   t   fittableR   R   R#   R.   R}   R2   R(   R,   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   N  s   t   RedshiftScaleFactorc           B` sP   e  Z d  Z e d d d d  Z e d    Z e d    Z e d    Z	 RS(   u   
    One dimensional redshift scale factor model.

    Parameters
    ----------
    z : float
        Redshift value.

    Notes
    -----
    Model formula:

        .. math:: f(x) = x (1 + z)
    t   descriptionu   redshiftR   i    c         C` s   d | |  S(   u2   One dimensional RedshiftScaleFactor model functioni   (    (   R'   t   z(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    c         C` s   |  } | g S(   u4   One dimensional RedshiftScaleFactor model derivative(    (   R'   R   t   d_z(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,     s    c         C` s(   |  j    } d d |  j d | _ | S(   u!   Inverse RedshiftScaleFactor modelg      ?(   R{   R   (   R   R|   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR}     s    (
   R   R   R   R	   R   R2   R(   R,   R#   R}   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s
   t   Sersic1Dc           B` sh   e  Z d  Z e d d  Z e d d  Z e d d  Z d Z e	 d    Z
 e d    Z d   Z RS(   u  
    One dimensional Sersic surface brightness profile.

    Parameters
    ----------
    amplitude : float
        Surface brightness at r_eff.
    r_eff : float
        Effective (half-light) radius
    n : float
        Sersic Index.

    See Also
    --------
    Gaussian1D, Moffat1D, Lorentz1D

    Notes
    -----
    Model formula:

    .. math::

        I(r)=I_e\exp\left\{-b_n\left[\left(\frac{r}{r_{e}}\right)^{(1/n)}-1\right]\right\}

    The constant :math:`b_n` is defined such that :math:`r_e` contains half the total
    luminosity, and can be solved for numerically.

    .. math::

        \Gamma(2n) = 2\gamma (b_n,2n)

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        from astropy.modeling.models import Sersic1D
        import matplotlib.pyplot as plt

        plt.figure()
        plt.subplot(111, xscale='log', yscale='log')
        s1 = Sersic1D(amplitude=1, r_eff=5)
        r=np.arange(0, 100, .01)

        for n in range(1, 10):
             s1.n = n
             plt.plot(r, s1(r), color=str(float(n) / 15))

        plt.axis([1e-1, 30, 1e-2, 1e3])
        plt.xlabel('log Radius')
        plt.ylabel('log Surface Brightness')
        plt.text(.25, 1.5, 'n=1')
        plt.text(.25, 300, 'n=10')
        plt.xticks([])
        plt.yticks([])
        plt.show()

    References
    ----------
    .. [1] http://ned.ipac.caltech.edu/level5/March05/Graham/Graham2.html
    R   i   i   c         C` s   |  j  d k rO y d d l m } | |  _  WqO t k
 rK t d   qO Xn  | t j |  j  d | d  | | d | d  S(   u(   One dimensional Sersic profile function.i    (   t   gammaincinvu%   Sersic1D model requires scipy > 0.11.i   g      ?i   N(   t   _gammaincinvR"   t   scipy.specialR   RE   t   ImportErrorR%   R&   (   t   clst   rR    t   r_efft   nR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    	c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` s$   t  d | d f d | d f g  S(   Nu   r_effu   xu	   amplitudeu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    N(   R   R   R   R	   R    R   R   R"   R   t   classmethodR(   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   >t   Sine1Dc           B` sq   e  Z d  Z e d d  Z e d d  Z e d d  Z e d    Z e d    Z	 e
 d    Z d   Z RS(   uL  
    One dimensional Sine model.

    Parameters
    ----------
    amplitude : float
        Oscillation amplitude
    frequency : float
        Oscillation frequency
    phase : float
        Oscillation phase

    See Also
    --------
    Const1D, Linear1D


    Notes
    -----
    Model formula:

        .. math:: f(x) = A \sin(2 \pi f x + 2 \pi p)

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import Sine1D

        plt.figure()
        s1 = Sine1D(amplitude=1, frequency=.25)
        r=np.arange(0, 10, .01)

        for amplitude in range(1,4):
             s1.amplitude = amplitude
             plt.plot(r, s1(r), color=str(0.25 * amplitude), lw=2)

        plt.axis([0, 10, -5, 5])
        plt.show()
    R   i   i    c         C` s>   t  | |  | } t | t  r- | j } n  | t j |  S(   u#   One dimensional Sine model function(   t   TWOPIR~   R   RQ   R%   RV   (   R'   R    t	   frequencyt   phaset   argument(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   =  s    c         C` s~   t  j t | |  t |  } t |  | t  j t | |  t |  } t | t  j t | |  t |  } | | | g S(   u%   One dimensional Sine model derivative(   R%   RV   R   RU   (   R'   R    R   R   R)   t   d_frequencyt   d_phase(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,   J  s      c         C` s/   |  j  j d  k r d  Si d |  j  j d 6Sd  S(   Ng      ?u   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   U  s    c         C` s(   t  d | d d f d | d f g  S(   Nu	   frequencyu   xiu	   amplitudeu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   \  s    (   R   R   R   R	   R    R   R   R2   R(   R,   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   ,t   Linear1Dc           B` sw   e  Z d  Z e d d  Z e d d  Z e Z e d    Z	 e d    Z
 e d    Z e d    Z d   Z RS(	   u(  
    One dimensional Line model.

    Parameters
    ----------
    slope : float
        Slope of the straight line

    intercept : float
        Intercept of the straight line

    See Also
    --------
    Const1D

    Notes
    -----
    Model formula:

        .. math:: f(x) = a x + b
    R   i   i    c         C` s   | |  | S(   u#   One dimensional Line model function(    (   R'   t   slopet	   intercept(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   |  s    c         C` s   |  } t  j |   } | | g S(   u@   One dimensional Line model derivative with respect to parameters(   R%   R   (   R'   R   R   t   d_slopet   d_intercept(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,     s    c         C` s4   |  j  d } |  j |  j  } |  j d | d |  S(   NiR   R   (   R   R   RB   (   R   t	   new_slopet   new_intercept(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR}     s    c         C` sG   |  j  j d  k r( |  j j d  k r( d  Si |  j  j |  j j d 6Sd  S(   Nu   x(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    $c         C` s,   t  d | d f d | d | d f g  S(   Nu	   interceptu   yu   slopeu   x(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R   R   R   R   R2   R(   R,   R#   R}   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   a  s   t   Planar2Dc           B` s_   e  Z d  Z e d d  Z e d d  Z e d d  Z e Z e	 d    Z
 e	 d    Z RS(   u  
    Two dimensional Plane model.

    Parameters
    ----------
    slope_x : float
        Slope of the straight line in X

    slope_y : float
        Slope of the straight line in Y

    intercept : float
        Z-intercept of the straight line

    See Also
    --------
    Linear1D, Polynomial2D

    Notes
    -----
    Model formula:

        .. math:: f(x, y) = a x + b y + c
    R   i   i    c         C` s   | |  | | | S(   u$   Two dimensional Plane model function(    (   R'   RW   t   slope_xt   slope_yR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    c         C` s(   |  } | } t  j |   } | | | g S(   uA   Two dimensional Plane model derivative with respect to parameters(   R%   R   (   R'   RW   R   R   R   t	   d_slope_xt	   d_slope_yR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,     s    (   R   R   R   R	   R   R   R   R   R   R2   R(   R,   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   t	   Lorentz1Dc           B` s}   e  Z d  Z e d d  Z e d d  Z e d d  Z e d    Z e d    Z	 d d  Z
 e d    Z d	   Z RS(
   u_  
    One dimensional Lorentzian model.

    Parameters
    ----------
    amplitude : float
        Peak value
    x_0 : float
        Position of the peak
    fwhm : float
        Full width at half maximum

    See Also
    --------
    Gaussian1D, Box1D, MexicanHat1D

    Notes
    -----
    Model formula:

    .. math::

        f(x) = \frac{A \gamma^{2}}{\gamma^{2} + \left(x - x_{0}\right)^{2}}

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import Lorentz1D

        plt.figure()
        s1 = Lorentz1D()
        r = np.arange(-5, 5, .01)

        for factor in range(1, 4):
            s1.amplitude = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -1, 4])
        plt.show()
    R   i   i    c         C` s(   | | d d |  | d | d d S(   u)   One dimensional Lorentzian model functiong       @i   (    (   R'   R    t   x_0R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    c         C` ss   | d | d |  | d } | | d |  d | | d |  | d } d | | | d | } | | | g S(   uF   One dimensional Lorentzian model derivative with respect to parametersi   i   (    (   R'   R    R   R   R)   t   d_x_0t   d_fwhm(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,     s
    i   c         C` s(   |  j  } | |  j } | | | | f S(   ur  Tuple defining the default ``bounding_box`` limits,
        ``(x_low, x_high)``.

        Parameters
        ----------
        factor : float
            The multiple of FWHM used to define the limits.
            Default is chosen to include most (99%) of the
            area under the curve, while still showing the
            central feature of interest.

        (   R   R   (   R   R   R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    	c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   !  s    c         C` s1   t  d | d f d | d f d | d f g  S(   Nu   x_0u   xu   fwhmu	   amplitudeu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   (  s    (   R   R   R   R	   R    R   R   R2   R(   R,   R   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   -
t   Voigt1Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d e j  Z e d e j	 d   Z
 e j d d d d g d d d	 d
 g d d d d g d d d d g g  Z e d    Z e d    Z e d    Z d   Z RS(   u!  
    One dimensional model for the Voigt profile.

    Parameters
    ----------
    x_0 : float
        Position of the peak
    amplitude_L : float
        The Lorentzian amplitude
    fwhm_L : float
        The Lorentzian full width at half maximum
    fwhm_G : float
        The Gaussian full width at half maximum

    See Also
    --------
    Gaussian1D, Lorentz1D

    Notes
    -----
    Algorithm for the computation taken from
    McLean, A. B., Mitchell, C. E. J. & Swanston, D. M. Implementation of an
    efficient analytical approximation to the Voigt function for photoemission
    lineshape analysis. Journal of Electron Spectroscopy and Related Phenomena
    69, 125-132 (1994)

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        from astropy.modeling.models import Voigt1D
        import matplotlib.pyplot as plt

        plt.figure()
        x = np.arange(0, 10, 0.01)
        v1 = Voigt1D(x_0=5, amplitude_L=10, fwhm_L=0.5, fwhm_G=0.9)
        plt.plot(x, v1(x))
        plt.show()
    R   i    i   i   gq=
ףpgQIg??g~:?g?g~:ؿgX9vӿg.1?g/$?g~k	g/$g~k	?c         C` s   |  j  \ } } } }	 t j t j d   }
 | | d |
 | } t j |  d t j f } | |
 | } t j |  d t j f } t j | | | |	 | | | | d | | d d d } | | t j t j  |
 | | S(   Ni   .t   axisi(   t   _abcdR%   RH   t   logt
   atleast_1dt   newaxist   sumt   pi(   R   R'   R   t   amplitude_Lt   fwhm_Lt   fwhm_Gt   At   Bt   Ct   Dt   sqrt_ln2t   Xt   Yt   V(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   d  s    Ac      	   C` s  |  j  \ } } } }	 t j t j d   }
 | | d |
 | } t j |  d  d   t j f } | |
 | } t j |  d  d   t j f } | | t j t j  |
 | } | | | |	 | | } | | d | | d } t j | | d d } t j |	 | d | | | t j |  d d } t j | | d | | | t j |  d d } | | d |
 | | | | | | | | |
 | | | |
 | d | | | | | | g } | S(   Ni   R   i(	   R   R%   RH   R   R   R   R   R   t   square(   R   R'   R   R   R   R   R   R   R   R   R   R   R   t   constantt   alphat   betaR   t   dVdxt   dVdyt   dyda(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,   r  s"    """662c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` s>   t  d | d f d | d f d | d f d | d f g  S(   Nu   x_0u   xu   fwhm_Lu   fwhm_Gu   amplitude_Lu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R   R   R%   R   R   R   R   RC   R   R   R(   R,   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   .  s   )t   Const1Dc           B` sY   e  Z d  Z e d d  Z e Z e d    Z e d    Z	 e
 d    Z d   Z RS(   u  
    One dimensional Constant model.

    Parameters
    ----------
    amplitude : float
        Value of the constant function

    See Also
    --------
    Const2D

    Notes
    -----
    Model formula:

        .. math:: f(x) = A

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import Const1D

        plt.figure()
        s1 = Const1D()
        r = np.arange(-5, 5, .01)

        for factor in range(1, 4):
            s1.amplitude = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -1, 4])
        plt.show()
    R   i   c         C` s   | j  d k r: t j |  d t }  |  j | j    n | t j |  d t }  t | t  r{ t |  d | j	 d t S|  Sd S(   u'   One dimensional Constant model functioni   t   subokR-   R{   N(
   t   sizeR%   t
   empty_liket   Falset   fillt   itemR   R~   R   R-   (   R'   R    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    c         C` s   t  j |   } | g S(   uD   One dimensional Constant model derivative with respect to parameters(   R%   R   (   R'   R    R)   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,     s    c         C` s   d  S(   N(   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` s   t  d | d f g  S(   Nu	   amplitudeu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R    R   R   R2   R(   R,   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   't   Const2Dc           B` sJ   e  Z d  Z e d d  Z e Z e d    Z e	 d    Z
 d   Z RS(   u   
    Two dimensional Constant model.

    Parameters
    ----------
    amplitude : float
        Value of the constant function

    See Also
    --------
    Const1D

    Notes
    -----
    Model formula:

        .. math:: f(x, y) = A
    R   i   c         C` s   | j  d k r: t j |  d t }  |  j | j    n | t j |  d t }  t | t  r{ t |  d | j	 d t S|  Sd S(   u'   Two dimensional Constant model functioni   R   R-   R{   N(
   R   R%   R   R   R   R   R   R~   R   R-   (   R'   RW   R    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    c         C` s   d  S(   N(   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` s   t  d | d f g  S(   Nu	   amplitudeu   z(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R    R   R   R2   R(   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   t	   Ellipse2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z	 e
 d    Z e d    Z e d    Z d   Z RS(   uA  
    A 2D Ellipse model.

    Parameters
    ----------
    amplitude : float
        Value of the ellipse.

    x_0 : float
        x position of the center of the disk.

    y_0 : float
        y position of the center of the disk.

    a : float
        The length of the semimajor axis.

    b : float
        The length of the semiminor axis.

    theta : float
        The rotation angle in radians of the semimajor axis.  The
        rotation angle increases counterclockwise from the positive x
        axis.

    See Also
    --------
    Disk2D, Box2D

    Notes
    -----
    Model formula:

    .. math::

        f(x, y) = \left \{
                    \begin{array}{ll}
                      \mathrm{amplitude} & : \left[\frac{(x - x_0) \cos
                        \theta + (y - y_0) \sin \theta}{a}\right]^2 +
                        \left[\frac{-(x - x_0) \sin \theta + (y - y_0)
                        \cos \theta}{b}\right]^2  \leq 1 \\
                      0 & : \mathrm{otherwise}
                    \end{array}
                  \right.

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        from astropy.modeling.models import Ellipse2D
        from astropy.coordinates import Angle
        import matplotlib.pyplot as plt
        import matplotlib.patches as mpatches
        x0, y0 = 25, 25
        a, b = 20, 10
        theta = Angle(30, 'deg')
        e = Ellipse2D(amplitude=100., x_0=x0, y_0=y0, a=a, b=b,
                      theta=theta.radian)
        y, x = np.mgrid[0:50, 0:50]
        fig, ax = plt.subplots(1, 1)
        ax.imshow(e(x, y), origin='lower', interpolation='none', cmap='Greys_r')
        e2 = mpatches.Ellipse((x0, y0), 2*a, 2*b, theta.degree, edgecolor='red',
                              facecolor='none')
        ax.add_patch(e2)
        plt.show()
    R   i   i    c         C` s   |  | } | | }	 t  j |  }
 t  j |  } | |
 |	 | } | | |	 |
 } | | d | | d d k } t  j | g | g  } t | t  r t | d | j d t S| Sd S(   u'   Two dimensional Ellipse model function.i   g      ?R-   R{   N(   R%   RU   RV   t   selectR~   R   R-   R   (   R'   RW   R    R   t   y_0RR   RS   RA   t   xxt   yyR`   Ra   t
   numerator1t
   numerator2t
   in_ellipset   result(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   b  s    

 c         C` sh   |  j  } |  j } |  j j } t | | |  \ } } |  j | |  j | f |  j | |  j | f f S(   uu   
        Tuple defining the default ``bounding_box`` limits.

        ``((y_low, y_high), (x_low, x_high))``
        (   RR   RS   RA   RQ   R   R   R   (   R   RR   RS   RA   R   RT   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   t  s    		c         C` s8   |  j  j d  k r d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c      	   C` sz   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d f d t j f d	 | d
 f g  S(   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   au   bu   thetau	   amplitudeu   z(   R   R   Rw   Rx   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R    R   R   RR   RS   RA   R2   R(   R#   R   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   Dt   Disk2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d    Z	 e
 d    Z e
 d    Z d   Z RS(   uf  
    Two dimensional radial symmetric Disk model.

    Parameters
    ----------
    amplitude : float
        Value of the disk function
    x_0 : float
        x position center of the disk
    y_0 : float
        y position center of the disk
    R_0 : float
        Radius of the disk

    See Also
    --------
    Box2D, TrapezoidDisk2D

    Notes
    -----
    Model formula:

        .. math::

            f(r) = \left \{
                     \begin{array}{ll}
                       A & : r \leq R_0 \\
                       0 & : r > R_0
                     \end{array}
                   \right.
    R   i   i    c         C` sl   |  | d | | d } t  j | | d k g | g  } t | t  rd t | d | j d t S| Sd S(   u#   Two dimensional Disk model functioni   R-   R{   N(   R%   R   R~   R   R-   R   (   R'   RW   R    R   R   t   R_0t   rrR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s
    "c         C` s>   |  j  |  j |  j  |  j f |  j |  j |  j |  j f f S(   uu   
        Tuple defining the default ``bounding_box`` limits.

        ``((y_low, y_high), (x_low, x_high))``
        (   R   R   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    c         C` sJ   |  j  j d  k r( |  j j d  k r( d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    $c         C` sa   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d f g  S(	   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   R_0u	   amplitudeu   z(   R   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R    R   R   R   R2   R(   R#   R   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   t   Ring2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z e j	 e j	 e j	 e j	 e j	 d	 d  Z e d    Z e d    Z e d    Z d   Z RS(
   u7  
    Two dimensional radial symmetric Ring model.

    Parameters
    ----------
    amplitude : float
        Value of the disk function
    x_0 : float
        x position center of the disk
    y_0 : float
        y position center of the disk
    r_in : float
        Inner radius of the ring
    width : float
        Width of the ring.
    r_out : float
        Outer Radius of the ring. Can be specified instead of width.

    See Also
    --------
    Disk2D, TrapezoidDisk2D

    Notes
    -----
    Model formula:

        .. math::

            f(r) = \left \{
                     \begin{array}{ll}
                       A & : r_{in} \leq r \leq r_{out} \\
                       0 & : \text{else}
                     \end{array}
                   \right.

    Where :math:`r_{out} = r_{in} + r_{width}`.
    R   i   i    c         K` s   | d  k	 r: | |  j j k r- t d   n  | | } n | d  k rU |  j j } n  t t |   j d | d | d | d | d | |  d  S(   Nu6   Cannot specify both width and outer radius separately.R    R   R   t   r_int   width(   R"   R   R   R
   R5   R   R6   (   R   R    R   R   R   R   t   r_outR8   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR6     s    c   
      C` s   |  | d | | d } t  j | | d k | | | d k  } t  j | g | g  }	 t | t  r t |	 d | j d t S|	 Sd S(   u$   Two dimensional Ring model function.i   R-   R{   N(   R%   t   logical_andR   R~   R   R-   R   (
   R'   RW   R    R   R   R   R   R   t   r_rangeR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   (  s    *c         C` sB   |  j  |  j } |  j | |  j | f |  j | |  j | f f S(   un   
        Tuple defining the default ``bounding_box``.

        ``((y_low, y_high), (x_low, x_high))``
        (   R   R   R   R   (   R   t   dr(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   5  s    c         C` s8   |  j  j d  k r d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   B  s    c         C` sn   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d f d | d	 f g  S(
   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   r_inu   widthu	   amplitudeu   z(   R   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   J  s    N(   R   R   R   R	   R    R   R   R   R   R   R"   R6   R2   R(   R#   R   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   %t   Delta1Dc           B` s   e  Z d  Z d   Z RS(   u%   One dimensional Dirac delta function.c         C` s   t  d   d  S(   Nu   Not implemented(   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR6   Z  s    (   R   R   R   R6   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   W  s   t   Delta2Dc           B` s   e  Z d  Z d   Z RS(   u%   Two dimensional Dirac delta function.c         C` s   t  d   d  S(   Nu   Not implemented(   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR6   a  s    (   R   R   R   R6   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   ^  s   t   Box1Dc           B` sq   e  Z d  Z e d d  Z e d d  Z e d d  Z e d    Z e	 d    Z
 e	 d    Z d   Z RS(   u  
    One dimensional Box model.

    Parameters
    ----------
    amplitude : float
        Amplitude A
    x_0 : float
        Position of the center of the box function
    width : float
        Width of the box

    See Also
    --------
    Box2D, TrapezoidDisk2D

    Notes
    -----
    Model formula:

      .. math::

            f(x) = \left \{
                     \begin{array}{ll}
                       A & : x_0 - w/2 \leq x \leq x_0 + w/2 \\
                       0 & : \text{else}
                     \end{array}
                   \right.

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import Box1D

        plt.figure()
        s1 = Box1D()
        r = np.arange(-5, 5, .01)

        for factor in range(1, 4):
            s1.amplitude = factor
            s1.width = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -1, 4])
        plt.show()
    R   i   i    c         C` sy   t  j |  | | d k |  | | d k  } t  j | g | g d  } t | t  rq t | d | j d t S| Sd S(   u"   One dimensional Box model functiong       @i    R-   R{   N(   R%   R   R   R~   R   R-   R   (   R'   R    R   R   t   insideR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s
    .c         C` s%   |  j  d } |  j | |  j | f S(   uc   
        Tuple defining the default ``bounding_box`` limits.

        ``(x_low, x_high))``
        i   (   R   R   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` s1   t  d | d f d | d f d | d f g  S(   Nu   x_0u   xu   widthu	   amplitudeu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R    R   R   R2   R(   R#   R   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   e  s   3t   Box2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z e	 d    Z
 e d    Z e d    Z d   Z RS(   u  
    Two dimensional Box model.

    Parameters
    ----------
    amplitude : float
        Amplitude A
    x_0 : float
        x position of the center of the box function
    x_width : float
        Width in x direction of the box
    y_0 : float
        y position of the center of the box function
    y_width : float
        Width in y direction of the box

    See Also
    --------
    Box1D, Gaussian2D, Moffat2D

    Notes
    -----
    Model formula:

      .. math::

            f(x, y) = \left \{
                     \begin{array}{ll}
            A : & x_0 - w_x/2 \leq x \leq x_0 + w_x/2 \text{ and} \\
                & y_0 - w_y/2 \leq y \leq y_0 + w_y/2 \\
            0 : & \text{else}
                     \end{array}
                   \right.

    R   i   i    c   
      C` s   t  j |  | | d k |  | | d k  } t  j | | | d k | | | d k  } t  j t  j | |  g | g d  }	 t | t  r t |	 d | j d t S|	 Sd S(   u"   Two dimensional Box model functiong       @i    R-   R{   N(   R%   R   R   R~   R   R-   R   (
   R'   RW   R    R   R   t   x_widtht   y_widtht   x_ranget   y_rangeR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    'c         C` sL   |  j  d } |  j d } |  j | |  j | f |  j | |  j | f f S(   un   
        Tuple defining the default ``bounding_box``.

        ``((y_low, y_high), (x_low, x_high))``
        i   (   R   R   R   R   (   R   R   RT   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    c         C` s8   |  j  j d  k r d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` sK   t  d | d f d | d f d | d f d | d f d | d f g  S(	   Nu   x_0u   xu   y_0u   yu   x_widthu   y_widthu	   amplitudeu   z(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s
    (   R   R   R   R	   R    R   R   R   R   R2   R(   R#   R   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   #t   Trapezoid1Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d    Z	 e
 d    Z e
 d    Z d   Z RS(   ue  
    One dimensional Trapezoid model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the trapezoid
    x_0 : float
        Center position of the trapezoid
    width : float
        Width of the constant part of the trapezoid.
    slope : float
        Slope of the tails of the trapezoid

    See Also
    --------
    Box1D, Gaussian1D, Moffat1D

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import Trapezoid1D

        plt.figure()
        s1 = Trapezoid1D()
        r = np.arange(-5, 5, .01)

        for factor in range(1, 4):
            s1.amplitude = factor
            s1.width = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -1, 4])
        plt.show()
    R   i   i    c         C` s  | | d } | | d } | | | } | | | } t  j |  | k |  | k   }	 t  j |  | k |  | k   }
 t  j |  | k |  | k   } | |  | } | } | | |  } t  j |	 |
 | g | | | g  } t | t  r t | d | j d t S| Sd S(   u(   One dimensional Trapezoid model functiong       @R-   R{   N(   R%   R   R   R~   R   R-   R   (   R'   R    R   R   R   t   x2t   x3t   x1t   x4t   range_at   range_bt   range_ct   val_at   val_bt   val_cR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   K  s    $c         C` s3   |  j  d |  j |  j } |  j | |  j | f S(   uc   
        Tuple defining the default ``bounding_box`` limits.

        ``(x_low, x_high))``
        i   (   R   R    R   R   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   d  s    c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   p  s    c         C` sF   t  d | d f d | d f d | d | d f d | d f g  S(   Nu   x_0u   xu   widthu   slopeu   yu	   amplitude(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   w  s    (   R   R   R   R	   R    R   R   R   R2   R(   R#   R   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   (t   TrapezoidDisk2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z e	 d    Z
 e d    Z e d    Z d   Z RS(   u  
    Two dimensional circular Trapezoid model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the trapezoid
    x_0 : float
        x position of the center of the trapezoid
    y_0 : float
        y position of the center of the trapezoid
    R_0 : float
        Radius of the constant part of the trapezoid.
    slope : float
        Slope of the tails of the trapezoid in x direction.

    See Also
    --------
    Disk2D, Box2D
    R   i   i    c         C` s   t  j |  | d | | d  } | | k } t  j | | k | | | | k  }	 | }
 | | | | } t  j | |	 g |
 | g  } t | t  r t | d | j d t S| Sd S(   u-   Two dimensional Trapezoid Disk model functioni   R-   R{   N(   R%   RH   R   R   R~   R   R-   R   (   R'   RW   R    R   R   R   R   R   t   range_1t   range_2t   val_1t   val_2R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    #&c         C` sI   |  j  |  j |  j } |  j | |  j | f |  j | |  j | f f S(   un   
        Tuple defining the default ``bounding_box``.

        ``((y_low, y_high), (x_low, x_high))``
        (   R   R    R   R   R   (   R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    c         C` sJ   |  j  j d  k r( |  j j d  k r( d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    $c         C` sv   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d | d f d	 | d f g  S(
   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   R_0u   slopeu   zu	   amplitude(   R   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R    R   R   R   R   R2   R(   R#   R   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   ~  s   t   MexicanHat1Dc           B` sn   e  Z d  Z e d d  Z e d d  Z e d d  Z e d    Z d d  Z	 e
 d    Z d   Z RS(	   u  
    One dimensional Mexican Hat model.

    Parameters
    ----------
    amplitude : float
        Amplitude
    x_0 : float
        Position of the peak
    sigma : float
        Width of the Mexican hat

    See Also
    --------
    MexicanHat2D, Box1D, Gaussian1D, Trapezoid1D

    Notes
    -----
    Model formula:

    .. math::

        f(x) = {A \left(1 - \frac{\left(x - x_{0}\right)^{2}}{\sigma^{2}}\right)
        e^{- \frac{\left(x - x_{0}\right)^{2}}{2 \sigma^{2}}}}

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import MexicanHat1D

        plt.figure()
        s1 = MexicanHat1D()
        r = np.arange(-5, 5, .01)

        for factor in range(1, 4):
            s1.amplitude = factor
            s1.width = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -2, 4])
        plt.show()
    R   i   i    c         C` s8   |  | d d | d } | d d | t  j |  S(   u*   One dimensional Mexican Hat model functioni   i   (   R%   R&   (   R'   R    R   t   sigmat   xx_ww(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s    g      $@c         C` s(   |  j  } | |  j } | | | | f S(   u   Tuple defining the default ``bounding_box`` limits,
        ``(x_low, x_high)``.

        Parameters
        ----------
        factor : float
            The multiple of sigma used to define the limits.

        (   R   R  (   R   R   R   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    
	c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` s1   t  d | d f d | d f d | d f g  S(   Nu   x_0u   xu   sigmau	   amplitudeu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    (   R   R   R   R	   R    R   R  R2   R(   R   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s   /t   MexicanHat2Dc           B` sq   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d    Z	 e
 d    Z d   Z RS(   uY  
    Two dimensional symmetric Mexican Hat model.

    Parameters
    ----------
    amplitude : float
        Amplitude
    x_0 : float
        x position of the peak
    y_0 : float
        y position of the peak
    sigma : float
        Width of the Mexican hat

    See Also
    --------
    MexicanHat1D, Gaussian2D

    Notes
    -----
    Model formula:

    .. math::

        f(x, y) = A \left(1 - \frac{\left(x - x_{0}\right)^{2}
        + \left(y - y_{0}\right)^{2}}{\sigma^{2}}\right)
        e^{\frac{- \left(x - x_{0}\right)^{2}
        - \left(y - y_{0}\right)^{2}}{2 \sigma^{2}}}
    R   i   i    c         C` s@   |  | d | | d d | d } | d | t  j |  S(   u*   Two dimensional Mexican Hat model functioni   i   (   R%   R&   (   R'   RW   R    R   R   R  t   rr_ww(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   H  s    &c         C` s8   |  j  j d  k r d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   O  s    c         C` sa   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d f g  S(	   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   sigmau	   amplitudeu   z(   R   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   W  s    (   R   R   R   R	   R    R   R   R  R2   R(   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR  $  s   t
   AiryDisk2Dc           B` s}   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z d Z	 d Z
 e d    Z e d    Z d   Z RS(   u  
    Two dimensional Airy disk model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the Airy function.
    x_0 : float
        x position of the maximum of the Airy function.
    y_0 : float
        y position of the maximum of the Airy function.
    radius : float
        The radius of the Airy disk (radius of the first zero).

    See Also
    --------
    Box2D, TrapezoidDisk2D, Gaussian2D

    Notes
    -----
    Model formula:

        .. math:: f(r) = A \left[\frac{2 J_1(\frac{\pi r}{R/R_z})}{\frac{\pi r}{R/R_z}}\right]^2

    Where :math:`J_1` is the first order Bessel function of the first
    kind, :math:`r` is radial distance from the maximum of the Airy
    function (:math:`r = \sqrt{(x - x_0)^2 + (y - y_0)^2}`), :math:`R`
    is the input ``radius`` parameter, and :math:`R_z =
    1.2196698912665045`).

    For an optical system, the radius of the first zero represents the
    limiting angular resolution and is approximately 1.22 * lambda / D,
    where lambda is the wavelength of the light and D is the diameter of
    the aperture.

    See [1]_ for more details about the Airy disk.

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Airy_disk
    R   i   i    c         C` sJ  |  j  d k rr y@ d d l m } m } | d d  d t j |  _  | |  _ Wqr t k
 rn t	 d   qr Xn  t j
 | | d | | d  | |  j  }	 t |	 t  r |	 j t j  }	 n  t j |	 j  }
 t j |	 |	 d k } d |  j |  | d |
 |	 d k <t | t  r<t |
 t j d t }
 n  |
 | 9}
 |
 S(	   u#   Two dimensional Airy model functioni    (   t   j1t   jn_zerosi   u'   AiryDisk2D model requires scipy > 0.11.i   g       @R{   N(   t   _rzR"   R   R  R  R%   R   t   _j1RE   R   RH   R~   R   t   to_valueRw   t   dimensionless_unscaledt   onesRD   R   (   R   R'   RW   R    R   R   t   radiusR  R  R   R   t   rt(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(     s"    .%
c         C` s8   |  j  j d  k r d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.     s    c         C` sa   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d f g  S(	   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   radiusu	   amplitudeu   z(   R   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1     s    N(   R   R   R   R	   R    R   R   R  R"   R  R	  R   R(   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR  c  s   )t   Moffat1Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d    Z	 e
 d    Z e
 d    Z e d    Z d   Z RS(	   u  
    One dimensional Moffat model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the model.
    x_0 : float
        x position of the maximum of the Moffat model.
    gamma : float
        Core width of the Moffat model.
    alpha : float
        Power index of the Moffat model.

    See Also
    --------
    Gaussian1D, Box1D

    Notes
    -----
    Model formula:

    .. math::

        f(x) = A \left(1 + \frac{\left(x - x_{0}\right)^{2}}{\gamma^{2}}\right)^{- \alpha}

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        import matplotlib.pyplot as plt

        from astropy.modeling.models import Moffat1D

        plt.figure()
        s1 = Moffat1D()
        r = np.arange(-5, 5, .01)

        for factor in range(1, 4):
            s1.amplitude = factor
            s1.width = factor
            plt.plot(r, s1(r), color=str(0.25 * factor), lw=2)

        plt.axis([-5, 5, -1, 4])
        plt.show()
    R   i   i    c         C` s'   d |  j  t j d d |  j d  S(   u   
        Moffat full width at half maximum.
        Derivation of the formula is available in
        `this notebook by Yoonsoo Bach <http://nbviewer.jupyter.org/github/ysbach/AO_2017/blob/master/04_Ground_Based_Concept.ipynb#1.2.-Moffat>`_.
        g       @g      ?(   t   gammaR%   RH   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR     s    c         C` s   | d |  | | d | S(   u%   One dimensional Moffat model functioni   i   (    (   R'   R    R   R  R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   	  s    c   	      C` s   d |  | d | d | } | | | d |  d | | d | | } d | | | |  | d | d | | } | | t  j d |  | d | d  } | | | | g S(   uB   One dimensional Moffat model derivative with respect to parametersi   i   ii   (   R%   R   (	   R'   R    R   R  R   t   d_AR   t   d_gammat   d_alpha(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,   	  s    ,c         C` s+   |  j  j d  k r d  Si |  j  j d 6Sd  S(   Nu   x(   R   R-   R"   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   	  s    c         C` s1   t  d | d f d | d f d | d f g  S(   Nu   x_0u   xu   gammau	   amplitudeu   y(   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   !	  s    (   R   R   R   R	   R    R   R  R   R#   R   R2   R(   R,   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR    s   0	t   Moffat2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z e	 d    Z
 e d    Z e d    Z e	 d    Z d   Z RS(	   uk  
    Two dimensional Moffat model.

    Parameters
    ----------
    amplitude : float
        Amplitude of the model.
    x_0 : float
        x position of the maximum of the Moffat model.
    y_0 : float
        y position of the maximum of the Moffat model.
    gamma : float
        Core width of the Moffat model.
    alpha : float
        Power index of the Moffat model.

    See Also
    --------
    Gaussian2D, Box2D

    Notes
    -----
    Model formula:

    .. math::

        f(x, y) = A \left(1 + \frac{\left(x - x_{0}\right)^{2} +
        \left(y - y_{0}\right)^{2}}{\gamma^{2}}\right)^{- \alpha}
    R   i   i    c         C` s'   d |  j  t j d d |  j d  S(   u   
        Moffat full width at half maximum.
        Derivation of the formula is available in
        `this notebook by Yoonsoo Bach <http://nbviewer.jupyter.org/github/ysbach/AO_2017/blob/master/04_Ground_Based_Concept.ipynb#1.2.-Moffat>`_.
        g       @g      ?(   R  R%   RH   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR   L	  s    c         C` s3   |  | d | | d | d } | d | | S(   u%   Two dimensional Moffat model functioni   i   (    (   R'   RW   R    R   R   R  R   t   rr_gg(    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   U	  s    "c         C` s   |  | d | | d | d } d | | } | | | d |  d | | d d | }	 | | | d | d | | d d | }
 | | t  j d |  } d | | | | | d | } | |	 |
 | | g S(   uB   Two dimensional Moffat model derivative with respect to parametersi   i   i(   R%   R   (   R'   RW   R    R   R   R  R   R  R  R   t   d_y_0R  R  (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR,   \	  s    ""c         C` s8   |  j  j d  k r d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   j	  s    c         C` sa   | d | d k r# t  d   n  t d | d f d | d f d | d f d | d f g  S(	   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   gammau	   amplitudeu   z(   R   R   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   r	  s    (   R   R   R   R	   R    R   R   R  R   R#   R   R2   R(   R,   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR  '	  s   	t   Sersic2Dc           B` s   e  Z d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z e d d  Z	 e d d  Z
 d Z e d    Z e d    Z d   Z RS(	   u  
    Two dimensional Sersic surface brightness profile.

    Parameters
    ----------
    amplitude : float
        Surface brightness at r_eff.
    r_eff : float
        Effective (half-light) radius
    n : float
        Sersic Index.
    x_0 : float, optional
        x position of the center.
    y_0 : float, optional
        y position of the center.
    ellip : float, optional
        Ellipticity.
    theta : float, optional
        Rotation angle in radians, counterclockwise from
        the positive x-axis.

    See Also
    --------
    Gaussian2D, Moffat2D

    Notes
    -----
    Model formula:

    .. math::

        I(x,y) = I(r) = I_e\exp\left\{-b_n\left[\left(\frac{r}{r_{e}}\right)^{(1/n)}-1\right]\right\}

    The constant :math:`b_n` is defined such that :math:`r_e` contains half the total
    luminosity, and can be solved for numerically.

    .. math::

        \Gamma(2n) = 2\gamma (b_n,2n)

    Examples
    --------
    .. plot::
        :include-source:

        import numpy as np
        from astropy.modeling.models import Sersic2D
        import matplotlib.pyplot as plt

        x,y = np.meshgrid(np.arange(100), np.arange(100))

        mod = Sersic2D(amplitude = 1, r_eff = 25, n=4, x_0=50, y_0=50,
                       ellip=.5, theta=-1)
        img = mod(x, y)
        log_img = np.log10(img)


        plt.figure()
        plt.imshow(log_img, origin='lower', interpolation='nearest',
                   vmin=-1, vmax=2)
        plt.xlabel('x')
        plt.ylabel('y')
        cbar = plt.colorbar()
        cbar.set_label('Log Brightness', rotation=270, labelpad=25)
        cbar.set_ticks([-1, 0, 1, 2], update_ticks=True)
        plt.show()

    References
    ----------
    .. [1] http://ned.ipac.caltech.edu/level5/March05/Graham/Graham2.html
    R   i   i   i    c
         C` s  |  j  d k rO y d d l m }
 |
 |  _  WqO t k
 rK t d   qO Xn  |  j  d | d  } | d | | } } t j |	  t j |	  } } | | | | | | } | | | | | | } t j	 | | d | | d  } | t j
 | | d | d  S(	   u(   Two dimensional Sersic profile function.i    (   R   u%   Sersic2D model requires scipy > 0.11.g       @g      ?i   i   N(   R   R"   R   R   RE   R   R%   RU   RV   RH   R&   (   R   R'   RW   R    R   R   R   R   t   ellipRA   R   t   bnRR   RS   t	   cos_thetat	   sin_thetat   x_majt   x_minR   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR(   	  s    #c         C` s8   |  j  j d  k r d  Si |  j  j d 6|  j j d 6Sd  S(   Nu   xu   y(   R   R-   R"   R   (   R   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR.   	  s    c         C` sm   | d | d k r# t  d   n  t d | d f d | d f d | d f d t j f d | d	 f g  S(
   Nu   xu   yu(   Units of 'x' and 'y' inputs should matchu   x_0u   y_0u   r_effu   thetau	   amplitudeu   z(   R   R   Rw   Rx   (   R   R/   R0   (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR1   	  s    N(   R   R   R   R	   R    R   R   R   R   R  RA   R"   R   R   R(   R#   R.   R1   (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyR  ~	  s   G(E   R   t
   __future__R    R   R   R   t   collectionsR   t   numpyR%   t   coreR   R   R   R   t
   parametersR	   R
   t   utilsR   t   extern.six.movesR   t   stats.funcsR   t    R   Rw   R   R   t   utils.decoratorsR   t   __all__R   R   t   floatt   finfot   float32t   tinyR!   R   R$   R4   R<   Ry   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R  (    (    (    sA   lib/python2.7/site-packages/astropy/modeling/functional_models.pyt   <module>   sf   ""	5rE ;6(_V;/ciM1Ql^YbNX?e_W