AlkantarClanX12

Your IP : 13.59.205.182


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/fft/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/fft/__pycache__/helper.cpython-311.pyc

�

�܋f
���dZddlmZmZmZmZmZddlmZm	Z	gd�Z
eefZdd�Z
ee
d���dd	���Zee
d���dd
���Ze	d��dd���Ze	d��dd
���ZdS)z*
Discrete Fourier Transforms - helper.py

�)�integer�empty�arange�asarray�roll)�array_function_dispatch�
set_module)�fftshift�	ifftshift�fftfreq�rfftfreqNc��|fS�N�)�x�axess  �G/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/fft/helper.py�_fftshift_dispatcherrs	��
�4�K�z	numpy.fft)�modulec���t����|�3tt�j����}d��jD��}n4t|t��r�j|dz}n�fd�|D��}t�||��S)ad
    Shift the zero-frequency component to the center of the spectrum.

    This function swaps half-spaces for all axes listed (defaults to all).
    Note that ``y[0]`` is the Nyquist component only if ``len(x)`` is even.

    Parameters
    ----------
    x : array_like
        Input array.
    axes : int or shape tuple, optional
        Axes over which to shift.  Default is None, which shifts all axes.

    Returns
    -------
    y : ndarray
        The shifted array.

    See Also
    --------
    ifftshift : The inverse of `fftshift`.

    Examples
    --------
    >>> freqs = np.fft.fftfreq(10, 0.1)
    >>> freqs
    array([ 0.,  1.,  2., ..., -3., -2., -1.])
    >>> np.fft.fftshift(freqs)
    array([-5., -4., -3., -2., -1.,  0.,  1.,  2.,  3.,  4.])

    Shift the zero-frequency component only along the second axis:

    >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
    >>> freqs
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])
    >>> np.fft.fftshift(freqs, axes=(1,))
    array([[ 2.,  0.,  1.],
           [-4.,  3.,  4.],
           [-1., -3., -2.]])

    Nc��g|]}|dz��S��r��.0�dims  r�
<listcomp>zfftshift.<locals>.<listcomp>Cs��-�-�-�c����-�-�-rrc�0��g|]}�j|dz��Sr��shape�r�axrs  �rrzfftshift.<locals>.<listcomp>Gs$���1�1�1�b������!�1�1�1r�r�tuple�range�ndimr!�
isinstance�
integer_typesr�rr�shifts`  rr
r
s����Z	��
�
�A��|��U�1�6�]�]�#�#��-�-�Q�W�-�-�-���	�D�-�	(�	(�2����
��"���1�1�1�1�D�1�1�1����5�$���rc���t����|�3tt�j����}d��jD��}n5t|t��r�j|dz}n�fd�|D��}t�||��S)a/
    The inverse of `fftshift`. Although identical for even-length `x`, the
    functions differ by one sample for odd-length `x`.

    Parameters
    ----------
    x : array_like
        Input array.
    axes : int or shape tuple, optional
        Axes over which to calculate.  Defaults to None, which shifts all axes.

    Returns
    -------
    y : ndarray
        The shifted array.

    See Also
    --------
    fftshift : Shift zero-frequency component to the center of the spectrum.

    Examples
    --------
    >>> freqs = np.fft.fftfreq(9, d=1./9).reshape(3, 3)
    >>> freqs
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])
    >>> np.fft.ifftshift(np.fft.fftshift(freqs))
    array([[ 0.,  1.,  2.],
           [ 3.,  4., -4.],
           [-3., -2., -1.]])

    Nc��g|]}|dz��	Srrrs  rrzifftshift.<locals>.<listcomp>rs��0�0�0��3�!�8��0�0�0rrc�2��g|]}�j|dz��Srr r"s  �rrzifftshift.<locals>.<listcomp>vs'���4�4�4��1�7�2�;�!�#�$�4�4�4rr$r*s`  rrrLs����F	��
�
�A��|��U�1�6�]�]�#�#��0�0���0�0�0���	�D�-�	(�	(�5��'�$�-�1�$�%���4�4�4�4�t�4�4�4����5�$���r��?c�$�t|t��std���d||zz}t|t��}|dz
dzdz}td|t���}||d|�<t|dzdt���}|||d�<||zS)a-
    Return the Discrete Fourier Transform sample frequencies.

    The returned float array `f` contains the frequency bin centers in cycles
    per unit of the sample spacing (with zero at the start).  For instance, if
    the sample spacing is in seconds, then the frequency unit is cycles/second.

    Given a window length `n` and a sample spacing `d`::

      f = [0, 1, ...,   n/2-1,     -n/2, ..., -1] / (d*n)   if n is even
      f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n)   if n is odd

    Parameters
    ----------
    n : int
        Window length.
    d : scalar, optional
        Sample spacing (inverse of the sampling rate). Defaults to 1.

    Returns
    -------
    f : ndarray
        Array of length `n` containing the sample frequencies.

    Examples
    --------
    >>> signal = np.array([-2, 8, 6, 4, 1, 0, 3, 5], dtype=float)
    >>> fourier = np.fft.fft(signal)
    >>> n = signal.size
    >>> timestep = 0.1
    >>> freq = np.fft.fftfreq(n, d=timestep)
    >>> freq
    array([ 0.  ,  1.25,  2.5 , ..., -3.75, -2.5 , -1.25])

    �n should be an integerr/�rr��dtypeN)r(r)�
ValueErrorr�intr)�n�d�val�results�N�p1�p2s       rrr{s���J�a��'�'�3��1�2�2�2�

��Q��-�C��A�s�m�m�G�	
�1��q��1��A�	��1�C�	 �	 �	 �B��G�B�Q�B�K�	�!�Q�$���#�	&�	&�	&�B��G�A�B�B�K��S�=�rc��t|t��std���d||zz}|dzdz}td|t���}||zS)a?
    Return the Discrete Fourier Transform sample frequencies
    (for usage with rfft, irfft).

    The returned float array `f` contains the frequency bin centers in cycles
    per unit of the sample spacing (with zero at the start).  For instance, if
    the sample spacing is in seconds, then the frequency unit is cycles/second.

    Given a window length `n` and a sample spacing `d`::

      f = [0, 1, ...,     n/2-1,     n/2] / (d*n)   if n is even
      f = [0, 1, ..., (n-1)/2-1, (n-1)/2] / (d*n)   if n is odd

    Unlike `fftfreq` (but like `scipy.fftpack.rfftfreq`)
    the Nyquist frequency component is considered to be positive.

    Parameters
    ----------
    n : int
        Window length.
    d : scalar, optional
        Sample spacing (inverse of the sampling rate). Defaults to 1.

    Returns
    -------
    f : ndarray
        Array of length ``n//2 + 1`` containing the sample frequencies.

    Examples
    --------
    >>> signal = np.array([-2, 8, 6, 4, 1, 0, 3, 5, -3, 4], dtype=float)
    >>> fourier = np.fft.rfft(signal)
    >>> n = signal.size
    >>> sample_rate = 100
    >>> freq = np.fft.fftfreq(n, d=1./sample_rate)
    >>> freq
    array([  0.,  10.,  20., ..., -30., -20., -10.])
    >>> freq = np.fft.rfftfreq(n, d=1./sample_rate)
    >>> freq
    array([  0.,  10.,  20.,  30.,  40.,  50.])

    r1r/rr2rr3)r(r)r5rr6)r7r8r9r;r:s     rr
r
�s^��X�a��'�'�3��1�2�2�2�

�q��s�)�C�	�1��q��A��Q���%�%�%�G��S�=�rr)r/)�__doc__�
numpy.corerrrrr�numpy.core.overridesrr	�__all__r6r)rr
rrr
rrr�<module>rCsF����=�<�<�<�<�<�<�<�<�<�<�<�<�<�D�D�D�D�D�D�D�D�;�
:�
:���g��
�������-�k�B�B�B�5 �5 �5 �C�B�5 �p��-�k�B�B�B�+ �+ �+ �C�B�+ �\��K���-�-�-���-�`��K���0�0�0���0�0�0r