B
    d                 @   sh  d Z ddl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lmZmZmZ d	d
ddddddddddgZG dd deZG dd deZG dd deZG dd deZG dd	 d	eZG dd deZG dd deZG dd deZG dd deZG d d deZG d!d
 d
eZG d"d deZG d#d$ d$eZG d%d deZG d&d deZ dS )'zN
This module contains models representing polynomials and polynomial series.

    N)indentcheck_broadcast   )FittableModelModel)Shift)	Parameter)poly_map_domaincomb_validate_domain_windowChebyshev1DChebyshev2D	Hermite1D	Hermite2D
InverseSIP
Legendre1D
Legendre2DPolynomial1DPolynomial2DSIPOrthoPolynomialBasePolynomialModelc               @   s(   e Zd ZdZdZdZdZedd ZdS )PolynomialBasez
    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.
     TFc             C   s   | j S )a  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.
        )_param_names)selfr   r   h/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/astropy/modeling/polynomial.pyparam_names(   s    zPolynomialBase.param_namesN)	__name__
__module____qualname____doc__r   ZlinearZcol_fit_derivpropertyr   r   r   r   r   r      s
   r   c                   sF   e Zd ZdZd fdd	Zedd Zdd Zd	d
 Zdd Z	  Z
S )r   z
    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.
    Nc       	         s   || _ | | j| _| | j| _|rB|d kr2d}d| |f }nd}x&| jD ]}t|t|d| j	|< qNW t
 jf ||||d| d S )Nr   )r   r   )default)n_modelsmodel_set_axisnamemeta)_degreeget_num_coeffn_inputs_order_generate_coeff_namesr   r   npzeros_parameters_super__init__)	r   degreer$   r%   r&   r'   paramsminshape
param_name)	__class__r   r   r1   B   s    zPolynomialModel.__init__c             C   s   | j S )zDegree of polynomial.)r(   )r   r   r   r   r2   U   s    zPolynomialModel.degreec             C   sB   | j dk rtd|dkr(t| j |}nd}| j | | d }|S )zH
        Return the number of coefficients in one parameter set
        r   z-Degree of polynomial must be positive or nullr   )r2   
ValueErrorr
   )r   ndimnmixednumcr   r   r   r)   [   s    
zPolynomialModel.get_num_coeffc             C   s\   g }| j d }x>t|D ]2}x,t|D ] }|| | j kr&|||f q&W qW |d d d S )Nr   )r2   rangeappend)r   clencoeffijr   r   r   _invlexk   s    
zPolynomialModel._invlexc             C   s   g }|dkr2xt | jD ]}|d|  qW nx,t | jd D ]}|d| dd  qBW x.t d| jd D ]}|dd d|  qrW xRt d| jD ]B}x<t d| jD ],}|| | jd k r|d| d|  qW qW t|S )Nr   r>   _r   )r<   r+   r=   r2   tuple)r   r8   namesnr@   rA   r   r   r   r,   t   s    z%PolynomialModel._generate_coeff_names)NNNN)r   r   r    r!   r1   r"   r2   r)   rB   r,   __classcell__r   r   )r6   r   r   9   s    	c                   sn   e Zd ZdZd fdd	Zedd Zejdd Zedd	 Zejd
d	 Zdd Z	dd Z
dd Z  ZS )_PolyDomainWindow1DzF
    This class sets ``domain`` and ``window`` of 1D polynomials.
    Nc       	         s.   t  j|||f||d| | || d S )N)r&   r'   )r0   r1   _set_default_domain_window)	r   r2   domainwindowr$   r%   r&   r'   r3   )r6   r   r   r1      s    z_PolyDomainWindow1D.__init__c             C   s   | j S )N)_window)r   r   r   r   rK      s    z_PolyDomainWindow1D.windowc             C   s   t || _d S )N)r   rL   )r   valr   r   r   rK      s    c             C   s   | j S )N)_domain)r   r   r   r   rJ      s    z_PolyDomainWindow1D.domainc             C   s   t || _d S )N)r   rN   )r   rM   r   r   r   rJ      s    c             C   s(   ddd| _ t|pd| _t|| _dS )z^
        This method sets the ``domain`` and ``window`` attributes on 1D subclasses.

        N)r;   r   )rJ   rK   )_default_domain_windowr   rL   rN   )r   rJ   rK   r   r   r   rI      s    
z._PolyDomainWindow1D._set_default_domain_windowc             C   s    | j | jg| j| jd| jdS )N)rJ   rK   )kwargsdefaults)_format_reprr2   rJ   rK   rO   )r   r   r   r   __repr__   s    
z_PolyDomainWindow1D.__repr__c             C   s&   |  d| jfd| jfd| jfg| jS )NDegreeDomainZWindow)_format_strr2   rJ   rK   rO   )r   r   r   r   __str__   s    
z_PolyDomainWindow1D.__str__)NNNNNN)r   r   r    r!   r1   r"   rK   setterrJ   rI   rS   rW   rG   r   r   )r6   r   rH      s    rH   c                   s   e Zd ZdZdZdZd) fdd	Zedd Zej	d	d Zed
d Z
e
j	dd Z
edd Zej	dd Zedd Zej	dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Z fd'd(Z  ZS )*r   aM  
    This is a base class for the 2D Chebyshev and Legendre models.

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

    For explanation of ``x_domain``, ``y_domain``, ```x_window`` and ```y_window``
    see :ref:`Notes regarding usage of domain and window <domain-window-note>`.


    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : tuple or None, optional
        domain of the x independent variable
    x_window : tuple or None, optional
        range of the x independent variable
    y_domain : tuple or None, optional
        domain of the y independent variable
    y_window : tuple or None, optional
        range of the y independent variable
    **params : dict
        {keyword: value} pairs, representing {parameter_name: value}
       r   Nc                s   || _ || _|  | _ddd d d| _t|p4| jd | _t|pH| jd | _t|| _t|| _	| 
 | _|r|d kr|d}d| |f }nd}x&| jD ]}t|t|d| j|< qW t jf |||	|
d	| d S )
N)r;   r   )x_windowy_windowx_domainy_domainrZ   r[   r   )r   r   )r#   )r$   r%   r&   r'   )x_degreey_degreer)   r+   rO   r   	_x_window	_y_window	_x_domain	_y_domainr,   r   r   r-   r.   r/   r0   r1   )r   r^   r_   r\   rZ   r]   r[   r$   r%   r&   r'   r3   r4   r5   )r6   r   r   r1      s,    




zOrthoPolynomialBase.__init__c             C   s   | j S )N)rb   )r   r   r   r   r\      s    zOrthoPolynomialBase.x_domainc             C   s   t || _d S )N)r   rb   )r   rM   r   r   r   r\      s    c             C   s   | j S )N)rc   )r   r   r   r   r]     s    zOrthoPolynomialBase.y_domainc             C   s   t || _d S )N)r   rc   )r   rM   r   r   r   r]     s    c             C   s   | j S )N)r`   )r   r   r   r   rZ     s    zOrthoPolynomialBase.x_windowc             C   s   t || _d S )N)r   r`   )r   rM   r   r   r   rZ     s    c             C   s   | j S )N)ra   )r   r   r   r   r[     s    zOrthoPolynomialBase.y_windowc             C   s   t || _d S )N)r   ra   )r   rM   r   r   r   r[     s    c             C   s,   | j | j| jg| j| j| j| jd| jdS )N)r\   r]   rZ   r[   )rP   rQ   )rR   r^   r_   r\   r]   rZ   r[   rO   )r   r   r   r   rS     s    zOrthoPolynomialBase.__repr__c          	   C   s>   |  d| jfd| jfd| jfd| jfd| jfd| jfg| jS )NZX_DegreeZY_DegreeX_DomainY_DomainX_WindowY_Window)rV   r^   r_   r\   r]   rZ   r[   rO   )r   r   r   r   rW   #  s    
zOrthoPolynomialBase.__str__c             C   s   | j d | jd  S )z
        Determine how many coefficients are needed

        Returns
        -------
        numc : int
            number of coefficients
        r   )r^   r_   )r   r   r   r   r)   -  s    
z!OrthoPolynomialBase.get_num_coeffc             C   sb   g }t | jd }t | jd }x(|D ] }x|D ]}|||f q4W q*W t |d d d S )Nr   r;   )r-   aranger^   r_   r=   array)r   r>   xvaryvarrA   r@   r   r   r   rB   9  s    

zOrthoPolynomialBase._invlexc       	      C   s~   g }t | jd }t | jd }xD|D ]<}x6|D ].}d| d| }|| j| }|| q4W q*W t |d d d S )Nr   r>   rC   r;   )r-   rh   r^   r_   r   indexr=   ri   )	r   coeffsinvlex_coeffsrj   rk   rA   r@   r&   coeffr   r   r   invlex_coeffD  s    

z OrthoPolynomialBase.invlex_coeffc             C   s   |   }|d d df | j d |d d df< | jd }| jd }t|| d || f}x<tt|D ],}ddg|| || < d|d< d|d|f< qjW |S )Nr      )r   )rB   r^   r_   r-   r.   r<   len)r   Z	invlexdegnxnyalpharF   r   r   r   _alphaO  s    &

zOrthoPolynomialBase._alphac             C   s  t |}|dddg |  }|d }t|}tj|dd}| ||}	| jd }
| jd }|
| }x.t	d|d d D ]}t
| dt| d qzW xt	d|D ]}||d   d  d }d}x,t	d|d D ]}|t| dt|  }qW |	|d  ||  }t
| dt| | || }x(t	d|D ]}t
| dt| d q0W qW |}x2t	d|d d D ]}|t| dt|  }qjW |S )Nr   )axisr   rq   rg        )listextendrx   rt   r-   diff_fcacher^   r_   r<   setattrstrZnonzeromaxgetattr)r   xyro   Z_coeffrw   r0Znalphakarrkfuncx_termsy_termsZntermsrF   kZrsumr@   rM   resultr   r   r   imhorner[  s4    

zOrthoPolynomialBase.imhornerc             C   sR   g }xDt | jd D ]2}x,t | jd D ]}|d| d|  q(W qW t|S )Nr   r>   rC   )r<   r_   r^   r=   rD   )r   rE   rA   r@   r   r   r   r,   y  s
    z)OrthoPolynomialBase._generate_coeff_namesc             C   s   t ddS )zk
        Computation and store the individual functions.

        To be implemented by subclasses"
        z Subclasses should implement thisN)NotImplementedError)r   r   r   r   r   r   r~     s    zOrthoPolynomialBase._fcachec             G   sL   | j d k	rt|| j | j}| jd k	r4t|| j| j}| |}| |||S )N)r\   r	   rZ   r]   r[   rp   r   )r   r   r   rm   invcoeffr   r   r   evaluate  s    


zOrthoPolynomialBase.evaluatec                s>   t  j||f|\}}|\}}|j|jkr2td||f|fS )Nz,Expected input arrays to have the same shape)r0   prepare_inputsshaper7   )r   r   r   rP   inputsformat_info)r6   r   r   r     s
    z"OrthoPolynomialBase.prepare_inputs)NNNNNNNN)r   r   r    r!   r*   	n_outputsr1   r"   r\   rX   r]   rZ   r[   rS   rW   r)   rB   rp   rx   r   r,   r~   r   r   rG   r   r   )r6   r   r      s2      
	c                   sV   e Zd ZdZdZdZdZd fdd	Zdd Z fd	d
Z	dd Z
edd Z  ZS )r   ac  
    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.

    For explanation of ```domain``, and ``window`` see
    :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------
    degree : int
        degree of the series
    domain : tuple or None, optional
    window : tuple 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.
    r   TNc       	   	      s&   t  j|f||||||d| d S )N)rJ   rK   r$   r%   r&   r'   )r0   r1   )	r   r2   rJ   rK   r$   r%   r&   r'   r3   )r6   r   r   r1     s    zChebyshev1D.__init__c             G   s   t j|tddd}t j| jd f|j |jd}d|d< | jdkrd| }||d< x8td| jd D ]$}||d  | ||d   ||< qdW t |d|j	S )a1  
        Computes the Vandermonde matrix.

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

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        Fr   )dtypecopyndmin)r   r   rY   )
r-   ri   floatemptyr2   r   r   r<   rollaxisr8   )r   r   r3   vx2r@   r   r   r   	fit_deriv  s    
$zChebyshev1D.fit_derivc                s&   t  j|f|\}}|d }|f|fS )Nr   )r0   r   )r   r   rP   r   r   )r6   r   r   r     s    zChebyshev1D.prepare_inputsc             G   s&   | j d k	rt|| j | j}| ||S )N)rJ   r	   rK   clenshaw)r   r   rm   r   r   r   r     s    
zChebyshev1D.evaluatec             C   s   t |dkr|d }d}npt |dkr8|d }|d }nRd|  }|d }|d }x8tdt |d D ]"}|}||  | }|||  }qdW |||   S )z4Evaluates the polynomial using Clenshaw's algorithm.r   r   rY   rr   r;   rq   )rt   r<   )r   rm   c0c1r   r@   tmpr   r   r   r     s    
zChebyshev1D.clenshaw)NNNNNN)r   r   r    r!   r*   r   
_separabler1   r   r   r   staticmethodr   rG   r   r   )r6   r   r     s   # c                   sV   e Zd ZdZdZdZdZd fdd	Zdd Z fd	d
Z	dd Z
edd Z  ZS )r   a\  
    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").

    For explanation of ``domain``, and ``window`` see
    :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------
    degree : int
        degree of the series
    domain : tuple or None, optional
    window : tuple 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.
    r   TNc       	         s&   t  j|||f||||d| d S )N)r$   r%   r&   r'   )r0   r1   )	r   r2   rJ   rK   r$   r%   r&   r'   r3   )r6   r   r   r1   0  s    
zHermite1D.__init__c             G   s   t j|tddd}t j| jd f|j |jd}d|d< | jdkrd| }d| |d< xDtd| jd D ]0}|||d   d|d  ||d    ||< qhW t |d|j	S )a1  
        Computes the Vandermonde matrix.

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

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        Fr   )r   r   r   )r   r   rY   )
r-   ri   r   r   r2   r   r   r<   r   r8   )r   r   r3   r   r   r@   r   r   r   r   6  s    
0zHermite1D.fit_derivc                s&   t  j|f|\}}|d }|f|fS )Nr   )r0   r   )r   r   rP   r   r   )r6   r   r   r   Q  s    zHermite1D.prepare_inputsc             G   s&   | j d k	rt|| j | j}| ||S )N)rJ   r	   rK   r   )r   r   rm   r   r   r   r   X  s    
zHermite1D.evaluatec             C   s   | d }t |dkr"|d }d}nt |dkr@|d }|d }nft |}|d }|d }xLtdt |d D ]6}|}|d }||  |d|d    }|||  }qlW |||  S )NrY   r   r   rr   r;   rq   )rt   r<   )r   rm   r   r   r   ndr@   tempr   r   r   r   ]  s     
zHermite1D.clenshaw)NNNNNN)r   r   r    r!   r*   r   r   r1   r   r   r   r   r   rG   r   r   )r6   r   r     s   # c                   s>   e Zd ZdZdZd fdd	Zdd Zdd	 Zd
d Z  Z	S )r   a  
    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.

    For explanation of ``x_domain``, ``y_domain``, ``x_window`` and ``y_window``
    see :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : tuple or None, optional
        domain of the x independent variable
    y_domain : tuple or None, optional
        domain of the y independent variable
    x_window : tuple or None, optional
        range of the x independent variable
        If None, it is set to (-1, 1)
        Fitters will remap the domain to this window
    y_window : tuple or None, optional
        range of the y independent variable
        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 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.
    FNc                s,   t  j||f|||||||	|
d| d S )N)r\   r]   rZ   r[   r$   r%   r&   r'   )r0   r1   )r   r^   r_   r\   rZ   r]   r[   r$   r%   r&   r'   r3   )r6   r   r   r1     s    
zHermite2D.__init__c             C   s   | j d }| jd }i }t|j|d< d|  |d< t|j||< d|  ||d < xBtd|D ]4}d| ||d   d|d  ||d    ||< qhW xJt|d || D ]4}d| ||d   d|d  ||d    ||< qW |S )zv
        Calculate the individual Hermite functions once and store them in a
        dictionary to be reused.
        r   r   rY   )r^   r_   r-   onesr   r   r<   )r   r   r   r   r   r   rF   r   r   r   r~     s    

44zHermite2D._fcachec       
      G   s   |j |j krtd| }| }| || jd j}| || jd j}g }xDt| jd D ]2}x,t| jd D ]}||| ||   qtW q`W t	
|}	|	jS )a  
        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 list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        z x and y must have the same shaper   )r   r7   flatten_hermderiv1dr^   Tr_   r<   r=   r-   ri   )
r   r   r   r3   x_derivy_derivijr@   rA   r   r   r   r   r     s    
zHermite2D.fit_derivc             C   s   t j|tddd}t j|d t|f|jd}|d d |d< |dkrd| }||d< xBtd|d D ]0}|||d   d|d  ||d    ||< qfW t |d|jS )z1
        Derivative of 1D Hermite series
        Fr   )r   r   r   )r   r   rY   )	r-   ri   r   r   rt   r   r<   r   r8   )r   r   degdr   r@   r   r   r   r     s    0zHermite2D._hermderiv1d)NNNNNNNN)
r   r   r    r!   r   r1   r~   r   r   rG   r   r   )r6   r   r   r  s   ,  )c                   sV   e Zd ZdZdZdZdZd fdd	Z fddZd	d
 Z	dd Z
edd Z  ZS )r   aT  
    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.

    For explanation of ``domain``, and ``window`` see
    :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------
    degree : int
        degree of the series
    domain : tuple or None, optional
    window : tuple 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.
    r   TNc       	         s&   t  j|||f||||d| d S )N)r$   r%   r&   r'   )r0   r1   )	r   r2   rJ   rK   r$   r%   r&   r'   r3   )r6   r   r   r1      s    
zLegendre1D.__init__c                s&   t  j|f|\}}|d }|f|fS )Nr   )r0   r   )r   r   rP   r   r   )r6   r   r   r   &  s    zLegendre1D.prepare_inputsc             G   s&   | j d k	rt|| j | j}| ||S )N)rJ   r	   rK   r   )r   r   rm   r   r   r   r   -  s    
zLegendre1D.evaluatec             G   s   t j|tddd}t j| jd f|j |jd}d|d< | jdkr||d< xPtd| jd D ]<}||d  | d| d  ||d  |d   | ||< q\W t |d|j	S )a1  
        Computes the Vandermonde matrix.

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

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        Fr   )r   r   r   )r   r   rY   )
r-   ri   r   r   r2   r   r   r<   r   r8   )r   r   r3   r   r@   r   r   r   r   2  s    
<zLegendre1D.fit_derivc             C   s   t |dkr|d }d}nt |dkr8|d }|d }nvt |}|d }|d }x\tdt |d D ]F}|}|d }||  ||d  |  }|||  d| d  |  }qdW |||   S )Nr   r   rY   rr   r;   rq   )rt   r<   )r   rm   r   r   r   r@   r   r   r   r   r   L  s    
 zLegendre1D.clenshaw)NNNNNN)r   r   r    r!   r*   r   r   r1   r   r   r   r   r   rG   r   r   )r6   r   r     s   $ c                   sj   e Zd ZdZdZdZdZd fdd	Z fddZd	d
 Z	dd Z
edd Zedd Zdd Z  ZS )r   a`  
    1D Polynomial model.

    It is defined as:

    .. math::

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

    For explanation of ``domain``, and ``window`` see
    :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------
    degree : int
        degree of the series
    domain : tuple or None, optional
        If None, it is set to (-1, 1)
    window : tuple 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

    r   TNc       	         sZ   t  j|||f||||d| ddd| _t|p<| jd | _t|pP| jd | _d S )N)r$   r%   r&   r'   )r;   r   )rJ   rK   rJ   rK   )r0   r1   rO   r   rN   )	r   r2   rJ   rK   r$   r%   r&   r'   r3   )r6   r   r   r1     s    

zPolynomial1D.__init__c                s&   t  j|f|\}}|d }|f|fS )Nr   )r0   r   )r   r   rP   r   r   )r6   r   r   r     s    zPolynomial1D.prepare_inputsc             G   s&   | j d k	rt|| j | j}| ||S )N)rJ   r	   rK   horner)r   r   rm   r   r   r   r     s    
zPolynomial1D.evaluatec             G   st   t j| jd f|j td}d|d< | jdkrd||d< x,td| jd D ]}||d  | ||< qHW t |d|jS )a1  
        Computes the Vandermonde matrix.

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

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        r   )r   r   rY   )r-   r   r2   r   r   r<   r   r8   )r   r   r3   r   r@   r   r   r   r     s    
zPolynomial1D.fit_derivc             C   s^   t |dkr$|d tj| dd }n6|d }x,tdt |d D ]}||  ||   }q@W |S )Nr   r;   F)subokrY   )rt   r-   Z	ones_liker<   )r   rm   r   r@   r   r   r   r     s    zPolynomial1D.hornerc             C   s8   | j dks| jjd krd S | jd | jj| jj iS d S )Nr   )r2   r   unitr   r   )r   r   r   r   input_units  s    zPolynomial1D.input_unitsc             C   sV   i }xLt | jd D ]:}t| d| }|| jd  || jd  |  ||j< qW |S )Nr   r>   r   )r<   r2   r   outputsr   r&   )r   inputs_unitoutputs_unitmappingr@   parr   r   r   _parameter_units_for_data_units  s
    *z,Polynomial1D._parameter_units_for_data_units)NNNNNN)r   r   r    r!   r*   r   r   r1   r   r   r   r   r   r"   r   r   rG   r   r   )r6   r   r   `  s    
c                   s   e Zd ZdZdZdZdZd& fdd	Z fdd	Zd
d Z	dd Z
dd Zdd Zdd Zdd Zedd Zdd Zedd Zejdd Zedd Zejdd Zed d! Zejd"d! Zed#d$ Zejd%d$ Z  ZS )'r   a  
    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

    For explanation of ``x_domain``, ``y_domain``, ``x_window`` and ``y_window``
    see :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------
    degree : int
        Polynomial degree: largest sum of exponents (:math:`i + j`) of
        variables in each monomial term of the form :math:`x^i y^j`. The
        number of terms in a 2D polynomial of degree ``n`` is given by binomial
        coefficient :math:`C(n + 2, 2) = (n + 2)! / (2!\,n!) = (n + 1)(n + 2) / 2`.
    x_domain : tuple or None, optional
        domain of the x independent variable
        If None, it is set to (-1, 1)
    y_domain : tuple or None, optional
        domain of the y independent variable
        If None, it is set to (-1, 1)
    x_window : tuple or None, optional
        range of the x independent variable
        If None, it is set to (-1, 1)
        Fitters will remap the x_domain to x_window
    y_window : tuple or None, optional
        range of the y independent variable
        If None, it is set to (-1, 1)
        Fitters will remap the y_domain to y_window
    **params : dict
        keyword: value pairs, representing parameter_name: value
    rY   r   FNc
                s   t  j|f||||	d|
 ddddd| _t|p<| jd | _t|pP| jd | _t|pd| jd | _t|px| jd | _d S )N)r$   r%   r&   r'   )r;   r   )r\   r]   rZ   r[   r\   r]   rZ   r[   )r0   r1   rO   r   rb   rc   r`   ra   )r   r2   r\   r]   rZ   r[   r$   r%   r&   r'   r3   )r6   r   r   r1     s    
zPolynomial2D.__init__c                s*   t  j||f|\}}|\}}||f|fS )N)r0   r   )r   r   r   rP   r   r   )r6   r   r   r     s    zPolynomial2D.prepare_inputsc             G   s   | j d k	rt|| j | j}| jd k	r4t|| j| j}| |}| |||}| jdkrtt	
|d |j
}|rt	|}||d d < |}|S )Nr   )r\   r	   rZ   r]   r[   rp   multivariate_hornerr2   r   r-   r   r   )r   r   r   rm   r   r   Zoutput_shapeZ
new_resultr   r   r   r     s    




zPolynomial2D.evaluatec             C   s(   | j | jg| j| j| j| jd| jdS )N)r\   r]   rZ   r[   )rP   rQ   )rR   r2   r\   r]   rZ   r[   rO   )r   r   r   r   rS   &  s    
zPolynomial2D.__repr__c             C   s6   |  d| jfd| jfd| jfd| jfd| jfg| jS )NrT   rd   re   rf   rg   )rV   r2   r\   r]   rZ   r[   rO   )r   r   r   r   rW   .  s    
zPolynomial2D.__str__c       
      G   s  |j dkr| }|j dkr$| }|j|jkr8td|dddf t| jd  }|dddf td| jd  }g }xNtd| jD ]>}x8td| jD ](}|| | jkr||| ||   qW qW t	|j
}| rt|||g}	nt||g}	|	S )aW  
        Computes the Vandermonde matrix.

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

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        rY   z$Expected x and y to be of equal sizeNr   )r8   r   sizer7   r-   rh   r2   r<   r=   ri   r   anyZhstack)
r   r   r   r3   ZdesignxZdesignyZdesignmixedr@   rA   r   r   r   r   r   6  s$    

 "zPolynomial2D.fit_derivc             C   st   g }t | jd }xR|D ]J}xD|D ]<}|| | jkr"d| d| }|| j| }|| q"W qW |d d d S )Nr   r>   rC   r;   )r<   r2   r   rl   r=   )r   rm   rn   r?   r@   rA   r&   ro   r   r   r   rp   _  s    

zPolynomial2D.invlex_coeffc       
      C   s   |   }|d }|d }|d }tj|dd}x`tt|D ]P}	||	df dkrt||| |  }tj|d dd}n|||  }||	d  }q<W || | S )z
        Multivariate Horner's scheme

        Parameters
        ----------
        x, y : array
        coeffs : array
            Coefficients in inverse lexical order.
        r   g        )ry   r   F)r   )rB   r-   r}   r<   rt   Z
zeros_like)
r   r   r   rm   rw   r   r1r2r   rF   r   r   r   r   j  s    z Polynomial2D.multivariate_hornerc             C   sV   | j dks"| jjd kr&| jjd kr&d S | jd | jj| jj | jd | jj| jj iS )Nr   r   )r2   Zc1_0r   Zc0_1r   Zc0_0)r   r   r   r   r     s    "zPolynomial2D.input_unitsc             C   s   i }xt | jd D ]x}xrt | jd D ]`}|| dkr:q(t| d| d| }|| jd  || jd  |  || jd  |  ||j< q(W qW |S )Nr   rY   r>   rC   r   )r<   r2   r   r   r   r&   )r   r   r   r   r@   rA   r   r   r   r   r     s    @z,Polynomial2D._parameter_units_for_data_unitsc             C   s   | j S )N)rb   )r   r   r   r   r\     s    zPolynomial2D.x_domainc             C   s   t || _d S )N)r   rb   )r   rM   r   r   r   r\     s    c             C   s   | j S )N)rc   )r   r   r   r   r]     s    zPolynomial2D.y_domainc             C   s   t || _d S )N)r   rc   )r   rM   r   r   r   r]     s    c             C   s   | j S )N)r`   )r   r   r   r   rZ     s    zPolynomial2D.x_windowc             C   s   t || _d S )N)r   r`   )r   rM   r   r   r   rZ     s    c             C   s   | j S )N)ra   )r   r   r   r   r[     s    zPolynomial2D.y_windowc             C   s   t || _d S )N)r   ra   )r   rM   r   r   r   r[     s    )NNNNNNNN)r   r   r    r!   r*   r   r   r1   r   r   rS   rW   r   rp   r   r"   r   r   r\   rX   r]   rZ   r[   rG   r   r   )r6   r   r     s0   %  )
c                   s>   e Zd ZdZdZd fdd	Zdd Zdd	 Zd
d Z  Z	S )r   a  
    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.

    For explanation of ``x_domain``, ``y_domain``, ``x_window`` and ``y_window``
    see :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : tuple or None, optional
        domain of the x independent variable
    y_domain : tuple or None, optional
        domain of the y independent variable
    x_window : tuple or None, optional
        range of the x independent variable
        If None, it is set to (-1, 1)
        Fitters will remap the domain to this window
    y_window : tuple or None, optional
        range of the y independent variable
        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 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.
    FNc                s,   t  j||f|||||||	|
d| d S )N)r\   r]   rZ   r[   r$   r%   r&   r'   )r0   r1   )r   r^   r_   r\   rZ   r]   r[   r$   r%   r&   r'   r3   )r6   r   r   r1     s    
zChebyshev2D.__init__c             C   s   | j d }| jd }i }t|j|d< | |d< t|j||< | ||d < x6td|D ](}d| ||d   ||d   ||< q`W x>t|d || D ](}d| ||d   ||d   ||< qW |S )zx
        Calculate the individual Chebyshev functions once and store them in a
        dictionary to be reused.
        r   r   rY   )r^   r_   r-   r   r   r   r<   )r   r   r   r   r   r   rF   r   r   r   r~     s    

((zChebyshev2D._fcachec       
      G   s   |j |j krtd| }| }| || jd j}| || jd j}g }xDt| jd D ]2}x,t| jd D ]}||| ||   qtW q`W t	
|}	|	jS )a  
        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 list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        z x and y must have the same shaper   )r   r7   r   _chebderiv1dr^   r   r_   r<   r=   r-   ri   )
r   r   r   r3   r   r   r   r@   rA   r   r   r   r   r     s    
zChebyshev2D.fit_derivc             C   s   t j|tddd}t j|d t|f|jd}|d d |d< |dkrd| }||d< x6td|d D ]$}||d  | ||d   ||< qfW t |d|jS )z3
        Derivative of 1D Chebyshev series
        Fr   )r   r   r   )r   r   rY   )	r-   ri   r   r   rt   r   r<   r   r8   )r   r   r   r   r   r@   r   r   r   r   +  s    $zChebyshev2D._chebderiv1d)NNNNNNNN)
r   r   r    r!   r   r1   r~   r   r   rG   r   r   )r6   r   r     s   -  )c                   s>   e Zd ZdZdZd fdd	Zdd Zdd	 Zd
d Z  Z	S )r   a  
    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.

    For explanation of ``x_domain``, ``y_domain``, ``x_window`` and ``y_window``
    see :ref:`Notes regarding usage of domain and window <domain-window-note>`.

    Parameters
    ----------

    x_degree : int
        degree in x
    y_degree : int
        degree in y
    x_domain : tuple or None, optional
        domain of the x independent variable
    y_domain : tuple or None, optional
        domain of the y independent variable
    x_window : tuple or None, optional
        range of the x independent variable
        If None, it is set to (-1, 1)
        Fitters will remap the domain to this window
    y_window : tuple or None, optional
        range of the y independent variable
        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
    -----
    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.
    FNc                s,   t  j||f|||||||	|
d| d S )N)r\   r]   rZ   r[   r$   r%   r&   r'   )r0   r1   )r   r^   r_   r\   rZ   r]   r[   r$   r%   r&   r'   r3   )r6   r   r   r1   q  s    
zLegendre2D.__init__c             C   s  | j d }| jd }i }t|j|d< | |d< t|j||< | ||d < xNtd|D ]@}d|d  d | ||d   |d ||d    | ||< q`W xZtd|D ]L}d|d  d | ||| d   |d ||| d    | ||| < qW |S )zw
        Calculate the individual Legendre functions once and store them in a
        dictionary to be reused.
        r   r   rY   )r^   r_   r-   r   r   r   r<   )r   r   r   r   r   r   rF   r   r   r   r~   z  s    

""*zLegendre2D._fcachec       
      G   s   |j |j krtd| }| }| || jd j}| || jd j}g }xDt| jd D ]2}x,t| jd D ]}||| ||   qtW q`W t	
|}	|	jS )a  
        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 list returned by non-linear fitters

        Returns
        -------
        result : ndarray
            The Vandermonde matrix
        z x and y must have the same shaper   )r   r7   r   _legendderiv1dr^   r   r_   r<   r=   r-   ri   )
r   r   r   r3   r   r   r   r@   rA   r   r   r   r   r     s    
zLegendre2D.fit_derivc             C   s   t j|tddd}t j|d f|j |jd}|d d |d< |dkr||d< xNtd|d D ]<}||d  | d| d  ||d  |d   | ||< q^W t |d|jS )z$Derivative of 1D Legendre polynomialFr   )r   r   r   )r   r   rY   )	r-   ri   r   r   r   r   r<   r   r8   )r   r   r   r   r@   r   r   r   r     s    <zLegendre2D._legendderiv1d)NNNNNNNN)
r   r   r    r!   r   r1   r~   r   r   rG   r   r   )r6   r   r   ;  s   3  $c                   sf   e Zd ZdZdZdZdZd fdd	Zdd	 Zd
d Z	dd Z
dd Zdd Zdd Zdd Z  ZS )_SIP1Dz
    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.
    rY   r   FNc       
         s   || _ || _| || _|r8|d kr(d}d| |f }nd}x&| jD ]}	t|	t|d| j|	< qDW t j	f ||||d| d S )Nr   )r   r   )r#   )r$   r%   r&   r'   )
ordercoeff_prefixr,   r   r   r-   r.   r/   r0   r1   )
r   r   r   r$   r%   r&   r'   r3   r4   r5   )r6   r   r   r1     s    z_SIP1D.__init__c             C   s   | j | j| jgdS )N)args)rR   r   r   )r   r   r   r   rS     s    z_SIP1D.__repr__c             C   s   |  d| jfd| jfgS )NZOrderzCoeff. Prefix)rV   r   r   )r   r   r   r   rW     s    z_SIP1D.__str__c             G   s   |  | j|}| |||S )N)_coeff_matrixr   	_eval_sip)r   r   r   rm   Zmcoefr   r   r   r     s    z_SIP1D.evaluatec             C   s>   | j dk s| j dkrtdt| j |}| j | | d }|S )zD
        Return the number of coefficients in one param set
        rY   	   z'Degree of polynomial must be 2< deg < 9)r   r7   r
   )r   r8   r9   r:   r   r   r   r)     s
    z_SIP1D.get_num_coeffc          	   C   s   g }x2t d| jd D ]}|| d| dd  qW x2t d| jd D ]}|| dd d|  qJW xVt d| jD ]F}x@t d| jD ]0}|| | jd k r|| d| d|  qW qzW t|S )NrY   r   rC   r   )r<   r   r=   rD   )r   r   rE   r@   rA   r   r   r   r,     s    "z_SIP1D._generate_coeff_namesc             C   s  t | jd | jd f}xDtd| jd D ]0}| d| dd }|| j| ||df< q,W xDtd| jd D ]0}| dd d| }|| j| |d|f< qrW xhtd| jD ]X}xRtd| jD ]B}|| | jd k r| d| d| }|| j| |||f< qW qW |S )Nr   rY   rC   r   )r-   r.   r   r<   r   rl   )r   r   rm   matr@   attrrA   r   r   r   r     s     z_SIP1D._coeff_matrixc             C   s   t j|t jd}t j|t jd}| jdkr8t |j}nt |j}xpt|jd D ]^}xXt|jd D ]F}d||   k r| jd k rhn qh||||f ||  ||   }qhW qTW |S )N)r   Ar   r   )r-   ZasarrayZfloat64r   r.   r   r<   r   )r   r   r   Zcoefr   r@   rA   r   r   r   r     s    
"(z_SIP1D._eval_sip)NNNN)r   r   r    r!   r*   r   r   r1   rS   rW   r   r)   r,   r   r   rG   r   r   )r6   r   r     s    r   c            
       sf   e Zd ZdZdZdZdZi i ddi i ddddf
 fdd	Zdd Zd	d
 Z	e
dd Zdd Z  ZS )r   a  
    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 (2,) ndarray
        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 <https://ui.adsabs.harvard.edu/abs/2005ASPC..347..491S>`_
    rY   FNc                s   || _ || _|| _|| _|| _|| _|| _|| _|	| _t	|d  | _
t	|d  | _t|fd|
|d|| _t|fd|
|d|| _t j|
|||d d| _d| _d S )	Nr   r   r   )r   r$   r%   B)r$   r%   r&   r'   )ur   )r   r   )Z_crpixZ_a_orderZ_b_orderZ_a_coeffZ_b_coeff	_ap_order	_bp_order	_ap_coeff	_bp_coeffr   shift_ashift_br   sip1d_asip1d_br0   r1   Z_inputsZ_outputs)r   ZcrpixZa_orderZb_orderZa_coeffZb_coeffap_orderbp_orderap_coeffbp_coeffr$   r%   r&   r'   )r6   r   r   r1   J  s&    



zSIP.__init__c             C   s    d | jj| j| j| j| jgS )Nz
<{}({!r})>)formatr6   r   r   r   r   r   )r   r   r   r   rS   a  s    
zSIP.__repr__c             C   sX   d| j j g}x<| j| j| j| jgD ]$}|tt|dd |d q&W d	|S )NzModel:    )width 
)
r6   r   r   r   r   r   r=   r   r   join)r   partsmodelr   r   r   rW   e  s
    zSIP.__str__c             C   s6   | j d k	r*| jd k	r*t| j | j| j| jS tdd S )Nz+SIP inverse coefficients are not available.)r   r   r   r   r   r   )r   r   r   r   inversem  s    
zSIP.inversec             C   sd   | j j|f| j j }| jj|f| jj }| jj||f| jj }| jj||f| jj }||fS )N)r   r   
param_setsr   r   r   )r   r   r   r   r   fgr   r   r   r   u  s
    zSIP.evaluate)r   r   r    r!   r*   r   r   r1   rS   rW   r"   r   r   rG   r   r   )r6   r   r   $  s   c                   sR   e Zd ZdZdZdZdZi i ddddf fdd	Zdd Zd	d
 Z	dd Z
  ZS )r   au  
    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

    rY   FNc	                s   || _ || _|| _|| _|dd |dd tdd | D }	tdd | D }
tf ||d|	| _tf ||d|
| _	t
 j||||d d S )	NZAP_0_0r   ZBP_0_0c             s   s"   | ]\}}| d d|fV  qdS )ZAP_r>   N)replace).0r   r   r   r   r   	<genexpr>  s   z&InverseSIP.__init__.<locals>.<genexpr>c             s   s"   | ]\}}| d d|fV  qdS )ZBP_r>   N)r   )r   r   r   r   r   r   r     s   )r2   r%   )r$   r%   r&   r'   )r   r   r   r   
setdefaultdictitemsr   sip1d_apsip1d_bpr0   r1   )r   r   r   r   r   r$   r%   r&   r'   Zap_coeff_paramsZbp_coeff_params)r6   r   r   r1     s$    


zInverseSIP.__init__c             C   s   d| j j d| j| jgdS )N<(z)>)r6   r   r   r   )r   r   r   r   rS     s    zInverseSIP.__repr__c             C   sP   d| j j g}x4| j| jgD ]$}|tt|dd |d qW d|S )NzModel: r   )r   r   r   )r6   r   r   r   r=   r   r   r   )r   r   r   r   r   r   rW     s
    zInverseSIP.__str__c             C   s8   | j j||f| j j }| jj||f| jj }||fS )N)r   r   r   r   )r   r   r   x1y1r   r   r   r     s    zInverseSIP.evaluate)r   r   r    r!   r*   r   r   r1   rS   rW   r   rG   r   r   )r6   r   r   }  s   )!r!   numpyr-   Zastropy.utilsr   r   corer   r   Zfunctional_modelsr   
parametersr   utilsr	   r
   r   __all__r   r   rH   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s<   !L4 dkk kk l  dY