403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/scipy/signal/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/signal/__pycache__/_savitzky_golay.cpython-311.pyc
�

d�ci4��h�ddlZddlmZddlmZddlmZddlm	Z			dd	�Z
d
�Zd�Zd�Z
		dd�ZdS)�N)�lstsq)�float_factorial)�
convolve1d�)�
axis_slice��?�convc�Z�||krtd���t|d��\}}|�|dkr|dz
}n|}d|cxkr|ksntd���|dvrtd���||krtj|��}|Stj|||z
t
�	��}	|d
kr|	ddd�}	tj|dz���dd��}
|	|
z}tj|dz��}t|��||zz||<t||��\}}
}
}
|S)
a	Compute the coefficients for a 1-D Savitzky-Golay FIR filter.

    Parameters
    ----------
    window_length : int
        The length of the filter window (i.e., the number of coefficients).
    polyorder : int
        The order of the polynomial used to fit the samples.
        `polyorder` must be less than `window_length`.
    deriv : int, optional
        The order of the derivative to compute. This must be a
        nonnegative integer. The default is 0, which means to filter
        the data without differentiating.
    delta : float, optional
        The spacing of the samples to which the filter will be applied.
        This is only used if deriv > 0.
    pos : int or None, optional
        If pos is not None, it specifies evaluation position within the
        window. The default is the middle of the window.
    use : str, optional
        Either 'conv' or 'dot'. This argument chooses the order of the
        coefficients. The default is 'conv', which means that the
        coefficients are ordered to be used in a convolution. With
        use='dot', the order is reversed, so the filter is applied by
        dotting the coefficients with the data set.

    Returns
    -------
    coeffs : 1-D ndarray
        The filter coefficients.

    See Also
    --------
    savgol_filter

    Notes
    -----
    .. versionadded:: 0.14.0

    References
    ----------
    A. Savitzky, M. J. E. Golay, Smoothing and Differentiation of Data by
    Simplified Least Squares Procedures. Analytical Chemistry, 1964, 36 (8),
    pp 1627-1639.
    Jianwen Luo, Kui Ying, and Jing Bai. 2005. Savitzky-Golay smoothing and
    differentiation filter for even number data. Signal Process.
    85, 7 (July 2005), 1429-1434.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.signal import savgol_coeffs
    >>> savgol_coeffs(5, 2)
    array([-0.08571429,  0.34285714,  0.48571429,  0.34285714, -0.08571429])
    >>> savgol_coeffs(5, 2, deriv=1)
    array([ 2.00000000e-01,  1.00000000e-01,  2.07548111e-16, -1.00000000e-01,
           -2.00000000e-01])

    Note that use='dot' simply reverses the coefficients.

    >>> savgol_coeffs(5, 2, pos=3)
    array([ 0.25714286,  0.37142857,  0.34285714,  0.17142857, -0.14285714])
    >>> savgol_coeffs(5, 2, pos=3, use='dot')
    array([-0.14285714,  0.17142857,  0.34285714,  0.37142857,  0.25714286])
    >>> savgol_coeffs(4, 2, pos=3, deriv=1, use='dot')
    array([0.45,  -0.85,  -0.65,  1.05])

    `x` contains data from the parabola x = t**2, sampled at
    t = -1, 0, 1, 2, 3.  `c` holds the coefficients that will compute the
    derivative at the last position.  When dotted with `x` the result should
    be 6.

    >>> x = np.array([1, 0, 1, 4, 9])
    >>> c = savgol_coeffs(5, 2, pos=4, deriv=1, use='dot')
    >>> c.dot(x)
    6.0
    z*polyorder must be less than window_length.�Nrg�?z4pos must be nonnegative and less than window_length.)r	�dotz`use` must be 'conv' or 'dot')�dtyper	���r)	�
ValueError�divmod�np�zeros�arange�float�reshaperr)�
window_length�	polyorder�deriv�delta�pos�use�halflen�rem�coeffs�x�order�A�y�_s              �>/usr/lib/python3/dist-packages/scipy/signal/_savitzky_golay.py�
savgol_coeffsr%sq��x�M�!�!��E�F�F�F��-��+�+�L�G�S�
�{��!�8�8��C�-�C�C��C�
��$�$�$�$�}�$�$�$�$��*�+�+�	+��/�!�!��8�9�9�9��y�����-�(�(���
�	�	�3�$�
��+�5�9�9�9�A�
�f�}�}�
�d�d��d�G���I�i�!�m�$�$�,�,�R��3�3�E�	�U�
�A�	���Q����A��u�%�%��%��8�A�e�H��A�q�k�k�O�F�A�q�!��M�c�z�|dkr|}n�t|��}||krtj|dd�df��}n}|d|����}t	|��D]N}tj||z
dz
||z
dz
d��}||�||z
fd|jdz
zz��z}�O|}|S)aHDifferentiate polynomials represented with coefficients.

    p must be a 1-D or 2-D array.  In the 2-D case, each column gives
    the coefficients of a polynomial; the first row holds the coefficients
    associated with the highest power. m must be a nonnegative integer.
    (numpy.polyder doesn't handle the 2-D case.)
    rNr.r)r)�lenr�
zeros_like�copy�rangerr�ndim)�p�m�result�n�dp�k�rngs       r$�_polyderr4�s���	�A�v�v������F�F����6�6��]�1�R�a�R��W�:�.�.�F�F��3�Q�B�3������B��1�X�X�
B�
B���i��A���	�1�q�5�1�9�b�9�9���c�k�k�1�q�5�(�T�Q�V�a�Z�-@�"@�A�A�A����F��Mr&c
���t||||���}
|dks||jkr|
}d}n|
�|d��}d}|�|jdd��}tjtjd||z
��||��}
|dkrt|
|��}
tj||z
||z
��}tj	|
|�dd����||zz}t|	j��}|||dc|d<||<|j||z
g|dd��R�}|r|�d|��}t|	|||���}||d<dS)	aE
    Given an N-d array `x` and the specification of a slice of `x` from
    `window_start` to `window_stop` along `axis`, create an interpolating
    polynomial of each 1-D slice, and evaluate that polynomial in the slice
    from `interp_start` to `interp_stop`. Put the result into the
    corresponding slice of `y`.
    )�start�stop�axisrFTrrN.)rr,�swapaxesr�shaper�polyfitrr4�polyval�list)r�window_start�window_stop�interp_start�interp_stopr8rrrr"�x_edge�xx_edge�swapped�poly_coeffs�i�values�shp�y_edges                  r$�	_fit_edgerJ�s������K�d�
K�
K�
K�F��q�y�y�D�Q�V�G�O�O�������/�/�$��*�*�����o�o�g�m�A�.��3�3�G��*�R�Y�q�+��*D�E�E�$�i�1�1�K�
�q�y�y��{�E�2�2��	�	�,��-�{�\�/I�J�J�A�
�Z��Q�Y�Y�r�1�%5�%5�
6�
6�%�5�.�
I�F��q�w�-�-�C��D�	�3�q�6��C��F�C��I�
�V�^�K�,�6�
A��Q�R�R��
A�
A�
A�F��*�����D�)�)��
���K�d�
K�
K�
K�F��F�3�K�K�Kr&c��|dz}t|d|d||||||�
�
|j|}t|||z
|||z
||||||�
�
dS)z�
    Use polynomial interpolation of x at the low and high ends of the axis
    to fill in the halflen values in y.

    This function just calls _fit_edge twice, once for each end of the axis.
    rrN)rJr:)	rrrrrr8r"rr0s	         r$�_fit_edges_polyfitrL�sz���q� �G�
�a��M�1�g�t����q�*�*�*�	���
�A�
�a��]�"�A�q�7�{�A�t����q�*�*�*�*�*r&r�interp�c	���|dvrtd���tj|��}|jtjkr4|jtjkr|�tj��}t||||���}|dkrI||j|krtd���t|||d���}	t|||||||	��nt|||||���}	|	S)	a� Apply a Savitzky-Golay filter to an array.

    This is a 1-D filter. If `x`  has dimension greater than 1, `axis`
    determines the axis along which the filter is applied.

    Parameters
    ----------
    x : array_like
        The data to be filtered. If `x` is not a single or double precision
        floating point array, it will be converted to type ``numpy.float64``
        before filtering.
    window_length : int
        The length of the filter window (i.e., the number of coefficients).
        If `mode` is 'interp', `window_length` must be less than or equal
        to the size of `x`.
    polyorder : int
        The order of the polynomial used to fit the samples.
        `polyorder` must be less than `window_length`.
    deriv : int, optional
        The order of the derivative to compute. This must be a
        nonnegative integer. The default is 0, which means to filter
        the data without differentiating.
    delta : float, optional
        The spacing of the samples to which the filter will be applied.
        This is only used if deriv > 0. Default is 1.0.
    axis : int, optional
        The axis of the array `x` along which the filter is to be applied.
        Default is -1.
    mode : str, optional
        Must be 'mirror', 'constant', 'nearest', 'wrap' or 'interp'. This
        determines the type of extension to use for the padded signal to
        which the filter is applied.  When `mode` is 'constant', the padding
        value is given by `cval`.  See the Notes for more details on 'mirror',
        'constant', 'wrap', and 'nearest'.
        When the 'interp' mode is selected (the default), no extension
        is used.  Instead, a degree `polyorder` polynomial is fit to the
        last `window_length` values of the edges, and this polynomial is
        used to evaluate the last `window_length // 2` output values.
    cval : scalar, optional
        Value to fill past the edges of the input if `mode` is 'constant'.
        Default is 0.0.

    Returns
    -------
    y : ndarray, same shape as `x`
        The filtered data.

    See Also
    --------
    savgol_coeffs

    Notes
    -----
    Details on the `mode` options:

        'mirror':
            Repeats the values at the edges in reverse order. The value
            closest to the edge is not included.
        'nearest':
            The extension contains the nearest input value.
        'constant':
            The extension contains the value given by the `cval` argument.
        'wrap':
            The extension contains the values from the other end of the array.

    For example, if the input is [1, 2, 3, 4, 5, 6, 7, 8], and
    `window_length` is 7, the following shows the extended data for
    the various `mode` options (assuming `cval` is 0)::

        mode       |   Ext   |         Input          |   Ext
        -----------+---------+------------------------+---------
        'mirror'   | 4  3  2 | 1  2  3  4  5  6  7  8 | 7  6  5
        'nearest'  | 1  1  1 | 1  2  3  4  5  6  7  8 | 8  8  8
        'constant' | 0  0  0 | 1  2  3  4  5  6  7  8 | 0  0  0
        'wrap'     | 6  7  8 | 1  2  3  4  5  6  7  8 | 1  2  3

    .. versionadded:: 0.14.0

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.signal import savgol_filter
    >>> np.set_printoptions(precision=2)  # For compact display.
    >>> x = np.array([2, 2, 5, 2, 1, 0, 1, 4, 9])

    Filter with a window length of 5 and a degree 2 polynomial.  Use
    the defaults for all other parameters.

    >>> savgol_filter(x, 5, 2)
    array([1.66, 3.17, 3.54, 2.86, 0.66, 0.17, 1.  , 4.  , 9.  ])

    Note that the last five values in x are samples of a parabola, so
    when mode='interp' (the default) is used with polyorder=2, the last
    three values are unchanged. Compare that to, for example,
    `mode='nearest'`:

    >>> savgol_filter(x, 5, 2, mode='nearest')
    array([1.74, 3.03, 3.54, 2.86, 0.66, 0.17, 1.  , 4.6 , 7.97])

    )�mirror�constant�nearestrM�wrapz@mode must be 'mirror', 'constant', 'nearest' 'wrap' or 'interp'.)rrrMzOIf mode is 'interp', window_length must be less than or equal to the size of x.rQ)r8�mode)r8rT�cval)rr�asarrayr
�float64�float32�astyper%r:rrL)
rrrrrr8rTrUrr"s
          r$�
savgol_filterrZ�s��L�F�F�F��/�0�0�	0�	�
�1�
�
�A��w�"�*�����B�J�!6�!6�
�H�H�R�Z� � ��
�=�)�5��
N�
N�
N�F��x����1�7�4�=�(�(��?�@�@�
@�
�q�&�t�*�=�=�=���1�m�Y��u�d�A�N�N�N�N�
�q�&�t�$�T�B�B�B���Hr&)rrNr	)rrrrMrN)�numpyr�scipy.linalgr�scipy._lib._utilr�
scipy.ndimager�_arraytoolsrr%r4rJrLrZ�r&r$�<module>ras�������������,�,�,�,�,�,�$�$�$�$�$�$�#�#�#�#�#�#�EI��H�H�H�H�V���0)�)�)�X*�*�*�?B�/2�
�
�
�
�
�
r&

Youez - 2016 - github.com/yon3zu
LinuXploit