
    \ciN"                     ^   d Z ddlZddlmZ g dZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Z G d de          Z e            Zd Z G d de          Z e            Zd Zd Zd Zd Zd Zd Zd Zd Z G d de          Z e            Z G d d e          Z  e             Z!dS )!zI Collection of Model instances for use with the odrpack fitting package.
    N)Model)r   exponentialmultilinear	unilinear	quadratic
polynomialc                     | d         | dd          }}|                     |j        d         df          }|||z                      d          z   S Nr      axis)reshapeshapesum)Bxabs       a/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/scipy/odr/_models.py_lin_fcnr   
   sO    Q4122qA			171:q/""A!yyay        c                     t          j        |j        d         t                    }t          j        ||                                f          }|                    | j        d         |j        d         f          S N)nponesr   floatconcatenateravelr   )r   r   r   ress       r   _lin_fjbr!      sW    
U##A
.!QWWYY
(
(C;;QWR[1222r   c                     | dd          }t          j        ||j        d         f|j        d         z  d          }|                    |j                  S )Nr   r   r   r   )r   repeatr   r   )r   r   r   s      r   _lin_fjdr$      sL    	!""A
	!agbk^AGBK/a888A99QWr   c                     t          | j        j                  dk    r| j        j        d         }nd}t          j        |dz   ft
                    S N   r   r   )lenr   r   r   r   r   )datams     r   _lin_estr+      sG    
 46<AFLO7AE8U###r   c                     | d         | dd          }}|                     |j        d         df          }|t          j        |t          j        ||          z  d          z   S r
   r   r   r   r   power)r   r   powersr   r   s        r   	_poly_fcnr0   *   s]    Q4122qA			171:q/""Arva"(1f---A66666r   c                     t          j        t          j        |j        d         t                    t          j        ||          j        f          }|                    | j        d         |j        d         f          S r   )r   r   r   r   r   r.   flatr   )r   r   r/   r    s       r   _poly_fjacbr3   1   sa    
."'!'"+u55(1f--24 5 5C;;QWR[1222r   c                     | dd          }|                     |j        d         df          }||z  }t          j        |t          j        ||dz
            z  d          S )Nr   r   r   r-   )r   r   r/   r   s       r   _poly_fjacdr5   7   s]    	!""A			171:q/""A	F
A6!bhq&(+++!4444r   c                 N    | d         t          j        | d         |z            z   S Nr   r   r   expr   r   s     r   _exp_fcnr;   @   #    Q4"&1""""r   c                 N    | d         t          j        | d         |z            z  S )Nr   r8   r:   s     r   _exp_fjdr>   D   r<   r   c                     t          j        t          j        |j        d         t                    |t          j        | d         |z            z  f          }|                    d|j        d         f          S )Nr   r   r'   )r   r   r   r   r   r9   r   )r   r   r    s      r   _exp_fjbr@   H   s\    
."'!'"+u55q26!A$(;K;K7KL
M
MC;;172;'(((r   c                 .    t          j        ddg          S )N      ?)r   arrayr)   s    r   _exp_estrE   M   s    8RHr   c                   "     e Zd ZdZ fdZ xZS )_MultilinearModela  
    Arbitrary-dimensional linear model

    .. deprecated:: 1.17.0
        `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
        `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
        instead.


    This model is defined by :math:`y=\beta_0 + \sum_{i=1}^m \beta_i x_i`

    Examples
    --------
    We can calculate orthogonal distance regression with an arbitrary
    dimensional linear model:

    >>> from scipy import odr
    >>> import numpy as np
    >>> x = np.linspace(0.0, 5.0)
    >>> y = 10.0 + 5.0 * x
    >>> data = odr.Data(x, y)
    >>> odr_obj = odr.ODR(data, odr.multilinear)
    >>> output = odr_obj.run()
    >>> print(output.beta)
    [10.  5.]

    c           
          t                                          t          t          t          t
          dddd           d S )NzArbitrary-dimensional Linearz y = B_0 + Sum[i=1..m, B_i * x_i]z&$y=\beta_0 + \sum_{i=1}^m \beta_i x_i$nameequTeXequ)fjacbfjacdestimatemeta)super__init__r   r!   r$   r+   self	__class__s    r   rR   z_MultilinearModel.__init__o   sQ    HHx8;EG G 	 	H 	H 	H 	H 	Hr   __name__
__module____qualname____doc__rR   __classcell__rU   s   @r   rG   rG   R   sK         8H H H H H H H H Hr   rG   c                 P   t          j        |           }|j        dk    rt          j        d|dz             }|                    t          |          df          }t          |          dz   }|fd}t          t          t          t          ||fdd|dz
  z  d|dz
  z  d          S )	az  
    Factory function for a general polynomial model.

    .. deprecated:: 1.17.0
        `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
        `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
        instead.

    Parameters
    ----------
    order : int or sequence
        If an integer, it becomes the order of the polynomial to fit. If
        a sequence of numbers, then these are the explicit powers in the
        polynomial.
        A constant term (power 0) is always included, so don't include 0.
        Thus, polynomial(n) is equivalent to polynomial(range(1, n+1)).

    Returns
    -------
    polynomial : Model instance
        Model instance.

    Examples
    --------
    We can fit an input data using orthogonal distance regression (ODR) with
    a polynomial model:

    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from scipy import odr
    >>> x = np.linspace(0.0, 5.0)
    >>> y = np.sin(x)
    >>> poly_model = odr.polynomial(3)  # using third order polynomial model
    >>> data = odr.Data(x, y)
    >>> odr_obj = odr.ODR(data, poly_model)
    >>> output = odr_obj.run()  # running ODR fitting
    >>> poly = np.poly1d(output.beta[::-1])
    >>> poly_y = poly(x)
    >>> plt.plot(x, y, label="input data")
    >>> plt.plot(x, poly_y, label="polynomial ODR")
    >>> plt.legend()
    >>> plt.show()

     r   c                 8    t          j        |ft                    S )N)r   r   r   )r)   len_betas     r   	_poly_estzpolynomial.<locals>._poly_est   s    w{E***r   zSorta-general Polynomialz$y = B_0 + Sum[i=1..%s, B_i * (x**i)]z)$y=\beta_0 + \sum_{i=1}^{%s} \beta_i x^i$rI   )rN   rM   rO   
extra_argsrP   )
r   asarrayr   aranger   r(   r   r0   r5   r3   )orderr/   r`   ra   s       r   r   r   z   s    \ ZF|r1fqj))^^S[[!,--F6{{QH!) + + + + +[#	9>(1*MG!!%& &' ' ' 'r   c                   "     e Zd ZdZ fdZ xZS )_ExponentialModela  
    Exponential model

    .. deprecated:: 1.17.0
        `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
        `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
        instead.

    This model is defined by :math:`y=\beta_0 + e^{\beta_1 x}`

    Examples
    --------
    We can calculate orthogonal distance regression with an exponential model:

    >>> from scipy import odr
    >>> import numpy as np
    >>> x = np.linspace(0.0, 5.0)
    >>> y = -10.0 + np.exp(0.5*x)
    >>> data = odr.Data(x, y)
    >>> odr_obj = odr.ODR(data, odr.exponential)
    >>> output = odr_obj.run()
    >>> print(output.beta)
    [-10.    0.5]

    c           
          t                                          t          t          t          t
          dddd           d S )NExponentialzy= B_0 + exp(B_1 * x)z$y=\beta_0 + e^{\beta_1 x}$rI   rN   rM   rO   rP   )rQ   rR   r;   r>   r@   rE   rS   s    r   rR   z_ExponentialModel.__init__   sQ    "*'4&=)GI I 	 	J 	J 	J 	J 	Jr   rV   r\   s   @r   rg   rg      K         4J J J J J J J J Jr   rg   c                 *    || d         z  | d         z   S r7   r^   r:   s     r   _unilinrm      s    QqT6AaD=r   c                 R    t          j        |j        t                    | d         z  S )Nr   )r   r   r   r   r:   s     r   _unilin_fjdro      s    717E""QqT))r   c                     t          j        |t          j        |j        t                    f          }|                    d|j        z             S )N)r'   r   r   r   r   r   r   r   r   _rets      r   _unilin_fjbrt      s<    >1bgagu55677D<<qw'''r   c                     dS )N)rB   rB   r^   rD   s    r   _unilin_estrv      s    8r   c                 B    ||| d         z  | d         z   z  | d         z   S )Nr   r   r'   r^   r:   s     r   
_quadraticrx      s&    a!fqtmqt##r   c                 0    d|z  | d         z  | d         z   S r&   r^   r:   s     r   	_quad_fjdrz      s    Q3qt8ad?r   c                     t          j        ||z  |t          j        |j        t                    f          }|                    d|j        z             S )N)   rq   rr   s      r   	_quad_fjbr}      sB    >1Q32717E#:#:;<<D<<qw'''r   c                     dS )N)rB   rB   rB   r^   rD   s    r   	_quad_estr      s    :r   c                   "     e Zd ZdZ fdZ xZS )_UnilinearModela  
    Univariate linear model

    .. deprecated:: 1.17.0
        `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
        `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
        instead.

    This model is defined by :math:`y = \beta_0 x + \beta_1`

    Examples
    --------
    We can calculate orthogonal distance regression with an unilinear model:

    >>> from scipy import odr
    >>> import numpy as np
    >>> x = np.linspace(0.0, 5.0)
    >>> y = 1.0 * x + 2.0
    >>> data = odr.Data(x, y)
    >>> odr_obj = odr.ODR(data, odr.unilinear)
    >>> output = odr_obj.run()
    >>> print(output.beta)
    [1. 2.]

    c           
          t                                          t          t          t          t
          dddd           d S )NzUnivariate Linearzy = B_0 * x + B_1z$y = \beta_0 x + \beta_1$rI   rj   )rQ   rR   rm   ro   rt   rv   rS   s    r   rR   z_UnilinearModel.__init__  sQ    ;"-':&9)FH H 	 	I 	I 	I 	I 	Ir   rV   r\   s   @r   r   r     sK         4I I I I I I I I Ir   r   c                   "     e Zd ZdZ fdZ xZS )_QuadraticModela  
    Quadratic model

    .. deprecated:: 1.17.0
        `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
        `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
        instead.

    This model is defined by :math:`y = \beta_0 x^2 + \beta_1 x + \beta_2`

    Examples
    --------
    We can calculate orthogonal distance regression with a quadratic model:

    >>> from scipy import odr
    >>> import numpy as np
    >>> x = np.linspace(0.0, 5.0)
    >>> y = 1.0 * x ** 2 + 2.0 * x + 3.0
    >>> data = odr.Data(x, y)
    >>> odr_obj = odr.ODR(data, odr.quadratic)
    >>> output = odr_obj.run()
    >>> print(output.beta)
    [1. 2. 3.]

    c           
          t                                          t          t          t          t
          dddd           d S )N	Quadraticzy = B_0*x**2 + B_1*x + B_2z&$y = \beta_0 x^2 + \beta_1 x + \beta_2rI   rj   )rQ   rR   rx   rz   r}   r   rS   s    r   rR   z_QuadraticModel.__init__E  sQ    iy9%5GI I 	 	J 	J 	J 	J 	Jr   rV   r\   s   @r   r   r   *  rk   r   r   )"rZ   numpyr   scipy.odr._odrpackr   __all__r   r!   r$   r+   r0   r3   r5   r;   r>   r@   rE   rG   r   r   rg   r   rm   ro   rt   rv   rx   rz   r}   r   r   r   r   r   r^   r   r   <module>r      sy        $ $ $ $ $ $  ! ! !3 3 3  
$ 
$ 
$7 7 73 3 35 5 5# # ## # #) ) )
  
"H "H "H "H "H "H "H "HJ  !!?' ?' ?'D J  J  J  J  J  J  J  JF  !!  * * *( ( (
  $ $ $  ( ( (
   I  I  I  I  Ie  I  I  IF O	 J  J  J  J  Je  J  J  JF O			r   