
[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 d d l m Z d d l m Z d d	 l m Z m Z d
 d l m Z m Z d
 d l m Z d
 d l m Z d d d d d d d d d d d d g 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% d0 e f d1     YZ& d2 e f d3     YZ' d4 e f d5     YZ( d S(6   uM   
This module contains models representing polynomials and polynomial series.
i    (   t   absolute_importt   unicode_literalst   divisiont   print_function(   t   OrderedDictNi   (   t   FittableModelt   Model(   t   Shift(   t	   Parameter(   t   poly_map_domaint   combi   (   t   indentt   check_broadcast(   t   range(   t   Quantityu   Chebyshev1Du   Chebyshev2Du	   Hermite1Du	   Hermite2Du
   InverseSIPu
   Legendre1Du
   Legendre2Du   Polynomial1Du   Polynomial2Du   SIPu   OrthoPolynomialBaseu   PolynomialModelt   PolynomialBasec           B` sA   e  Z d  Z d Z e Z e Z e d    Z	 d   Z
 d   Z RS(   u   
    Base class for all polynomial-like models with an arbitrary number of
    parameters in the form of coefficients.

    In this case Parameter instances are returned through the class's
    ``__getattr__`` rather than through class descriptors.
    c         C` s   |  j  S(   u  Coefficient names generated based on the model's polynomial degree
        and number of dimensions.

        Subclasses should implement this to return parameter names in the
        desired format.

        On most `Model` classes this is a class attribute, but for polynomial
        models it is an instance attribute since each polynomial model instance
        can have different parameters depending on the degree of the polynomial
        and the number of dimensions, for example.
        (   t   _param_names(   t   self(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   param_names.   s    c         C` s>   |  j  r. | |  j  k r. t | d d d |  St |   d  S(   Nt   defaultg        t   model(   R   R   t   AttributeError(   R   t   attr(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   __getattr__>   s    c         C` sp   | d d k rS |  j  rS | |  j  k rS t | d d d |  } | j |  |  n t t |   j | |  d  S(   Ni    u   _R   g        R   (   R   R   t   __set__t   superR   t   __setattr__(   R   R   t   valuet   param(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   D   s    ((    (   t   __name__t
   __module__t   __doc__R   t   Truet   lineart   Falset   col_fit_derivt   propertyR   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR      s   	t   PolynomialModelc           B` s_   e  Z d  Z d d d d d  Z d   Z d   Z e d    Z d   Z	 d   Z
 d   Z RS(	   u   
    Base class for polynomial models.

    Its main purpose is to determine how many coefficients are needed
    based on the polynomial order and dimension and to provide their
    default values, names and ordering.
    c      
   K` se   | |  _  |  j |  j  |  _ |  j |  j  |  _ t t |   j d | d | d | d | |  d  S(   Nt   n_modelst   model_set_axist   namet   meta(	   t   _degreet   get_num_coefft   n_inputst   _ordert   _generate_coeff_namesR   R   R%   t   __init__(   R   t   degreeR&   R'   R(   R)   t   params(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/   ^   s    	c         C` s   |  j  |  j g  S(   N(   t   _format_reprR0   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   __repr__h   s    c         C` s   |  j  d |  j f g  S(   Nu   Degree(   t   _format_strR0   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   __str__k   s    c         C` s   |  j  S(   u   Degree of polynomial.(   R*   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR0   n   s    c         C` s^   |  j  d k  r t d   n  | d k r? t |  j  |  } n d } |  j  | | d } | S(   uH   
        Return the number of coefficients in one parameter set
        i    u-   Degree of polynomial must be positive or nulli   (   R0   t
   ValueErrorR
   (   R   t   ndimt   nmixedt   numc(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR+   t   s    c         C` s{   g  } |  j  d } xT t |  D]F } x= t |  D]/ } | | |  j  k r3 | j | | f  q3 q3 Wq  W| d  d  d  S(   Ni   i(   R0   R   t   append(   R   t   ct   lencoefft   it   j(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   _invlex   s    c         C` s-  g  } | d k rE xt  |  j  D] } | j d j |   q" Wn x4 t  |  j d  D] } | j d j | d   qY Wx7 t  d |  j d  D] } | j d j d |   q Wxj t  d |  j  D]V } xM t  d |  j  D]9 } | | |  j d k  r | j d j | |   q q Wq Wt |  S(   Ni   u   c{0}u   c{0}_{1}i    (   R   R-   R:   t   formatR0   t   tuple(   R   R7   t   namest   nR=   R>   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR.      s    $N(   R   R   R   t   NoneR/   R3   R5   R$   R0   R+   R?   R.   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR%   U   s   						t   OrthoPolynomialBasec        	   B` s   e  Z d  Z d Z d Z d d d d d d d d d  Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   u  
    This is a base class for the 2D Chebyshev and Legendre models.

    The polynomials implemented here require a maximum degree in x and y.

    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : list or None, optional
        domain of the x independent variable
    x_window : list or None, optional
        range of the x independent variable
    y_domain : list or None, optional
        domain of the y independent variable
    y_window : list or None, optional
        range of the y independent variable
    **params : dict
        {keyword: value} pairs, representing {parameter_name: value}
    u   xu   yu   zc      
   K` s   | |  _  | |  _ |  j   |  _ | |  _ | |  _ | |  _ | |  _ |  j   |  _	 t
 t |   j d | d | d |	 d |
 |  d  S(   NR&   R'   R(   R)   (   t   x_degreet   y_degreeR+   R-   t   x_domaint   y_domaint   x_windowt   y_windowR.   R   R   RE   R/   (   R   RF   RG   RH   RJ   RI   RK   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/      s    						c         C` s   |  j  |  j |  j g  S(   N(   R2   RF   RG   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR3      s    c         C` s%   |  j  d |  j f d |  j f g  S(   Nu   X-Degreeu   Y-Degree(   R4   RF   RG   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR5      s    c         C` s   |  j  d |  j d S(   u   
        Determine how many coefficients are needed

        Returns
        -------
        numc : int
            number of coefficients
        i   (   RF   RG   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR+      s    
c         C` s   g  } t  j |  j d  } t  j |  j d  } x2 | D]* } x! | D] } | j | | f  qF Wq9 Wt  j | d  d  d   S(   Ni   i(   t   npt   arangeRF   RG   R:   t   array(   R   R;   t   xvart   yvarR>   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR?      s    c   	      C` s   g  } t  j |  j d  } t  j |  j d  } xT | D]L } xC | D]; } d j | |  } | |  j j |  } | j |  qF Wq9 Wt  j | d  d  d   S(   Ni   u   c{0}_{1}i(	   RL   RM   RF   RG   R@   R   t   indexR:   RN   (	   R   t   coeffst   invlex_coeffsRO   RP   R>   R=   R(   t   coeff(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   invlex_coeff   s    c         C` s   |  j    } | d  d   d f |  j d | d  d   d f <|  j d } |  j d } t j | | d | | f  } xL t t |   D]8 } d d g | | | | <d | d <d | d | f <q W| S(   Ni   i   ii    i(   ii    (   R?   RF   RG   RL   t   zerosR   t   len(   R   t	   invlexdegt   nxt   nyt   alphaRC   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   _alpha   s    1!
c         C` s  t  |  } | j d d d g  |  j   } | d } t |  } t j | d d } |  j | |  }	 |  j d }
 |  j d } |
 | } x9 t	 d | d d  D]  } t
 |  d t |  d  q Wx t	 d |  D] } | | d j   d j   d } d } x8 t	 d | d  D]# } | t |  d t |   } qW|	 | d | | } t
 |  d t |  |  | | } x1 t	 d |  D]  } t
 |  d t |  d  qWq W| } x< t	 d | d d  D]# } | t |  d t |   } qW| S(   Ni    t   axisi   i   u   rg        (   t   listt   extendR\   RW   RL   t   difft   _fcacheRF   RG   R   t   setattrt   strt   nonzerot   maxt   getattr(   R   t   xt   yRT   t   _coeffR[   t   r0t   nalphat   karrt   kfunct   x_termst   y_termst   ntermsRC   t   kt   rsumR=   t   valt   result(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   imhorner  s4    

"!
"!c         C` se   g  } xR t  |  j d  D]= } x4 t  |  j d  D] } | j d j | |   q4 Wq Wt |  S(   Ni   u   c{0}_{1}(   R   RG   RF   R:   R@   RA   (   R   RB   R>   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR.   "  s
    !c         C` s   t  d   d S(   u   To be implemented by subclassesu    Subclasses should implement thisN(   t   NotImplementedError(   R   Rg   Rh   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRa   )  s    c         G` sv   |  j  d  k	 r* t | |  j  |  j  } n  |  j d  k	 rT t | |  j |  j  } n  |  j |  } |  j | | |  S(   N(   RH   RD   R	   RJ   RI   RK   RU   Ru   (   R   Rg   Rh   RR   t   invcoeff(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   evaluate/  s    c         K` sa   t  t |   j | | |  \ } } | \ } } | j | j k rQ t d   n  | | f | f S(   Nu,   Expected input arrays to have the same shape(   R   RE   t   prepare_inputst   shapeR6   (   R   Rg   Rh   t   kwargst   inputst   format_info(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRy   7  s
    $(   u   xu   y(   u   zN(   R   R   R   R|   t   outputsRD   R/   R3   R5   R+   R?   RU   R\   Ru   R.   Ra   Rx   Ry   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRE      s"   											t   Chebyshev1Dc           B` se   e  Z d  Z d
 Z d Z d d d g d d d d d  Z d   Z d   Z d   Z	 e
 d	    Z RS(   u  
    Univariate Chebyshev series.

    It is defined as:

    .. math::

        P(x) = \sum_{i=0}^{i=n}C_{i} * T_{i}(x)

    where ``T_i(x)`` is the corresponding Chebyshev polynomial of the 1st kind.

    Parameters
    ----------
    degree : int
        degree of the series
    domain : list or None, optional
    window : list or None, optional
        If None, it is set to [-1,1]
        Fitters will remap the domain to this window
    **params : dict
        keyword : value pairs, representing parameter_name: value

    Notes
    -----

    This model does not support the use of units/quantities, because each term
    in the sum of Chebyshev polynomials is a polynomial in x - since the
    coefficients within each Chebyshev polynomial are fixed, we can't use
    quantities for x since the units would not be compatible. For example, the
    third Chebyshev polynomial (T2) is 2x^2-1, but if x was specified with
    units, 2x^2 and -1 would have incompatible units.
    u   xu   yii   c   	      K` sG   | |  _  | |  _ t t |   j | d | d | d | d | | d  S(   NR&   R'   R(   R)   (   t   domaint   windowR   R   R/   (	   R   R0   R   R   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/   h  s
    		c         G` s   t  j | d t  j d t d d } t  j |  j d f | j d | j } d | d <|  j d k r d | } | | d <xC t d |  j d  D]( } | | d | | | d | | <q Wn  t  j	 | d | j
  S(   u<  
        Computes the Vandermonde matrix.

        Parameters
        ----------
        x : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        t   dtypet   copyt   ndmini   i    i   (   RL   RN   t   floatR"   t   emptyR0   Rz   R   R   t   rollaxisR7   (   R   Rg   R1   t   vt   x2R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt	   fit_derivp  s    $)


)c         K` s8   t  t |   j | |  \ } } | d } | f | f S(   Ni    (   R   R%   Ry   (   R   Rg   R{   R|   R}   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRy     s    !
c         G` s:   |  j  d  k	 r* t | |  j  |  j  } n  |  j | |  S(   N(   R   RD   R	   R   t   clenshaw(   R   Rg   RR   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx     s    c         C` s   t  |  d k r% | d } d } n t  |  d k rN | d } | d } ne d |  } | d } | d } xD t d t  |  d  D]) } | } | | | } | | | } q W| | |  S(   u4   Evaluates the polynomial using Clenshaw's algorithm.i   i    i   iii   (   RW   R   (   Rg   RR   t   c0t   c1R   R=   t   tmp(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    
	



 (   u   x(   u   yN(   R   R   R   R|   R~   RD   R/   R   Ry   Rx   t   staticmethodR   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   C  s    			t	   Hermite1Dc           B` se   e  Z d  Z d Z d Z d
 d d g d
 d
 d
 d
 d  Z d   Z d   Z d   Z	 e
 d	    Z RS(   u  
    Univariate Hermite series.

    It is defined as:

    .. math::

        P(x) = \sum_{i=0}^{i=n}C_{i} * H_{i}(x)

    where ``H_i(x)`` is the corresponding Hermite polynomial ("Physicist's kind").

    Parameters
    ----------
    degree : int
        degree of the series
    domain : list or None, optional
    window : list or None, optional
        If None, it is set to [-1,1]
        Fitters will remap the domain to this window
    **params : dict
        keyword : value pairs, representing parameter_name: value

    Notes
    -----

    This model does not support the use of units/quantities, because each term
    in the sum of Hermite polynomials is a polynomial in x - since the
    coefficients within each Hermite polynomial are fixed, we can't use
    quantities for x since the units would not be compatible. For example, the
    third Hermite polynomial (H2) is 4x^2-2, but if x was specified with units,
    4x^2 and -2 would have incompatible units.
    u   xu   yii   c   	      K` sG   | |  _  | |  _ t t |   j | d | d | d | d | | d  S(   NR&   R'   R(   R)   (   R   R   R   R   R/   (	   R   R0   R   R   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/     s
    		c         G` s   t  j | d t  j d t d d } t  j |  j d f | j d | j } d | d <|  j d k r d | } d | | d <xO t d |  j d  D]4 } | | | d d | d | | d | | <q Wn  t  j	 | d | j
  S(   u<  
        Computes the Vandermonde matrix.

        Parameters
        ----------
        x : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        R   R   R   i   i    i   (   RL   RN   R   R"   R   R0   Rz   R   R   R   R7   (   R   Rg   R1   R   R   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    $)

5c         K` s8   t  t |   j | |  \ } } | d } | f | f S(   Ni    (   R   R%   Ry   (   R   Rg   R{   R|   R}   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRy     s    !
c         G` s:   |  j  d  k	 r* t | |  j  |  j  } n  |  j | |  S(   N(   R   RD   R	   R   R   (   R   Rg   RR   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx     s    c         C` s   |  d } t  |  d k r/ | d } d } n t  |  d k rX | d } | d } n} t  |  } | d } | d } xZ t d t  |  d  D]? } | } | d } | | | d | d } | | | } q W| | | S(   Ni   i   i    iii   (   RW   R   (   Rg   RR   R   R   R   t   ndR=   t   temp(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s     

	


 
N(   R   R   R   R|   R~   RD   R/   R   Ry   Rx   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    			t	   Hermite2Dc        	   B` sV   e  Z d  Z d d d g d d d g d d d d d  Z d   Z d   Z d   Z RS(   u  
    Bivariate Hermite series.

    It is defined as

    .. math:: P_{nm}(x,y) = \sum_{n,m=0}^{n=d,m=d}C_{nm} H_n(x) H_m(y)

    where ``H_n(x)`` and ``H_m(y)`` are Hermite polynomials.

    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : list or None, optional
        domain of the x independent variable
    y_domain : list or None, optional
        domain of the y independent variable
    x_window : list or None, optional
        range of the x independent variable
    y_window : list or None, optional
        range of the y independent variable
    **params : dict
        keyword: value pairs, representing parameter_name: value

    Notes
    -----

    This model does not support the use of units/quantities, because each term
    in the sum of Hermite polynomials is a polynomial in x and/or y - since the
    coefficients within each Hermite polynomial are fixed, we can't use
    quantities for x and/or y since the units would not be compatible. For
    example, the third Hermite polynomial (H2) is 4x^2-2, but if x was
    specified with units, 4x^2 and -2 would have incompatible units.
    ii   c         K` sP   t  t |   j | | d | d | d | d | d | d | d |	 d |
 | d  S(	   NRH   RI   RJ   RK   R&   R'   R(   R)   (   R   R   R/   (   R   RF   RG   RH   RJ   RI   RK   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/   >  s    c         C` s  |  j  d } |  j d } i  } t j | j  | d <d | j   | d <t j | j  | | <d | j   | | d <xI t d |  D]8 } d | | | d d | d | | d | | <q WxQ t | d | |  D]8 } d | | | d d | d | | d | | <q W| S(   uv   
        Calculate the individual Hermite functions once and store them in a
        dictionary to be reused.
        i   i    i   (   RF   RG   RL   t   onesRz   R   R   (   R   Rg   Rh   Rn   Ro   Rm   RC   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRa   F  s    66c   
      G` s   | j  | j  k r! t d   n  | j   } | j   } |  j | |  j d  j } |  j | |  j d  j } g  } xR t |  j d  D]= } x4 t |  j d  D] } | j | | | |  q Wq Wt	 j
 |  }	 |	 j S(   u  
        Derivatives with respect to the coefficients.

        This is an array with Hermite polynomials:

        .. math::

            H_{x_0}H_{y_0}, H_{x_1}H_{y_0}...H_{x_n}H_{y_0}...H_{x_n}H_{y_m}

        Parameters
        ----------
        x : ndarray
            input
        y : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        u    x and y must have the same shapei   (   Rz   R6   t   flattent   _hermderiv1dRF   t   TRG   R   R:   RL   RN   (
   R   Rg   Rh   R1   t   x_derivt   y_derivt   ijR=   R>   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   Y  s    !c         C` s   t  j | d t  j d t d d } t  j | d t |  f d | j } | d d | d <| d k r d | } | | d <xL t d | d  D]4 } | | | d d | d | | d | | <q Wn  t  j | d | j	  S(   u1   
        Derivative of 1D Hermite series
        R   R   R   i   i    i   (
   RL   RN   R   R"   R   RW   R   R   R   R7   (   R   Rg   t   degt   dR   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    $(

5N(   R   R   R   RD   R/   Ra   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s   %		)t
   Legendre1Dc           B` se   e  Z d  Z d
 Z d Z d d d g d d d d d  Z d   Z d   Z d   Z	 e
 d	    Z RS(   u  
    Univariate Legendre series.

    It is defined as:

    .. math::

        P(x) = \sum_{i=0}^{i=n}C_{i} * L_{i}(x)

    where ``L_i(x)`` is the corresponding Legendre polynomial.

    Parameters
    ----------
    degree : int
        degree of the series
    domain : list or None, optional
    window : list or None, optional
        If None, it is set to [-1,1]
        Fitters will remap the domain to this window
    **params : dict
        keyword: value pairs, representing parameter_name: value


    Notes
    -----

    This model does not support the use of units/quantities, because each term
    in the sum of Legendre polynomials is a polynomial in x - since the
    coefficients within each Legendre polynomial are fixed, we can't use
    quantities for x since the units would not be compatible. For example, the
    third Legendre polynomial (P2) is 1.5x^2-0.5, but if x was specified with
    units, 1.5x^2 and -0.5 would have incompatible units.
    u   xu   yii   c   	      K` sG   | |  _  | |  _ t t |   j | d | d | d | d | | d  S(   NR&   R'   R(   R)   (   R   R   R   R   R/   (	   R   R0   R   R   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/     s
    		c         K` s8   t  t |   j | |  \ } } | d } | f | f S(   Ni    (   R   R%   Ry   (   R   Rg   R{   R|   R}   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRy     s    !
c         G` s:   |  j  d  k	 r* t | |  j  |  j  } n  |  j | |  S(   N(   R   RD   R	   R   R   (   R   Rg   RR   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx     s    c         G` s   t  j | d t  j d t d d } t  j |  j d f | j d | j } d | d <|  j d k r | | d <x[ t d |  j d  D]@ } | | d | d | d | | d | d | | | <q Wn  t  j	 | d | j
  S(   u<  
        Computes the Vandermonde matrix.

        Parameters
        ----------
        x : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        R   R   R   i   i    i   (   RL   RN   R   R"   R   R0   Rz   R   R   R   R7   (   R   Rg   R1   R   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    $)

Ac         C` s   t  |  d k r% | d } d } n t  |  d k rN | d } | d } n t  |  } | d } | d } xj t d t  |  d  D]O } | } | d } | | | | d | } | | |  d | d | } q W| | |  S(   Ni   i    i   iii   (   RW   R   (   Rg   RR   R   R   R   R=   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    
	


 
"(   u   x(   u   yN(   R   R   R   R|   R~   RD   R/   Ry   Rx   R   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s   !			t   Polynomial1Dc           B` s   e  Z d  Z d Z d Z d d g d d g d d d d d  Z d   Z d   Z d   Z	 e
 d	    Z e d
    Z d   Z RS(   u  
    1D Polynomial model.

    It is defined as:

    .. math::

        P = \sum_{i=0}^{i=n}C_{i} * x^{i}

    Parameters
    ----------
    degree : int
        degree of the series
    domain : list or None, optional
    window : list or None, optional
        If None, it is set to [-1,1]
        Fitters will remap the domain to this window
    **params : dict
        keyword: value pairs, representing parameter_name: value

    u   xu   yii   c   	      K` sG   | |  _  | |  _ t t |   j | d | d | d | d | | d  S(   NR&   R'   R(   R)   (   R   R   R   R   R/   (	   R   R0   R   R   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/     s
    		c         K` s8   t  t |   j | |  \ } } | d } | f | f S(   Ni    (   R   R   Ry   (   R   Rg   R{   R|   R}   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRy     s    !
c         G` s:   |  j  d  k	 r* t | |  j  |  j  } n  |  j | |  S(   N(   R   RD   R	   R   t   horner(   R   Rg   RR   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx   $  s    c         G` s   t  j |  j d f | j d t  j } d | d <|  j d k r | | d <x7 t d |  j d  D] } | | d | | | <qc Wn  t  j | d | j  S(   u<  
        Computes the Vandermonde matrix.

        Parameters
        ----------
        x : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        i   R   i    i   (   RL   R   R0   Rz   R   R   R   R7   (   R   Rg   R1   R   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   )  s    )

c         C` sw   t  |  d k r2 | d t j |  d t } nA | d } x4 t d t  |  d  D] } | | | |  } qV W| S(   Ni   it   suboki   (   RW   RL   t	   ones_likeR"   R   (   Rg   RR   R   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   B  s     
 c         C` sD   |  j  d k s! |  j j d  k r% d  Si |  j j |  j j d 6Sd  S(   Ni    u   x(   R0   R   t   unitRD   R   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   input_unitsL  s    !c         C` sl   g  } xY t  |  j d  D]D } t |  d j |   } | j | j | d | d | f  q Wt |  S(   Ni   u   c{0}u   yu   x(   R   R0   Rf   R@   R:   R(   R   (   R   t   inputs_unitt   outputs_unitt   mappingR=   t   par(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   _parameter_units_for_data_unitsS  s
    *(   u   x(   u   yN(   R   R   R   R|   R~   RD   R/   Ry   Rx   R   R   R   R$   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s   			
t   Polynomial2Dc        	   B` s   e  Z d  Z d Z d Z d d g d d g d d g d d g d d d d d  Z d   Z d   Z d	   Z	 d
   Z
 d   Z e d    Z d   Z RS(   u$  
    2D Polynomial  model.

    Represents a general polynomial of degree n:

    .. math::

        P(x,y) = c_{00} + c_{10}x + ...+ c_{n0}x^n + c_{01}y + ...+ c_{0n}y^n
        + c_{11}xy + c_{12}xy^2 + ... + c_{1(n-1)}xy^{n-1}+ ... + c_{(n-1)1}x^{n-1}y

    Parameters
    ----------
    degree : int
        highest power of the polynomial,
        the number of terms is degree+1
    x_domain : list or None, optional
        domain of the x independent variable
    y_domain : list or None, optional
        domain of the y independent variable
    x_window : list or None, optional
        range of the x independent variable
    y_window : list or None, optional
        range of the y independent variable
    **params : dict
        keyword: value pairs, representing parameter_name: value
    u   xu   yu   zii   c
         K` sY   t  t |   j | d | d | d | d |	 |
 | |  _ | |  _ | |  _ | |  _ d  S(   NR&   R'   R(   R)   (   R   R   R/   RH   RI   RJ   RK   (   R   R0   RH   RI   RJ   RK   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/   z  s    			c         K` sa   t  t |   j | | |  \ } } | \ } } | j | j k rQ t d   n  | | f | f S(   Nu,   Expected input arrays to have the same shape(   R   R   Ry   Rz   R6   (   R   Rg   Rh   R{   R|   R}   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRy     s
    $c         G` s   |  j  d  k	 r* t | |  j  |  j  } n  |  j d  k	 rT t | |  j |  j  } n  |  j |  } |  j | | |  } |  j d k r t	 t
 j | d  | j  } | r t
 j |  } | | (| } q n  | S(   Ni    (   RH   RD   R	   RJ   RI   RK   RU   t   multivariate_hornerR0   R   RL   Rz   R   (   R   Rg   Rh   RR   Rw   Rt   t   output_shapet
   new_result(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx     s    c   
      G` su  | j  d k r | j   } n  | j  d k r< | j   } n  | j | j k r] t d   n  | d d  d f t j |  j d  } | d d  d f t j d |  j d  } g  } xf t d |  j  D]R } xI t d |  j  D]5 } | | |  j k r | j	 | | | |  q q Wq Wt j
 |  j } | j   r\t j | | | g  }	 n t j | | g  }	 |	 S(   ub  
        Computes the Vandermonde matrix.

        Parameters
        ----------
        x : ndarray
            input
        y : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        i   u$   Expected x and y to be of equal sizeNi   (   R7   R   t   sizeR6   RD   RL   RM   R0   R   R:   RN   R   t   anyt   hstack(
   R   Rg   Rh   R1   t   designxt   designyt   designmixedR=   R>   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s$    *-$c         C` s   g  } t  |  j d  } xj | D]b } xY | D]Q } | | |  j k r- d j | |  } | |  j j |  } | j |  q- q- Wq  W| d  d  d  S(   Ni   u   c{0}_{1}i(   R   R0   R@   R   RQ   R:   (   R   RR   RS   R<   R=   R>   R(   RT   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRU     s    c   
      C` s   |  j    } | d } | d } | d } t j | d d } xz t t |   D]f }	 | |	 d f d k r | | | | } t j | d d t } n | | | } | |	 d } qR W| | | S(   u   
        Multivariate Horner's scheme

        Parameters
        ----------
        x, y : array
        coeffs : array of coefficients in inverse lexical order
        i    g        R]   i   R   (   R?   RL   R`   R   RW   t
   zeros_likeR"   (
   R   Rg   Rh   RR   R[   Rj   t   r1t   r2Rl   RC   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    



c         C` sm   |  j  d k s3 |  j j d  k r7 |  j j d  k r7 d  Si |  j j |  j j d 6|  j j |  j j d 6Sd  S(   Ni    u   xu   y(   R0   t   c1_0R   RD   t   c0_1t   c0_0(   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    3c         C` s   g  } x t  |  j d  D] } x~ t  |  j d  D]i } | | d k rP q4 n  t |  d j | |   } | j | j | d | d | | d | f  q4 Wq Wt |  S(   Ni   i   u   c{0}_{1}u   zu   xu   y(   R   R0   Rf   R@   R:   R(   R   (   R   R   R   R   R=   R>   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    :(   u   xu   y(   u   zN(   R   R   R   R|   R~   RD   R/   Ry   Rx   R   RU   R   R$   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   [  s   		
		)		t   Chebyshev2Dc        	   B` sV   e  Z d  Z d d d g d d d g d d d d d  Z d   Z d   Z d   Z RS(   u  
    Bivariate Chebyshev series..

    It is defined as

    .. math:: P_{nm}(x,y) = \sum_{n,m=0}^{n=d,m=d}C_{nm}  T_n(x ) T_m(y)

    where ``T_n(x)`` and ``T_m(y)`` are Chebyshev polynomials of the first kind.


    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : list or None, optional
        domain of the x independent variable
    y_domain : list or None, optional
        domain of the y independent variable
    x_window : list or None, optional
        range of the x independent variable
    y_window : list or None, optional
        range of the y independent variable
    **params : dict
        keyword: value pairs, representing parameter_name: value

    Notes
    -----

    This model does not support the use of units/quantities, because each term
    in the sum of Chebyshev polynomials is a polynomial in x and/or y - since
    the coefficients within each Chebyshev polynomial are fixed, we can't use
    quantities for x and/or y since the units would not be compatible. For
    example, the third Chebyshev polynomial (T2) is 2x^2-1, but if x was
    specified with units, 2x^2 and -1 would have incompatible units.
    ii   c         K` sP   t  t |   j | | d | d | d | d | d | d | d |	 d |
 | d  S(	   NRH   RI   RJ   RK   R&   R'   R(   R)   (   R   R   R/   (   R   RF   RG   RH   RJ   RI   RK   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/   +  s    c         C` s   |  j  d } |  j d } i  } t j | j  | d <| j   | d <t j | j  | | <| j   | | d <x= t d |  D], } d | | | d | | d | | <q WxE t | d | |  D], } d | | | d | | d | | <q W| S(   ux   
        Calculate the individual Chebyshev functions once and store them in a
        dictionary to be reused.
        i   i    i   (   RF   RG   RL   R   Rz   R   R   (   R   Rg   Rh   Rn   Ro   Rm   RC   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRa   3  s    **c   
      G` s   | j  | j  k r! t d   n  | j   } | j   } |  j | |  j d  j } |  j | |  j d  j } g  } xR t |  j d  D]= } x4 t |  j d  D] } | j | | | |  q Wq Wt	 j
 |  }	 |	 j S(   u  
        Derivatives with respect to the coefficients.

        This is an array with Chebyshev polynomials:

        .. math::

            T_{x_0}T_{y_0}, T_{x_1}T_{y_0}...T_{x_n}T_{y_0}...T_{x_n}T_{y_m}

        Parameters
        ----------
        x : ndarray
            input
        y : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        u    x and y must have the same shapei   (   Rz   R6   R   t   _chebderiv1dRF   R   RG   R   R:   RL   RN   (
   R   Rg   Rh   R1   R   R   R   R=   R>   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   F  s    !c         C` s   t  j | d t  j d t d d } t  j | d t |  f d | j } | d d | d <| d k r d | } | | d <x@ t d | d  D]( } | | d | | | d | | <q Wn  t  j | d | j	  S(   u3   
        Derivative of 1D Chebyshev series
        R   R   R   i   i    i   (
   RL   RN   R   R"   R   RW   R   R   R   R7   (   R   Rg   R   R   R   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   o  s    $(

)N(   R   R   R   RD   R/   Ra   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s   &		)t
   Legendre2Dc        	   B` sV   e  Z d  Z d d d g d d d g d d d d d  Z d   Z d   Z d   Z RS(   u+  
    Bivariate Legendre series.

    Defined as:

    .. math:: P_{n_m}(x,y) = \sum_{n,m=0}^{n=d,m=d}C_{nm}  L_n(x ) L_m(y)

    where ``L_n(x)`` and ``L_m(y)`` are Legendre polynomials.

    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : list or None, optional
        domain of the x independent variable
    y_domain : list or None, optional
        domain of the y independent variable
    x_window : list or None, optional
        range of the x independent variable
    y_window : list or None, optional
        range of the y independent variable
    **params : dict
        keyword: value pairs, representing parameter_name: value

    Notes
    -----
    Model formula:

    .. math::

        P(x) = \sum_{i=0}^{i=n}C_{i} * L_{i}(x)

    where ``L_{i}`` is the corresponding Legendre polynomial.

    This model does not support the use of units/quantities, because each term
    in the sum of Legendre polynomials is a polynomial in x - since the
    coefficients within each Legendre polynomial are fixed, we can't use
    quantities for x since the units would not be compatible. For example, the
    third Legendre polynomial (P2) is 1.5x^2-0.5, but if x was specified with
    units, 1.5x^2 and -0.5 would have incompatible units.
    ii   c         K` sP   t  t |   j | | d | d | d | d | d | d | d |	 d |
 | d  S(	   NRH   RI   RJ   RK   R&   R'   R(   R)   (   R   R   R/   (   R   RF   RG   RH   RJ   RI   RK   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/     s    c         C` s0  |  j  d } |  j d } i  } t j | j  | d <| j   | d <t j | j  | | <| j   | | d <xU t d |  D]D } d | d d | | | d | d | | d | | | <q Wxa t d |  D]P } d | d d | | | | d | d | | | d | | | | <q W| S(   uw   
        Calculate the individual Legendre functions once and store them in a
        dictionary to be reused.
        i   i    i   (   RF   RG   RL   R   Rz   R   R   (   R   Rg   Rh   Rn   Ro   Rm   RC   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRa     s    ##+c   
      G` s   | j  | j  k r! t d   n  | j   } | j   } |  j | |  j d  j } |  j | |  j d  j } g  } xR t |  j d  D]= } x4 t |  j d  D] } | j | | | |  q Wq Wt	 j
 |  }	 |	 j S(   u  
        Derivatives with respect to the coefficients.
        This is an array with Legendre polynomials:

        Lx0Ly0  Lx1Ly0...LxnLy0...LxnLym

        Parameters
        ----------
        x : ndarray
            input
        y : ndarray
            input
        params : throw away parameter
            parameter list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        u    x and y must have the same shapei   (   Rz   R6   R   t   _legendderiv1dRF   R   RG   R   R:   RL   RN   (
   R   Rg   Rh   R1   R   R   R   R=   R>   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    !c         C` s   t  j | d t  j d t d d } t  j | d f | j d | j } | d d | d <| d k r | | d <xX t d | d  D]@ } | | d | d | d | | d | d | | | <q Wn  t  j | d | j	  S(   u$   Derivative of 1D Legendre polynomialR   R   R   i   i    i   (
   RL   RN   R   R"   R   Rz   R   R   R   R7   (   R   Rg   R   R   R=   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s    $&
AN(   R   R   R   RD   R/   Ra   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s   ,		$t   _SIP1Dc           B` sn   e  Z d  Z d Z d Z d d d d d  Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z RS(   u   
    This implements the Simple Imaging Polynomial Model (SIP) in 1D.

    It's unlikely it will be used in 1D so this class is private
    and SIP should be used instead.
    u   uu   vu   wc      
   K` sV   | |  _  | |  _ |  j |  |  _ t t |   j d | d | d | d | |  d  S(   NR&   R'   R(   R)   (   t   ordert   coeff_prefixR.   R   R   R   R/   (   R   R   R   R&   R'   R(   R)   R1   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/     s    		c         C` s   |  j  d |  j |  j g  S(   Nt   args(   R2   R   R   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR3     s    c         C` s%   |  j  d |  j f d |  j f g  S(   Nu   Orderu   Coeff. Prefix(   R4   R   R   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR5     s    c         G` s(   |  j  |  j |  } |  j | | |  S(   N(   t   _coeff_matrixR   t	   _eval_sip(   R   Rg   Rh   RR   t   mcoef(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx     s    c         C` sX   |  j  d k  s |  j  d k r- t d   n  t |  j  |  } |  j  | | d } | S(   uD   
        Return the number of coefficients in one param set
        i   i	   u'   Degree of polynomial must be 2< deg < 9(   R   R6   R
   (   R   R7   R8   R9   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR+     s
    c         C` s   g  } x: t  d |  j d  D]" } | j d j | | d   q Wx: t  d |  j d  D]" } | j d j | d |   qZ Wxm t  d |  j  D]Y } xP t  d |  j  D]< } | | |  j d k  r | j d j | | |   q q Wq W| S(   Ni   i   u   {0}_{1}_{2}i    (   R   R   R:   R@   (   R   R   RB   R=   R>   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR.   +  s      'c         C` s\  t  j |  j d |  j d f  } xS t d |  j d  D]; } d j | | d  } | |  j j |  | | d f <q: WxS t d |  j d  D]; } d j | d |  } | |  j j |  | d | f <q Wx t d |  j  D]r } xi t d |  j  D]U } | | |  j d k  r d j | | |  } | |  j j |  | | | f <q q Wq W| S(   Ni   i   u   {0}_{1}_{2}i    (   RL   RV   R   R   R@   R   RQ   (   R   R   RR   t   matR=   R   R>   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   7  s    #$$+c         C` s   t  j | d t  j } t  j | d t  j } |  j d k rT t  j | j  } n t  j | j  } x t | j d  D]r } xi t | j d  D]T } | | d k r | | |  j d k  r | | | | f | | | | } q q Wqz W| S(   NR   u   Ai    i   (   RL   t   asarrayt   float64R   RV   Rz   R   R   (   R   Rg   Rh   t   coefRt   R=   R>   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   F  s    '/(   u   uu   v(   u   wN(   R   R   R   R|   R~   RD   R/   R3   R5   Rx   R+   R.   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s   							t   SIPc           B` sk   e  Z d  Z d
 Z d Z i  i  d d i  i  d d d d d 
 Z d   Z d   Z e	 d    Z
 d	   Z RS(   u  
    Simple Imaging Polynomial (SIP) model.

    The SIP convention is used to represent distortions in FITS image headers.
    See [1]_ for a description of the SIP convention.

    Parameters
    ----------
    crpix : list or ndarray of length(2)
        CRPIX values
    a_order : int
        SIP polynomial order for first axis
    b_order : int
        SIP order for second axis
    a_coeff : dict
        SIP coefficients for first axis
    b_coeff : dict
        SIP coefficients for the second axis
    ap_order : int
        order for the inverse transformation (AP coefficients)
    bp_order : int
        order for the inverse transformation (BP coefficients)
    ap_coeff : dict
        coefficients for the inverse transform
    bp_coeff : dict
        coefficients for the inverse transform

    References
    ----------
    .. [1] `David Shupe, et al, ADASS, ASP Conference Series, Vol. 347, 2005 <http://adsabs.harvard.edu/abs/2005ASPC..347..491S>`_
    u   uu   vu   xu   yc      	   C` s   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ |	 |  _ t	 | d  |  _
 t	 | d  |  _ t | d d d |
 d | | |  _ t | d d d |
 d | | |  _ t t |   j d |
 d | d | d	 |  d  S(
   Ni    i   R   u   AR&   R'   u   BR(   R)   (   t   _crpixt   _a_ordert   _b_ordert   _a_coefft   _b_coefft	   _ap_ordert	   _bp_ordert	   _ap_coefft	   _bp_coeffR   t   shift_at   shift_bR   t   sip1d_at   sip1d_bR   R   R/   (   R   t   crpixt   a_ordert   b_ordert   a_coefft   b_coefft   ap_ordert   bp_ordert   ap_coefft   bp_coeffR&   R'   R(   R)   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/   y  s$    									c         C` s.   d j  |  j j |  j |  j |  j |  j g  S(   Nu   <{0}({1!r})>(   R@   t	   __class__R   R   R   R   R   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR3     s    c         C` sz   d j  |  j j  g } xR |  j |  j |  j |  j g D]2 } | j t t	 |  d d  | j d  q7 Wd j
 |  S(   Nu
   Model: {0}t   widthi   u    u   
(   R@   R   R   R   R   R   R   R:   R   Rc   t   join(   R   t   partsR   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR5     s
    %c         C` sM   |  j  d  k	 r= |  j d  k	 r= t |  j  |  j |  j |  j  St d   d  S(   Nu+   SIP inverse coefficients are not available.(   R   RD   R   t
   InverseSIPR   R   Rv   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   inverse  s    c         C` s|   |  j  j | |  j  j  } |  j j | |  j j  } |  j j | | |  j j  } |  j j | | |  j j  } | | f S(   N(   R   Rx   t
   param_setsR   R   R   (   R   Rg   Rh   t   uR   t   ft   g(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx     s
    (   u   uu   v(   u   xu   yN(   R   R   R   R|   R~   RD   R/   R3   R5   R$   R   Rx   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR   U  s   		R   c           B` sP   e  Z d  Z d	 Z d
 Z i  i  d d d d d  Z d   Z d   Z d   Z	 RS(   uu  
    Inverse Simple Imaging Polynomial

    Parameters
    ----------
    ap_order : int
        order for the inverse transformation (AP coefficients)
    bp_order : int
        order for the inverse transformation (BP coefficients)
    ap_coeff : dict
        coefficients for the inverse transform
    bp_coeff : dict
        coefficients for the inverse transform

    u   xu   yu   uu   vc	      	   C` s   | |  _  | |  _ | |  _ | |  _ | j d d  | j d d  t d   | j   D  }	 t d   | j   D  }
 t d | d | |	  |  _ t d | d | |
  |  _	 t
 t |   j d | d | d	 | d
 |  d  S(   Nu   AP_0_0i    u   BP_0_0c         s` s-   |  ]# \ } } | j  d  d  | f Vq d S(   u   AP_u   cN(   t   replace(   t   .0Rq   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pys	   <genexpr>  s   c         s` s-   |  ]# \ } } | j  d  d  | f Vq d S(   u   BP_u   cN(   R   (   R   Rq   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pys	   <genexpr>  s   R0   R'   R&   R(   R)   (   R   R   R   R   t
   setdefaultt   dictt   itemsR   t   sip1d_apt   sip1d_bpR   R   R/   (   R   R   R   R   R   R&   R'   R(   R)   t   ap_coeff_paramst   bp_coeff_params(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR/     s&    						c         C` s"   d j  |  j j |  j |  j g  S(   Nu   <{0}({1!r})>(   R@   R   R   R   R   (   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR3     s    c         C` sn   d j  |  j j  g } xF |  j |  j g D]2 } | j t t |  d d  | j d  q+ Wd j |  S(   Nu
   Model: {0}R   i   u    u   
(	   R@   R   R   R   R   R:   R   Rc   R   (   R   R   R   (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR5     s
    c         C` sF   |  j  j | | |  j  j  } |  j j | | |  j j  } | | f S(   N(   R   Rx   R   R   (   R   Rg   Rh   t   x1t   y1(    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyRx     s    (   u   xu   y(   u   uu   vN(
   R   R   R   R|   R~   RD   R/   R3   R5   Rx   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyR     s   		()   R   t
   __future__R    R   R   R   t   collectionsR   t   numpyRL   t   coreR   R   t   functional_modelsR   t
   parametersR   t   utilsR	   R
   R   R   t   extern.six.movesR   t   unitsR   t   __all__R   R%   RE   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/polynomial.pyt   <module>   s8   "		7Ijj{i`||ZV