CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
_cwt.cpython-310.pyc114 linesDownload Raw Back to __pycache__
1o

2��Yi��@s�ddlmZmZddlmZmZmZmZddlm	Z	m3Z4ddlmZdgZ
ddlZzddlZejZejZWneyEejZdd	�ZYnwdd
d�ZdS)�)�ceil�floor�)�ContinuousWavelet�DiscreteContinuousWavelet�Wavelet�_check_dtype)�integrate_wavelet�scale2frequency)�	AxisError�cwtNcCsdtt�|��S)aRound up size to the nearest power of two.5 6        Given a number of samples `n`, returns the next power of two7        following this number to take advantage of FFT speedup.8        This fallback is less efficient than `scipy.fftpack.next_fast_len`9        �)r�np�log2)�n�r�sE:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\pywt/_cwt.py�
next_fast_lensr��?�conv�����cCs�t|�}tj||d�}t�|tj�}t|ttf�st|�}t�	|�}t�10|dk�r-td��t�|�s6t
d��|jr;|n|}tjt�|�f|j|d�}	d}11t||12d�\}}|jr]t�|�n|}|jjdkrg|n|}
tj||
d�}tj||jjd�}|dkr�d	}d13}n|dkr�td��|jd
kr�|�d	|�}|j}|�d	|jd	f�}t|�D�]\}}|d
|d}t�||d	|dd
�||}|�t�}|d	|jkr�t�||jk|�}||d14d15d	�}|dk�r*|jd
kr�t�||�}nqt |j�}|d	|jd
7<t!|�}tj||d�}t"|jd�D]}t�|||�||d16d17�f<�qn<t#|jd	|jd
�}||k�rCt$j%||d	d�}|}t$j%||d	d�}t$j&||d	d�}|dd18|jd	|jd
�f}t�'|�tj(|d	d�}|	jjdk�r}|j}|jd	|jd	d}|dk�r�|dt)|�t*|��f}n
|dk�r�td|�d���|jd
k�r�|�|�}|�|d	�}||	|df<q�t+|||19�}t�|��r�t�,|g�}||}|	|fS)a�2021    cwt(data, scales, wavelet)22 23    One dimensional Continuous Wavelet Transform.24 25    Parameters26    ----------27    data : array_like28        Input signal29    scales : array_like30        The wavelet scales to use. One can use31        ``f = scale2frequency(wavelet, scale)/sampling_period`` to determine32        what physical frequency, ``f``. Here, ``f`` is in hertz when the33        ``sampling_period`` is given in seconds.34    wavelet : Wavelet object or name35        Wavelet to use36    sampling_period : float37        Sampling period for the frequencies output (optional).38        The values computed for ``coefs`` are independent of the choice of39        ``sampling_period`` (i.e. ``scales`` is not scaled by the sampling40        period).41    method : {'conv', 'fft'}, optional42        The method used to compute the CWT. Can be any of:43            - ``conv`` uses ``numpy.convolve``.44            - ``fft`` uses frequency domain convolution.45            - ``auto`` uses automatic selection based on an estimate of the46              computational complexity at each scale.47 48        The ``conv`` method complexity is ``O(len(scale) * len(data))``.49        The ``fft`` method is ``O(N * log2(N))`` with50        ``N = len(scale) + len(data) - 1``. It is well suited for large size51        signals but slightly slower than ``conv`` on small ones.52    axis: int, optional53        Axis over which to compute the CWT. If not given, the last axis is54        used.55 56    Returns57    -------58    coefs : array_like59        Continuous wavelet transform of the input signal for the given scales60        and wavelet. The first axis of ``coefs`` corresponds to the scales.61        The remaining axes match the shape of ``data``.62    frequencies : array_like63        If the unit of sampling period are seconds and given, then frequencies64        are in hertz. Otherwise, a sampling period of 1 is assumed.65 66    Notes67    -----68    Size of coefficients arrays depends on the length of the input array and69    the length of given scales.70 71    Examples72    --------73    >>> import pywt74    >>> import numpy as np75    >>> import matplotlib.pyplot as plt76    >>> x = np.arange(512)77    >>> y = np.sin(2*np.pi*x/32)78    >>> coef, freqs=pywt.cwt(y,np.arange(1,129),'gaus1')79    >>> plt.matshow(coef)80    >>> plt.show()81 82    >>> import pywt83    >>> import numpy as np84    >>> import matplotlib.pyplot as plt85    >>> t = np.linspace(-1, 1, 200, endpoint=False)86    >>> 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)))87    >>> widths = np.arange(1, 31)88    >>> cwtmatr, freqs = pywt.cwt(sig, widths, 'mexh')89    >>> plt.imshow(cwtmatr, extent=[-1, 1, 1, 31], cmap='PRGn', aspect='auto',90    ...            vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())91    >>> plt.show()92    )�dtyperz*`scales` must only include positive valueszaxis must be a scalar.�93)�	precision�c�fftrNrzmethod must be 'conv' or 'fft'r)�axis.g@zSelected scale of z too small.)-rrZasarrayZresult_typeZ	complex64�94isinstancerrrZ95atleast_1d�any�96ValueErrorZisscalarrZcomplex_cwt�empty�size�shaper	Zconjr�kind�real�ndimZswapaxesZreshape�	enumerateZarangeZastype�int�extractZconvolve�list�tuple�ranger�	fftmodulerZifft�sqrt�diffrrr97�array)�data�scalesZwaveletZsampling_period�methodr�dtZdt_cplxZdt_out�outrZint_psi�xZdt_psiZsize_scale0Zfft_dataZdata_shape_pre�i�scale�step�jZ
int_psi_scalerZ98conv_shaperZ99size_scaleZfft_wavZcoef�dZfrequenciesrrrr%s�L100101102&103104105106 ��107 108109110�111)rrr)�mathrrZ_extensions._pywtrrrrZ112_functionsr	r113Z_utilsr�__all__�numpyrZscipyrr,r�ImportErrorrrrrr�<module>s114�
Aluode/PerceptionLabPortable · CoolFace