
    !Цi                     n    S SK JrJr  SSKJrJrJrJr  SSKJ	r	J
r
  SSKJr  S/rS SKrS rSS	S
.S jjrg)    )ceilfloor   )ContinuousWaveletDiscreteContinuousWaveletWavelet_check_dtype)integrate_waveletscale2frequency)	AxisErrorcwtNc                 F    S[        [        R                  " U 5      5      -  $ )zRound up size to the nearest power of two.

Given a number of samples `n`, returns the next power of two
following this number to take advantage of FFT speedup.
   )r   nplog2)ns    H/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/pywt/_cwt.pynext_fast_lenr      s     d2771:       	precisionc                
   [        U 5      n[        R                  " XS9n [        R                  " U[        R                  5      n[        U[        [        45      (       d  [        U5      n[        R                  " U5      n[        R                  " US:*  5      (       a  [        S5      e[        R                  " U5      (       d  [        S5      eUR                  (       a  UOUn	[        R                  " [        R                   " U5      4U R"                  -   U	S9n
[%        X&S9u  pUR                  (       a  [        R&                  " U5      OUnUR(                  R*                  S:X  a  UOUn[        R                  " XS9n[        R                  " XR,                  R(                  S9nUS:X  a  SnS	nOUS
:w  a  [        S5      eU R.                  S:  a>  U R1                  SU5      n U R"                  nU R3                  SU R"                  S   45      n [5        U5       GH  u  nnUS   US   -
  n[        R6                  " UUS   US   -
  -  S-   5      UU-  -  nUR9                  [:        5      nUS   UR                   :  a$  [        R<                  " UUR                   :  U5      nUU   S	S	S2   nUS
:X  a  U R.                  S:X  a  [        R>                  " U U5      nGOE[A        U R"                  5      nUS==   UR                   S-
  -  ss'   [C        U5      n[        R                  " UU	S9n[E        U R"                  S   5       H$  n[        R>                  " U U   U5      UUS	S	24'   M&     O[G        U R"                  S   UR                   -   S-
  5      nUW:w  a  [        RH                  RI                  U USS9nUn[        RH                  RI                  UUSS9n[        RH                  RK                  UW-  SS9nUSS	U R"                  S   UR                   -   S-
  24   n[        RL                  " U5      * [        RN                  " USS9-  nU
R(                  R*                  S:w  a  UR,                  nUR"                  S   U R"                  S   -
  S-  nUS:  a  US[Q        U5      [S        U5      * 24   nOUS:  a  [        SU S35      eU R.                  S:  a#  UR3                  W5      nUR1                  US5      nUU
US4'   GM     [U        X!U5      n[        R                  " U5      (       a  [        RV                  " U/5      nUU-  nU
U4$ )a  
One dimensional Continuous Wavelet Transform.

Parameters
----------
data : array_like
    Input signal
scales : array_like
    The wavelet scales to use. One can use
    ``f = scale2frequency(wavelet, scale)/sampling_period`` to determine
    what physical frequency, ``f``. Here, ``f`` is in hertz when the
    ``sampling_period`` is given in seconds.
wavelet : Wavelet object or name
    Wavelet to use
sampling_period : float
    Sampling period for the frequencies output (optional).
    The values computed for ``coefs`` are independent of the choice of
    ``sampling_period`` (i.e. ``scales`` is not scaled by the sampling
    period).
method : {'conv', 'fft'}, optional
    The method used to compute the CWT. Can be any of:
        - ``conv`` uses ``numpy.convolve``.
        - ``fft`` uses frequency domain convolution.
        - ``auto`` uses automatic selection based on an estimate of the
          computational complexity at each scale.

    The ``conv`` method complexity is ``O(len(scale) * len(data))``.
    The ``fft`` method is ``O(N * log2(N))`` with
    ``N = len(scale) + len(data) - 1``. It is well suited for large size
    signals but slightly slower than ``conv`` on small ones.
axis: int, optional
    Axis over which to compute the CWT. If not given, the last axis is
    used.
precision: int, optional
    Length of wavelet (``2 ** precision``) used to compute the CWT. Greater
    will increase resolution, especially for higher scales, but will
    compute a bit slower. Too low will distort coefficients and their
    norms, with a zipper-like effect. The default is 12, it's recommended
    to use >=12.

Returns
-------
coefs : array_like
    Continuous wavelet transform of the input signal for the given scales
    and wavelet. The first axis of ``coefs`` corresponds to the scales.
    The remaining axes match the shape of ``data``.
frequencies : array_like
    If the unit of sampling period are seconds and given, then frequencies
    are in hertz. Otherwise, a sampling period of 1 is assumed.

Notes
-----
Size of coefficients arrays depends on the length of the input array and
the length of given scales.

Examples
--------
>>> import pywt
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> x = np.exp(np.linspace(0, 2, 512))
>>> y = np.cos(2*np.pi*x)  # exponential chirp
>>> scales = np.logspace(np.log10(1), np.log10(128), 128)
>>> coef, freqs = pywt.cwt(y, scales, 'gaus1')
>>> plt.matshow(coef)
>>> plt.show()

>>> import pywt
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> t = np.linspace(-1, 1, 200, endpoint=False)
>>> sig  = np.cos(2 * np.pi * 7 * t) + np.real(np.exp(-7*(t-0.4)**2)*np.exp(1j*2*np.pi*2*(t-0.4)))
>>> widths = np.logspace(np.log10(1), np.log10(30), 30)
>>> cwtmatr, freqs = pywt.cwt(sig, widths, 'mexh')
>>> plt.imshow(cwtmatr, extent=[-1, 1, 1, 31], cmap='PRGn', aspect='auto',
...            vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
>>> plt.show()
)dtyper   z*`scales` must only include positive valueszaxis must be a scalar.r   cfftNconvzmethod must be 'conv' or 'fft'r   )axis.g       @zSelected scale of z too small.),r	   r   asarrayresult_type	complex64
isinstancer   r   r   
atleast_1dany
ValueErrorisscalarr   complex_cwtemptysizeshaper
   conjr   kindrealndimswapaxesreshape	enumeratearangeastypeintextractconvolvelisttupleranger   r   ifftsqrtdiffr   r   r   array)datascaleswaveletsampling_periodmethodr   r   dtdt_cplxdt_outoutint_psixdt_psisize_scale0fft_datadata_shape_preiscalestepjint_psi_scaler   
conv_shaper   
size_scalefft_wavcoefdfrequenciess                                 r   r   r      s   d 
d	B::d%DnnR.Gg 17;<<+G4]]6"F	vvfkEFF;;t011++WF
((BGGFO%

2&
AC"7@JG")"5"5bggg7G  **c1WrFjj/G


1IIOO,A	6	9::yy1}}}R& ||RB01f%5tad{IIequqt|,q01UT\BHHSMR5GLL 

1w||+Q/A
4R4(VyyA~{{47 "$**-
2-"4"4q"88":.
xx
&9tzz!}-A!#T!Wm!DDAJ . '

2!3!33a7J [(66::dJR:@$Kffjj
jDG66;;w1;;DEdjjn}/A/AAAEEEFD"''$R"8899>>S 99DZZ^djjn,2q5U1XtAwh../DU$UG;79 999q=<</D==r*DAsFc &f "'9=K	{{;hh}-?"Kr   )g      ?r   r   )mathr   r   _extensions._pywtr   r   r   r	   
_functionsr
   r   _utilsr   __all__numpyr   r   r    r   r   <module>r`      s:      ; ' oor   