
     e                         d Z ddlmZmZmZ ddlZddlZddlm	Z	 ddl
mZmZmZ g dZdZd	 Zd
 Zd Zd Zd ZddZddZddZddZd Zd ZdS )z"
Other wavelet related functions.
    )divisionprint_functionabsolute_importN)fft   )DiscreteContinuousWaveletWaveletContinuousWavelet)
integrate_waveletcentral_frequencyscale2frequencyfrequency2scaleqmforthogonal_filter_bankintwavecentrfrqscal2frqorthfiltzT`{old}` has been renamed to `{new}` and will be removed in a future version of pywt.c                 8    t          j        |           }||z  }|S )N)npcumsum)arrstepintegrals      /lib/python3.11/site-packages/pywt/_functions.py
_integrater      s    y~~HHO    c                      t                               dd          }t          j        |t                     t          | i |S )Nr   r   oldnew)_DEPRECATION_MSGformatwarningswarnDeprecationWarningr   argskwargsmsgs      r   r   r   $   sA    

!
!i5H
!
I
ICM#)***d-f---r   c                      t                               dd          }t          j        |t                     t          | i |S )Nr   r   r   )r"   r#   r$   r%   r&   r   r'   s      r   r   r   *   sA    

!
!j6I
!
J
JCM#)***d-f---r   c                      t                               dd          }t          j        |t                     t          | i |S )Nr   r   r   )r"   r#   r$   r%   r&   r   r'   s      r   r   r   0   sA    

!
!j6G
!
H
HCM#)***D+F+++r   c                      t                               dd          }t          j        |t                     t          | i |S )Nr   r   r   )r"   r#   r$   r%   r&   r   r'   s      r   r   r   6   sA    

!
!j6N
!
O
OCM#)***!426222r      c                 @   t          |           t          t          fv rd}t          j        |t
                     n+t          | t          t          f          st          |           } t          |           t          t          fv rWt          j        | d                   t          j        | d                   }}|d         |d         z
  }t          ||          |fS |                     |          }t          |          dk    r(|\  }}|d         |d         z
  }t          ||          |fS t          |          dk    r)|\  }}}|d         |d         z
  }t          ||          |fS |\  }}	}
}}|d         |d         z
  }t          |	|          t          ||          |fS )ac  
    Integrate `psi` wavelet function from -Inf to x using the rectangle
    integration method.

    Parameters
    ----------
    wavelet : Wavelet instance or str
        Wavelet to integrate.  If a string, should be the name of a wavelet.
    precision : int, optional
        Precision that will be used for wavelet function
        approximation computed with the wavefun(level=precision)
        Wavelet's method (default: 8).

    Returns
    -------
    [int_psi, x] :
        for orthogonal wavelets
    [int_psi_d, int_psi_r, x] :
        for other wavelets


    Examples
    --------
    >>> from pywt import Wavelet, integrate_wavelet
    >>> wavelet1 = Wavelet('db2')
    >>> [int_psi, x] = integrate_wavelet(wavelet1, precision=5)
    >>> wavelet2 = Wavelet('bior1.3')
    >>> [int_psi_d, int_psi_r, x] = integrate_wavelet(wavelet2, precision=5)

    z^Integration of a general signal is deprecated and will be removed in a future version of pywt.r   r         )typetuplelistr$   r%   r&   
isinstancer	   r
   r   r   asarrayr   wavefunlen)wavelet	precisionr*   psixr   functions_approximationsphiphi_dpsi_dphi_rpsi_rs               r   r   r   <   s   B G}}%%Bc-....'+<!=>> 5+G44G}}%%GAJ''GAJ)?)?Qtad{#t$$a''&y99
#$$)))Qtad{#t$$a''	%	&	&!	+	+.S!tad{#t$$a'' )A%ueUAtad{%&&
5$(?(?BBr   c                    t          | t          t          f          st          |           } |                     |          }t          |          dk    r|\  }}n|d         |d         }}t          |d         |d         z
            }|dk    sJ t          j        t          t          |          dd                             dz   }|t          |          dz  k    rt          |          |z
  dz   }d||dz
  z  z  S )a  
    Computes the central frequency of the `psi` wavelet function.

    Parameters
    ----------
    wavelet : Wavelet instance, str or tuple
        Wavelet to integrate.  If a string, should be the name of a wavelet.
    precision : int, optional
        Precision that will be used for wavelet function
        approximation computed with the wavefun(level=precision)
        Wavelet's method (default: 8).

    Returns
    -------
    scalar

    r0   r   r   Ng      ?)r5   r	   r
   r   r7   r8   floatr   argmaxabsr   )r9   r:   r=   r;   r<   domainindexs          r   r   r   {   s    & g):;<< 5+G44&y99
#$$)))QQ *!,.Fr.JQ1R51Q4<  FA::::Ic#c((122,''((1,Es3xx!|C5 1$&EAI&''r   c                 *    t          | |          |z  S )a  Convert from CWT "scale" to normalized frequency.

    Parameters
    ----------
    wavelet : Wavelet instance or str
        Wavelet to integrate.  If a string, should be the name of a wavelet.
    scale : scalar
        The scale of the CWT.
    precision : int, optional
        Precision that will be used for wavelet function approximation computed
        with ``wavelet.wavefun(level=precision)``.  Default is 8.

    Returns
    -------
    freq : scalar
        Frequency normalized to the sampling frequency. In other words, for a
        sampling interval of `dt` seconds, the normalized frequency of 1.0
        corresponds to (`1/dt` Hz).

    r:   r   )r9   scaler:   s      r   r   r      s    * W	:::UBBr   c                 *    t          | |          |z  S )a  Convert from to normalized frequency to CWT "scale".

    Parameters
    ----------
    wavelet : Wavelet instance or str
        Wavelet to integrate.  If a string, should be the name of a wavelet.
    freq : scalar
        Frequency, normalized so that the sampling frequency corresponds to a
        value of 1.0.
    precision : int, optional
        Precision that will be used for wavelet function approximation computed
        with ``wavelet.wavefun(level=precision)``.  Default is 8.

    Returns
    -------
    scale : scalar

    rK   rL   )r9   freqr:   s      r   r   r      s    & W	:::TAAr   c                 d    t          j        |           ddd         }|ddd          |ddd<   |S )ad  
    Returns the Quadrature Mirror Filter(QMF).

    The magnitude response of QMF is mirror image about `pi/2` of that of the
    input filter.

    Parameters
    ----------
    filt : array_like
        Input filter for which QMF needs to be computed.

    Returns
    -------
    qm_filter : ndarray
        Quadrature mirror of the input filter.

    NrD   r   r0   )r   array)filt	qm_filters     r   r   r      s>    $ ttt$I A&IaddOr   c                 >   t          |           dz  dk    st          d          t          j        | t          j                  } t          j        d          | z  t          j        |           z  }|ddd         }t          |          }|ddd         }||||f}|S )a,  
    Returns the orthogonal filter bank.

    The orthogonal filter bank consists of the HPFs and LPFs at
    decomposition and reconstruction stage for the input scaling filter.

    Parameters
    ----------
    scaling_filter : array_like
        Input scaling filter (father wavelet).

    Returns
    -------
    orth_filt_bank : tuple of 4 ndarrays
        The orthogonal filter bank of the input scaling filter in the order :
        1] Decomposition LPF
        2] Decomposition HPF
        3] Reconstruction LPF
        4] Reconstruction HPF

    r0   r   z'`scaling_filter` length has to be even.)dtypeNrD   )r8   
ValueErrorr   r6   float64sqrtsumr   )scaling_filterrec_lodec_lorec_hidec_hiorth_filt_banks         r   r   r      s    , !#q((BCCCZbjAAANWQZZ.(26.+A+AAFDDbD\F[[FDDbD\Ffff5Nr   )r.   )__doc__
__future__r   r   r   r$   numpyr   	numpy.fftr   _extensions._pywtr   r	   r
   __all__r"   r   r   r   r   r   r   r   r   r   r   r    r   r   <module>rg      s_    A @ @ @ @ @ @ @ @ @            T T T T T T T T T T: : :>   . . .. . ., , ,3 3 3<C <C <C <C~&( &( &( &(RC C C C.B B B B*  ." " " " "r   